@cloudbase/js-sdk 3.4.8 → 3.4.9-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/ai/dist/index.esm.js +1 -1
  3. package/ai/dist/index.esm.js.map +1 -1
  4. package/ai/dist/index.js +1 -1
  5. package/ai/dist/index.js.map +1 -1
  6. package/app/dist/index.esm.js +1 -1
  7. package/app/dist/index.esm.js.map +1 -1
  8. package/app/dist/index.js +1 -1
  9. package/app/dist/index.js.map +1 -1
  10. package/auth/dist/index.esm.js +1 -1
  11. package/auth/dist/index.esm.js.map +1 -1
  12. package/auth/dist/index.js +1 -1
  13. package/auth/dist/index.js.map +1 -1
  14. package/cloudrun/dist/index.esm.js +1 -1
  15. package/cloudrun/dist/index.esm.js.map +1 -1
  16. package/cloudrun/dist/index.js +1 -1
  17. package/cloudrun/dist/index.js.map +1 -1
  18. package/container/dist/index.esm.js +1 -1
  19. package/container/dist/index.esm.js.map +1 -1
  20. package/container/dist/index.js +1 -1
  21. package/container/dist/index.js.map +1 -1
  22. package/dist/index.cjs.js +1 -1
  23. package/dist/index.cjs.js.map +1 -1
  24. package/dist/index.esm.js +1 -1
  25. package/dist/index.esm.js.map +1 -1
  26. package/functions/dist/index.esm.js +1 -1
  27. package/functions/dist/index.esm.js.map +1 -1
  28. package/functions/dist/index.js +1 -1
  29. package/functions/dist/index.js.map +1 -1
  30. package/index.d.ts +654 -45
  31. package/miniprogram_dist/ai.js +1 -1
  32. package/miniprogram_dist/app.js +1 -1
  33. package/miniprogram_dist/auth.js +1 -1
  34. package/miniprogram_dist/cloudrun.js +1 -1
  35. package/miniprogram_dist/container.js +1 -1
  36. package/miniprogram_dist/functions.js +1 -1
  37. package/miniprogram_dist/index.js +1 -1
  38. package/miniprogram_dist/model.js +1 -1
  39. package/miniprogram_dist/oauth.js +1 -1
  40. package/miniprogram_dist/storage.js +1 -1
  41. package/model/dist/index.esm.js +1 -1
  42. package/model/dist/index.esm.js.map +1 -1
  43. package/model/dist/index.js +1 -1
  44. package/model/dist/index.js.map +1 -1
  45. package/oauth/dist/index.esm.js +1 -1
  46. package/oauth/dist/index.esm.js.map +1 -1
  47. package/oauth/dist/index.js +1 -1
  48. package/oauth/dist/index.js.map +1 -1
  49. package/package.json +1 -1
  50. package/storage/dist/index.esm.js +1 -1
  51. package/storage/dist/index.esm.js.map +1 -1
  52. package/storage/dist/index.js +1 -1
  53. package/storage/dist/index.js.map +1 -1
  54. package/types/index.d.ts +2 -2
  55. package/types/package.json +1 -1
  56. package/utilities/dist/cjs/adapters/platforms/web.js +12 -4
  57. package/utilities/dist/esm/adapters/platforms/web.js +12 -4
  58. package/utilities/dist/miniprogram/index.js +1 -1
  59. package/utilities/package.json +2 -2
package/dist/index.cjs.js CHANGED
@@ -1,3 +1,3 @@
1
1
  /*! For license information please see index.cjs.js.LICENSE.txt */
2
- !function(){var e,t,r={7756: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.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},u=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AI=void 0;var c=r(9737),l=s(r(5305)),d=r(1689),h=r(2877),f=l.MODELS,p=function(){function e(e,t,r){var o=this;this.req=e,this.baseUrl=t,this.modelRequest=function(e){var t=e.url,r=e.data,i=e.headers,s=e.stream,c=e.timeout;return a(o,void 0,void 0,(function(){var e,o,a,l,d,h,f;return u(this,(function(u){switch(u.label){case 0:return e={"Content-Type":"application/json"},s&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:n(n((d={},d[null===(h=this.i18n)||void 0===h?void 0:h.LANG_HEADER_KEY]=null===(f=this.i18n)||void 0===f?void 0:f.lang,d),e),i),body:JSON.stringify(r),url:t,stream:s,timeout:c})];case 1:return o=u.sent(),a=o.data,l=o.header,[2,this.handleResponseData(a,l)]}}))}))},this.botRequest=function(e){var t=e.method,r=e.url,i=e.data,s=void 0===i?{}:i,c=e.headers,l=e.stream,d=e.timeout;return a(o,void 0,void 0,(function(){var e,o,i,a,h,f,p,v;return u(this,(function(u){switch(u.label){case 0:return"get"!==t?[3,2]:(e=this.handleResponseData,[4,this.req.fetch({url:"".concat(r,"?").concat((y=s,Object.entries(y).map((function(e){var t=e[0],r=e[1];return"".concat(t,"=").concat(r)})).join("&"))),method:t,headers:c,stream:l,timeout:d})]);case 1:return[2,e.apply(this,[u.sent().data])];case 2:return o={"Content-Type":"application/json"},l&&Object.assign(o,{Accept:"text/event-stream"}),[4,this.req.fetch({url:r,body:JSON.stringify(s),headers:n(n((f={},f[null===(p=this.i18n)||void 0===p?void 0:p.LANG_HEADER_KEY]=null===(v=this.i18n)||void 0===v?void 0:v.lang,f),o),c),stream:l,method:t,timeout:d})];case 3:return i=u.sent(),a=i.data,h=i.header,[2,this.handleResponseData(a,h)]}var y}))}))},this.aiBaseUrl="".concat(t,"/ai"),this.aiBotBaseUrl="".concat(t,"/aibot"),this.bot=new c.Bot(this.botRequest,this.aiBotBaseUrl),this.i18n=r,h.langEvent.bus.on(h.langEvent.LANG_CHANGE_EVENT,(function(e){var t;o.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||o.i18n}))}return e.prototype.handleResponseData=function(e,t){var r,n;return a(this,void 0,void 0,(function(){var o,i;return u(this,(function(s){switch(s.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),"object"==typeof e&&e&&"then"in e?[4,e]:[3,2];case 1:if("object"==typeof(i=s.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));return[2,e];case 2:return(null===(n=null===(r=null==t?void 0:t.get)||void 0===r?void 0:r.call(t,"content-type"))||void 0===n?void 0:n.includes("application/json"))?[4,(0,d.readableStream2JsonObject)(e)]:[3,4];case 3:if("object"==typeof(i=s.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));s.label=4;case 4:return[2,e]}}))}))},e.prototype.createModel=function(e,t){var r,n=f[e];if(n)r=new n(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==t?void 0:t.defaultModelSubUrl)?t.defaultModelSubUrl:"/chat/completions";r=new l.DefaultSimpleModel(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new l.ReactModel(r)},e.prototype.registerModel=function(e,t){null==f[e]?f[e]=t:console.warn("AI model ".concat(e," already exists!"))},e.prototype.createImageModel=function(e){return new l.DefaultImageModel(this.modelRequest,this.aiBaseUrl,e)},e.prototype.registerFunctionTool=function(e){l.toolMap.has(e.name)&&console.warn("AI function tool ".concat(e.name," already exists and will be overwritten!")),l.toolMap.set(e.name,e.fn)},e}();t.AI=p},9737: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.Bot=void 0;var a=r(1689),u=function(){function e(e,t){this.baseUrl=t;var r=arguments[2];this.req="string"==typeof r?function(t){var o=t.headers,i=void 0===o?{}:o,a=s(t,["headers"]);return e(n(n({},a),{headers:n(n({},i),{Authorization:"Bearer ".concat(r)})}))}:e}return e.prototype.list=function(e,t){return this.req({method:"get",url:this.join("bots"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.create=function(e,t){var r=e.botInfo;return this.req({method:"post",url:this.join("bots"),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.get=function(e,t){var r=e.botId;return this.req({method:"get",url:this.join("bots/".concat(r)),timeout:null==t?void 0:t.timeout})},e.prototype.update=function(e,t){var r=e.botId,n=e.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(r)),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.delete=function(e,t){var r=e.botId;return this.req({method:"delete",url:this.join("bots/".concat(r)),timeout:null==t?void 0:t.timeout})},e.prototype.getChatRecords=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/records")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendFeedback=function(e,t){var r=e.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(r.botId,"/feedback")),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.getFeedback=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/feedback")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.uploadFiles=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/files")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.createConversation=function(e,t){var r=e.botId,n=s(e,["botId"]);return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.req({method:"post",url:this.join("bots/".concat(r,"/conversation")),data:n,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getConversation=function(e,t){var r=e.pageSize,a=void 0===r?10:r,u=e.pageNumber,c=void 0===u?1:u,l=e.botId,d=s(e,["pageSize","pageNumber","botId"]);return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){if(c<1)throw new Error("pageNumber must be greater than 0");return e=a*(c-1),r=a,[2,this.req({method:"get",url:this.join("bots/".concat(l,"/conversation")),data:n(n({},d),{offset:e,limit:r}),timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.deleteConversation=function(e,t){var r=e.botId,n=e.conversationId,a=s(e,["botId","conversationId"]);return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.req({method:"delete",url:this.join("bots/".concat(r,"/conversation/").concat(n)),data:a,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.speechToText=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/speech-to-text")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.textToSpeech=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getTextToSpeechResult=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(r){return[2,this.req({method:"get",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getRecommendQuestions=function(e,t){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/recommend-questions")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new c(r)]}}))}))},e.prototype.generateBot=function(e,t){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new c(r)]}}))}))},e.prototype.getPreview=function(e,t){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new c(r)]}}))}))},e.prototype.generateImage=function(e,t){return this.req({method:"post",url:this.join("generate-image"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendMessage=function(e,t){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/send-message")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return r=n.sent(),[2,new c(r)]}}))}))},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}();t.Bot=u;var c=function(){function e(e){var t=(0,a.toPolyfillReadable)(e);this._eventSourceStream=t.pipeThrough(new a.TextDecoderStream).pipeThrough((0,a.createEventSourceParserTransformStream)())}return Object.defineProperty(e.prototype,"teeedStream",{get:function(){var e=this._eventSourceStream.tee(),t=e[0],r=e[1];return this._eventSourceStream=r,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eventSourceStream",{get:function(){return(0,a.createAsyncIterable)(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataStream",{get:function(){return(0,a.createAsyncIterable)(this.eventSourceStream.pipeThrough(new a.TransformStream({transform:function(e,t){try{var r=JSON.parse(e.data);t.enqueue(r)}catch(r){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",r,e):t.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textStream",{get:function(){return(0,a.createAsyncIterable)(this.dataStream.pipeThrough(new a.TransformStream({transform:function(e,t){var r;t.enqueue(null!==(r=null==e?void 0:e.content)&&void 0!==r?r:"")}})))},enumerable:!1,configurable:!0}),e}()},9964:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0;var n=r(6298);Object.defineProperty(t,"createParser",{enumerable:!0,get:function(){return n.createParser}})},6298:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0,t.createParser=function(e){var t,n,o,i,s,a,u;return c(),{feed:function(e){n=n?n+e:e,t&&function(e){return r.every((function(t,r){return e.charCodeAt(r)===t}))}(n)&&(n=n.slice(r.length)),t=!1;for(var s=n.length,a=0,u=!1;a<s;){u&&("\n"===n[a]&&(a+=1),u=!1);for(var c=-1,d=i,h=void 0,f=o;c<0&&f<s;f++)":"===(h=n[f])&&d<0?d=f-a:"\r"===h?(u=!0,c=f-a):"\n"===h&&(c=f-a);if(c<0){o=s-a,i=d;break}o=0,i=-1,l(n,a,d,c),a+=c+1}a===s?n="":a>0&&(n=n.slice(a))},reset:c};function c(){t=!0,n="",o=0,i=-1,s=void 0,a=void 0,u=""}function l(t,r,n,o){if(0===o)return u.length>0&&(e({type:"event",id:s,event:a||void 0,data:u.slice(0,-1)}),u="",s=void 0),void(a=void 0);var i,c=n<0,l=t.slice(r,r+(c?o:n)),d=r+(i=c?o:" "===t[r+n+1]?n+2:n+1),h=o-i,f=t.slice(d,d+h).toString();if("data"===l)u+=f?"".concat(f,"\n"):"\n";else if("event"===l)a=f;else if("id"!==l||f.includes("\0")){if("retry"===l){var p=parseInt(f,10);Number.isNaN(p)||e({type:"reconnect-interval",value:p})}}else s=f}};var r=[239,187,191]},5337: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.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t},a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},u=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},l=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.registerAi=t.models=t.createAI=t.createAi=t.Bot=t.AI=void 0;var d=r(7756);Object.defineProperty(t,"AI",{enumerable:!0,get:function(){return d.AI}});var h=r(9737);Object.defineProperty(t,"Bot",{enumerable:!0,get:function(){return h.Bot}});var f=s(r(5305)),p=s(r(1689));t.utils=p,f.MODELS;var v=l(f,["MODELS"]);t.models=v;function y(e){var t=e.env,r=e.baseUrl,o=e.req,i=e.getAccessToken,s=e.handleReqInstance,a=e.i18n;return new d.AI(function(){if(null==s){if(null==i)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return function(e){var t=e.getAccessToken,r=e.req;return{download:r.download,post:r.post,upload:r.upload,fetch:function(e){return u(void 0,void 0,void 0,(function(){var o,i,s,a,u;return c(this,(function(c){switch(c.label){case 0:if("function"!=typeof r.fetch)throw new Error("req.fetch is not a function");return o=e.token,i=e.headers,s=void 0===i?{}:i,a=l(e,["token","headers"]),null==o?[3,1]:(u=o,[3,3]);case 1:return[4,t()];case 2:u=c.sent().accessToken,c.label=3;case 3:return[2,r.fetch(n({headers:n({Authorization:"Bearer ".concat(u)},s)},a))]}}))}))}}}({req:o,getAccessToken:i})}return s({req:o})}(),function(){if(null!=r)return r;if(null==t)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(t,".api.tcloudbasegateway.com/v1")}(),a)}t.createAI=y;var m=y;t.createAi=m;var g={name:"ai",entity:{ai:function(e){var t,r=this,n=this.request;if(null==n.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");return y({req:n,baseUrl:null!==(t=null==e?void 0:e.baseUrl)&&void 0!==t?t:function(){var e=r.getEndPointWithKey("GATEWAY"),t=e.BASE_URL,n=e.PROTOCOL;return"".concat(n).concat(t)}(),handleReqInstance:function(e){return e.req},i18n:this.config.i18n})}}};function b(e){try{e.registerComponent(g)}catch(e){console.warn(e)}}t.registerAi=b,a(r(4669),t);try{window.registerAi=b}catch(e){}},5476: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ArkSimpleModel=void 0;var s=r(1689);function a(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,s=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:s,temperature:o})}var u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="ark/api/v3/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var r,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e})),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},e}();t.ArkSimpleModel=u},7265: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DSSimpleModel=void 0;var s=r(1689);function a(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,s=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:s,temperature:o})}var u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var r,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),n(n({},e),r?{finish_reason:"tool_calls",delta:t}:{delta:t})})),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},e}();t.DSSimpleModel=u},2102: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepSeekSimpleModel=void 0;var s=r(1689),a=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="deepseek/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},e),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var r,o,a,u,c;return i(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),a=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(a),c=u.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e})),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(c)]}}))}))},e}();t.DeepSeekSimpleModel=a},8017: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSimpleModel=void 0;var s=r(1689),a=function(){function e(e,t,r){void 0===r&&(r=""),this.req=e,this.baseUrl=t,this.subUrl=r}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:n(n({},e),{stream:!1}),stream:!1})];case 1:return t=r.sent(),[2,n(n({},t),{rawResponse:t})]}}))}))},e.prototype.doStream=function(e){return o(this,void 0,Promise,(function(){var t,r,o,a,u;return i(this,(function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:n(n({},e),{stream:!0}),stream:!0})];case 1:return r=i.sent(),o=(0,s.toPolyfillReadable)(r),a=(0,s.intoStandardStream)(o),u=a.pipeThrough(new s.TransformStream({transform:function(e,r){var o=e.choices.map((function(e){var r=e.delta;return null==t&&(t=(0,s.isToolCallAssistantMessage)(r)),t?n(n({},e),{finish_reason:"tool_calls",delta:r}):e})),i=n(n({},e),{choices:o});r.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(u)]}}))}))},e}();t.DefaultSimpleModel=a},7239: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanSimpleModel=void 0;var s=r(1689),a=r(8586),u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:n(n({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=i.sent(),o=(0,a.titleCaseToSnakeCase)(r.Response),[2,n(n({},o),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var r,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:n(n({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=(0,a.titleCaseToSnakeCase)(e),i=o.choices.map((function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e})),u=n(n({},o),{choices:i});t.enqueue(n(n({},u),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},e}();t.HunYuanSimpleModel=u},8586:function(e,t){"use strict";var r=this&&this.__assign||function(){return r=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},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.titleCaseToSnakeCase=t.processInput=void 0,t.processInput=function(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tool_choice,s=e.tools,a=e.top_p;return r(r({},e),{messages:(t.forEach((function(e){"tool_calls"in e&&e.tool_calls.filter((function(e){return"function"!==e.type})).forEach((function(t){return console.warn("`type` in tool_call is not 'function'",t,e)}))})),t),model:n,tools:function(){if(s)return s.forEach((function(e){"function"!==e.type&&console.warn("`type` in tool is not 'function'",e)})),s}(),top_p:a,tool_choice:i,temperature:o})},t.titleCaseToSnakeCase=function e(t){return"object"!=typeof t||null==t?t:Array.isArray(t)?t.map((function(t){return e(t)})):Object.entries(t).reduce((function(t,r){var n,o=r[0],i=r[1];return t["_"===(n=o.replace(/[A-Z]/g,(function(e){return"_".concat(e.toLowerCase())}))).charAt(0)?n.slice(1):n]="object"==typeof i?e(i):i,t}),{})}},9301: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanBetaSimpleModel=void 0;var s=r(1689),a=r(8586),u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var r,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e})),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},e}();t.HunYuanBetaSimpleModel=u},5720: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanExpSimpleModel=void 0;var s=r(1689),a=r(8586),u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-exp/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!1}),stream:!1})];case 1:return t=r.sent(),[2,n(n({},t),{rawResponse:t})]}}))}))},e.prototype.doStream=function(e){return o(this,void 0,Promise,(function(){var t,r,o,u,c;return i(this,(function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!0}),stream:!0})];case 1:return r=i.sent(),o=(0,s.toPolyfillReadable)(r),u=(0,s.intoStandardStream)(o),c=u.pipeThrough(new s.TransformStream({transform:function(e,r){var o=e.choices.map((function(e){var r=e.delta;return null==t&&(t=(0,s.isToolCallAssistantMessage)(r)),t?n(n({},e),{finish_reason:"tool_calls",delta:r}):e})),i=n(n({},e),{choices:o});r.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(c)]}}))}))},e}();t.HunYuanExpSimpleModel=u},1586: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanOpenSimpleModel=void 0;var s=r(1689),a=r(8586),u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-open/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var r,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},(0,a.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e})),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},e}();t.HunYuanOpenSimpleModel=u},3925: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.MoonshotSimpleModel=void 0;var s=r(1689);function a(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,s=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:s,temperature:o})}var u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="moonshot/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var r,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e})),i=n(n({},e),{choices:o});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},e}();t.MoonshotSimpleModel=u},4532: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.YiSimpleModel=void 0;var s=r(1689);function a(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,s=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:s,temperature:o})}var u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="01-ai/v1/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=o.sent(),[2,n(n({},r),{rawResponse:r})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var r,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},a(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(e,t){var o,i,a,u,c,l;if((null===(a=null===(i=null===(o=null==e?void 0:e.choices)||void 0===o?void 0:o[0])||void 0===i?void 0:i.delta)||void 0===a?void 0:a.content)||(null===(l=null===(c=null===(u=null==e?void 0:e.choices)||void 0===u?void 0:u[0])||void 0===c?void 0:c.delta)||void 0===l?void 0:l.tool_calls)){var d=e.choices.map((function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==r&&(r=(0,s.isToolCallAssistantMessage)(t)),n(n({},e),r?{finish_reason:"tool_calls",delta:t}:{delta:t})})),h=n(n({},e),{choices:d});t.enqueue(n(n({},h),{rawResponse:e}))}}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},e}();t.YiSimpleModel=u},7173: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ZhiPuSimpleModel=void 0;var s=r(1689);function a(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tool_choice,s=e.tools,a=e.top_p;return n(n({},e),{messages:t,model:r,temperature:o,tool_choice:(i&&"auto"!==i&&console.warn("`tool_choice` is not 'auto'"),i),tools:s,top_p:a})}var u=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=r&&(this.subUrl=r)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return r=a(e),[4,this.req({url:this.url,data:n(n({},r),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),[2,n(n({},o),{rawResponse:o})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var r,o,u,c,l,d;return i(this,(function(i){switch(i.label){case 0:return r=a(e),o=null,[4,this.req({url:this.url,data:n(n({},r),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return u=i.sent(),c=(0,s.toPolyfillReadable)(u),l=(0,s.intoStandardStream)(c),d=l.pipeThrough(new s.TransformStream({transform:function(e,t){var r=e.choices.map((function(e){var t=e.delta;return null==o&&(o=(0,s.isToolCallAssistantMessage)(t)),o?n(n({},e),{finish_reason:"tool_calls",delta:t}):e})),i=n(n({},e),{choices:r});t.enqueue(n(n({},i),{rawResponse:e}))}})),[2,(0,s.createAsyncIterable)(d)]}}))}))},e}();t.ZhiPuSimpleModel=u},8328:function(e,t){"use strict";var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultImageModel=void 0;var o=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.provider=r,this.defaultGenerateImageSubUrl="images/generations",this.generateImageSubUrlConfig={"hunyuan-image":{"hunyuan-image-v3.0-v1.0.4":"images/ar/generations","hunyuan-image-v3.0-v1.0.1":"images/ar/generations"}},this.generateImage=this.generateImageImpl.bind(this)}return e.prototype.generateImageImpl=function(e){var t;return r(this,void 0,Promise,(function(){var r,o;return n(this,(function(n){switch(n.label){case 0:return r=this.defaultGenerateImageSubUrl,"object"==typeof e&&e&&"model"in e&&"string"==typeof e.model&&(o=null===(t=this.generateImageSubUrlConfig[this.provider])||void 0===t?void 0:t[e.model])&&(r=o),[4,this.req({url:this.getGenerateUrl(r),data:e,stream:!1})];case 1:return[2,n.sent()]}}))}))},e.prototype.getGenerateUrl=function(e){return"".concat(this.baseUrl,"/").concat(this.provider,"/").concat(e)},e}();t.DefaultImageModel=o},5305:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toolMap=t.ReactModel=t.DefaultImageModel=t.DefaultSimpleModel=t.HunYuanOpenSimpleModel=t.HunYuanExpSimpleModel=t.MoonshotSimpleModel=t.YiSimpleModel=t.DSSimpleModel=t.ArkSimpleModel=t.HunYuanSimpleModel=t.HunYuanBetaSimpleModel=t.ZhiPuSimpleModel=t.MODELS=void 0;var n=r(7173);Object.defineProperty(t,"ZhiPuSimpleModel",{enumerable:!0,get:function(){return n.ZhiPuSimpleModel}});var o=r(9301);Object.defineProperty(t,"HunYuanBetaSimpleModel",{enumerable:!0,get:function(){return o.HunYuanBetaSimpleModel}});var i=r(7239);Object.defineProperty(t,"HunYuanSimpleModel",{enumerable:!0,get:function(){return i.HunYuanSimpleModel}});var s=r(5476);Object.defineProperty(t,"ArkSimpleModel",{enumerable:!0,get:function(){return s.ArkSimpleModel}});var a=r(7265);Object.defineProperty(t,"DSSimpleModel",{enumerable:!0,get:function(){return a.DSSimpleModel}});var u=r(4532);Object.defineProperty(t,"YiSimpleModel",{enumerable:!0,get:function(){return u.YiSimpleModel}});var c=r(3925);Object.defineProperty(t,"MoonshotSimpleModel",{enumerable:!0,get:function(){return c.MoonshotSimpleModel}});var l=r(5720);Object.defineProperty(t,"HunYuanExpSimpleModel",{enumerable:!0,get:function(){return l.HunYuanExpSimpleModel}});var d=r(1586);Object.defineProperty(t,"HunYuanOpenSimpleModel",{enumerable:!0,get:function(){return d.HunYuanOpenSimpleModel}});var h=r(2102),f=r(8017);Object.defineProperty(t,"DefaultSimpleModel",{enumerable:!0,get:function(){return f.DefaultSimpleModel}});var p=r(8328);Object.defineProperty(t,"DefaultImageModel",{enumerable:!0,get:function(){return p.DefaultImageModel}}),t.MODELS={hunyuan:i.HunYuanSimpleModel,"hunyuan-beta":o.HunYuanBetaSimpleModel,ark:s.ArkSimpleModel,dashscope:a.DSSimpleModel,"01-ai":u.YiSimpleModel,moonshot:c.MoonshotSimpleModel,zhipu:n.ZhiPuSimpleModel,"hunyuan-exp":l.HunYuanExpSimpleModel,"hunyuan-open":d.HunYuanOpenSimpleModel,deepseek:h.DeepSeekSimpleModel};var v=r(1443);Object.defineProperty(t,"ReactModel",{enumerable:!0,get:function(){return v.ReactModel}}),Object.defineProperty(t,"toolMap",{enumerable:!0,get:function(){return v.toolMap}})},1443: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},a=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,o,(t=e[r](t)).done,t.value)}))}}},u=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.toolMap=t.ReactModel=void 0;var c=r(1689);function l(e){var t,r=e.onStepFinish,o=e.abortSignal,i=e.maxSteps,a=e.topP,u=e.toolChoice,l=s(e,["onStepFinish","abortSignal","maxSteps","topP","toolChoice"]);if(null!=i&&i<1)throw new Error("`maxSteps` muse be greater than 0.");return[{onStepFinish:r,abortSignal:o,maxSteps:i},n(n({},l),{tools:null===(t=l.tools)||void 0===t?void 0:t.map((function(e){return"fn"in e?(0,c.functionToolToModelTool)(e):e})),top_p:null!=a?a:l.top_p,tool_choice:null!=u?u:l.tool_choice})]}var d=function(){function e(e){this.model=e}return e.prototype.generateText=function(e,t){var r,n;return o(this,void 0,Promise,(function(){var o,s,a,c,d,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N,D,U=this;return i(this,(function(i){switch(i.label){case 0:return o=[],s={completion_tokens:0,prompt_tokens:0,total_tokens:0},a=l(e),c=a[0],d=c.onStepFinish,m=c.maxSteps,g=void 0===m?10:m,b=a[1],[4,(_=function(){return U.model.doGenerate(b,t)})()];case 1:w=i.sent(),E=1,w.rawResponse&&o.push(w.rawResponse),I=null,i.label=2;case 2:if(!(E<g&&null!=(I=h(w))))return[3,9];S=v(w.usage),y(s,S),i.label=3;case 3:return i.trys.push([3,7,,8]),[4,p(I)];case 4:return O=i.sent(),A=w.choices[0],[4,null==d?void 0:d({finishReason:A.finish_reason,messages:b.messages.slice(),text:A.message.content,toolCall:I,toolResult:O,stepUsage:S,totalUsage:Object.assign({},s)})];case 5:return i.sent(),f(b.messages,A.message,O),[4,_()];case 6:return(w=i.sent()).rawResponse&&o.push(w.rawResponse),E+=1,[3,8];case 7:return T=i.sent(),[2,{text:"",messages:b.messages,usage:s,error:T,rawResponses:o}];case 8:return[3,2];case 9:return P=null===(r=null==w?void 0:w.choices)||void 0===r?void 0:r[0],R=null==P?void 0:P.message,C=null!==(n=null==R?void 0:R.content)&&void 0!==n?n:"",N=R?u(u([],b.messages,!0),[R],!1):b.messages,D=v(w.usage),y(s,D),[4,null==d?void 0:d({finishReason:P.finish_reason,messages:N.slice(),text:C,toolCall:h(w),toolResult:null,stepUsage:D,totalUsage:Object.assign({},s)})];case 10:return i.sent(),[2,{text:C,messages:N,usage:s,rawResponses:o}]}}))}))},e.prototype.streamText=function(e,t){var r;return o(this,void 0,Promise,(function(){var n,s,d,h,v,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N,D,U,x,L,j,k,M,q,W,F,B,H,G,V,K,Y,J=this;return i(this,(function(z){switch(z.label){case 0:return n={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=l(e),d=s[0],h=d.onStepFinish,v=d.maxSteps,m=void 0===v?10:v,g=s[1],[4,(b=function(){return J.model.doStream(g,t)})()];case 1:_=z.sent(),w=1,E=null,I=function(){var e=_.tee(),t=e[0],r=e[1];return _=(0,c.createAsyncIterable)(t),function(e){var t,r,n,s,u,l,d,h,f,p;return o(this,void 0,Promise,(function(){var o,v,y,m,g,b,_,w,E,I,S,O,A;return i(this,(function(i){switch(i.label){case 0:o={completion_tokens:0,prompt_tokens:0,total_tokens:0},v=(0,c.createAsyncIterable)(e),m={role:"assistant",content:"",tool_calls:[y={id:"",function:{name:"",arguments:""},type:""}]},i.label=1;case 1:i.trys.push([1,6,7,12]),g=!0,b=a(v),i.label=2;case 2:return[4,b.next()];case 3:if(_=i.sent(),t=_.done)return[3,5];s=_.value,g=!1;try{if(!(E=null==(w=s)?void 0:w.choices[0]))return[2,null];if(I=E.finish_reason,S=E.delta,"tool_calls"!==I)return[2,null];if(!S)return[3,4];if(S.content&&(m.content+=S.content),!("tool_calls"in S))return[3,4];(null==(O=null===(u=null==S?void 0:S.tool_calls)||void 0===u?void 0:u[0])?void 0:O.id)&&(y.id=O.id),(null==O?void 0:O.type)&&(y.type=O.type),(null===(l=null==O?void 0:O.function)||void 0===l?void 0:l.name)&&(y.function.name=O.function.name),(null===(d=null==O?void 0:O.function)||void 0===d?void 0:d.arguments)&&(y.function.arguments+=O.function.arguments),(null===(h=null==w?void 0:w.usage)||void 0===h?void 0:h.completion_tokens)&&(o.completion_tokens=w.usage.completion_tokens),(null===(f=null==w?void 0:w.usage)||void 0===f?void 0:f.prompt_tokens)&&(o.prompt_tokens=w.usage.prompt_tokens),(null===(p=null==w?void 0:w.usage)||void 0===p?void 0:p.total_tokens)&&(o.total_tokens=w.usage.total_tokens)}finally{g=!0}i.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return A=i.sent(),r={error:A},[3,12];case 7:return i.trys.push([7,,10,11]),g||t||!(n=b.return)?[3,9]:[4,n.call(b)];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:if(r)throw r.error;return[7];case 11:return[7];case 12:return[2,{message:m,usage:o}]}}))}))}(r)},z.label=2;case 2:return(S=w<m)?[4,I()]:[3,4];case 3:S=null!=(E=z.sent()),z.label=4;case 4:if(!S)return[3,11];O=E.message,A=E.usage,y(n,A),T=null===(r=O.tool_calls)||void 0===r?void 0:r[0],z.label=5;case 5:return z.trys.push([5,9,,10]),[4,p(T)];case 6:return P=z.sent(),[4,null==h?void 0:h({finishReason:"tool_calls",messages:g.messages.slice(),text:O.content,toolCall:T,toolResult:P,stepUsage:A,totalUsage:Object.assign({},n)})];case 7:return z.sent(),f(g.messages,O,P),[4,b()];case 8:return _=z.sent(),[3,10];case 9:return R=z.sent(),C=_.tee(),N=C[0],D=C[1],[2,{messages:Promise.resolve(g.messages),dataStream:(0,c.createAsyncIterable)(N),textStream:(0,c.createAsyncIterable)(D.pipeThrough(new c.TransformStream({transform:function(e,t){var r,n,o,i=null===(o=null===(n=null===(r=null==e?void 0:e.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:Promise.resolve(n),error:R}];case 10:return[3,2];case 11:return[4,I()];case 12:return(E=z.sent())?(U=E.message,x=E.usage,y(n,x),L=u(u([],g.messages,!0),[U],!1),h({messages:L.slice(),finishReason:"tool_call",stepUsage:x,text:U.content,toolCall:U.tool_calls[0],totalUsage:Object.assign({},n)}),j=_.tee(),k=j[0],M=j[1],[2,{messages:Promise.resolve(u(u([],g.messages,!0),[U],!1)),dataStream:(0,c.createAsyncIterable)(k),textStream:(0,c.createAsyncIterable)(M.pipeThrough(new c.TransformStream({transform:function(e,t){var r,n,o,i=null===(o=null===(n=null===(r=null==e?void 0:e.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:Promise.resolve(n)}]):(q=(0,c.createPromise)(),W=(0,c.createPromise)(),F={role:"assistant",content:""},B="",H={completion_tokens:0,prompt_tokens:0,total_tokens:0},G=_.pipeThrough(new c.TransformStream({transform:function(e,t){var r,n,o,i,s,a,u,c,l=null===(o=null===(n=null===(r=null==e?void 0:e.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof l&&(F.content+=l);var d=null===(s=null===(i=null==e?void 0:e.choices)||void 0===i?void 0:i[0])||void 0===s?void 0:s.finish_reason;d&&(B=d),(null===(a=null==e?void 0:e.usage)||void 0===a?void 0:a.completion_tokens)&&(H.completion_tokens=e.usage.completion_tokens),(null===(u=null==e?void 0:e.usage)||void 0===u?void 0:u.prompt_tokens)&&(H.prompt_tokens=e.usage.prompt_tokens),(null===(c=null==e?void 0:e.usage)||void 0===c?void 0:c.total_tokens)&&(H.total_tokens=e.usage.total_tokens),t.enqueue(e)},flush:function(){q.res(u(u([],g.messages,!0),[F],!1)),y(n,H),W.res(Object.assign({},n)),null==h||h({messages:u(u([],g.messages,!0),[F],!1),finishReason:B,text:F.content,stepUsage:H,totalUsage:Object.assign({},n)})}})),V=G.tee(),K=V[0],Y=V[1],[2,{messages:q.promise,dataStream:(0,c.createAsyncIterable)(K),textStream:(0,c.createAsyncIterable)(Y.pipeThrough(new c.TransformStream({transform:function(e,t){var r,n,o,i=null===(o=null===(n=null===(r=null==e?void 0:e.choices)||void 0===r?void 0:r[0])||void 0===n?void 0:n.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:W.promise}])}}))}))},e}();function h(e){var t,r=null===(t=null==e?void 0:e.choices)||void 0===t?void 0:t[0];if(!r)return null;var n=r.finish_reason,o=r.message;return"tool_calls"!==n?null:o&&(0,c.isToolCallAssistantMessage)(o)?o.tool_calls[0]:null}function f(e,t,r){e.push(t,{role:"tool",tool_call_id:t.tool_calls[0].id,content:JSON.stringify(r)})}function p(e){return t.toolMap.get(e.function.name)(JSON.parse(e.function.arguments))}function v(e){var t,r,n;return{completion_tokens:null!==(t=null==e?void 0:e.completion_tokens)&&void 0!==t?t:0,prompt_tokens:null!==(r=null==e?void 0:e.prompt_tokens)&&void 0!==r?r:0,total_tokens:null!==(n=null==e?void 0:e.total_tokens)&&void 0!==n?n:0}}function y(e,t){e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens}t.ReactModel=d,t.toolMap=new Map},4669:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleChatModel=void 0;t.SimpleChatModel=function(){}},1689: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},i=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,o,(t=e[r](t)).done,t.value)}))}}};Object.defineProperty(t,"__esModule",{value:!0}),t.functionToolToModelTool=t.isToolCallAssistantMessage=t.createPromise=t.readableStream2JsonObject=t.intoTextStream=t.intoStandardStream=t.createAsyncIterable=t.TextDecoderStream=t.toPolyfillReadable=t.createEventSourceParserTransformStream=t.TransformStream=t.ReadableStream=void 0;var s=r(8775),a=r(766),u=r(9964),c=r(6282);t.ReadableStream=s.ReadableStream,t.TransformStream=s.TransformStream,t.createEventSourceParserTransformStream=function(){var e;return new t.TransformStream({start:function(t){e=(0,u.createParser)((function(e){"event"===e.type&&t.enqueue(e)}))},transform:function(t){e.feed(t)}})},t.toPolyfillReadable=(0,a.createReadableStreamWrapper)(t.ReadableStream);var l=function(){function e(e,r){void 0===e&&(e="utf-8"),void 0===r&&(r={});var n=this;this.transform=new t.TransformStream({transform:function(e,t){var r=n.handle.decode(new Uint8Array(e),{stream:!0});r&&t.enqueue(r)},flush:function(e){var t=n.handle.decode();t&&e.enqueue(t),e.terminate()}}),this.handle=new c.TextDecoder(e,r)}return Object.defineProperty(e.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),e}();function d(e){var t=e;return t[Symbol.asyncIterator]=function(){var t=e.getReader();return{next:function(){return n(this,void 0,Promise,(function(){var e,r,n;return o(this,(function(o){switch(o.label){case 0:return[4,t.read()];case 1:return e=o.sent(),r=e.done,n=e.value,[2,r?{done:!0,value:void 0}:{done:!1,value:n}]}}))}))}}},t}function h(e){return d((0,t.toPolyfillReadable)(e).pipeThrough(new l))}t.TextDecoderStream=l,t.createAsyncIterable=d,t.intoStandardStream=function(e){return d(e.pipeThrough(new l).pipeThrough((0,t.createEventSourceParserTransformStream)()).pipeThrough(new t.TransformStream({transform:function(e,t){try{var r=JSON.parse(e.data);t.enqueue(r)}catch(r){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",r,e):t.terminate()}}})))},t.intoTextStream=h,t.readableStream2JsonObject=function(e){var t,r,s,a;return n(this,void 0,void 0,(function(){var n,u,c,l,d,f;return o(this,(function(o){switch(o.label){case 0:n=h(e),u="",o.label=1;case 1:o.trys.push([1,6,7,12]),c=!0,l=i(n),o.label=2;case 2:return[4,l.next()];case 3:if(d=o.sent(),t=d.done)return[3,5];a=d.value,c=!1;try{u+=a}finally{c=!0}o.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return f=o.sent(),r={error:f},[3,12];case 7:return o.trys.push([7,,10,11]),c||t||!(s=l.return)?[3,9]:[4,s.call(l)];case 8:o.sent(),o.label=9;case 9:return[3,11];case 10:if(r)throw r.error;return[7];case 11:return[7];case 12:return[2,JSON.parse(u)]}}))}))},t.createPromise=function(){var e,t;return{promise:new Promise((function(r,n){e=r,t=n})),res:e,rej:t}},t.isToolCallAssistantMessage=function(e){var t;return"assistant"===e.role&&"tool_calls"in e&&null!=(null===(t=e.tool_calls)||void 0===t?void 0:t[0])},t.functionToolToModelTool=function(e){return{type:"function",function:{description:e.description,name:e.name,parameters:e.parameters}}}},5378: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateApis=t.generateCallApis=t.callApi=void 0;var s=r(794);function a(e,t){var r,a,u,c;return o(this,void 0,Promise,(function(){var o,l,d,h,f,p,v,y,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N;return i(this,(function(i){switch(i.label){case 0:l=(o=e||{}).name,d=o.body,h=o.path,f=void 0===h?"":h,p=o.method,v=void 0===p?"POST":p,y=o.headers,m=void 0===y?{}:y,g=(e||{}).token,b={};try{b=JSON.parse(d)}catch(e){b=d||{}}if(!l)throw new Error(JSON.stringify({code:s.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return _="",E=(w=this).gatewayOrigin,I=w.getAccessToken,S=w.env,E?_="".concat(E,"/v1"):this.getEndPointWithKey?(O=this.getEndPointWithKey("GATEWAY"),A=O.BASE_URL,T=O.PROTOCOL,_="".concat(T).concat(A)):_="https://".concat(S,".api.tcloudbasegateway.com/v1"),P="".concat(_,"/apis/").concat(l),R=f.startsWith("/")?f:"/".concat(f),I?[4,I()]:[3,2];case 1:C=i.sent().accessToken,m.Authorization="Bearer ".concat(C),i.label=2;case 2:if(N=["GET","HEAD"].includes(null===(r=null==v?void 0:v.toUpperCase)||void 0===r?void 0:r.call(v)))try{R="".concat(R).concat(R.includes("?")?"&":"?").concat(Object.keys(b).map((function(e){return"".concat(e,"=").concat(b[e])})).join("&"))}catch(e){}return[4,this.request.fetch(n(n(n({url:"".concat(P).concat(R),method:v||"POST",headers:n({"Content-Type":"application/json; charset=utf-8"},m)},N?{}:{body:JSON.stringify(b)}),{token:(null===(a=null==g?void 0:g.trim)||void 0===a?void 0:a.call(g))||(null===(c=null===(u=m.Authorization)||void 0===u?void 0:u.replace)||void 0===c?void 0:c.call(u,/^Bearer /,""))||null}),t))];case 3:return[4,i.sent().data];case 4:return[2,i.sent()]}}))}))}t.callApi=a;var u=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function c(e){var t=this;return new Proxy({},{get:function(r,s){if("string"!=typeof s)throw new Error("[apis] method must be string");var c=s.toLocaleUpperCase();if(!u.includes(c))throw new Error("[apis] invalid method: ".concat(s));return function(r,s){return o(t,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,a.call(this,n({name:e,method:("REQUEST"===c?r.method:c)||"POST"},r),s)];case 1:return[2,t.sent()]}}))}))}}})}t.generateCallApis=c,t.generateApis=function(e){var t=this;return Object.keys(e||{}).forEach((function(r){void 0!==e[r]&&(t[r]=e[r])})),new Proxy({},{get:function(e,r){if("string"==typeof r)return c.call(t,r)}})}},1944:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.registerApis=t.generateApis=void 0;var i=r(5378);Object.defineProperty(t,"generateApis",{enumerable:!0,get:function(){return i.generateApis}});var s="apis",a={name:s,IIFE:!0,entity:function(){Object.defineProperty(this.prototype,s,{get:function(){return i.generateApis.call(this)},configurable:!0,enumerable:!0})}};function u(e){try{e.registerComponent(a)}catch(e){console.warn(e)}}t.registerApis=u;try{cloudbase.registerComponent(a)}catch(e){}o(r(2026),t);try{window.registerApis=u}catch(e){}},2026:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},7922: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)};Object.defineProperty(t,"__esModule",{value:!0}),t.OAUTH2_LOGINTYPE_PREFIX=t.LOGINTYPE=t.getBaseEndPoint=t.setRegionLevelEndpoint=t.setGatewayEndPointWithEnv=t.getEndPointInfo=t.setEndPointInfo=t.DEFAULT_PROTOCOL=t.DATA_VERSION=t.getSdkName=t.setSdkName=t.getSdkVersion=t.setSdkVersion=void 0;var o=r(2877),i=o.constants.setSdkName,s=o.constants.setProtocol,a="",u="@cloudbase/js-sdk";t.setSdkVersion=function(e){a=e},t.getSdkVersion=function(){return a},t.setSdkName=function(e){u=e,i(e)},t.getSdkName=function(){return u},t.DATA_VERSION="2020-01-10";var c,l=[],d=["env","endPointKey","region"];function h(e){return l.find((function(t){return d.filter((function(t){return null!=e[t]})).every((function(r){return t[r]===e[r]}))}))}function f(e){var r,o;e.protocol&&!/:$/.test(e.protocol)&&(e.protocol="".concat(e.protocol,":"));var i=h(e);i?(null!=e.baseUrl&&(i.baseUrl=e.baseUrl),null!=e.protocol&&(i.protocol=e.protocol)):l.push(n(n({},e),{protocol:null!==(r=e.protocol)&&void 0!==r?r:t.DEFAULT_PROTOCOL})),"CLOUD_API"===e.endPointKey&&s(null!==(o=e.protocol)&&void 0!==o?o:t.DEFAULT_PROTOCOL)}function p(e,t,r){return h({env:e,endPointKey:t,region:r})}t.DEFAULT_PROTOCOL="https:",t.setEndPointInfo=f,t.getEndPointInfo=p,t.setGatewayEndPointWithEnv=function(e,t,r){var n="//".concat(e,".api.tcloudbasegateway.com/v1");r&&(n="//".concat(e,".api.intl.tcloudbasegateway.com/v1")),f({endPointKey:"GATEWAY",env:e,baseUrl:n,protocol:t})},t.setRegionLevelEndpoint=function(e,t,r){f({env:e,region:t,baseUrl:"//".concat(e,".").concat(t||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:r,endPointKey:"CLOUD_API"})},t.getBaseEndPoint=function(e,t){void 0===t&&(t="CLOUD_API");var r=p(e,t||"CLOUD_API"),n=r.protocol,o=r.baseUrl;return"".concat(n).concat(o).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]},(c=t.LOGINTYPE||(t.LOGINTYPE={})).NULL="NULL",c.ANONYMOUS="ANONYMOUS",c.WECHAT="WECHAT",c.WECHAT_PUBLIC="WECHAT-PUBLIC",c.WECHAT_OPEN="WECHAT-OPEN",c.CUSTOM="CUSTOM",c.EMAIL="EMAIL",c.USERNAME="USERNAME",c.PHONE="PHONE",t.OAUTH2_LOGINTYPE_PREFIX="OAUTH2"},6950: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.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.cloudbase=t.LANGS=t.getBaseEndPoint=void 0;var u=r(2877),c=r(4276),l=r(1985),d=r(6938),h=r(901),f=r(7922),p=r(3509),v=r(7922);Object.defineProperty(t,"getBaseEndPoint",{enumerable:!0,get:function(){return v.getBaseEndPoint}});var y=r(3509);Object.defineProperty(t,"LANGS",{enumerable:!0,get:function(){return y.LANGS}});var m=u.adapters.useAdapters,g=u.adapters.useDefaultAdapter,b=u.constants.ERRORS,_=u.constants.COMMUNITY_SITE_URL,w=u.utils.printWarn,E=u.helpers.catchErrorsDecorator,I={timeout:15e3,persistence:"local"},S=6e5,O={},A=function(){function e(e){this.cloudbaseConfig=e||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=(0,f.getSdkVersion)()}return Object.defineProperty(e.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"platform",{get:function(){return l.Platform},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cache",{get:function(){return(0,d.getCacheByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"localCache",{get:function(){return(0,d.getLocalCache)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"request",{get:function(){return(0,h.getRequestByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),e.prototype.init=function(t){var r,o,i;if(void 0===t&&(t={env:""}),t.endPointMode=t.endPointMode||"GATEWAY",l.Platform.adapter||this.useDefaultAdapter(),!(t=this.dealNodeAdapterConfig(t)).env)throw new Error(JSON.stringify({code:b.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(t);var s={timeout:t.timeout||15e3,timeoutMsg:"[".concat((0,f.getSdkName)(),"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(t.timeout/1e3,"s"),auth:t.auth};this.requestClient=new l.Platform.adapter.reqClass(s),this.cloudbaseConfig=n(n(n({},I),t),{i18n:(0,p.i18nProxy)(l.Platform,t)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var a=this.cloudbaseConfig,u=a.env,c=a.persistence,v=a.debug,y=a.timeout,m=a.oauthClient,g=a.i18n;(0,d.initCache)({env:u,persistence:c,debug:v,platformInfo:this.platform}),(0,f.setRegionLevelEndpoint)(u,t.region||""),(0,f.setGatewayEndPointWithEnv)(u,f.DEFAULT_PROTOCOL,t.intl);var _=new e(this.cloudbaseConfig);return(0,h.initRequest)({env:u,region:t.region||"",timeout:y,oauthClient:m,_fromApp:_,i18n:g,endPointMode:t.endPointMode,auth:t.auth}),_.requestClient=this.requestClient,null===(r=null==this?void 0:this.fire)||void 0===r||r.call(this,"cloudbase_init",_),this.try2InitAuth(_),(null===(o=l.Platform.adapter)||void 0===o?void 0:o.nodeTool)&&(null===(i=l.Platform.adapter)||void 0===i||i.nodeTool(_,this.cloudbaseConfig)),_},e.prototype.updateConfig=function(e){var t=e.persistence,r=e.debug;this.cloudbaseConfig.persistence=t,this.cloudbaseConfig.debug=r,(0,d.initCache)({env:this.cloudbaseConfig.env,persistence:t,debug:r,platformInfo:this.platform})},e.prototype.updateLang=function(e){var t;e&&e!==(null===(t=this.cloudbaseConfig.i18n)||void 0===t?void 0:t.lang)&&(this.cloudbaseConfig.i18n.lang=e)},e.prototype.registerExtension=function(e){O[e.name]=e},e.prototype.invokeExtension=function(e,t){return s(this,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:if(!(r=O[e]))throw new Error(JSON.stringify({code:b.INVALID_PARAMS,msg:"extension:".concat(e," must be registered before invoke")}));return[4,r.invoke(t,this)];case 1:return[2,n.sent()]}}))}))},e.prototype.useAdapters=function(e,t){var r=m(e,t)||{},n=r.adapter,o=r.runtime;n&&(l.Platform.adapter=n),o&&(l.Platform.runtime=o)},e.prototype.registerHook=function(t){(0,c.registerHook)(e,t)},e.prototype.registerComponent=function(t){(0,c.registerComponent)(e,t)},e.prototype.registerVersion=function(e){(0,f.setSdkVersion)(e),this.version=e},e.prototype.registerSdkName=function(e){(0,f.setSdkName)(e)},e.prototype.isInitialized=function(e){return void 0===e&&(e=this.cloudbaseConfig),["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some((function(t){return e.env.toLowerCase()===t.toLowerCase()}))&&w(b.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(e.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==e?void 0:e.env)},e.prototype.registerEndPoint=function(e,t){(0,f.setEndPointInfo)({baseUrl:e,protocol:t,env:this.config.env,endPointKey:"CLOUD_API"})},e.prototype.registerEndPointWithKey=function(e){(0,f.setEndPointInfo)({env:this.config.env,endPointKey:e.key,baseUrl:e.url,protocol:e.protocol})},e.prototype.getEndPointWithKey=function(e){var t=(0,f.getEndPointInfo)(this.config.env,e);return{BASE_URL:t.baseUrl,PROTOCOL:t.protocol}},e.prototype.parseCaptcha=function(e){return u.utils.parseCaptcha(e)},e.prototype.useDefaultAdapter=function(){var e=g.bind(this)(),t=e.adapter,r=e.runtime;l.Platform.adapter=t,l.Platform.runtime=r},e.prototype.formatTimeout=function(e){switch(!0){case e>S:return w(b.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),S;case e<100:return w(b.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return e}},e.prototype.try2InitAuth=function(e){try{e.auth()}catch(e){console.log("try2InitAuth error:",e)}},e.prototype.dealNodeAdapterConfig=function(e){return e},o([E({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(_)]}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",e)],e.prototype,"init",null),o([E({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(_)]}),i("design:type",Function),i("design:paramtypes",[String,Object]),i("design:returntype",Promise)],e.prototype,"invokeExtension",null),e}();t.cloudbase=new A,t.cloudbase.useAdapters((0,l.getWxDefaultAdapter)()),t.default=t.cloudbase},1985: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.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t},a=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.getWxDefaultAdapter=t.Platform=void 0;var u=s(r(7917)),c=r(2764);t.Platform={},t.getWxDefaultAdapter=function(){return u.WxRequest.prototype.upload=function(e){var t=this,r=this;return new Promise((function(o){var i=e.url,s=e.file,a=e.data,u=e.headers,c=wx.getFileSystemManager(),l=wx.request({url:i,method:e.method,header:n({"content-type":" "},u),data:c.readFileSync(s),timeout:t._timeout,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&(null==a?void 0:a.success_action_status)&&(t.statusCode=parseInt(a.success_action_status,10)),o(t)},fail:function(e){o(e)},complete:function(e){if((null==e?void 0:e.errMsg)&&r._timeout&&-1!==r._restrictedMethods.indexOf("upload")&&"request:fail timeout"===e.errMsg){console.warn(r._timeoutMsg);try{l.abort()}catch(e){}}}})}))},u.default.genAdapter=function(e){return{root:{globalThis:{}},reqClass:u.WxRequest,wsClass:u.WxMpWebSocket,captchaOptions:{openURIWithCallback:function(t){var r=e.EventBus,o={},i=t;console.log("openURIWithCallback",t);var s=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(s){i=s[1],console.log("openURIWithCallback url",i);var c=s[2];c&&(o=(0,u.parseQueryString)(c))}console.log("openURIWithCallback queryObj",o);var l=o.token,d=a(o,["token"]);return/^data:/.test(i)&&!l?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(t)}):l?new Promise((function(e){console.log("wait for captcha..."),r.$emit("CAPTCHA_DATA_CHANGE",n(n({},d),{token:l,url:i})),r.$once("RESOLVE_CAPTCHA_DATA",(function(t){e(t)}))})):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:u.wxMpStorage,primaryStorage:c.StorageType.local,getAppSign:function(){var e=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?e&&e.miniProgram?e.miniProgram.appId:"":e&&e.plugin?e.plugin.appId:""}}},u.default}},6938: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)};Object.defineProperty(t,"__esModule",{value:!0}),t.getLocalCache=t.getCacheByEnvId=t.initCache=void 0;var o=r(2877).cache.CloudbaseCache,i={},s={};t.initCache=function(e){var t=e.env,r=e.platformInfo,a={userInfoKey:"".concat("user_info","_").concat(t)};i[t]=i[t]||new o(n(n({},e),{keys:a,platformInfo:r})),s[t]=s[t]||new o(n(n({},e),{keys:a,platformInfo:r,persistence:"local"}))},t.getCacheByEnvId=function(e){return i[e]},t.getLocalCache=function(e){return s[e]}},4276:function(e,t,r){"use strict";var n=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.registerHook=t.registerComponent=void 0;var o=r(2877).constants.ERRORS,i={};function s(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&&(e={});break;case Array:e=[];break;default:return t}for(var r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=s(e[o],t[o]))}return e}t.registerComponent=function(e,t){var r=t.name,a=t.namespace,u=t.entity,c=t.injectEvents,l=t.IIFE,d=void 0!==l&&l;if(i[r]||a&&e[a])throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"Duplicate component ".concat(r)}));if(d){if(!u||"function"!=typeof u)throw new Error(JSON.stringify({code:o.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));u.call(e)}if(i[r]=t,a?e.prototype[a]=u:s(e.prototype,u),c){var h=c.bus,f=c.events;if(!h||!f||0===f.length)return;var p=e.prototype.fire||function(){};e.prototype.events||(e.prototype.events={}),(e.prototype.events||{})[r]?e.prototype.events[r].events=n(n([],e.prototype.events[r].events,!0),f,!0):e.prototype.events[r]={bus:h,events:f},e.prototype.fire=function(e,t){p(e,t);for(var r=0,n=Object.keys(this.events);r<n.length;r++){var o=n[r],i=this.events[o],s=i.bus;if(i.events.includes(e)){s.fire(e,t);break}}}}},t.registerHook=function(e,t){var r=t.entity,i=t.target;if(Object.prototype.hasOwnProperty.call(e,i))throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:".concat(i," is not exist")}));var s=e.prototype[i];if("function"!=typeof s)throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:".concat(i," is not a function which is the only type supports hook")}));e.prototype[i]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r.call.apply(r,n([this],e,!1)),s.call.apply(s,n([this],e,!1))}}},3509:function(e,t,r){"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.i18nProxy=t.t=t.langMap=t.LANG_HEADER_KEY=t.LANGS=void 0;var o,i=r(2877);!function(e){e.ZH="zh-CN",e.EN="en-US"}(o=t.LANGS||(t.LANGS={})),t.LANG_HEADER_KEY="Accept-Language",t.langMap=((n={})[o.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code","错误信息":"error message","未实现":"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs","请求超时":"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},n),t.t=function(e,r){var n;return(null===(n=t.langMap[r])||void 0===n?void 0:n[e])||e},t.i18nProxy=function(e,r){var n,s,a=function(e){return"lang_".concat(e.clientId||e.env)}(r),u=(e.adapter||{}).localStorage,c=r.lang||(null===(n=null==u?void 0:u.getItem)||void 0===n?void 0:n.call(u,a))||o.ZH;return null===(s=null==u?void 0:u.setItem)||void 0===s||s.call(u,a,c),new Proxy({t:function(e){return(0,t.t)(e,c)},LANG_HEADER_KEY:t.LANG_HEADER_KEY,lang:c},{get:function(e,t){var r;return"lang"===t&&(null===(r=null==u?void 0:u.getItem)||void 0===r?void 0:r.call(u,a))||e[t]},set:function(e,r,n){var o;return"lang"===r&&n!==e[r]&&(e[r]=n,e.t=function(e){return(0,t.t)(e,n)},null===(o=null==u?void 0:u.setItem)||void 0===o||o.call(u,a,n),i.langEvent.bus.fire(i.langEvent.LANG_CHANGE_EVENT,{i18n:e})),e[r]=n,!0}})}},901: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.getRequestByEnvId=t.initRequest=t.CloudbaseRequest=void 0;var a=r(7922),u=r(2877),c=r(6938),l=r(1985),d=u.constants.ERRORS,h=u.utils.genSeqId,f=u.utils.isFormData,p=u.utils.formatUrl,v=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function y(e,t,r){var o=e[t];e[t]=function(t){var i={},s={};r.forEach((function(r){var n=r.call(e,t),o=n.data,a=n.headers;Object.assign(i,o),Object.assign(s,a)}));var a=t.data;return a&&(f(a)?Object.keys(i).forEach((function(e){a.append(e,i[e])})):t.data=n(n({},a),i)),t.headers=n(n({},t.headers||{}),s),o.call(e,t)}}function m(){var e=h();return{data:{seqId:e},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat((0,a.getSdkVersion)()),"x-seqid":e}}}var g=function(){function e(e){var t=this;this.throwWhenRequestFail=!1,this.config=e;var r={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"],auth:e.auth};this.reqClass=new l.Platform.adapter.reqClass(r),this.throwWhenRequestFail=e.throw||!1,this.localCache=(0,c.getLocalCache)(this.config.env),"GATEWAY"!==this.config.endPointMode&&(y(this.reqClass,"post",[m]),y(this.reqClass,"upload",[m]),y(this.reqClass,"download",[m])),u.langEvent.bus.on(u.langEvent.LANG_CHANGE_EVENT,(function(e){var r;t.config.i18n=(null===(r=e.data)||void 0===r?void 0:r.i18n)||t.config.i18n}))}return e.prototype.getAccessToken=function(e){return void 0===e&&(e=null),o(this,void 0,void 0,(function(){var t,r,n;return i(this,(function(o){switch(o.label){case 0:if(null!=e)return[2,e];if(!(t=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return r=t.oauthInstance,n=r.oauth2client,[4,this.getOauthAccessTokenV2(n)];case 1:return[2,o.sent().accessToken]}}))}))},e.prototype.getDefaultHeaders=function(){var e,t,r;return(e={})[null===(t=this.config.i18n)||void 0===t?void 0:t.LANG_HEADER_KEY]=null===(r=this.config.i18n)||void 0===r?void 0:r.lang,e["X-SDK-Version"]="@cloudbase/js-sdk/".concat((0,a.getSdkVersion)()),e},e.prototype.post=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.reqClass.post(n(n({},e),{headers:n(n({},e.headers),this.getDefaultHeaders()),customReqOpts:t}))];case 1:return[2,r.sent()]}}))}))},e.prototype.upload=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.reqClass.upload(n(n({},e),{headers:n(n({},e.headers),this.getDefaultHeaders())}))];case 1:return[2,t.sent()]}}))}))},e.prototype.download=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.reqClass.download(n(n({},e),{headers:n(n({},e.headers),this.getDefaultHeaders())}))];case 1:return[2,t.sent()]}}))}))},e.prototype.getBaseEndPoint=function(e){return void 0===e&&(e="CLOUD_API"),(0,a.getBaseEndPoint)(this.config.env,e)},e.prototype.getOauthAccessTokenV2=function(e){return o(this,void 0,Promise,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:return[4,e.getAccessToken()];case 1:return t=n.sent(),[4,e.getCredentials()];case 2:return r=n.sent(),[2,{accessToken:t,accessTokenExpire:new Date(r.expires_at).getTime()}]}}))}))},e.prototype.request=function(e,t,r,s){var u,c;return o(this,void 0,Promise,(function(){var o,l,d,h,f,y,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N,D,U;return i(this,(function(i){switch(i.label){case 0:if(i.trys.push([0,4,,5]),o="x-tcb-trace_".concat(this.config.env),l="application/x-www-form-urlencoded",d=n({action:e,dataVersion:a.DATA_VERSION,env:this.config.env},t),-1!==v.indexOf(e))return[3,2];if(!(h=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return f=h.oauthInstance,y=f.oauth2client,m=d,[4,this.getOauthAccessTokenV2(y)];case 1:m.access_token=i.sent().accessToken,i.label=2;case 2:return"storage.uploadFile"===e?(g=new FormData,Object.keys(g).forEach((function(e){Object.prototype.hasOwnProperty.call(g,e)&&void 0!==g[e]&&g.append(e,d[e])})),l="multipart/form-data"):(l="application/json;charset=UTF-8",g={},Object.keys(d).forEach((function(e){void 0!==d[e]&&(g[e]=d[e])}))),b={headers:n(n({"content-type":l},this.getDefaultHeaders()),null==r?void 0:r.headers)},(null==r?void 0:r.onUploadProgress)&&(b.onUploadProgress=r.onUploadProgress),this.config.region&&(b.headers["X-TCB-Region"]=this.config.region),(_=this.localCache.getStore(o))&&(b.headers["X-TCB-Trace"]=_),w=void 0!==(null==r?void 0:r.parse)?r.parse:t.parse,E=void 0!==(null==r?void 0:r.inQuery)?r.inQuery:t.inQuery,I=void 0!==(null==r?void 0:r.search)?r.search:t.search,S=n(n({},(null==r?void 0:r.defaultQuery)||{}),{env:this.config.env}),w&&(S.parse=!0),E&&(S=n(n({},E),S)),O=(null==r?void 0:r.endPointMode)||this.config.endPointMode||"CLOUD_API",A=(0,a.getEndPointInfo)(this.config.env,O),T=A.baseUrl,P=A.protocol,"GATEWAY"===O&&/^((database)\.)|(auth\.wsWebSign)/.test(e)&&(R=(0,a.getEndPointInfo)(this.config.env,"CLOUD_API"),T="".concat(R.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),C=void 0,C=r.pathname?p(P,"".concat(null===(u=(0,a.getBaseEndPoint)(this.config.env,O))||void 0===u?void 0:u.replace(/^https?:/,""),"/").concat(r.pathname),S):p(P,T,S),I&&(C+=I),[4,this.post(n({url:C,data:g},b),s)];case 3:if(N=i.sent(),(D=null===(c=N.header)||void 0===c?void 0:c["x-tcb-trace"])&&this.localCache.setStore(o,D),200!==Number(N.status)&&200!==Number(N.statusCode)||!N.data)throw new Error("network request error");return[2,N];case 4:U=i.sent();try{U.requestId=U.requestId||(null==r?void 0:r.headers["x-request-id"])||(null==r?void 0:r.headers["X-Request-Id"])||""}catch(e){}throw U;case 5:return[2]}}))}))},e.prototype.fetch=function(e){var t,r,u,c,l,d,h,f;return o(this,void 0,Promise,(function(){var p,v,y,m,g,b,_,w,E=this;return i(this,(function(I){switch(I.label){case 0:p=e.token,v=e.headers,y=void 0===v?{}:v,m=e.withCredentials,g=void 0===m||m,b=s(e,["token","headers","withCredentials"]),_=function(){return o(E,void 0,void 0,(function(){var e,t,r;return i(this,(function(o){switch(o.label){case 0:return e={},g?(t=e,r="Bearer ".concat,[4,this.getAccessToken(p)]):[3,2];case 1:t.Authorization=r.apply("Bearer ",[o.sent()]),o.label=2;case 2:return[2,this.reqClass.fetch(n({headers:n(n(n({"X-SDK-Version":"@cloudbase/js-sdk/".concat((0,a.getSdkVersion)())},e),this.getDefaultHeaders()),y)},b))]}}))}))},I.label=1;case 1:return I.trys.push([1,3,,6]),[4,_()];case 2:return[2,I.sent()];case 3:w=I.sent();try{w.requestId=w.requestId||y["x-request-id"]||y["X-Request-Id"]||""}catch(e){}if("ACCESS_TOKEN_EXPIRED"!==(null==w?void 0:w.code))return[3,5];if("function"!=typeof(null===(c=null===(u=null===(r=null===(t=this.config)||void 0===t?void 0:t._fromApp)||void 0===r?void 0:r.oauthInstance)||void 0===u?void 0:u.authApi)||void 0===c?void 0:c.refreshTokenForce))throw w;return[4,null===(f=null===(h=null===(d=null===(l=this.config)||void 0===l?void 0:l._fromApp)||void 0===d?void 0:d.oauthInstance)||void 0===h?void 0:h.authApi)||void 0===f?void 0:f.refreshTokenForce()];case 4:return I.sent(),[2,_()];case 5:throw w;case 6:return[2]}}))}))},e.prototype.send=function(e,t,r,s){return void 0===t&&(t={}),void 0===r&&(r={}),o(this,void 0,Promise,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return[4,this.request(e,t,n(n({},r),{onUploadProgress:t.onUploadProgress}),s)];case 1:if((o=i.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:d.OPERATION_FAIL,msg:"[".concat(o.data.code,"] ").concat(o.data.message)}));return[2,o.data]}}))}))},e.prototype.gateWay=function(e,t){var r;return o(this,void 0,void 0,(function(){var o,s,c,l,h,f,p,v,y,m,g,b,_,w,E,I,S,O,A;return i(this,(function(i){switch(i.label){case 0:if(o=e.url,s=e.name,c=e.data,l=e.path,h=void 0===l?"":l,f=e.method,p=e.header,v=void 0===p?{}:p,!(s&&h||o))throw new Error(JSON.stringify({code:d.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"}));try{y=c?JSON.stringify(c):""}catch(e){throw new Error(JSON.stringify({code:d.INVALID_PARAMS,msg:"[gateWay] invalid data"}))}if(m=u.utils.generateRequestId(),g=(0,a.getEndPointInfo)(this.config.env,"GATEWAY"),b=g.baseUrl,_=g.protocol,w="".concat(_).concat(b).concat(o||"/".concat(h,"/").concat(s)),E=["GET","HEAD"].includes(null===(r=null==f?void 0:f.toUpperCase)||void 0===r?void 0:r.call(f)))try{I={};try{I=JSON.parse(c)}catch(e){I=c||{}}w="".concat(w).concat(w.includes("?")?"&":"?").concat(Object.keys(I).map((function(e){return"".concat(e,"=").concat(I[e])})).join("&"))}catch(e){}return[4,this.fetch(n(n({method:f||"POST",headers:n({"Content-Type":"application/json; charset=utf-8","X-Request-Id":m},v)},E?{}:{body:y}),{url:w,customReqOpts:t}))];case 1:return S=i.sent(),O=[n({requestId:m},S)],A={},[4,S.data];case 2:return[2,n.apply(void 0,O.concat([(A.data=i.sent(),A)]))]}}))}))},e}();t.CloudbaseRequest=g;var b={};t.initRequest=function(e){b[e.env]=new g(n(n({},e),{throw:!0}))},t.getRequestByEnvId=function(e){return b[e]}},3548: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.useAuthAdapter=void 0;var s=r(1019),a=function(){function e(e){var t,r;try{this.localStorage=(null==e?void 0:e.localStorage)||((null===(r=null===(t=null==e?void 0:e.adapter)||void 0===t?void 0:t.root)||void 0===r?void 0:r.globalThis)||globalThis).localStorage}catch(t){this.localStorage=(null==e?void 0:e.localStorage)||{}}}return e.prototype.getItem=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.localStorage.getItem(e)]}))}))},e.prototype.removeItem=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){return this.localStorage.removeItem(e),[2]}))}))},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(r){return this.localStorage.setItem(e,t),[2]}))}))},e.prototype.getItemSync=function(e){return this.localStorage.getItem(e)},e.prototype.setItemSync=function(e,t){this.localStorage.setItem(e,t)},e.prototype.removeItemSync=function(e){this.localStorage.removeItem(e)},e}(),u=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,c=function(e,t){var r,n,o,i,s=null===(r=null==t?void 0:t.headers)||void 0===r?void 0:r["x-request-id"];return e||(e={}),((null==e?void 0:e.code)||(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.error_code))&&(e={error:e.code||e.data.error,error_description:e.data.error_description||e.message||e.code||e.data.error_code,request_id:e.requestId,error_code:null===(o=e.data)||void 0===o?void 0:o.error_code}),(null==e?void 0:e.request_id)||(e.request_id=e.request_id||s),(null==e?void 0:e.error)?(e.error_uri=(i=null==t?void 0:t.url,u.test(i)?RegExp.$1:i),e):(null==e?void 0:e.data)||{}};t.useAuthAdapter=function(e){return e.adapter&&"default"!==e.adapter.type?function(e,t){var r=n({},e);try{if(!(null==e?void 0:e.storage)&&(null==t?void 0:t.localStorage)&&(r.storage=new a({localStorage:t.localStorage,adapter:t})),!e.captchaOptions&&(null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!e.baseRequest&&!e.request&&(null==t?void 0:t.reqClass)){var s={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:e.auth},u=new t.reqClass(s);r.baseRequest=function(e,t){var r,s,a,l,d;return o(this,void 0,void 0,(function(){var o,h,f,p;return i(this,(function(i){switch(i.label){case 0:if(o={},h=(null===(r=t.method)||void 0===r?void 0:r.toLocaleLowerCase())||"post","function"!=typeof(f=null===(a=null===(s=null==u?void 0:u[h])||void 0===s?void 0:s.bind)||void 0===a?void 0:a.call(s,u)))throw new Error("invalid 【".concat(h,"】 request method"));i.label=1;case 1:return i.trys.push([1,3,,4]),(null===(l=t.headers)||void 0===l?void 0:l["content-type"])&&!(null===(d=t.headers)||void 0===d?void 0:d["content-type"].includes("application/json"))||["string","undefined"].includes(typeof t.body)||(t.data=t.data||t.body,t.body=JSON.stringify(t.body)),[4,f(n({url:e},t))];case 2:return o=i.sent(),o=c(o,n(n({},t),{url:e})),[3,4];case 3:throw p=i.sent(),o=n(n({},null==p?void 0:p.data),p);case 4:if(null==o?void 0:o.error)throw o;return[2,o]}}))}))}}}catch(e){console.error("user adapter generate fail:",e)}return r}(e,e.adapter):function(e,t){var r=n({},e),u={};if((null==t?void 0:t.captchaOptions)&&(r.captchaOptions=t.captchaOptions),!s.adapterForWxMp.isMatch()||e.storage&&e.baseRequest)return r;try{var l=s.adapterForWxMp.genAdapter({}),d=l.localStorage,h=l.reqClass;if(d&&(u.storage=new a({localStorage:d,adapter:t})),h){var f=new h({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});u.request=function(e){return function(t,r){return o(this,void 0,void 0,(function(){return i(this,(function(o){return[2,new Promise((function(o,i){var s=Object.assign({},r);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:t,data:s.body,timeout:e._timeout,method:s.method||"GET",header:s.headers,success:function(e){(e=c(e,n(n({},r),{url:t}))).error&&i(e),o(e)},fail:function(e){i({error:"unreachable",error_description:e.message})},complete:function(t){if(t&&t.errMsg&&e._timeout&&-1!==e._restrictedMethods.indexOf("request")&&"request:fail timeout"===t.errMsg){console.warn(e._timeoutMsg);try{a.abort()}catch(e){}}}})}))]}))}))}}(f)}return r.captchaOptions&&(u.baseRequest=u.request,u.request=void 0),n(n({},r),u)}catch(e){console.error("adapter generate fail:",e)}return r}(e,e.adapter)}},9895:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},l=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.registerAuth=t.AuthError=t.AuthErrorCategory=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=t.Auth=t.generateAuthInstance=t.LoginState=t.User=void 0;var d=r(6722),h=r(3548),f=r(1019),p=r(5266),v=r(916);Object.defineProperty(t,"WeixinAuthProvider",{enumerable:!0,get:function(){return v.WeixinAuthProvider}}),Object.defineProperty(t,"CustomAuthProvider",{enumerable:!0,get:function(){return v.CustomAuthProvider}}),Object.defineProperty(t,"AnonymousAuthProvider",{enumerable:!0,get:function(){return v.AnonymousAuthProvider}});var y=r(2877),m=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},g=t.User=function(){function e(e){var t=e.cache,r=e.oauthInstance;this.cache=t,this.oauthInstance=r,this.setUserInfo()}var t,r,n;return e.prototype.checkLocalInfo=function(){return u(this,void 0,void 0,(function(){return c(this,(function(e){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},e.prototype.checkLocalInfoAsync=function(){return u(this,void 0,void 0,(function(){var e,t,r,n;return c(this,(function(o){switch(o.label){case 0:return e=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return e.uid=o.sent(),t=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return t.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),r=this,[4,this.getLocalUserInfoAsync("email")];case 3:return r.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),n=this,[4,this.getLocalUserInfoAsync("username")];case 4:return n.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},e.prototype.update=function(e){return u(this,void 0,Promise,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(i({},e))];case 1:return t=r.sent(),this.setLocalUserInfo(t),[2]}}))}))},e.prototype.updateUserBasicInfo=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(i({},e))];case 1:return t.sent(),[4,this.refresh()];case 2:return t.sent(),[2]}}))}))},e.prototype.updatePassword=function(e,t){return this.oauthInstance.authApi.updatePasswordByOld({old_password:t,new_password:e})},e.prototype.updateUsername=function(e){return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:e})},e.prototype.refresh=function(e){return u(this,void 0,Promise,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(e)];case 1:if("INVALID_ACCESS_TOKEN"===(t=r.sent()).code)throw this.setLocalUserInfo({}),t;return this.setLocalUserInfo(t),[2,t]}}))}))},e.prototype.getLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);return e?r[e]:r||{}},e.prototype.setLocalUserInfo=function(e){var t=this.cache.keys.userInfoKey;this.cache.setStore(t,e),this.setUserInfo()},e.prototype.getLocalUserInfoAsync=function(e){return u(this,void 0,Promise,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return t=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(t)];case 1:return[2,r.sent()[e]]}}))}))},e.prototype.setUserInfo=function(){var e=this,t=this.cache.keys.userInfoKey,r=this.cache.getStore(t);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach((function(t){e[t]=r[t]}))},s([(0,f.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(t=void 0!==d.authModels&&d.authModels.UserProfile)?t:Object]),a("design:returntype","function"==typeof(r="undefined"!=typeof Promise&&Promise)?r:Object)],e.prototype,"update",null),s([(0,f.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String,String]),a("design:returntype",void 0)],e.prototype,"updatePassword",null),s([(0,f.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],e.prototype,"updateUsername",null),s([(0,f.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"refresh",null),e}();(0,v.applyUserV1Compat)(g);var b=function(){function e(e){var t=e.envId,r=e.cache,n=e.oauthInstance;t||(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=r,this.oauthInstance=n,this.user=new g({cache:this.cache,oauthInstance:n})}return e.prototype.checkLocalState=function(){var e;this.oauthLoginState=null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},e.prototype.checkLocalStateAsync=function(){var e;return u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.getLoginState()];case 1:return t.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return t.sent(),[2]}}))}))},e}();t.LoginState=b;var _=function(e){function t(t){var r=e.call(this)||this;return r.listeners=new Map,r.hasListenerSetUp=!1,r.config=t,r.oauthInstance=t.oauthInstance,r.cache=t.cache,r.init(),r.setAccessKey(),r}var r,n,h,v,g,_,w,E,I,S,O,A,T,P,R,C,N,D,U,x;return o(t,e),t.prototype.signInAnonymously=function(e){return u(this,void 0,Promise,(function(){var t,r,n,o,s;return c(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(e)];case 1:return a.sent(),[4,this.createLoginState()];case 2:return t=a.sent(),[4,this.getSession()];case 3:return r=a.sent().data,n=(void 0===r?{}:r).session,[2,i(i({},t),{data:{user:n.user,session:n},error:null})];case 4:return o=a.sent(),(s=new d.AuthError(o,{method:"signInAnonymously"})).category===d.AuthErrorCategory.PROVIDER_NOT_ENABLED?(console.error(s.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(s.category,"]: ").concat(s.message)),s.loginMethodHint&&console.warn(s.loginMethodHint)),[2,{data:{},error:s}];case 5:return[2]}}))}))},t.prototype.signUp=function(e){return u(this,void 0,Promise,(function(){var t,r,n=this;return c(this,(function(o){switch(o.label){case 0:return e.phone_number||e.verification_code||e.verification_token||e.provider_token?(e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[4,this.oauthInstance.authApi.signUp(e)]):[3,2];case 1:return o.sent(),[2,this.createLoginState()];case 2:return o.trys.push([2,4,,5]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)})];case 3:return t=o.sent(),[2,{data:{verifyOtp:function(r){var o=r.token,s=r.messageId,a=void 0===s?t.verification_id:s;return u(n,void 0,Promise,(function(){var r,n,s,u,l;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:a||t.verification_id,verification_code:String(o)})];case 1:return r=c.sent(),t.is_user?[4,this.signIn({username:e.email||this.formatPhone(e.phone),verification_token:r.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(n=JSON.parse(JSON.stringify(e))).email,delete n.phone,[4,this.oauthInstance.authApi.signUp(i(i(i({},n),e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}),{verification_token:r.verification_token,verification_code:o}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return s=c.sent().data,[2,{data:{user:(u=(void 0===s?{}:s).session).user,session:u},error:null}];case 8:return l=c.sent(),[2,{data:{},error:new d.AuthError(l,{method:"signUp"})}];case 9:return[2]}}))}))}},error:null}];case 4:return r=o.sent(),[2,{data:{},error:new d.AuthError(r,{method:"signUp"})}];case 5:return[2]}}))}))},t.prototype.signOut=function(e){var t,r;return u(this,void 0,Promise,(function(){var n,o,s;return c(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),n=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(e)];case 1:return o=a.sent(),[4,this.cache.removeStoreAsync(n)];case 2:return a.sent(),this.setAccessKey(),null===(t=this.config.eventBus)||void 0===t||t.fire(d.EVENTS.LOGIN_STATE_CHANGED,{eventType:d.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),null===(r=this.config.eventBus)||void 0===r||r.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,i(i({},o),{data:{},error:null})];case 3:return s=a.sent(),[2,{data:{},error:new d.AuthError(s,{method:"signOut"})}];case 4:return[2]}}))}))},t.prototype.onAuthStateChange=function(e){var t=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var r=Math.random().toString(36);return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e),{data:{subscription:{id:r,callback:e,unsubscribe:function(){var n=t.listeners.get(r);n&&(n.delete(e),0===n.size&&t.listeners.delete(r))}}}}},t.prototype.signInWithPassword=function(e){return u(this,void 0,Promise,(function(){var t,r,n,o;return c(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),this.validateAtLeastOne(e,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.signIn(i({username:e.username||e.email||this.formatPhone(e.phone),password:e.password},e.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];case 1:return s.sent(),[4,this.getSession()];case 2:return t=s.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=s.sent(),(o=new d.AuthError(n,{method:"signInWithPassword"})).category===d.AuthErrorCategory.PROVIDER_NOT_ENABLED?console.error(o.helpMessage):o.category===d.AuthErrorCategory.INVALID_CREDENTIALS||o.category===d.AuthErrorCategory.USER_NOT_FOUND?console.warn(o.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(o.category,"]: ").concat(o.message)),o.loginMethodHint&&console.info(o.loginMethodHint),[2,{data:{},error:o}];case 4:return[2]}}))}))},t.prototype.signInWithIdToken=function(e){return u(this,void 0,Promise,(function(){var t,r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(e,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:e.token})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new d.AuthError(n,{method:"signInWithIdToken"})}];case 4:return[2]}}))}))},t.prototype.signInWithOtp=function(e){var t,r,n,o;return u(this,void 0,Promise,(function(){var s,a,l=this;return c(this,(function(h){switch(h.label){case 0:if(!(null===(t=e.options)||void 0===t?void 0:t.emailRedirectTo)&&(void 0===(null===(r=e.options)||void 0===r?void 0:r.shouldCreateUser)||(null===(n=e.options)||void 0===n?void 0:n.shouldCreateUser)))return[2,this.signUp({email:e.email,phone:e.phone})];h.label=1;case 1:return h.trys.push([1,3,,4]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(i({email_redirect_to:null===(o=e.options)||void 0===o?void 0:o.emailRedirectTo},e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)}))];case 2:return s=h.sent(),[2,{data:{user:null,session:null,verifyOtp:function(t){var r=t.token,n=t.messageId,o=void 0===n?s.verification_id:n;return u(l,void 0,Promise,(function(){return c(this,(function(t){return[2,this.verifyOtp({email:e.email,phone:e.phone,token:String(r),messageId:o})]}))}))}},error:null}];case 3:return a=h.sent(),[2,{data:{},error:new d.AuthError(a,{method:"signInWithOtp"})}];case 4:return[2]}}))}))},t.prototype.verifyOAuth=function(e){return u(this,void 0,Promise,(function(){var t,r,n,o,s,a,u,l,h;return c(this,(function(c){switch(c.label){case 0:t={},c.label=1;case 1:return c.trys.push([1,7,,8]),r=(null==e?void 0:e.code)||y.utils.getQuery("code"),n=(null==e?void 0:e.state)||y.utils.getQuery("state"),r?n?(o=(0,p.getBrowserSession)(n),t.type=null==o?void 0:o.type,(s=(null==e?void 0:e.provider)||(null==o?void 0:o.provider)||y.utils.getQuery("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:r})]:[2,{data:t,error:new d.AuthError({message:"Provider is required"})}]):[2,{data:{},error:new d.AuthError({message:"State is required"})}]:[2,{data:{},error:new d.AuthError({message:"Code is required"})}];case 2:return a=c.sent().provider_token,u=void 0,o.type!==d.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return u=c.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(u=c.sent()).data=i(i({},t),u.data),c.label=6;case 6:return(l=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),l.delete("state"),u.data.redirectUrl=(0,p.addUrlSearch)(void 0===(null==o?void 0:o.search)?"?".concat(l.toString()):null==o?void 0:o.search,(null==o?void 0:o.hash)||location.hash),(0,p.removeBrowserSession)(n),[2,u];case 7:return h=c.sent(),[2,{data:t,error:new d.AuthError(h,{method:"verifyOAuth"})}];case 8:return[2]}}))}))},t.prototype.signInWithOAuth=function(e){var t,r,n,o,i;return u(this,void 0,Promise,(function(){var s,a,u,l,h,f,v,y,g;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),s=(null===(t=e.options)||void 0===t?void 0:t.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,l=(null===(r=e.options)||void 0===r?void 0:r.state)||"prd-".concat(e.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:e.provider,provider_redirect_uri:u,state:l})];case 1:return h=c.sent().uri,f=decodeURIComponent(h),v=f,(null===(n=e.options)||void 0===n?void 0:n.queryParams)&&(y=new URL(f),Object.entries(e.options.queryParams).forEach((function(e){var t=e[0],r=e[1];y.searchParams.set(t,r)})),v=y.toString()),(0,p.saveToBrowserSession)(l,{provider:e.provider,search:a.search,hash:a.hash,type:(null===(o=e.options)||void 0===o?void 0:o.type)||d.OAUTH_TYPE.SIGN_IN}),m()&&!(null===(i=e.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(v),[2,{data:{url:v,provider:e.provider},error:null}];case 2:return g=c.sent(),[2,{data:{},error:new d.AuthError(g,{method:"signInWithOAuth"})}];case 3:return[2]}}))}))},t.prototype.getClaims=function(){return u(this,void 0,Promise,(function(){var e,t;return c(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return e=r.sent().accessToken,[2,{data:(0,d.weAppJwtDecodeAll)(e),error:null}];case 2:return t=r.sent(),[2,{data:{},error:new d.AuthError(t,{method:"getClaims"})}];case 3:return[2]}}))}))},t.prototype.resetPasswordForEmail=function(e,t){return u(this,void 0,Promise,(function(){var r,n,o,i,s,a,l=this;return c(this,(function(h){switch(h.label){case 0:return h.trys.push([0,2,,3]),this.validateParams({emailOrPhone:e},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),r=(t||{}).redirectTo,n=e.includes("@"),o=void 0,n?o={email:e}:(i=this.formatPhone(e),o={phone_number:i}),[4,this.getVerification(o)];case 1:return s=h.sent(),[2,{data:{updateUser:function(t){return u(l,void 0,Promise,(function(){var o,i,a,u;return c(this,(function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:s.verification_id,verification_code:t.nonce})];case 2:return o=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:n?e:void 0,phone_number:n?void 0:e,new_password:t.password,verification_token:o.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:n?e:void 0,phone:n?void 0:e,password:t.password})];case 4:return i=c.sent(),r&&m()&&window.location.assign(r),[2,i];case 5:return a=c.sent(),[2,{data:{},error:new d.AuthError(a,{method:"resetPasswordForEmail"})}];case 6:return[2]}}))}))}},error:null}];case 2:return a=h.sent(),[2,{data:{},error:new d.AuthError(a,{method:"resetPasswordForEmail"})}];case 3:return[2]}}))}))},t.prototype.resetPasswordForOld=function(e){return u(this,void 0,void 0,(function(){var t,r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:e.old_password,new_password:e.new_password})];case 1:return o.sent(),[4,this.getSession()];case 2:return t=o.sent().data,[2,{data:{user:(r=(void 0===t?{}:t).session).user,session:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new d.AuthError(n,{method:"resetPasswordForOld"})}];case 4:return[2]}}))}))},t.prototype.verifyOtp=function(e){return u(this,void 0,Promise,(function(){var t,r,n,o,i;return c(this,(function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),t=e.type,r=String(e.token),this.validateParams(e,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(t)?[4,this.verify({verification_id:e.messageId,verification_code:r})]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:e.messageId,is_user:!0},verificationCode:r,username:e.email||this.formatPhone(e.phone)||"",loginType:e.email?"email":"phone"})];case 3:s.sent(),s.label=4;case 4:return[4,this.getSession()];case 5:return n=s.sent().data,[2,{data:{user:(o=(void 0===n?{}:n).session).user,session:o},error:null}];case 6:return i=s.sent(),[2,{data:{},error:new d.AuthError(i,{method:"verifyOtp"})}];case 7:return[2]}}))}))},t.prototype.getSession=function(){return u(this,void 0,Promise,(function(){var e,t,r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=o.sent())&&"accessKey"!==e.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return t=o.sent().data,r=(void 0===t?{}:t).user,[2,{data:{session:i(i({},e),{user:r}),user:r},error:null}];case 3:return n=o.sent(),[2,{data:{},error:new d.AuthError(n,{method:"getSession"})}];case 4:return[2]}}))}))},t.prototype.refreshSession=function(e){return u(this,void 0,Promise,(function(){var t,r,n,o,s;return c(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(t=a.sent()).refresh_token=e||t.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(t)];case 2:return r=a.sent(),[4,this.getUser(!1)];case 3:return n=a.sent().data,[2,{data:{user:o=(void 0===n?{}:n).user,session:i(i({},r),{user:o})},error:null}];case 4:return s=a.sent(),[2,{data:{},error:new d.AuthError(s,{method:"refreshSession"})}];case 5:return[2]}}))}))},t.prototype.getUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,(function(){var t,r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=o.sent())&&"accessKey"!==t.scope?(r=this.convertToUser,[4,this.getCurrentUser(e)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:r.apply(this,[o.sent()])},error:null}];case 3:return n=o.sent(),[2,{data:{user:null},error:new d.AuthError(n,{method:"getUser"})}];case 4:return[2]}}))}))},t.prototype.refreshUser=function(){return u(this,void 0,Promise,(function(){var e,t,r;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return n.sent(),[4,this.getSession()];case 2:return e=n.sent().data,[2,{data:{user:(t=(void 0===e?{}:e).session).user,session:t},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new d.AuthError(r,{method:"refreshUser"})}];case 4:return[2]}}))}))},t.prototype.updateUser=function(e){var t;return u(this,void 0,Promise,(function(){var r,n,o,s,a,h,f,p,v,y,m,g,b=this;return c(this,(function(_){switch(_.label){case 0:if(_.trys.push([0,8,,9]),!Object.keys(e).some((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})))throw new d.AuthError({message:"At least one field must be provided for update"});return r=e.email,n=e.phone,o=l(e,["email","phone"]),a=void 0!==n,h={},(s=void 0!==r)||a?(f=void 0,s?(f={email:e.email},p="email_change"):(v=this.formatPhone(e.phone),f={phone_number:v},p="phone_change"),[4,this.getVerification(f)]):[3,4];case 1:return y=_.sent(),Object.keys(o).length>0?[4,this.updateUserBasicInfo(o)]:[3,3];case 2:_.sent(),_.label=3;case 3:return h={messageId:y.verification_id,verifyOtp:function(t){return u(b,void 0,Promise,(function(){var r,n,o;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,11,,12]),t.email&&e.email===t.email?[4,this.verifyOtp({type:"email_change",email:e.email,token:t.token,messageId:y.verification_id})]:[3,3];case 1:return i.sent(),[4,this.updateUserBasicInfo({email:e.email})];case 2:return i.sent(),[3,9];case 3:return t.phone&&e.phone===t.phone?[4,this.verifyOtp({type:"phone_change",phone:e.phone,token:t.token,messageId:y.verification_id})]:[3,6];case 4:return i.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(e.phone)})];case 5:return i.sent(),[3,9];case 6:return[4,this.verifyOtp({type:p,email:s?e.email:void 0,phone:s?void 0:e.phone,token:t.token,messageId:y.verification_id})];case 7:return i.sent(),[4,this.updateUserBasicInfo(e)];case 8:i.sent(),i.label=9;case 9:return[4,this.getUser(!1)];case 10:return r=i.sent().data.user,null===(o=this.config.eventBus)||void 0===o||o.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:r},error:null}];case 11:return n=i.sent(),[2,{data:{},error:new d.AuthError(n,{method:"updateUser"})}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(e)];case 5:_.sent(),_.label=6;case 6:return[4,this.getUser(!1)];case 7:return m=_.sent().data.user,null===(t=this.config.eventBus)||void 0===t||t.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:i({user:m},h),error:null}];case 8:return g=_.sent(),[2,{data:{},error:new d.AuthError(g,{method:"updateUser"})}];case 9:return[2]}}))}))},t.prototype.getUserIdentities=function(){var e;return u(this,void 0,Promise,(function(){var t,r;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return t=n.sent(),[2,{data:{identities:null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.filter((function(e){return!!e.bind}))},error:null}];case 2:return r=n.sent(),[2,{data:{},error:new d.AuthError(r,{method:"getUserIdentities"})}];case 3:return[2]}}))}))},t.prototype.linkIdentity=function(e){return u(this,void 0,Promise,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:e.provider,options:{type:d.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return r.sent(),[2,{data:{provider:e.provider},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new d.AuthError(t,{method:"linkIdentity"})}];case 3:return[2]}}))}))},t.prototype.unlinkIdentity=function(e){return u(this,void 0,Promise,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.validateParams(e,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:e.provider})];case 1:return r.sent(),[2,{data:{},error:null}];case 2:return t=r.sent(),[2,{data:{},error:new d.AuthError(t,{method:"unlinkIdentity"})}];case 3:return[2]}}))}))},t.prototype.reauthenticate=function(){return u(this,void 0,Promise,(function(){var e,t,r,n,o=this;return c(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return e=s.sent().data.user,this.validateAtLeastOne(e,[["email","phone"]],"You must provide either an email or phone number"),t=e.email?{email:e.email}:{phone_number:this.formatPhone(e.phone)},[4,this.getVerification(t)];case 2:return r=s.sent(),[2,{data:{updateUser:function(e){return u(o,void 0,Promise,(function(){var n,o,s,a,u;return c(this,(function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),e.password?[4,this.verify({verification_id:r.verification_id,verification_code:e.nonce})]:[3,5];case 2:return n=c.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:n.verification_token})];case 3:return o=c.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:e.password,sudo_token:o.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(i(i({verificationInfo:r,verificationCode:e.nonce},t),{loginType:t.email?"email":"phone"}))];case 6:c.sent(),c.label=7;case 7:return[4,this.getSession()];case 8:return s=c.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return u=c.sent(),[2,{data:{},error:new d.AuthError(u,{method:"reauthenticate"})}];case 10:return[2]}}))}))}},error:null}];case 3:return n=s.sent(),[2,{data:{},error:new d.AuthError(n,{method:"reauthenticate"})}];case 4:return[2]}}))}))},t.prototype.resend=function(e){return u(this,void 0,Promise,(function(){var t,r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(e,[["email"],["phone"]],"You must provide either an email or phone number"),t="signup"===e.type?"ANY":"USER",r={target:t},"email"in e&&(r.email=e.email),"phone"in e&&(r.phone_number=this.formatPhone(e.phone)),[4,this.oauthInstance.authApi.getVerification(r)];case 1:return[2,{data:{messageId:o.sent().verification_id},error:null}];case 2:return n=o.sent(),[2,{data:{},error:new d.AuthError(n,{method:"resend"})}];case 3:return[2]}}))}))},t.prototype.setSession=function(e){var t;return u(this,void 0,Promise,(function(){var r,n,o;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(e,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(e,{throwError:!0})];case 1:return i.sent(),[4,this.getSession()];case 2:return r=i.sent().data,n=(void 0===r?{}:r).session,null===(t=this.config.eventBus)||void 0===t||t.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:n.user,session:n},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new d.AuthError(o,{method:"setSession"})}];case 4:return[2]}}))}))},t.prototype.exchangeCodeForSession=function(){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2]}))}))},t.prototype.deleteUser=function(e){return u(this,void 0,Promise,(function(){var t,r;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.validateParams(e,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(e)];case 1:return t=n.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:t})];case 2:return n.sent(),[2,{data:{},error:null}];case 3:return r=n.sent(),[2,{data:{},error:new d.AuthError(r,{method:"deleteUser"})}];case 4:return[2]}}))}))},t.prototype.toDefaultLoginPage=function(e){return void 0===e&&(e={}),u(this,void 0,Promise,(function(){var t,r,n,o,i;return c(this,(function(s){try{return t=e.config_version||"env",r=Object.keys(e.query||{}).map((function(t){return"".concat(t,"=").concat(e.query[t])})).join("&"),f.adapterForWxMp.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(r?"?".concat(r):"")}):(n=e.redirect_uri||window.location.href,o=new URL(n),i="".concat(o.origin,"/__auth/?app_id=").concat(e.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(t,"&redirect_uri=").concat(encodeURIComponent(n)).concat(r?"&".concat(r):""),window.location.href=i),[2,{data:{},error:null}]}catch(e){return[2,{data:{},error:new d.AuthError(e,{method:"toDefaultLoginPage"})}]}return[2]}))}))},t.prototype.signInWithCustomTicket=function(e){return u(this,void 0,Promise,(function(){var t,r,n,o;return c(this,(function(s){switch(s.label){case 0:e&&this.setCustomSignFunc(e),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return t=s.sent(),[4,this.getSession()];case 4:return r=s.sent().data,n=(void 0===r?{}:r).session,[2,i(i({},t),{data:{user:n.user,session:n},error:null})];case 5:return o=s.sent(),[2,{data:{},error:new d.AuthError(o,{method:"signInWithCustomTicket"})}];case 6:return[2]}}))}))},t.prototype.signInWithOpenId=function(e){var t=(void 0===e?{}:e).useWxCloud,r=void 0===t||t;return u(this,void 0,Promise,(function(){var e,t,n,o,s,a,l=this;return c(this,(function(h){switch(h.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(l,void 0,void 0,(function(){var n,o;return c(this,(function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},r)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:n.provider_token},r)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}}))}))},h.label=1;case 1:return h.trys.push([1,5,,6]),[4,new Promise((function(e,r){wx.login({success:function(n){return u(l,void 0,void 0,(function(){var o;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(n.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return o=i.sent(),r(o),[3,3];case 3:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})}))];case 2:return h.sent(),[4,this.createLoginState()];case 3:return n=h.sent(),[4,this.getSession()];case 4:return o=h.sent().data,s=(void 0===o?{}:o).session,[2,i(i({},n),{data:{user:s.user,session:s},error:null})];case 5:return a=h.sent(),[2,{data:{},error:new d.AuthError(a,{method:"signInWithOpenId"})}];case 6:return[2]}}))}))},t.prototype.signInWithPhoneAuth=function(e){var t=e.phoneCode,r=void 0===t?"":t,n=e.useWxCloud,o=void 0!==n&&n;return u(this,void 0,Promise,(function(){var e,t,n,s,a,u,l,h,p;return c(this,(function(c){switch(c.label){case 0:return f.adapterForWxMp.isMatch()?(e=wx.getAccountInfoSync().miniProgram,t={provider_params:{provider_code_type:"phone",code:r,appid:e.appId},provider_id:e.appId},[4,wx.login()]):[2,{data:{},error:new d.AuthError({message:"wx api undefined"})}];case 1:n=c.sent().code,t.provider_code=n,c.label=2;case 2:return c.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(t,o)];case 3:if((s=c.sent()).error_code)throw s;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:s.provider_token},o)];case 4:if(null==(a=c.sent())?void 0:a.error_code)throw a;return[3,6];case 5:return u=c.sent(),[2,{data:{},error:new d.AuthError(u,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return l=c.sent(),[4,this.getSession()];case 8:return h=c.sent().data,p=(void 0===h?{}:h).session,[2,i(i({},l),{data:{user:p.user,session:p},error:null})]}}))}))},t.prototype.bindPhoneNumber=function(e){return u(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.editContact(e)]}))}))},t.prototype.unbindProvider=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.unbindProvider(e)]}))}))},t.prototype.bindEmail=function(e){return this.oauthInstance.authApi.editContact(e)},t.prototype.verify=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.verify(e)]}))}))},t.prototype.getVerification=function(e,t){return u(this,void 0,Promise,(function(){return c(this,(function(r){return e.phone_number&&(e.phone_number=this.formatPhone(e.phone_number)),[2,this.oauthInstance.authApi.getVerification(e,t)]}))}))},Object.defineProperty(t.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var e=this.hasLoginState();return e&&e.user||null}(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),t.prototype.getCurrentUser=function(e){return void 0===e&&(e=!0),u(this,void 0,Promise,(function(){var t,r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),e?[4,this.getLoginState()]:[3,3];case 1:return(t=o.sent())?[4,t.user.refresh()]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return o.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(r=o.sent())?(n=r.user.getLocalUserInfo(),[4,r.user.checkLocalInfoAsync()]):[3,8];case 7:return o.sent(),[2,i(i({},r.user),n)];case 8:return[2,null]}}))}))},t.prototype.signInAnonymouslyInWx=function(e){var t=(void 0===e?{}:e).useWxCloud;return u(this,void 0,Promise,(function(){var e,r,n=this;return c(this,(function(o){switch(o.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,r=function(r){return u(n,void 0,void 0,(function(){var n,o;return c(this,(function(i){switch(i.label){case 0:n=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:r,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}},t)];case 2:if((null==(n=i.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:n.provider_token},t)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}}))}))},[4,new Promise((function(e,t){wx.login({success:function(o){return u(n,void 0,void 0,(function(){var n;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return n=i.sent(),t(n),[3,3];case 3:return[2]}}))}))},fail:function(e){var r=new Error(null==e?void 0:e.errMsg);r.code=null==e?void 0:e.errno,t(r)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},t.prototype.bindOpenId=function(){return u(this,void 0,Promise,(function(){var e,t,r=this;return c(this,(function(n){switch(n.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return e=wx.getAccountInfoSync().miniProgram,t=function(t){return u(r,void 0,void 0,(function(){var r;return c(this,(function(n){switch(n.label){case 0:r=void 0,n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==e?void 0:e.appId,provider_code:t,provider_params:{provider_code_type:"open_id",appid:null==e?void 0:e.appId}})];case 2:if((null==(r=n.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:r.provider_token})];case 3:return n.sent(),[3,5];case 4:throw n.sent();case 5:return[2]}}))}))},[4,new Promise((function(e,n){wx.login({success:function(o){return u(r,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t(o.code)];case 1:return i.sent(),e(!0),[3,3];case 2:return r=i.sent(),n(r),[3,3];case 3:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,n(t)}})}))];case 1:return n.sent(),[2]}}))}))},t.prototype.signInWithUnionId=function(){return u(this,void 0,Promise,(function(){var e=this;return c(this,(function(t){switch(t.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");t.label=1;case 1:return t.trys.push([1,3,,4]),[4,new Promise((function(t,r){var n=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return u(e,void 0,void 0,(function(){var e,i,s,a,u;return c(this,(function(c){switch(c.label){case 0:e=null==n?void 0:n.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:e,provider_params:{provider_code_type:"union_id",appid:null==n?void 0:n.appId}})];case 2:return i=c.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:e,provider_token:s})]:(r(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(r(a),[2]):(t(!0),[3,5]);case 4:return u=c.sent(),r(u),[3,5];case 5:return[2]}}))}))},fail:function(e){var t=new Error(null==e?void 0:e.errMsg);t.code=null==e?void 0:e.errno,r(t)}})}))];case 2:return t.sent(),[3,4];case 3:throw t.sent();case 4:return[2,this.createLoginState()]}}))}))},t.prototype.signInWithSms=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.phoneNum,s=void 0===i?"":i,a=e.bindInfo,l=void 0===a?void 0:a;return u(this,void 0,Promise,(function(){return c(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:l,username:s,loginType:"sms"})]}catch(e){throw e}return[2]}))}))},t.prototype.signInWithEmail=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,i=e.bindInfo,s=void 0===i?void 0:i,a=e.email,l=void 0===a?"":a;return u(this,void 0,Promise,(function(){return c(this,(function(e){try{return[2,this.signInWithUsername({verificationInfo:r,verificationCode:o,bindInfo:s,username:l,loginType:"email"})]}catch(e){throw e}return[2]}))}))},t.prototype.setCustomSignFunc=function(e){this.oauthInstance.authApi.setCustomSignFunc(e)},t.prototype.signIn=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signIn(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},t.prototype.setPassword=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.setPassword(e)]}))}))},t.prototype.isUsernameRegistered=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:e})];case 1:return[2,t.sent().exist]}}))}))},t.prototype.hasLoginState=function(){var e;if("async"!==this.cache.mode)return(null===(e=this.oauthInstance)||void 0===e?void 0:e.authApi.hasLoginStateSync())?new b({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},t.prototype.getLoginState=function(){return u(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:e=null,t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return e=t.sent(),[3,4];case 3:return t.sent(),[2,null];case 4:return e?[2,new b({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},t.prototype.getUserInfo=function(){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.getCurrentUser()]}))}))},t.prototype.getWedaUserInfo=function(){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},t.prototype.updateUserBasicInfo=function(e){return u(this,void 0,void 0,(function(){var t;return c(this,(function(r){switch(r.label){case 0:return[4,this.getLoginState()];case 1:return(t=r.sent())?[4,t.user.updateUserBasicInfo(e)]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))},t.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},t.prototype.bindWithProvider=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.bindWithProvider(e)]}))}))},t.prototype.queryUser=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.queryUserProfile(e)]}))}))},t.prototype.getAccessToken=function(){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:e.sent(),env:this.config.env}]}}))}))},t.prototype.grantProviderToken=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.grantProviderToken(e)]}))}))},t.prototype.patchProviderToken=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.patchProviderToken(e)]}))}))},t.prototype.signInWithProvider=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},t.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(e)];case 1:return t.sent(),[2,this.createLoginState(e)]}}))}))},t.prototype.grantToken=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.authApi.grantToken(e)];case 1:return t.sent(),[2,this.createLoginState()]}}))}))},t.prototype.genProviderRedirectUri=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.genProviderRedirectUri(e)]}))}))},t.prototype.resetPassword=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.resetPassword(e)]}))}))},t.prototype.deviceAuthorize=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.deviceAuthorize(e)]}))}))},t.prototype.sudo=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.sudo(e)]}))}))},t.prototype.deleteMe=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.deleteMe(e)]}))}))},t.prototype.getProviders=function(){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.getProviders()]}))}))},t.prototype.loginScope=function(){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.loginScope()]}))}))},t.prototype.loginGroups=function(){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},t.prototype.onLoginStateChanged=function(e){var t;return u(this,void 0,void 0,(function(){var r,n=this;return c(this,(function(o){switch(o.label){case 0:return null===(t=this.config.eventBus)||void 0===t||t.on(d.EVENTS.LOGIN_STATE_CHANGED,(function(t){return u(n,void 0,void 0,(function(){var r,n,o;return c(this,(function(s){switch(s.label){case 0:return(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.eventType)===d.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return n=s.sent(),[3,3];case 2:n={},s.label=3;case 3:return r=n,e.call(this,i(i({},t),r)),[2]}}))}))})),[4,this.getLoginState()];case 1:return r=o.sent(),e.call(this,r),[2]}}))}))},t.prototype.refreshTokenForce=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.refreshTokenForce(e)]}))}))},t.prototype.getCredentials=function(){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},t.prototype.setCredentials=function(e){return u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(e)];case 1:return t.sent(),[2]}}))}))},t.prototype.getProviderSubType=function(){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},t.prototype.createCaptchaData=function(e){return u(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.createCaptchaData(e)]}))}))},t.prototype.verifyCaptchaData=function(e){return u(this,void 0,void 0,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.verifyCaptchaData(e)]}))}))},t.prototype.getMiniProgramQrCode=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramCode(e)]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(e)]}))}))},t.prototype.modifyPassword=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.modifyPassword(e)]}))}))},t.prototype.modifyPasswordWithoutLogin=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(e)]}))}))},t.prototype.getUserBehaviorLog=function(e){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.getUserBehaviorLog(e)]}))}))},t.prototype.signInWithUsername=function(e){var t=e.verificationInfo,r=void 0===t?{verification_id:"",is_user:!1}:t,n=e.verificationCode,o=void 0===n?"":n,s=e.username,a=void 0===s?"":s,l=e.bindInfo,d=void 0===l?void 0:l,h=e.loginType,f=void 0===h?"":h;return u(this,void 0,Promise,(function(){var e,t,n,s,u,l,h;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:r.verification_id,verification_code:o})];case 1:if(null==(e=c.sent())?void 0:e.error_code)throw e;return t=e.verification_token,n=this.formatPhone(a),s={phone_number:n},"email"===f&&(s={email:n=a}),r.is_user?[4,this.oauthInstance.authApi.signIn({username:n,verification_token:t})]:[3,5];case 2:if(null==(u=c.sent())?void 0:u.error_code)throw u;return d?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==d?void 0:d.providerToken})]:[3,4];case 3:if(null==(l=c.sent())?void 0:l.error_code)throw l;c.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(i(i({},s),{verification_token:t,provider_token:null==d?void 0:d.providerId}))];case 6:if(null==(h=c.sent())?void 0:h.error_code)throw h;c.label=7;case 7:return[2,this.createLoginState()];case 8:throw c.sent();case 9:return[2]}}))}))},t.prototype.createLoginState=function(e,t){var r,n;return u(this,void 0,Promise,(function(){var o;return c(this,(function(i){switch(i.label){case 0:return[4,(o=new b({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return i.sent(),(null==t?void 0:t.userInfo)?(o.user.setLocalUserInfo(t.userInfo),[3,5]):[3,2];case 2:return(null==t?void 0:t.asyncRefreshUser)?(o.user.refresh(e),[3,5]):[3,3];case 3:return[4,o.user.refresh(e)];case 4:i.sent(),i.label=5;case 5:return null===(r=this.config.eventBus)||void 0===r||r.fire(d.EVENTS.LOGIN_STATE_CHANGED,{eventType:d.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),null===(n=this.config.eventBus)||void 0===n||n.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,o]}}))}))},t.prototype.setAccessKey=function(){var e,t;return u(this,void 0,void 0,(function(){var r,n;return c(this,(function(o){if(r="",n="",this.config.accessKey?(r=this.config.accessKey,n="accessKey"):(null===(e=this.config.auth)||void 0===e?void 0:e.secretId)&&(null===(t=this.config.auth)||void 0===t?void 0:t.secretKey)&&(r="",n=d.DEFAULT_NODE_ACCESS_SCOPE),!n)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:r,token_type:"Bearer",scope:n,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(e){console.warn("accessKey error: ",e)}return[2]}))}))},t.prototype.formatPhone=function(e){return!/\s+/.test(e)&&/^\+\d{1,3}\d+/.test(e)?e.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(e)?e:"+86 ".concat(e)},t.prototype.notifyListeners=function(e,t,r){this.listeners.forEach((function(n){n.forEach((function(n){try{n(e,t,r)}catch(e){console.error("Error in auth state change callback:",e)}}))}))},t.prototype.setupListeners=function(){var e,t=this;null===(e=this.config.eventBus)||void 0===e||e.on(d.EVENTS.AUTH_STATE_CHANGED,(function(e){return u(t,void 0,void 0,(function(){var t,r,n,o,i;return c(this,(function(s){switch(s.label){case 0:return t=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.event,r=null===(i=null==e?void 0:e.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return n=s.sent().data.session,this.notifyListeners(t,n,r),[2]}}))}))}))},t.prototype.convertToUser=function(e){var t,r,n,o,i,s;if(!e)return null;var a=(null==e?void 0:e.email)||"",u=(null==e?void 0:e.phone_number)||"",c=(null==e?void 0:e.sub)||(null==e?void 0:e.uid)||"";return{id:c,aud:"authenticated",role:null===(r=null===(t=e.groups)||void 0===t?void 0:t.map)||void 0===r?void 0:r.call(t,(function(e){return"string"==typeof e?e:e.id})),email:a||"",email_confirmed_at:(null==e||e.email_verified,e.created_at),phone:u,phone_confirmed_at:u?e.created_at:void 0,confirmed_at:e.created_at,last_sign_in_at:e.last_sign_in_at,app_metadata:{provider:(null===(n=e.loginType)||void 0===n?void 0:n.toLowerCase())||"cloudbase",providers:[(null===(o=e.loginType)||void 0===o?void 0:o.toLowerCase())||"cloudbase"]},user_metadata:{name:null==e?void 0:e.name,picture:null==e?void 0:e.picture,username:null==e?void 0:e.username,gender:null==e?void 0:e.gender,locale:null==e?void 0:e.locale,uid:e.uid,nickName:e.nickName||(null==e?void 0:e.name),avatarUrl:e.avatarUrl||e.picture,location:e.location,hasPassword:null!==(i=e.hasPassword)&&void 0!==i?i:"SET"===e.password,open_id:null==e?void 0:e.open_id},identities:(null===(s=null==e?void 0:e.providers)||void 0===s?void 0:s.map((function(t){return{id:t.id||"",identity_id:t.id||"",user_id:c,identity_data:{provider_id:t.id,provider_user_id:t.provider_user_id,name:t.name},provider:t.id||"cloudbase",created_at:e.created_at,updated_at:e.updated_at,last_sign_in_at:e.last_sign_in_at}})))||[],created_at:e.created_at,updated_at:e.updated_at,is_anonymous:"anonymous"===e.name}},t.prototype.validateParams=function(e,t){for(var r=0,n=Object.entries(t);r<n.length;r++){var o=n[r],i=o[0],s=o[1];if(s.required&&(void 0===(null==e?void 0:e[i])||null===(null==e?void 0:e[i])||""===(null==e?void 0:e[i])))throw new d.AuthError({message:s.message})}},t.prototype.validateAtLeastOne=function(e,t,r){if(!t.some((function(t){return t.some((function(t){return void 0!==(null==e?void 0:e[t])&&null!==(null==e?void 0:e[t])&&""!==(null==e?void 0:e[t])}))})))throw new d.AuthError({message:r})},t.prototype.init=function(){var e;return u(this,void 0,Promise,(function(){return c(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return t.sent()&&(null===(e=this.config.eventBus)||void 0===e||e.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return t.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},s([(0,f.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(r=void 0!==d.authModels&&d.authModels.BindPhoneRequest)?r:Object]),a("design:returntype",Promise)],t.prototype,"bindPhoneNumber",null),s([(0,f.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(n=void 0!==d.authModels&&d.authModels.UnbindProviderRequest)?n:Object]),a("design:returntype","function"==typeof(h="undefined"!=typeof Promise&&Promise)?h:Object)],t.prototype,"unbindProvider",null),s([(0,f.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(v=void 0!==d.authModels&&d.authModels.BindEmailRequest)?v:Object]),a("design:returntype",void 0)],t.prototype,"bindEmail",null),s([(0,f.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(g=void 0!==d.authModels&&d.authModels.VerifyRequest)?g:Object]),a("design:returntype","function"==typeof(_="undefined"!=typeof Promise&&Promise)?_:Object)],t.prototype,"verify",null),s([(0,f.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(w=void 0!==d.authModels&&d.authModels.GetVerificationRequest)?w:Object,Object]),a("design:returntype","function"==typeof(E="undefined"!=typeof Promise&&Promise)?E:Object)],t.prototype,"getVerification",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(I="undefined"!=typeof Promise&&Promise)?I:Object)],t.prototype,"getCurrentUser",null),s([(0,f.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],t.prototype,"signInAnonymouslyInWx",null),s([(0,f.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],t.prototype,"bindOpenId",null),s([(0,f.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],t.prototype,"signInWithUnionId",null),s([(0,f.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],t.prototype,"signInWithSms",null),s([(0,f.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],t.prototype,"signInWithEmail",null),s([(0,f.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype","function"==typeof(R="undefined"!=typeof Promise&&Promise)?R:Object)],t.prototype,"isUsernameRegistered",null),s([(0,f.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],t.prototype,"getLoginState",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],t.prototype,"getUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],t.prototype,"getWedaUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(D=void 0!==d.authModels&&d.authModels.BindWithProviderRequest)?D:Object]),a("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],t.prototype,"bindWithProvider",null),s([(0,f.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(x="undefined"!=typeof Promise&&Promise)?x:Object)],t.prototype,"getProviderSubType",null),t}(v.AuthV1Compat);function w(e,t){var r,n,o,s,a=this,l=e.region,p=void 0===l?"ap-shanghai":l,v=e.i18n,y=e.accessKey,m=e.useWxCloud,g=(null==t?void 0:t.platform)||f.useDefaultAdapter.bind(t)(),b=g.runtime,w=g.adapter,E=t||{},I=E.env,S=E.clientId,O=E.debug,A=E.cache,T=E.app,P=(t||{}).apiOrigin;P||(P="https://".concat(I,".").concat(p,".tcb-api.tencentcloudapi.com"));var R,C={env:I,clientId:S,i18n:v,accessKey:y,useWxCloud:m,eventBus:new f.CloudbaseEventEmitter},N=new d.CloudbaseOAuth((0,h.useAuthAdapter)(i(i({},C),{apiOrigin:P,apiPath:(null==e?void 0:e.apiPath)||d.AUTH_API_PREFIX,storage:null==e?void 0:e.storage,baseRequest:null==e?void 0:e.baseRequest,request:null==e?void 0:e.request,anonymousSignInFunc:null==e?void 0:e.anonymousSignInFunc,captchaOptions:null==e?void 0:e.captchaOptions,wxCloud:null==e?void 0:e.wxCloud,adapter:w,onCredentialsError:(R=C.eventBus,function(e){R.fire(d.EVENTS.LOGIN_STATE_CHANGED,i(i({},e),{eventType:d.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:i({"X-SDK-Version":"@cloudbase/js-sdk/".concat(e.sdkVersion)},e.headers||{}),detectSessionInUrl:e.detectSessionInUrl,debug:O,auth:null===(n=null===(r=t.app)||void 0===r?void 0:r.config)||void 0===n?void 0:n.auth}))),D=new _(i(i({},C),{region:p,persistence:e.persistence,debug:O,cache:A||new f.CloudbaseCache({persistence:e.persistence,keys:{userInfoKey:"user_info_".concat(I)},platformInfo:g}),runtime:b||"web",_fromApp:T,oauthInstance:N,auth:null===(s=null===(o=t.app)||void 0===o?void 0:o.config)||void 0===s?void 0:s.auth}));return N.initializeSession((function(e,t){return u(a,void 0,void 0,(function(){return c(this,(function(r){return e?(e.type===d.OAUTH_TYPE.SIGN_IN?t?C.eventBus.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:i(i({},e),{error:t})}):e.user&&D.createLoginState({},{userInfo:e.user}):e.type===d.OAUTH_TYPE.BIND_IDENTITY&&C.eventBus.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:i(i({},e),{error:t})}),[2]):[2]}))}))})),{authInstance:D,oauthInstance:N}}t.Auth=_,t.generateAuthInstance=w;var E="auth";function I(e,t){for(var r=[],n=0;n<=e.length;n++)r[n]=[n];for(var o=0;o<=t.length;o++)r[0][o]=o;for(n=1;n<=e.length;n++)for(o=1;o<=t.length;o++){var i=e[n-1].toLowerCase()===t[o-1].toLowerCase()?0:1;r[n][o]=Math.min(r[n-1][o]+1,r[n][o-1]+1,r[n-1][o-1]+i)}return r[e.length][t.length]}var S={name:"auth",namespace:E,entity:function(e){var t=function(e){var t;if(this.authInstance&&!e)return this.authInstance;e=e||{region:"",persistence:"local",apiPath:d.AUTH_API_PREFIX};var r=this.platform.adapter,n=e.persistence||r.primaryStorage;n&&n!==this.config.persistence&&this.updateConfig({persistence:n});var o=w(i(i({wxCloud:this.config.wxCloud,storage:this.config.storage},e),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(t=this.config.auth)||void 0===t?void 0:t.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(this.config.endPointMode||"CLOUD_API"),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),s=o.authInstance,a=o.oauthInstance;return this.oauthInstance=a,this.authInstance=s,this.authInstance},r=t.call(this,e);Object.assign(t,r),Object.setPrototypeOf(t,Object.getPrototypeOf(r));var n="undefined"!=typeof Proxy?new Proxy(t,{get:function(e,t,r){var n=Reflect.get(e,t,r);if(void 0!==n||"string"!=typeof t)return n;var o=function(e,t){for(var r=null,n=1/0,o=0,i=t;o<i.length;o++){var s=i[o];if(!s.startsWith("_")&&"constructor"!==s){var a=I(e,s);a<n&&(n=a,r=s)}}return r}(t,Object.getOwnPropertyNames(Object.getPrototypeOf(e)).concat(Object.keys(e)).filter((function(t){return"function"==typeof e[t]})));return o&&console.warn("[CloudBase Auth] auth.".concat(t," is not a function. Did you mean: auth.").concat(o,"() ?")),n}}):t;return this[E]=n,n}};try{cloudbase.registerComponent(S)}catch(e){}var O=r(6722);Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return O.AuthErrorCategory}}),Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return O.AuthError}}),t.registerAuth=function(e){try{e.registerComponent(S)}catch(e){console.warn(e)}}},1019:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.adapterForWxMp=t.CloudbaseCache=t.CloudbaseEventEmitter=t.catchErrorsDecorator=t.COMMUNITY_SITE_URL=t.ERRORS=t.throwError=t.printWarn=void 0;var o=r(3616);Object.defineProperty(t,"printWarn",{enumerable:!0,get:function(){return o.printWarn}}),Object.defineProperty(t,"throwError",{enumerable:!0,get:function(){return o.throwError}});var i=r(794);Object.defineProperty(t,"ERRORS",{enumerable:!0,get:function(){return i.ERRORS}}),Object.defineProperty(t,"COMMUNITY_SITE_URL",{enumerable:!0,get:function(){return i.COMMUNITY_SITE_URL}});var s=r(141);Object.defineProperty(t,"catchErrorsDecorator",{enumerable:!0,get:function(){return s.catchErrorsDecorator}});var a=r(9689);Object.defineProperty(t,"CloudbaseEventEmitter",{enumerable:!0,get:function(){return a.CloudbaseEventEmitter}});var u=r(6197);Object.defineProperty(t,"CloudbaseCache",{enumerable:!0,get:function(){return u.CloudbaseCache}});var c=r(7917);Object.defineProperty(t,"adapterForWxMp",{enumerable:!0,get:function(){return n(c).default}});var l=r(8182);Object.defineProperty(t,"useDefaultAdapter",{enumerable:!0,get:function(){return l.useDefaultAdapter}})},5266:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.removeUrlParams=t.addUrlSearch=t.removeBrowserSession=t.getBrowserSession=t.saveToBrowserSession=void 0,t.saveToBrowserSession=function(e,t){try{sessionStorage.setItem(e,JSON.stringify(t))}catch(e){console.error("Failed to save to browser session:",e)}},t.getBrowserSession=function(e){try{return JSON.parse(sessionStorage.getItem(e))}catch(e){return console.error("Failed to get browser session:",e),null}},t.removeBrowserSession=function(e){try{return sessionStorage.removeItem(e),!0}catch(e){return console.error("Failed to remove browser session:",e),null}},t.addUrlSearch=function(e,t){if(void 0!==e){var r=new URL(window.location.href);return r.search=e,r.hash=t||r.hash,window.history.replaceState({},"",r.href),r.href}},t.removeUrlParams=function(e){if("undefined"!=typeof window)try{var t=new URL(window.location.href);e.forEach((function(e){t.searchParams.delete(e)})),window.history.replaceState({},"",t.href)}catch(e){console.error("Failed to remove URL params:",e)}}},916:function(e,t,r){"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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.applyUserV1Compat=t.AuthV1Compat=t.AnonymousAuthProvider=t.CustomAuthProvider=t.WeixinAuthProvider=void 0;var s=r(6722),a=r(1019),u=function(){function e(e){}return e.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},e.prototype.getRedirectResult=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")}))}))},e.prototype.getLinkRedirectResult=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(e){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")}))}))},e}();t.WeixinAuthProvider=u;var c=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.authInstance.signInWithCustomTicket((function(){return Promise.resolve(e)}))];case 1:return t.sent(),[2]}}))}))},e}();t.CustomAuthProvider=c;var l=function(){function e(e){this.authInstance=e.authInstance}return e.prototype.signIn=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return e.sent(),[2]}}))}))},e}();t.AnonymousAuthProvider=l;var d=function(){function e(){}return e.prototype.weixinAuthProvider=function(e){return new u({authInstance:this,appid:e.appid,scope:e.scope})},e.prototype.customAuthProvider=function(){return new c({authInstance:this})},e.prototype.anonymousAuthProvider=function(){return new l({authInstance:this})},e.prototype.signUpWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:e,password:t})];case 1:return[2,r.sent()]}}))}))},e.prototype.signInWithEmailAndPassword=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}}))}))},e.prototype.sendPasswordResetEmail=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:e})];case 1:return t.sent(),[2]}}))}))},e.prototype.signInWithUsernameAndPassword=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:e,password:t})];case 1:return r.sent(),[2,this.createLoginState()]}}))}))},e.prototype.sendPhoneCode=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),t=this.formatPhone(e),[4,this.getVerification({phone_number:t})];case 1:return r.sent(),[2,!0]}}))}))},e.prototype.signUpWithPhoneCode=function(e,t,r){return o(this,void 0,Promise,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),o=this.formatPhone(e),[4,this.signUp(n({phone_number:o,verification_code:t},r?{password:r}:{}))];case 1:return i.sent(),[2,this.createLoginState()]}}))}))},e.prototype.signInWithPhoneCodeOrPassword=function(e){return o(this,void 0,Promise,(function(){var t,r,n,o;return i(this,(function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),o=this.formatPhone(t),n?[4,this.signIn({username:o,password:n})]:[3,2];case 1:return i.sent(),[3,5];case 2:return r?[4,this.signIn({username:o,verification_token:r})]:[3,4];case 3:return i.sent(),[3,5];case 4:(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),i.label=5;case 5:return[2,this.createLoginState()]}}))}))},e.prototype.forceResetPwdByPhoneCode=function(e){return o(this,void 0,Promise,(function(){var t,r,n,o;return i(this,(function(i){switch(i.label){case 0:return t=e.phoneNumber,r=e.phoneCode,n=e.password,"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof r&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof n&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),o=this.formatPhone(t),[4,this.resetPassword({phone_number:o,new_password:n,verification_token:r})];case 1:return i.sent(),[4,this.signIn({username:o,password:n})];case 2:return i.sent(),[2,this.createLoginState()]}}))}))},e.prototype.shouldRefreshAccessToken=function(e){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},e.prototype.onLoginStateExpired=function(e){var t=this;this.onLoginStateChanged((function(r){(null==r?void 0:r.eventType)===s.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR&&e.call(t)}))},e.prototype.onAccessTokenRefreshed=function(e){var t=this;this.onAuthStateChange((function(r){r===s.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED&&e.call(t)}))},e.prototype.onAnonymousConverted=function(e){var t=this;this.onAuthStateChange((function(r){r===s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&e.call(t)}))},e.prototype.onLoginTypeChanged=function(e){var t=this;this.onAuthStateChange((function(r){r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&r!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT||e.call(t)}))},e}();t.AuthV1Compat=d,t.applyUserV1Compat=function(e){e.prototype.linkWithTicket=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(e){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")}))}))},e.prototype.linkWithRedirect=function(e){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},e.prototype.updateEmail=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:e})];case 1:return t.sent(),[2]}}))}))},e.prototype.linkWithPhoneNumber=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(e){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")}))}))},e.prototype.updatePhoneNumber=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(e){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")}))}))},e.prototype.unlink=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(e){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")}))}))}}},3198:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerDatabase=void 0;var u=r(543),c=r(2701),l={filterRes:function(e){return delete e.header,delete e.statusCode,e},flattenResData:function(e){if("object"==typeof e.data&&null!==e.data){var t=i(i({},e),e.data);return delete t.data,t}return e},safeParseEJSON:function(e){if("string"!=typeof e)return e;try{return c.EJSON.parse(e)}catch(t){return e}},buildQueryParams:function(e){return Object.entries(e).filter((function(e){e[0];var t=e[1];return null!=t&&""!==t})).map((function(e){var t=e[0],r=e[1],n="object"==typeof r?JSON.stringify(r):String(r);return"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(n))})).join("&")},getUrlPrefix:function(e){var t=(null==e?void 0:e.instance)||"(default)",r=(null==e?void 0:e.database)||"(default)";return"/database/instances/".concat(t,"/databases/").concat(r)},"database.queryDocument":function(e){var t,r,n,o,u,d;return s(this,void 0,Promise,(function(){var s,h,f,p;return a(this,(function(a){switch(a.label){case 0:return s=!!(null===(r=null===(t=e.query)||void 0===t?void 0:t._id)||void 0===r?void 0:r.$eq),h=l.buildQueryParams(i({projection:e.projection,transactionId:e.transactionId},s?{}:{offset:null!==(n=e.offset)&&void 0!==n?n:0,limit:null!==(o=e.limit)&&void 0!==o?o:100,order:e.order,query:e.query?c.EJSON.stringify(e.query,{relaxed:!1}):void 0})),f="".concat(l.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(h),s&&(f="".concat(l.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/").concat((null===(u=e.query._id)||void 0===u?void 0:u.$eq)||e.query._id,"?").concat(h)),[4,this.gateWay({url:f,method:"GET"})];case 1:return(p=a.sent()).data=l.safeParseEJSON(JSON.stringify(p.data)),!s||p.code||(null===(d=p.data)||void 0===d?void 0:d.code)?[2,l.filterRes(p)]:[2,i(i({},p),{data:{list:[p.data]}})]}}))}))},"database.addDocument":function(e){var t,r,n;return s(this,void 0,Promise,(function(){var o;return a(this,(function(s){switch(s.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"POST",data:i({data:Array.isArray(e.data)?e.data:[e.data]},e.transactionId&&{transactionId:e.transactionId})})];case 1:return o=s.sent(),Array.isArray(e.data)?o=i(i({},o),{data:i({ids:(null===(t=o.data)||void 0===t?void 0:t.insertedIds)||[]},o.data)}):(null===(n=null===(r=o.data)||void 0===r?void 0:r.insertedIds)||void 0===n?void 0:n[0])&&(o=i(i({},o),{data:i({_id:o.data.insertedIds[0]},o.data)})),[2,l.filterRes(o)]}}))}))},"database.updateDocument":function(e){return s(this,void 0,Promise,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents"),method:"PATCH",data:i({query:e.query,data:e.data,multi:!!e.multi,upsert:!!e.upsert,replaceMode:!!e.replaceMode},e.transactionId&&{transactionId:e.transactionId})})];case 1:return t=r.sent(),[2,l.filterRes(t)]}}))}))},"database.deleteDocument":function(e){return s(this,void 0,Promise,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/remove"),method:"POST",data:i({query:e.query,multi:!!e.multi},e.transactionId&&{transactionId:e.transactionId})})];case 1:return t=r.sent(),[2,l.filterRes(t)]}}))}))},"database.countDocument":function(e){return s(this,void 0,Promise,(function(){var t,r;return a(this,(function(n){switch(n.label){case 0:return t=l.buildQueryParams({count:!0,query:e.query?c.EJSON.stringify(e.query,{relaxed:!1}):void 0}),[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents?").concat(t),method:"GET"})];case 1:return r=n.sent(),[2,l.filterRes(r)]}}))}))},"database.addCollection":function(e){return s(this,void 0,Promise,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/collections"),method:"POST",data:{collectionName:e.collectionName}})];case 1:return t=r.sent(),[2,l.filterRes(t)]}}))}))},"database.aggregate":function(e){var t;return s(this,void 0,Promise,(function(){var r,n;return a(this,(function(o){switch(o.label){case 0:return r=e.stages.map((function(e){var t,r;try{var n="string"==typeof e.stageValue?JSON.parse(e.stageValue):e.stageValue;return(t={})[e.stageKey]=c.EJSON.serialize(n),t}catch(t){return(r={})[e.stageKey]=e.stageValue,r}})),[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/collections/").concat(e.collectionName,"/documents/aggregations"),method:"POST",data:{pipeline:r}})];case 1:return n=o.sent(),Array.isArray(null===(t=n.data)||void 0===t?void 0:t.list)&&(n.data.list=JSON.stringify(n.data.list.map((function(e){return JSON.stringify(e)})))),[2,l.filterRes(n)]}}))}))},"database.startTransaction":function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/transactions"),method:"POST"})];case 1:return t=r.sent(),[2,l.filterRes(l.flattenResData(t))]}}))}))},"database.commitTransaction":function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/commit"),method:"POST"})];case 1:return t=r.sent(),[2,l.filterRes(t)]}}))}))},"database.abortTransaction":function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/transactions/").concat(e.transactionId,"/rollback"),method:"POST"})];case 1:return t=r.sent(),[2,l.filterRes(t)]}}))}))},"database.getInTransaction":function(e){var t;return s(this,void 0,void 0,(function(){var r;return a(this,(function(n){switch(n.label){case 0:return[4,l["database.queryDocument"].call(this,e)];case 1:return"object"==typeof(r=n.sent()).data&&null!==r.data?(null===(t=r.data)||void 0===t?void 0:t.code)?[2,l.flattenResData(r)]:[2,i(i({},r),{data:JSON.stringify(r.data)})]:[2,r]}}))}))},"database.updateDocInTransaction":function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return e.data=l.safeParseEJSON(e.data),[4,l["database.updateDocument"].call(this,e)];case 1:return t=r.sent(),[2,l.flattenResData(t)]}}))}))},"database.deleteDocInTransaction":function(e){return s(this,void 0,void 0,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,l["database.deleteDocument"].call(this,e)];case 1:return t=r.sent(),[2,l.flattenResData(t)]}}))}))},"database.insertDocInTransaction":function(e){var t;return s(this,void 0,Promise,(function(){var r,n;return a(this,(function(o){switch(o.label){case 0:return e.data=l.safeParseEJSON(e.data),[4,l["database.addDocument"].call(this,e)];case 1:return"object"==typeof(r=o.sent()).data&&null!==r.data?(n=!!(null===(t=r.data)||void 0===t?void 0:t._id),r=i(i(i({},r),{inserted:n?1:0,ok:n?1:0}),r.data)):r=i({inserted:0,ok:0},r),delete r.data,[2,r]}}))}))},"database.runCommands":function(e){return s(this,void 0,Promise,(function(){var t;return a(this,(function(r){switch(r.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(e),"/commands"),method:"POST",data:i({commands:c.EJSON.serialize(e.commands)},e.transactionId&&{transactionId:e.transactionId})})];case 1:"object"==typeof(t=r.sent()).data&&null!==t.data&&(delete(t=i(i({},t),t.data)).data,delete t.request_id);try{t=c.EJSON.deserialize(t)}catch(e){}return[2,l.filterRes(t)]}}))}))}},d={name:"database",entity:{database:function(e){var t=this.platform,r=t.adapter,n=t.runtime,c=function(e){function t(t){return e.call(this,t)||this}return o(t,e),t.prototype.send=function(t,r){return s(this,void 0,void 0,(function(){var n;return a(this,(function(o){switch(o.label){case 0:return n=null,"GATEWAY"===this.config.endPointMode&&l[t]?[4,l[t].call(this,r)]:[3,2];case 1:return n=o.sent(),[3,4];case 2:return[4,e.prototype.send.call(this,t,r)];case 3:n=o.sent(),o.label=4;case 4:return[2,n]}}))}))},t}(this.request.constructor);return u.Db.reqClass=c,u.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},u.Db.runtime=n,this.wsClientClass&&(u.Db.wsClass=r.wsClass,u.Db.wsClientClass=this.wsClientClass),u.Db.ws||(u.Db.ws=null),new(function(e){function t(t){return e.call(this,t)||this}return o(t,e),t.prototype.runCommands=function(e){return s(this,void 0,Promise,(function(){return a(this,(function(t){return[2,u.Db.createRequest(this.config).send("database.runCommands",e)]}))}))},t}(u.Db))(i(i(i({},this.config),{_fromApp:this}),e))}}};try{cloudbase.registerComponent(d)}catch(e){}function h(e){try{e.registerComponent(d)}catch(e){console.warn(e)}}t.registerDatabase=h;try{window.registerDatabase=h}catch(e){}},8795:function(e,t,r){"use strict";var n=(this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(r(6950)),o=r(9895),i=r(1060),s=r(3456),a=r(7209),u=r(3645),c=r(5337),l=r(9253),d=r(9126),h=r(1944),f=r(3198);n.default.registerVersion("3.4.7");try{(0,o.registerAuth)(n.default),(0,i.registerFunctions)(n.default),(0,s.registerStorage)(n.default),(0,f.registerDatabase)(n.default),(0,a.registerRealtime)(n.default),(0,u.registerModel)(n.default),(0,c.registerAi)(n.default),(0,l.registerCloudrun)(n.default),(0,d.registerMySQL)(n.default),(0,h.registerApis)(n.default)}catch(e){}try{window.cloudbase=n.default}catch(e){}t.default=n.default,e.exports=n.default},9253: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerCloudrun=t.requestContainer=void 0;var s=r(2877).constants.ERRORS,a="cloudrun",u=function(){function e(){}return e.prototype.callContainer=function(e,t){return o(this,void 0,void 0,(function(){var r,o,u;return i(this,(function(i){switch(i.label){case 0:if(r=e.name,o=e.data,!r)throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(a,".callContainer] invalid name")}));try{u=o?JSON.stringify(o):""}catch(e){throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(a,".callContainer] invalid data")}))}return[4,c.call(this,n(n({},e),{data:u}),t)];case 1:return[2,i.sent()]}}))}))},e}();function c(e,t){var r;return o(this,void 0,void 0,(function(){var o,s,a,u,c,l,d,h,f,p,v,y,m,g,b;return i(this,(function(i){switch(i.label){case 0:if(o=e.name,s=e.data,a=e.path,u=void 0===a?"":a,c=e.method,l=e.header,d=void 0===l?{}:l,h=this.getEndPointWithKey("GATEWAY"),f=h.BASE_URL,p=h.PROTOCOL,v="".concat(p).concat(f,"/cloudrun/").concat(o),y=u.startsWith("/")?u:"/".concat(u),m=["GET","HEAD"].includes(null===(r=null==c?void 0:c.toUpperCase)||void 0===r?void 0:r.call(c)))try{g={};try{g=JSON.parse(s)}catch(e){g=s||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(g).map((function(e){return"".concat(e,"=").concat(g[e])})).join("&"))}catch(e){}return[4,this.request.fetch(n(n({method:c||"POST",headers:Object.assign({},{"Content-Type":"application/json; charset=utf-8"},d)},m?{}:{body:s}),{url:"".concat(v).concat(y),customReqOpts:t}))];case 1:return b=i.sent(),"node-sdk"===(null==t?void 0:t.from)?[2,b]:[4,b.data];case 2:return[2,i.sent()]}}))}))}t.requestContainer=c;var l=new u,d={name:a,entity:{callContainer:l.callContainer}};try{cloudbase.registerComponent(d)}catch(e){}function h(e){try{e.registerComponent(d)}catch(e){console.warn(e)}}t.registerCloudrun=h;try{window.registerCloudrun=h}catch(e){}},1060: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.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerFunctions=void 0;var u=r(3388),c=r(2877),l=r(9253),d=c.constants.getSdkName,h=c.constants.ERRORS,f=c.constants.COMMUNITY_SITE_URL,p=c.utils.execCallback,v=c.helpers.catchErrorsDecorator,y="functions",m=new(function(){function e(){}var t,r,m;return e.prototype.callFunction=function(e,t,r){var o,i,u;return s(this,void 0,void 0,(function(){var s,f,v,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N,D,U,x,L,j;return a(this,(function(a){switch(a.label){case 0:if(s=e.name,f=e.data,v=e.query,m=e.parse,g=e.search,b=e.type,_=e.path,w=void 0===_?"":_,E=e.method,I=e.header,S=void 0===I?{}:I,!s)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(y,".callFunction] invalid function name")}));try{O=f?JSON.stringify(f):""}catch(e){throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(y,".callFunction] invalid data")}))}return"cloudrun"!==b?[3,2]:(A=c.utils.generateRequestId(),[4,l.requestContainer.call(this,{name:s,data:O,path:w,method:E,header:n(n({},S),{"X-Request-Id":A})})]);case 1:return[2,{result:L=a.sent(),requestId:A}];case 2:P=(T=this).request,R=T.config,C="functions.invokeFunction",N={inQuery:v,parse:m,search:g,function_name:s,request_data:O},D={},U=!("GATEWAY"!==R.endPointMode||(k=s,"lcap-common-service"===k||"lcap-datasource-test"===k||k.startsWith("lcap-data")||k.startsWith("lowcode-datasource")||"cloudbase_module"===k)||function(e){return"lowcode-wx-datasource"===e}(s)),a.label=3;case 3:return a.trys.push([3,8,,9]),U?[4,P.gateWay(n(n({},e),{path:"functions"}),r)]:[3,5];case 4:return x=a.sent(),D=n({requestId:x.requestId},(null===(o=x.data)||void 0===o?void 0:o.code)?x.data:{data:{response_data:x.data}}),[3,7];case 5:return[4,P.send(C,N,{endPointMode:"CLOUD_API",defaultQuery:(null===(i=null==f?void 0:f.params)||void 0===i?void 0:i.action)?{action:null===(u=null==f?void 0:f.params)||void 0===u?void 0:u.action}:{}},r)];case 6:D=a.sent(),a.label=7;case 7:if(D.code)return[2,p(t,null,D)];if(L=D.data.response_data,m||U)return[2,p(t,null,{result:L,requestId:D.requestId})];try{return L=JSON.parse(D.data.response_data),[2,p(t,null,{result:L,requestId:D.requestId})]}catch(e){p(t,new Error("[".concat(d(),"][").concat(h.INVALID_PARAMS,"][").concat(y,".callFunction] response data must be json")))}return[3,9];case 8:return j=a.sent(),p(t,j),[3,9];case 9:return[2]}var k}))}))},o([v({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(t=void 0!==u.ICallFunctionOptions&&u.ICallFunctionOptions)?t:Object,"function"==typeof(r="undefined"!=typeof Function&&Function)?r:Object,"function"==typeof(m=void 0!==u.ICustomReqOpts&&u.ICustomReqOpts)?m:Object]),i("design:returntype",Promise)],e.prototype,"callFunction",null),e}()),g={name:y,entity:{callFunction:m.callFunction}};try{cloudbase.registerComponent(g)}catch(e){}t.registerFunctions=function(e){try{e.registerComponent(g)}catch(e){console.warn(e)}}},3645: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.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerModel=t.lazyGetEntity=void 0;var u=r(8630),c=r(2877).events.CloudbaseEventEmitter,l="models",d=new WeakMap;function h(e){return new Proxy({},{get:function(t,r){var o=e.getEndPointWithKey("GATEWAY"),i=o.BASE_URL,c=o.PROTOCOL,l=n(n({},e),{BASE_URL:i,PROTOCOL:c}),h=d.get(l);return h||(h=function(e){var t=this,r=e.callFunction.bind(e),o=e.request.fetch.bind(e.request),i=e.getEndPointWithKey("GATEWAY"),c=i.BASE_URL,l=i.PROTOCOL,d="".concat(l).concat(c,"/model"),h="".concat(l).concat(c,"/sql"),f=(0,u.generateHTTPClient)(r,(function(e){return s(t,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,o(n(n({},e),{headers:n({"Content-Type":"application/json"},e.headers)}))];case 1:return[4,t.sent().data];case 2:return[2,t.sent()]}}))}))}),d,{sqlBaseUrl:h});return f}(e),d.set(l,h)),h[r]}})}t.lazyGetEntity=h;var f="cloudbase_init",p=new c;p.on(f,(function(e){var t=e.data;Object.assign(t,{models:h(t)})}));var v={name:l,namespace:l,entity:new Proxy({},{get:function(e,t){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(t,"."))}}),injectEvents:{bus:p,events:[f]}};try{cloudbase.registerComponent(v)}catch(e){}function y(e){try{e.registerComponent(v)}catch(e){console.warn(e)}}t.registerModel=y;try{window.registerModel=y}catch(e){}i(r(8630),t)},9126: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.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerMySQL=void 0;var u=r(8630);function c(e,t,r){var o=this,i=e.request.fetch.bind(e.request),c=t||{},l=c.instance,d=void 0===l?r?void 0:"default":l,h=c.database,f=void 0===h?r?void 0:e.config.env:h,p=function(e,t){return s(o,void 0,void 0,(function(){var r,o,s,u;return a(this,(function(a){switch(a.label){case 0:return r={},t.headers instanceof Headers?t.headers.forEach((function(e,t){r[t]=e})):r=t.headers||{},[["X-Db-Instance",d],["Accept-Profile",f],["Content-Profile",f]].forEach((function(e){var t=e[0],n=e[1];r[t]||r[t.toLocaleLowerCase()]||!n||(r[t]=n)})),[4,i(n(n({url:e.toString()},t),{headers:n({"Content-Type":"application/json"},r),shouldThrowOnError:!1}))];case 1:o=a.sent(),s={},a.label=2;case 2:return a.trys.push([2,4,,5]),[4,o.data];case 3:return s=a.sent(),[3,5];case 4:if(!(u=a.sent()).message.includes("Unexpected end of JSON input"))throw u;return[3,5];case 5:return[2,{ok:(null==o?void 0:o.statusCode)>=200&&(null==o?void 0:o.statusCode)<300,status:(null==o?void 0:o.statusCode)||200,statusText:(null==o?void 0:o.statusMessage)||"OK",json:function(){return Promise.resolve(s||{})},text:function(){return Promise.resolve("string"==typeof s?s:JSON.stringify(s||{}))},headers:null==o?void 0:o.header}]}}))}))},v=e.getEndPointWithKey("GATEWAY"),y=v.BASE_URL,m=v.PROTOCOL,g="".concat(m).concat(y,"/rdb/rest");return r?(0,u.generatePGClient)(e,{pgBaseUrl:g,fetch:p}):(0,u.generateMySQLClient)(e,{mysqlBaseUrl:g,fetch:p})}var l={name:"mysql",entity:{mysql:function(e){return c(this,e,!1)(e)}}},d={name:"rdb",entity:{rdb:function(e){return c(this,e,!0)(e)}}};try{cloudbase.registerComponent(l),cloudbase.registerComponent(d)}catch(e){}function h(e){try{e.registerComponent(l),e.registerComponent(d)}catch(e){console.warn(e)}}t.registerMySQL=h;try{window.registerMySQL=h}catch(e){}i(r(8630),t)},5413: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Auth=void 0;var u=r(4949),c=r(5257),l=r(2962),d=r(2631),h=a(r(9639)),f=r(8308);function p(e,t){var n;return o(this,void 0,void 0,(function(){var s,a=this;return i(this,(function(u){s=function(){return o(a,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,1,,6]),[2,r(5814)];case 1:e.sent(),e.label=2;case 2:return e.trys.push([2,4,,5]),[4,Promise.resolve().then(r.t.bind(r,5814,23))];case 3:return[2,e.sent()];case 4:return e.sent(),[2];case 5:return[3,6];case 6:return[2]}}))}))};try{if(((null===(n=null==t?void 0:t.root)||void 0===n?void 0:n.globalThis)||globalThis).IS_MP_BUILD)return[2];if(e)return[2,s()]}catch(t){if(e)return[2,s()]}return[2]}))}))}var v=function(){function e(e){var t=e.request,r=e.credentialsClient;if(!r){var o={apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,storage:e.storage,env:e.env,baseRequest:e.baseRequest,anonymousSignInFunc:e.anonymousSignInFunc,wxCloud:e.wxCloud,onCredentialsError:e.onCredentialsError,headers:e.headers||{},i18n:e.i18n,debug:e.debug};r=new c.OAuth2Client(o)}if(!t){var i=r.request.bind(r),s=new l.Captcha(n({env:e.env,clientId:e.clientId,request:i,storage:e.storage,adapter:e.adapter,oauthInstance:this},e.captchaOptions));t=s.request.bind(s)}this.config={env:e.env,apiOrigin:e.apiOrigin,apiPath:e.apiPath,clientId:e.clientId,request:t,credentialsClient:r,storage:e.storage||c.defaultStorage,adapter:e.adapter}}return e.parseParamsToSearch=function(e){return Object.keys(e).forEach((function(t){e[t]||delete e[t]})),new h.default(e).toString()},e.prototype.getParamsByVersion=function(e,t){var r,n=(0,d.deepClone)(e),o=(null===(r={v2:u.ApiUrlsV2}[null==n?void 0:n.version])||void 0===r?void 0:r[t])||u.ApiUrls[t];return n&&delete n.version,{params:n,url:o}},e.prototype.signIn=function(e){return o(this,void 0,Promise,(function(){var t,r,o,s;return i(this,(function(i){switch(i.label){case 0:return t=e.version||"v1",(r=this.getParamsByVersion(e,"AUTH_SIGN_IN_URL")).params.query&&delete r.params.query,[4,this.getEncryptParams(r.params)];case 1:return o=i.sent(),[4,this.config.request(r.url,{method:"POST",body:o})];case 2:return s=i.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},s),{version:t}))];case 3:return i.sent(),[2,Promise.resolve(s)]}}))}))},e.prototype.signInAnonymously=function(e,t){return void 0===e&&(e={}),void 0===t&&(t=!1),o(this,void 0,Promise,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:e,useWxCloud:t})];case 1:return r=n.sent(),[4,this.config.credentialsClient.setCredentials(r)];case 2:return n.sent(),[2,Promise.resolve(r)]}}))}))},e.prototype.signUp=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_UP_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}}))}))},e.prototype.signOut=function(e){return o(this,void 0,Promise,(function(){var t,r,n,o;return i(this,(function(i){switch(i.label){case 0:if(t={},!e)return[3,6];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.config.request(u.ApiUrls.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:e})];case 2:return t=i.sent(),[3,4];case 3:return(r=i.sent()).error!==u.ErrorType.UNAUTHENTICATED&&console.log("sign_out_error",r),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return i.sent(),[2,t];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return n=i.sent(),[4,this.config.request(u.ApiUrls.AUTH_REVOKE_URL,{method:"POST",body:{token:n}})];case 8:return o=i.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return i.sent(),[2,Promise.resolve(o)]}}))}))},e.prototype.revokeAllDevices=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}}))}))},e.prototype.revokeDevice=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.config.request(u.ApiUrls.AUTHORIZED_DEVICES_DELETE_URL+e.device_id,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}}))}))},e.prototype.getVerification=function(e,t){return o(this,void 0,Promise,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return r=!1,"CUR_USER"!==e.target?[3,1]:(r=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:o.sent()&&(r=!0),o.label=3;case 3:return(n=(0,d.deepClone)(e)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(n.phone_number)&&(n.phone_number="+86 ".concat(n.phone_number)),[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:n,withCaptcha:(null==t?void 0:t.withCaptcha)||!1,withCredentials:r})]}}))}))},e.prototype.verify=function(e){return o(this,void 0,Promise,(function(){var t,r;return i(this,(function(o){switch(o.label){case 0:return t=this.getParamsByVersion(e,"VERIFY_URL"),[4,this.config.request(t.url,{method:"POST",body:t.params})];case 1:return r=o.sent(),"v2"!==(null==e?void 0:e.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(n(n({},r),{version:"v2"}))];case 2:o.sent(),o.label=3;case 3:return[2,r]}}))}))},e.prototype.genProviderRedirectUri=function(t){return o(this,void 0,Promise,(function(){var r,n,o,a,c;return i(this,(function(i){return r=t.provider_redirect_uri,n=t.other_params,o=void 0===n?{}:n,a=s(t,["provider_redirect_uri","other_params"]),r&&!a.redirect_uri&&(a.redirect_uri=r),c="".concat(u.ApiUrls.PROVIDER_URI_URL,"?").concat(e.parseParamsToSearch(a)),Object.keys(o).forEach((function(e){var t=o[e];("sign_out_uri"!==e||(null==t?void 0:t.length)>0)&&(c+="&other_params[".concat(e,"]=").concat(encodeURIComponent(t)))})),[2,this.config.request(c,{method:"GET"})]}))}))},e.prototype.grantProviderToken=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,(function(){return i(this,(function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"POST",body:e,useWxCloud:t})]}))}))},e.prototype.patchProviderToken=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"PATCH",body:e})]}))}))},e.prototype.signInWithProvider=function(e,t){return void 0===t&&(t=!1),o(this,void 0,Promise,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return r=this.getParamsByVersion(e,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(r.url,{method:"POST",body:r.params,useWxCloud:t})];case 1:return o=i.sent(),[4,this.config.credentialsClient.setCredentials(n(n({},o),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return i.sent(),[2,Promise.resolve(o)]}}))}))},e.prototype.toBindIdentity=function(e){var t,r;return o(this,void 0,void 0,(function(){var n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return(o=e.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:o=i.sent(),i.label=2;case 2:n=o,i.label=3;case 3:return i.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:e.provider_token},n)];case 4:return i.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY,provider:e.provider},error:null},[3,6];case 5:return a=i.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY},error:new f.AuthError(a)},[3,6];case 6:return e.fireEvent&&(null===(r=null===(t=this.config.eventBus)||void 0===t?void 0:t.fire)||void 0===r||r.call(t,u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:s})),[2,s]}}))}))},e.prototype.getInitialSession=function(){return o(this,void 0,Promise,(function(){var e,t,r,o,s,a,c,l,d,h,p,v,y,m,g;return i(this,(function(i){switch(i.label){case 0:e={},i.label=1;case 1:if(i.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(t=new URLSearchParams(null===location||void 0===location?void 0:location.search),r=t.get("code"),o=t.get("state"),!r||!o)return[2,{data:null,error:null}];s=null;try{s=JSON.parse(sessionStorage.getItem(o)||"null")}catch(e){}return e={type:null==s?void 0:s.type},a=t.get("error"),c=t.get("error_description"),a||c?[2,{data:e,error:new f.AuthError({message:c||a||"Unknown error from OAuth provider"})}]:(l=(null==s?void 0:s.provider)||t.get("provider"))?(d=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:l,provider_redirect_uri:d,provider_code:r})]):[2,{data:e,error:new f.AuthError({message:"Provider is required for OAuth verification"})}];case 2:return h=i.sent().provider_token,p=void 0,v=null,y=void 0,s.type!==u.OAUTH_TYPE.BIND_IDENTITY?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return p=i.sent(),[4,this.toBindIdentity({provider:l,provider_token:h,credentials:p})];case 4:return y=i.sent(),[3,11];case 5:return s.type!==u.OAUTH_TYPE.SIGN_IN?[3,11]:(y=this.getParamsByVersion({provider:l},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(y.url,{method:"POST",body:{provider_token:h}})]);case 6:p=i.sent(),i.label=7;case 7:return i.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:p})];case 8:return v=i.sent(),[3,10];case 9:return m=i.sent(),console.error("get user info error",m),[3,10];case 10:y={data:n(n({},e),{session:p,user:v}),error:null},i.label=11;case 11:t.delete("code"),t.delete("state"),t.delete("provider"),this.restoreUrlState(void 0===(null==s?void 0:s.search)?"?".concat(t.toString()):s.search,(null==s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(o)}catch(e){}return[2,y];case 12:return g=i.sent(),[2,{data:e,error:new f.AuthError(g)}];case 13:return[2]}}))}))},e.prototype.signInCustom=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}}))}))},e.prototype.signInWithWechat=function(e){return void 0===e&&(e={}),o(this,void 0,Promise,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:e})];case 1:return t=r.sent(),[4,this.config.credentialsClient.setCredentials(t)];case 2:return r.sent(),[2,Promise.resolve(t)]}}))}))},e.prototype.bindWithProvider=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(r){return[2,this.config.request(u.ApiUrls.PROVIDER_BIND_URL,{method:"POST",body:e,withCredentials:!0,getCredentials:t?function(){return t}:void 0})]}))}))},e.prototype.getUserProfile=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.getUserInfo(e)]}))}))},e.prototype.getUserInfo=function(e){var t,r,n;return void 0===e&&(e={}),o(this,void 0,Promise,(function(){var o,s,a,u,c;return i(this,(function(i){switch(i.label){case 0:return o=this.getParamsByVersion(e,"USER_ME_URL"),(null===(t=o.params)||void 0===t?void 0:t.query)&&(s=new h.default(o.params.query),o.url+="?".concat(s.toString())),[4,this.config.request(o.url,{method:"GET",withCredentials:!0,getCredentials:e.credentials?function(){return e.credentials}:void 0})];case 1:if((a=i.sent()).sub&&(a.uid=a.sub),null===(r=a.providers)||void 0===r?void 0:r.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(u=null===(n=wx.getAccountInfoSync().miniProgram)||void 0===n?void 0:n.appId,(null==(c=a.providers.find((function(e){return e.id===u})))?void 0:c.provider_user_id)&&(a.open_id=c.provider_user_id))}catch(e){}return[2,a]}}))}))},e.prototype.getWedaUserInfo=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,e.sent()]}}))}))},e.prototype.deleteMe=function(t){return o(this,void 0,Promise,(function(){var r,n;return i(this,(function(o){return r=this.getParamsByVersion(t,"USER_ME_URL"),n="".concat(r.url,"?").concat(e.parseParamsToSearch(r.params)),[2,this.config.request(n,{method:"DELETE",withCredentials:!0})]}))}))},e.prototype.hasLoginState=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}}))}))},e.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},e.prototype.getLoginState=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},e.prototype.transByProvider=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:e,withCredentials:!0})]}))}))},e.prototype.grantToken=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){return t=this.getParamsByVersion(e,"AUTH_TOKEN_URL"),[2,this.config.request(t.url,{method:"POST",body:t.params})]}))}))},e.prototype.getProviders=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},e.prototype.unbindProvider=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_UNBIND_URL,"/").concat(e.provider_id),{method:"DELETE",withCredentials:!0})]}))}))},e.prototype.checkPassword=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request("".concat(u.ApiUrls.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:e})]}))}))},e.prototype.editContact=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request("".concat(u.ApiUrls.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:e})]}))}))},e.prototype.setPassword=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request("".concat(u.ApiUrls.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:e})]}))}))},e.prototype.updatePasswordByOld=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,this.sudo({password:e.old_password})];case 1:return t=r.sent(),[2,this.setPassword({sudo_token:t.sudo_token,new_password:e.new_password})]}}))}))},e.prototype.sudo=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request("".concat(u.ApiUrls.SUDO_URL),{method:"POST",withCredentials:!0,body:e})]}))}))},e.prototype.sendVerificationCodeToCurrentUser=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return e.target="CUR_USER",[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:e,withCredentials:!0,withCaptcha:!0})]}))}))},e.prototype.changeBoundProvider=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_LIST,"/").concat(e.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:e.trans_token},withCredentials:!0})]}))}))},e.prototype.setUserProfile=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.USER_PRIFILE_URL,{method:"PATCH",body:e,withCredentials:!0})]}))}))},e.prototype.updateUserBasicInfo=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:e})]}))}))},e.prototype.queryUserProfile=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){return t=new h.default(e),[2,this.config.request("".concat(u.ApiUrls.USER_QUERY_URL,"?").concat(t.toString()),{method:"GET",withCredentials:!0})]}))}))},e.prototype.setCustomSignFunc=function(e){this.getCustomSignTicketFn=e},e.prototype.signInWithCustomTicket=function(){return o(this,void 0,Promise,(function(){var e,t;return i(this,(function(r){switch(r.label){case 0:return(e=this.getCustomSignTicketFn)?[4,e()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return t=r.sent(),[2,this.signInCustom({provider_id:"custom",ticket:t})]}}))}))},e.prototype.resetPassword=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.AUTH_RESET_PASSWORD,{method:"POST",body:e})]}))}))},e.prototype.authorize=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:e})]}))}))},e.prototype.authorizeDevice=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:e})]}))}))},e.prototype.deviceAuthorize=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.AUTH_GET_DEVICE_CODE,{method:"POST",body:e})]}))}))},e.prototype.authorizeInfo=function(t){return o(this,void 0,Promise,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r="".concat(u.ApiUrls.AUTHORIZE_INFO_URL,"?").concat(e.parseParamsToSearch(t)),n=!0,o=!1,[4,this.hasLoginState()];case 1:return i.sent()&&(o=!0,n=!1),[2,this.config.request(r,{method:"GET",withBasicAuth:n,withCredentials:o})]}}))}))},e.prototype.checkUsername=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.CHECK_USERNAME,{method:"GET",body:e,withCredentials:!0})]}))}))},e.prototype.checkIfUserExist=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){return t=new h.default(e),[2,this.config.request("".concat(u.ApiUrls.CHECK_IF_USER_EXIST,"?").concat(t.toString()),{method:"GET"})]}))}))},e.prototype.loginScope=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.credentialsClient.getScope()]}))}))},e.prototype.loginGroups=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.credentialsClient.getGroups()]}))}))},e.prototype.refreshTokenForce=function(e){return o(this,void 0,void 0,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return t=r.sent(),[4,this.config.credentialsClient.refreshToken(n(n({},t),{version:(null==e?void 0:e.version)||"v1"}))];case 2:return[2,r.sent()]}}))}))},e.prototype.getCredentials=function(){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.config.credentialsClient.getCredentials()]}))}))},e.prototype.getPublicKey=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrlsV2.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]}))}))},e.prototype.getEncryptParams=function(e){return o(this,void 0,Promise,(function(){var t,r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return t=e.isEncrypt,delete e.isEncrypt,r=(0,d.deepClone)(e),[4,p(t,this.config.adapter)];case 1:if(!(n=i.sent()))return[2,e];o="",s="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(a=i.sent(),o=a.public_key,s=a.public_key_thumbprint,!o||!s)throw a;return[3,5];case 4:throw i.sent();case 5:return[2,{params:n.getEncryptInfo({publicKey:o,payload:r}),public_key_thumbprint:s}]}}))}))},e.prototype.getProviderSubType=function(){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]}))}))},e.prototype.verifyCaptchaData=function(e){var t=e.token,r=e.key;return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:t,key:r},withCredentials:!1})]}))}))},e.prototype.createCaptchaData=function(e){var t=e.state,r=e.redirect_uri,n=void 0===r?void 0:r;return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:n},withCredentials:!1})]}))}))},e.prototype.getMiniProgramCode=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE,{method:"POST",body:e})]}))}))},e.prototype.getMiniProgramQrCodeStatus=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:e})]}))}))},e.prototype.getUserBehaviorLog=function(e){return o(this,void 0,Promise,(function(){var t,r;return i(this,(function(n){return t={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},r="".concat(u.ApiUrls.GET_USER_BEHAVIOR_LOG,"?").concat(t[e.type],"&limit=").concat(e.limit).concat(e.page_token?"&page_token=".concat(e.page_token):""),[2,this.config.request(r,{method:"GET",withCredentials:!0})]}))}))},e.prototype.modifyPassword=function(e){return o(this,void 0,Promise,(function(){var t,r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return t="",r="",[4,p(!0,this.config.adapter)];case 1:if(!(n=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,r=o.public_key_thumbprint,!t||!r)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:e.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:r}})]}}))}))},e.prototype.modifyPasswordWithoutLogin=function(e){return o(this,void 0,Promise,(function(){var t,r,n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return t="",r="",[4,p(!0,this.config.adapter)];case 1:if(!(n=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),t=o.public_key,r=o.public_key_thumbprint,!t||!r)throw o;return[3,5];case 4:throw i.sent();case 5:return s=e.password?n.getEncryptInfo({publicKey:t,payload:e.password}):"",a=n.getEncryptInfo({publicKey:t,payload:e.new_password}),[2,this.config.request(u.ApiUrlsV2.AUTH_RESET_PASSWORD,{method:"POST",body:{username:e.username,password:s,new_password:a,public_key_thumbprint:r}})]}}))}))},e.prototype.restoreUrlState=function(e,t){if(void 0!==e)try{var r=new URL(window.location.href);r.search=e,r.hash=t||"",window.history.replaceState(null,"",r.toString()),window.location.replace(r.toString())}catch(e){}},e}();t.Auth=v},8308:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0}),t.AuthError=t.AuthErrorCategory=void 0;var i,s=r(4949);!function(e){e.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",e.INVALID_CREDENTIALS="INVALID_CREDENTIALS",e.USER_NOT_FOUND="USER_NOT_FOUND",e.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",e.SERVICE_ERROR="SERVICE_ERROR",e.INVALID_PARAMS="INVALID_PARAMS",e.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",e.UNKNOWN="UNKNOWN"}(i=t.AuthErrorCategory||(t.AuthErrorCategory={}));var a="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",u="https://docs.cloudbase.net/api-reference/webv3-next/initialization",c=function(e){function t(t,r){var n,o=this,c=t.error_description||t.message;return(o=e.call(this,c)||this).__isAuthError=!0,o.name="AuthError",o.status=t.error,o.code=t.error_code,o.requestId=t.requestId,o.category=function(e,t){if(!e&&!t)return i.UNKNOWN;try{var r=(e||"").toLowerCase();return t===s.ErrorType.FAILED_PRECONDITION||t===s.ErrorType.PROVIDER_NOT_ENABLED||t===s.ErrorType.LOGIN_METHOD_DISABLED||r.includes("身份源")||r.includes("开启")||r.includes("identity provider")||r.includes("provider not enabled")||r.includes("login method")||r.includes("登录方式")||r.includes("not enabled")||r.includes("未开启")||r.includes("未启用")||r.includes("请联系开发者")||r.includes("anonymous login is not enabled")||r.includes("匿名登录未开启")?i.PROVIDER_NOT_ENABLED:t===s.ErrorType.INVALID_PASSWORD||t===s.ErrorType.INVALID_GRANT||t===s.ErrorType.INVALID_VERIFICATION_CODE||t===s.ErrorType.INVALID_USERNAME_OR_PASSWORD||t===s.ErrorType.INVALID_CREDENTIALS||t===s.ErrorType.WRONG_PASSWORD||t===s.ErrorType.UNAUTHENTICATED||t===s.ErrorType.INVALID_TWO_FACTOR||t===s.ErrorType.INVALID_TWO_FACTOR_RECOVERY||t===s.ErrorType.PASSWORD_NOT_SET||r.includes("密码不正确")||r.includes("password")||r.includes("invalid_password")||r.includes("凭据")||r.includes("credentials")||r.includes("验证码")||r.includes("verification")||r.includes("invalid_verification_code")||r.includes("invalid_username_or_password")||r.includes("username or password")||r.includes("用户名或密码")||r.includes("wrong password")||r.includes("incorrect password")?i.INVALID_CREDENTIALS:t===s.ErrorType.NOT_FOUND||t===s.ErrorType.USER_NOT_FOUND||r.includes("用户不存在")||r.includes("not found")||r.includes("user not found")||r.includes("不存在")||r.includes("no such user")||r.includes("user does not exist")?i.USER_NOT_FOUND:t===s.ErrorType.USER_BLOCKED||t===s.ErrorType.USER_PENDING||t===s.ErrorType.UNDER_REVIEW||t===s.ErrorType.INVALID_STATUS||r.includes("被封禁")||r.includes("blocked")||r.includes("pending")||r.includes("审核")||r.includes("review")||r.includes("locked")||r.includes("已锁定")?i.USER_STATUS_ABNORMAL:t===s.ErrorType.SERVER_ERROR||t===s.ErrorType.UNAVAILABLE||t===s.ErrorType.TEMPORARILY_UNAVAILABLE||t===s.ErrorType.INTERNAL||t===s.ErrorType.UNREACHABLE||t===s.ErrorType.DEADLINE_EXCEEDED||t===s.ErrorType.DATA_LOSS||r.includes("network")||r.includes("timeout")||r.includes("服务")||r.includes("timed out")||r.includes("超时")?i.SERVICE_ERROR:t===s.ErrorType.INVALID_ARGUMENT||t===s.ErrorType.INVALID_REQUEST||t===s.ErrorType.INVALID_SCOPE||t===s.ErrorType.INVALID_REQUEST_URI||t===s.ErrorType.INVALID_REQUEST_OBJECT?i.INVALID_PARAMS:t===s.ErrorType.PERMISSION_DENIED||t===s.ErrorType.ACCESS_DENIED||t===s.ErrorType.UNAUTHORIZED_CLIENT?i.PROVIDER_NOT_ENABLED:i.UNKNOWN}catch(e){return t}}(c,o.status),o.helpMessage=function(e,t){var r=(null==t?void 0:t.method)||"signIn",n={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」"}[r]||"对应的登录方式";switch(e){case i.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(r,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(n,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(a,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(u);case i.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(r,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case i.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(a,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case i.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(a);case i.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。";case i.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求,参考 API 文档确认各参数的格式和约束。\n"+" 文档地址:".concat(u);case i.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(r,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(a);default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(a,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(u)}}(o.category,r),o.loginMethodHint=(n=null==r?void 0:r.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[n]||"",o}return o(t,e),t}(Error);t.AuthError=c},4949:function(e,t){"use strict";var r,n,o,i;Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.EVENTS=t.AUTH_STATE_CHANGED_TYPE=t.LOGIN_STATE_CHANGED_TYPE=t.ErrorType=t.VerificationUsages=t.ApiUrlsV2=t.ApiUrls=t.AUTH_API_PREFIX=void 0,t.AUTH_API_PREFIX="/auth",(i=t.ApiUrls||(t.ApiUrls={})).AUTH_SIGN_UP_URL="/v1/signup",i.AUTH_TOKEN_URL="/v1/token",i.AUTH_REVOKE_URL="/v1/revoke",i.WEDA_USER_URL="/v1/plugin/weda/userinfo",i.AUTH_RESET_PASSWORD="/v1/reset",i.AUTH_GET_DEVICE_CODE="/v1/device/code",i.CHECK_USERNAME="/v1/checkUsername",i.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",i.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",i.AUTH_SIGN_IN_URL="/v1/signin",i.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",i.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",i.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",i.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",i.PROVIDER_TOKEN_URL="/v1/provider/token",i.PROVIDER_URI_URL="/v1/provider/uri",i.USER_ME_URL="/v1/user/me",i.AUTH_SIGNOUT_URL="/v1/user/signout",i.USER_QUERY_URL="/v1/user/query",i.USER_PRIFILE_URL="/v1/user/profile",i.USER_BASIC_EDIT_URL="/v1/user/basic/edit",i.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",i.PROVIDER_LIST="/v1/user/provider",i.PROVIDER_BIND_URL="/v1/user/provider/bind",i.PROVIDER_UNBIND_URL="/v1/user/provider",i.CHECK_PWD_URL="/v1/user/sudo",i.SUDO_URL="/v1/user/sudo",i.BIND_CONTACT_URL="/v1/user/contact",i.AUTH_SET_PASSWORD="/v1/user/password",i.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",i.AUTHORIZE_URL="/v1/user/authorize",i.AUTHORIZE_INFO_URL="/v1/user/authorize/info",i.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",i.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",i.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",i.VERIFICATION_URL="/v1/verification",i.VERIFY_URL="/v1/verification/verify",i.CAPTCHA_DATA_URL="/v1/captcha/data",i.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",i.GET_CAPTCHA_URL="/v1/captcha/init",i.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",i.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status",(o=t.ApiUrlsV2||(t.ApiUrlsV2={})).AUTH_SIGN_IN_URL="/v2/signin/username",o.AUTH_TOKEN_URL="/v2/token",o.USER_ME_URL="/v2/user/me",o.VERIFY_URL="/v2/signin/verificationcode",o.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",o.AUTH_PUBLIC_KEY="/v2/signin/publichkey",o.AUTH_RESET_PASSWORD="/v2/signin/password/update",(n=t.VerificationUsages||(t.VerificationUsages={})).REGISTER="REGISTER",n.SIGN_IN="SIGN_IN",n.PASSWORD_RESET="PASSWORD_RESET",n.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",n.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE",(r=t.ErrorType||(t.ErrorType={})).UNREACHABLE="unreachable",r.LOCAL="local",r.CANCELLED="cancelled",r.UNKNOWN="unknown",r.UNAUTHENTICATED="unauthenticated",r.RESOURCE_EXHAUSTED="resource_exhausted",r.FAILED_PRECONDITION="failed_precondition",r.INVALID_ARGUMENT="invalid_argument",r.DEADLINE_EXCEEDED="deadline_exceeded",r.NOT_FOUND="not_found",r.ALREADY_EXISTS="already_exists",r.PERMISSION_DENIED="permission_denied",r.ABORTED="aborted",r.OUT_OF_RANGE="out_of_range",r.UNIMPLEMENTED="unimplemented",r.INTERNAL="internal",r.UNAVAILABLE="unavailable",r.DATA_LOSS="data_loss",r.INVALID_PASSWORD="invalid_password",r.PASSWORD_NOT_SET="password_not_set",r.INVALID_STATUS="invalid_status",r.USER_PENDING="user_pending",r.USER_BLOCKED="user_blocked",r.INVALID_VERIFICATION_CODE="invalid_verification_code",r.TWO_FACTOR_REQUIRED="two_factor_required",r.INVALID_TWO_FACTOR="invalid_two_factor",r.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",r.UNDER_REVIEW="under_review",r.INVALID_REQUEST="invalid_request",r.UNAUTHORIZED_CLIENT="unauthorized_client",r.ACCESS_DENIED="access_denied",r.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",r.INVALID_SCOPE="invalid_scope",r.INVALID_GRANT="invalid_grant",r.SERVER_ERROR="server_error",r.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",r.INTERACTION_REQUIRED="interaction_required",r.LOGIN_REQUIRED="login_required",r.ACCOUNT_SELECTION_REQUIRED="account_selection_required",r.CONSENT_REQUIRED="consent_required",r.INVALID_REQUEST_URI="invalid_request_uri",r.INVALID_REQUEST_OBJECT="invalid_request_object",r.REQUEST_NOT_SUPPORTED="request_not_supported",r.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",r.REGISTRATION_NOT_SUPPORTED="registration_not_supported",r.CAPTCHA_REQUIRED="captcha_required",r.CAPTCHA_INVALID="captcha_invalid",r.PROVIDER_NOT_ENABLED="provider_not_enabled",r.LOGIN_METHOD_DISABLED="login_method_disabled",r.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",r.INVALID_CREDENTIALS="invalid_credentials",r.WRONG_PASSWORD="wrong_password",r.USER_NOT_FOUND="user_not_found",t.LOGIN_STATE_CHANGED_TYPE={SIGN_OUT:"sign_out",SIGN_IN:"sign_in",CREDENTIALS_ERROR:"credentials_error"},t.AUTH_STATE_CHANGED_TYPE={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},t.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},t.OAUTH_TYPE={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},t.DEFAULT_NODE_ACCESS_SCOPE="node-sdk-scope"},3538:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2084: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.openURIWithCallback=void 0;var s=r(9689),a=r(3616),u=function(e,t){var r;return function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];clearTimeout(r),r=setTimeout((function(){return e.apply(null,n)}),t)}},c=new s.CloudbaseEventEmitter,l="resolveCaptchaData",d="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",h="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",f="background:#6c757d;cursor:not-allowed";t.openURIWithCallback=function(e,t){return o(void 0,void 0,Promise,(function(){var r,s,p,v;return i(this,(function(y){return r=(0,a.parseCaptcha)(e),s=r.captchaData,p=r.state,v=r.token,function(e){var t=e.oauthInstance,r=e.captchaState,s="captcha-image",a=function(){return o(void 0,void 0,void 0,(function(){var e,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t.createCaptchaData({state:r.state})];case 1:return e=i.sent(),r=n(n({},r),{captchaData:e.data,token:e.token}),document.getElementById(s).src=e.data,[3,3];case 2:return o=i.sent(),console.error("刷新图形验证码失败",o),[3,3];case 3:return[2]}}))}))},p=function(e,t,r){var n=document.createElement(e);return t&&(n.style.cssText=t),r&&(n.textContent=r),n},v=p("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),y=p("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");y.appendChild(p("p","margin-bottom:15px","请输入你看到的字符:"));var m=p("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),g=p("img","width:100%;height:auto;border:1px solid #eee");g.id=s,g.src=r.captchaData,m.appendChild(g);var b=p("button",d,"刷新");b.onclick=u((function(){return o(void 0,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:b.textContent="加载中...",b.disabled=!0,b.style.cssText="".concat(d,";").concat(f),e.label=1;case 1:return e.trys.push([1,,3,4]),[4,a()];case 2:return e.sent(),[3,4];case 3:return b.textContent="刷新",b.disabled=!1,b.style.cssText=d,[7];case 4:return[2]}}))}))}),500),m.appendChild(b),y.appendChild(m);var _=p("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");_.type="text",_.placeholder="输入字符",_.maxLength=4,y.appendChild(_);var w=p("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");y.appendChild(w);var E=function(e){w.textContent=e,w.style.display="block"},I=p("button",h,"确定");I.onclick=u((function(){return o(void 0,void 0,void 0,(function(){var e,n,o,s;return i(this,(function(i){switch(i.label){case 0:if(!(e=_.value.trim()))return E("请输入字符"),[2];w.style.display="none",I.textContent="验证中...",I.disabled=!0,I.style.cssText="".concat(h,";").concat(f),i.label=1;case 1:return i.trys.push([1,3,5,6]),[4,t.verifyCaptchaData({token:r.token,key:e})];case 2:return n=i.sent(),c.fire(l,n),console.log("图形验证码校验成功"),document.body.removeChild(v),document.body.removeChild(y),[3,6];case 3:return o=i.sent(),console.error("图形验证码校验失败",o),s=o.error_description||"图形验证码校验失败",E(s),_.value="",_.focus(),[4,a()];case 4:return i.sent(),[3,6];case 5:return I.textContent="确定",I.disabled=!1,I.style.cssText=h,[7];case 6:return[2]}}))}))}),500),y.appendChild(I),document.body.appendChild(v),document.body.appendChild(y)}({oauthInstance:t,captchaState:{captchaData:s,state:p,token:v}}),[2,new Promise((function(e){console.log("等待图形验证码校验结果..."),c.on(l,(function(t){e(null==t?void 0:t.data)}))}))]}))}))}},2962: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.Captcha=void 0;var i=r(4949),s=r(5257),a=r(7425),u=r(2084),c=function(){function e(e){e.openURIWithCallback||(e.openURIWithCallback=this.getDefaultOpenURIWithCallback()),e.storage||(e.storage=s.defaultStorage),this.config=e,this.tokenSectionName="captcha_".concat(e.clientId||e.env)}return e.prototype.isMatch=function(){var e,t,r;return(null===(r=null===(t=null===(e=this.config)||void 0===e?void 0:e.adapter)||void 0===t?void 0:t.isMatch)||void 0===r?void 0:r.call(t))||(0,a.isMp)()},e.prototype.request=function(e,t){return n(this,void 0,Promise,(function(){var r,n,s,a;return o(this,(function(o){switch(o.label){case 0:return t||(t={}),t.method||(t.method="GET"),r="".concat(t.method,":").concat(e),n=e,t.withCaptcha?[4,this.appendCaptchaTokenToURL(e,r,!1)]:[3,2];case 1:n=o.sent(),o.label=2;case 2:return o.trys.push([2,4,,7]),[4,this.config.request(n,t)];case 3:return s=o.sent(),[3,7];case 4:return(a=o.sent()).error!==i.ErrorType.CAPTCHA_REQUIRED&&a.error!==i.ErrorType.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(e,r,a.error===i.ErrorType.CAPTCHA_INVALID)];case 5:return e=o.sent(),[2,this.config.request(e,t)];case 6:return[2,Promise.reject(a)];case 7:return[2,s]}}))}))},e.prototype.getDefaultOpenURIWithCallback=function(){var e=this;return function(t){return(0,u.openURIWithCallback)(t,e.config.oauthInstance)}},e.prototype.getCaptchaToken=function(e,t){return n(this,void 0,Promise,(function(){var r,n,s,a;return o(this,(function(o){switch(o.label){case 0:return e?[3,2]:[4,this.findCaptchaToken()];case 1:if(r=o.sent())return[2,r];o.label=2;case 2:return[4,this.config.request(i.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:t,redirect_uri:""},withCredentials:!1})];case 3:return n=o.sent(),s="".concat(n.data,"?state=").concat(encodeURIComponent(t),"&token=").concat(encodeURIComponent(n.token)),[4,this.config.openURIWithCallback(s)];case 4:return a=o.sent(),this.saveCaptchaToken(a),[2,a.captcha_token]}}))}))},e.prototype.appendCaptchaTokenToURL=function(e,t,r){return n(this,void 0,Promise,(function(){var n;return o(this,(function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(r,t)];case 1:return n=o.sent(),e.indexOf("?")>0?e+="&captcha_token=".concat(n):e+="?captcha_token=".concat(n),[2,e]}}))}))},e.prototype.saveCaptchaToken=function(e){return n(this,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return e.expires_at=new Date(Date.now()+1e3*(e.expires_in-10)),t=JSON.stringify(e),[4,this.config.storage.setItem(this.tokenSectionName,t)];case 1:return r.sent(),[2]}}))}))},e.prototype.findCaptchaToken=function(){return n(this,void 0,Promise,(function(){var e,t;return o(this,(function(r){switch(r.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(e=r.sent()))return[3,5];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),t.expires_at<new Date?[2,null]:[2,t.captcha_token];case 3:return r.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),[2,null];case 5:return[2,null]}}))}))},e}();t.Captcha=c},6722: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.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseOAuth=t.AUTH_STATE_CHANGED_TYPE=t.EVENTS=t.LOGIN_STATE_CHANGED_TYPE=t.DEFAULT_NODE_ACCESS_SCOPE=t.OAUTH_TYPE=t.AUTH_API_PREFIX=t.weAppJwtDecodeAll=t.authModels=t.AuthErrorCategory=t.AuthError=t.Auth=void 0;var a=r(5257),u=r(5413),c=r(4949),l=r(5413);Object.defineProperty(t,"Auth",{enumerable:!0,get:function(){return l.Auth}});var d=r(8308);Object.defineProperty(t,"AuthError",{enumerable:!0,get:function(){return d.AuthError}}),Object.defineProperty(t,"AuthErrorCategory",{enumerable:!0,get:function(){return d.AuthErrorCategory}}),t.authModels=s(r(3538));var h=r(2344);Object.defineProperty(t,"weAppJwtDecodeAll",{enumerable:!0,get:function(){return h.weAppJwtDecodeAll}});var f=r(4949);Object.defineProperty(t,"AUTH_API_PREFIX",{enumerable:!0,get:function(){return f.AUTH_API_PREFIX}}),Object.defineProperty(t,"OAUTH_TYPE",{enumerable:!0,get:function(){return f.OAUTH_TYPE}}),Object.defineProperty(t,"DEFAULT_NODE_ACCESS_SCOPE",{enumerable:!0,get:function(){return f.DEFAULT_NODE_ACCESS_SCOPE}}),Object.defineProperty(t,"LOGIN_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.LOGIN_STATE_CHANGED_TYPE}}),Object.defineProperty(t,"EVENTS",{enumerable:!0,get:function(){return f.EVENTS}}),Object.defineProperty(t,"AUTH_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.AUTH_STATE_CHANGED_TYPE}});var p=function(){function e(e){var t=e.apiOrigin,r=e.apiPath,o=void 0===r?c.AUTH_API_PREFIX:r,i=e.clientId,s=e.env,l=e.storage,d=e.request,h=e.baseRequest,f=e.anonymousSignInFunc,p=e.wxCloud,v=e.adapter,y=e.onCredentialsError,m=e.headers,g=e.i18n,b=e.useWxCloud,_=e.eventBus,w=e.detectSessionInUrl,E=e.debug;if(this.detectSessionInUrl=null!=w&&w,this.oauth2client=new a.OAuth2Client({apiOrigin:t,apiPath:o,clientId:i,env:s,storage:l,baseRequest:h||d,anonymousSignInFunc:f,wxCloud:p,onCredentialsError:y,headers:m||{},i18n:g,useWxCloud:b,eventBus:_,debug:E}),this.authApi=new u.Auth(n(n({credentialsClient:this.oauth2client},e),{request:d?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:v})),w)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var I=new URL(window.location.href),S=I.searchParams.get("code"),O=I.searchParams.get("state"),A=JSON.parse(sessionStorage.getItem(O)||"null");S&&O&&(null==A?void 0:A.hash)&&(I.hash=A.hash,window.history.replaceState(null,"",I.toString()),window.location.replace(I.toString()))}catch(e){}}return e.prototype.initializeSession=function(e){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(e),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},e}();t.CloudbaseOAuth=p},6877:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Syntax=t.ErrorType=void 0;var n,o=r(4949);Object.defineProperty(t,"ErrorType",{enumerable:!0,get:function(){return o.ErrorType}}),(n=t.Syntax||(t.Syntax={})).CLIENT_ID="client_id",n.CLIENT_SECRET="client_secret",n.RESPONSE_TYPE="response_type",n.SCOPE="scope",n.STATE="state",n.REDIRECT_URI="redirect_uri",n.ERROR="error",n.ERROR_DESCRIPTION="error_description",n.ERROR_URI="error_uri",n.GRANT_TYPE="grant_type",n.CODE="code",n.ACCESS_TOKEN="access_token",n.TOKEN_TYPE="token_type",n.EXPIRES_IN="expires_in",n.USERNAME="username",n.PASSWORD="password",n.REFRESH_TOKEN="refresh_token"},5257: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.OAuth2Client=t.defaultStorage=t.generateRequestId=t.toResponseError=t.defaultRequest=void 0;var a=r(6877),u=r(4949),c=r(873),l=r(2631),d=r(8547),h=r(2344),f=r(7425),p=r(2877),v="x-request-id",y="x-device-id",m="device_id";function g(){return(0,c.uuidv4)()}t.defaultRequest=function(e,t){return o(this,void 0,Promise,(function(){var r,n,o,s,u;return i(this,(function(i){switch(i.label){case 0:r=null,n=null,i.label=1;case 1:return i.trys.push([1,4,,5]),(o=Object.assign({},t)).method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)),[4,fetch(e,o)];case 2:return[4,i.sent().json()];case 3:return(null==(s=i.sent())?void 0:s.error)?(n=s).error_uri=new URL(e).pathname:r=s,[3,5];case 4:return u=i.sent(),n={error:a.ErrorType.UNREACHABLE,error_description:u.message,error_uri:new URL(e).pathname},[3,5];case 5:if(n)throw n;return[2,r]}}))}))},t.toResponseError=function(e,t){var r,n=t||{};if(e instanceof Error)r={error:n.error||a.ErrorType.LOCAL,error_description:n.error_description||e.message,error_uri:n.error_uri,details:n.details||e.stack};else{var o=e||{};r={error:n.error||o.error||a.ErrorType.LOCAL,error_description:n.error_description||o.error_description,error_uri:n.error_uri||o.error_uri,details:n.details||o.details}}return r},t.generateRequestId=g;var b=function(){function e(e){this._env=(null==e?void 0:e.env)||""}return e.prototype.getItem=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,window.localStorage.getItem("".concat(e).concat(this._env))]}))}))},e.prototype.removeItem=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return window.localStorage.removeItem("".concat(e).concat(this._env)),[2]}))}))},e.prototype.setItem=function(e,t){return o(this,void 0,Promise,(function(){return i(this,(function(r){return window.localStorage.setItem("".concat(e).concat(this._env),t),[2]}))}))},e.prototype.getItemSync=function(e){return window.localStorage.getItem("".concat(e).concat(this._env))},e.prototype.removeItemSync=function(e){window.localStorage.removeItem("".concat(e).concat(this._env))},e.prototype.setItemSync=function(e,t){window.localStorage.setItem("".concat(e).concat(this._env),t)},e}();function _(e){var t=!0;return(null==e?void 0:e.expires_at)&&(null==e?void 0:e.access_token)&&(t=e.expires_at<new Date),t}t.defaultStorage=new b;var w=function(){function e(e){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=e.tokenSectionName,this.storage=e.storage,this.clientId=e.clientId,this.singlePromise=new d.SinglePromise({clientId:this.clientId}),this.credentials=e.credentials||null}return e.prototype.getStorageCredentialsSync=function(){var e=null,t=this.storage.getItemSync(this.tokenSectionName);if(null!=t)try{(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at))}catch(t){this.storage.removeItem(this.tokenSectionName),e=null}return e},e.prototype.setCredentials=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(r){switch(r.label){case 0:return(null==e?void 0:e.expires_in)?((null==e?void 0:e.expires_at)||(e.expires_at=new Date(Date.now()+1e3*(e.expires_in-30))),this.storage?(t=JSON.stringify(e),[4,this.storage.setItem(this.tokenSectionName,t)]):[3,2]):[3,3];case 1:r.sent(),r.label=2;case 2:return this.credentials=e,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:r.sent(),r.label=5;case 5:this.credentials=null,r.label=6;case 6:return[2]}}))}))},e.prototype.setAccessKeyCredentials=function(e){this.accessKeyCredentials=e,e.scope===u.DEFAULT_NODE_ACCESS_SCOPE&&(this.credentials=e)},e.prototype.getCredentials=function(){return o(this,void 0,Promise,(function(){var e=this;return i(this,(function(t){return[2,this.singlePromise.run("getCredentials",(function(){return o(e,void 0,void 0,(function(){var e,t;return i(this,(function(r){switch(r.label){case 0:return _(this.credentials)?[4,this.getStorageCredentials()]:[3,2];case 1:if(e=r.sent(),t=e.credentials,e.isAccessKeyCredentials)return[2,t];this.credentials=t,r.label=2;case 2:return[2,this.credentials]}}))}))}))]}))}))},e.prototype.getStorageCredentials=function(){return o(this,void 0,Promise,(function(){var e=this;return i(this,(function(t){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return o(e,void 0,void 0,(function(){var e,t,r;return i(this,(function(n){switch(n.label){case 0:return e=null,t=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(r=n.sent()))return[3,6];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(r))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),[3,5];case 3:return n.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),e=null,[3,5];case 5:return[3,7];case 6:e=this.accessKeyCredentials||null,t=!0,n.label=7;case 7:return[2,{credentials:e,isAccessKeyCredentials:t}]}}))}))}))]}))}))},e}();t.OAuth2Client=function(){function e(r){var n,o=this;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,r.clientSecret||(r.clientSecret=""),!r.clientId&&r.env&&(r.clientId=r.env),this.apiOrigin=r.apiOrigin,this.apiPath=r.apiPath||u.AUTH_API_PREFIX,this.clientId=r.clientId,this.i18n=r.i18n,this.eventBus=r.eventBus,this.singlePromise=new d.SinglePromise({clientId:this.clientId}),this.retry=this.formatRetry(r.retry,e.defaultRetry),r.baseRequest?this.baseRequest=r.baseRequest:this.baseRequest=t.defaultRequest,this.tokenInURL=r.tokenInURL,this.headers=r.headers,this.storage=r.storage||t.defaultStorage,this.localCredentials=new w({tokenSectionName:"credentials_".concat(r.clientId),storage:this.storage,clientId:r.clientId}),this.clientSecret=r.clientSecret,r.clientId&&(this.basicAuth="Basic ".concat((0,h.weBtoa)("".concat(r.clientId,":").concat(this.clientSecret)))),this.wxCloud=r.wxCloud;try{(0,f.isMp)()&&(this.useWxCloud=r.useWxCloud,void 0===this.wxCloud&&r.env&&(wx.cloud.init({env:r.env}),this.wxCloud=wx.cloud))}catch(e){}this.refreshTokenFunc=r.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=r.anonymousSignInFunc,this.onCredentialsError=r.onCredentialsError,this.getInitialSession=r.getInitialSession,this.onInitialSessionObtained=r.onInitialSessionObtained,this.logDebugMessages=null!==(n=r.debug)&&void 0!==n&&n,p.langEvent.bus.on(p.langEvent.LANG_CHANGE_EVENT,(function(e){var t;o.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||o.i18n}))}return e.prototype.setGetInitialSession=function(e){this.getInitialSession=e},e.prototype.setOnInitialSessionObtained=function(e){this.onInitialSessionObtained=e},e.prototype.initialize=function(e){return o(this,void 0,Promise,(function(){var t=this;return i(this,(function(r){switch(r.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,r.sent()];case 2:return void 0===e?[3,4]:(this.initializePromise=e,[4,this.initializePromise]);case 4:return this.initializePromise=o(t,void 0,void 0,(function(){var e=this;return i(this,(function(t){switch(t.label){case 0:return[4,this._acquireLock(-1,(function(){return o(e,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this._initialize()];case 1:return[2,e.sent()]}}))}))}))];case 1:return[2,t.sent()]}}))})),[4,this.initializePromise]}}))}))},e.prototype.setCredentials=function(e){return o(this,void 0,Promise,(function(){var t=this;return i(this,(function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,(function(){return o(t,void 0,void 0,(function(){return i(this,(function(t){return[2,this.localCredentials.setCredentials(e)]}))}))}))]}}))}))},e.prototype.setAccessKeyCredentials=function(e){return this.localCredentials.setAccessKeyCredentials(e)},e.prototype.getAccessToken=function(){return o(this,void 0,Promise,(function(){var e,t;return i(this,(function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[4,this.getCredentials()];case 2:return(null==(e=r.sent())?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE||(null==e?void 0:e.access_token)?[2,Promise.resolve(e.access_token)]:(t={error:a.ErrorType.UNAUTHENTICATED},[2,Promise.reject(t)])}}))}))},e.prototype.request=function(t,r){var s,u;return o(this,void 0,Promise,(function(){var o,c,l,d,h,f,p,m,b;return i(this,(function(i){switch(i.label){case 0:return r||(r={}),o=this.formatRetry(r.retry,this.retry),r.headers=n(n({},r.headers),((b={})[null===(s=this.i18n)||void 0===s?void 0:s.LANG_HEADER_KEY]=null===(u=this.i18n)||void 0===u?void 0:u.lang,b)),this.headers&&(r.headers=n(n({},this.headers),r.headers)),r.headers[v]||(r.headers[v]=g()),r.headers[y]?[3,2]:[4,this.getDeviceId()];case 1:c=i.sent(),r.headers[y]=c,i.label=2;case 2:return(null==r?void 0:r.withBasicAuth)&&this.basicAuth&&(r.headers.Authorization=this.basicAuth),(null==r?void 0:r.withCredentials)?r.getCredentials?[4,r.getCredentials()]:[3,4]:[3,7];case 3:return d=i.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:d=i.sent(),i.label=6;case 6:return(l=d)&&(this.tokenInURL?(t.indexOf("?")<0&&(t+="?"),t+="access_token=".concat(l.access_token)):r.headers.Authorization="".concat(l.token_type," ").concat(l.access_token)),[3,8];case 7:this.clientId&&t.indexOf("client_id")<0&&(t+=t.indexOf("?")<0?"?":"&",t+="client_id=".concat(this.clientId)),i.label=8;case 8:t.startsWith("/")&&(t="".concat(this.apiOrigin).concat(this.apiPath).concat(t)),h=null,f=o+1,p=0,i.label=9;case 9:if(!(p<f))return[3,21];i.label=10;case 10:return i.trys.push([10,15,,18]),r.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(t,r)]:[3,12];case 11:return h=i.sent(),[3,14];case 12:return[4,this.baseRequest(t,r)];case 13:h=i.sent(),i.label=14;case 14:if(null==h?void 0:h.code)throw{error:h.code,error_description:h.message,error_uri:new URL(t).pathname};return[3,21];case 15:m=i.sent();try{m.requestId=m.requestId||r.headers[v]||""}catch(e){}return r.withCredentials&&m&&m.error===a.ErrorType.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return i.sent(),[2,Promise.reject(m)];case 17:return p!==o&&m&&"unreachable"===m.error?[3,18]:[2,Promise.reject(m)];case 18:return[4,this.sleep(e.retryInterval)];case 19:i.sent(),i.label=20;case 20:return p++,[3,9];case 21:return[2,h]}}))}))},e.prototype.wxCloudCallFunction=function(e,t){var r;return o(this,void 0,Promise,(function(){var o,s,u,c,d;return i(this,(function(i){switch(i.label){case 0:o=null,s=null,i.label=1;case 1:i.trys.push([1,7,,8]),u="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return u=i.sent(),[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:e,method:t.method,headers:n({origin:"https://servicewechat.com","User-Agent":u},t.headers),body:t.body}})];case 6:return c=i.sent().result,(null===(r=null==c?void 0:c.body)||void 0===r?void 0:r.error_code)?(s=null==c?void 0:c.body).error_uri=(0,l.getPathName)(e):o=null==c?void 0:c.body,[3,8];case 7:return d=i.sent(),s={error:a.ErrorType.UNREACHABLE,error_description:d.message,error_uri:(0,l.getPathName)(e)},[3,8];case 8:if(s)throw s;return[2,o]}}))}))},e.prototype.getCredentials=function(){return o(this,void 0,Promise,(function(){var e=this;return i(this,(function(t){switch(t.label){case 0:return[4,this.initializePromise];case 1:return t.sent(),[2,this._acquireLock(-1,(function(){return o(e,void 0,void 0,(function(){return i(this,(function(e){return[2,this._getCredentials()]}))}))}))]}}))}))},e.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},e.prototype.getCredentialsAsync=function(){return this.getCredentials()},e.prototype.getScope=function(){var e;return o(this,void 0,Promise,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.scope]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}}))}))},e.prototype.getGroups=function(){var e;return o(this,void 0,Promise,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(t=n.sent())?[2,t.groups]:(r="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:r}),[2,this.unAuthenticatedError(r)])}}))}))},e.prototype.refreshToken=function(e,t){return o(this,void 0,Promise,(function(){var r=this;return i(this,(function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,(function(){return o(r,void 0,void 0,(function(){return i(this,(function(r){return[2,this._refreshToken(e,t)]}))}))}))]}}))}))},e.prototype._refreshToken=function(e,t){return o(this,void 0,Promise,(function(){var r=this;return i(this,(function(n){return[2,this.singlePromise.run("_refreshToken",(function(){return o(r,void 0,void 0,(function(){var r,n,o,s,c,l,d;return i(this,(function(i){switch(i.label){case 0:if((null==e?void 0:e.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,e];if(!e||!e.refresh_token)return o="no refresh token found in credentials",null===(s=this.onCredentialsError)||void 0===s||s.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];i.label=1;case 1:return i.trys.push([1,4,,7]),[4,this.refreshTokenFunc(e.refresh_token,e)];case 2:return r=i.sent(),[4,this.localCredentials.setCredentials(r)];case 3:return i.sent(),null===(c=this.eventBus)||void 0===c||c.fire(u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED}),[2,r];case 4:if(n=i.sent(),null==t?void 0:t.throwError)throw n;return n.error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return i.sent(),o=n.error_description,null===(l=this.onCredentialsError)||void 0===l||l.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];case 6:return null===(d=this.onCredentialsError)||void 0===d||d.call(this,{msg:n.error_description}),[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},e.prototype.anonymousLogin=function(e){return o(this,void 0,void 0,(function(){var t=this;return i(this,(function(r){return[2,this.singlePromise.run("_anonymousLogin",(function(){return o(t,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(e)]:[3,4];case 1:return t=n.sent(),(r=t)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:r=n.sent(),n.label=3;case 3:return e=r,[3,6];case 4:return[4,this.anonymousSignIn(e)];case 5:e=n.sent(),n.label=6;case 6:return[2,e]}}))}))}))]}))}))},e.prototype.checkRetry=function(t){var r=null;if(("number"!=typeof t||t<e.minRetry||t>e.maxRetry)&&(r={error:a.ErrorType.UNREACHABLE,error_description:"wrong options param: retry"}),r)throw r;return t},e.prototype.formatRetry=function(e,t){return void 0===e?t:this.checkRetry(e)},e.prototype.sleep=function(e){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,new Promise((function(t){setTimeout((function(){t()}),e)}))]}))}))},e.prototype.anonymousSignIn=function(e){return o(this,void 0,Promise,(function(){var t=this;return i(this,(function(r){return[2,this.singlePromise.run("_anonymous",(function(){return o(t,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:if(!e||"anonymous"!==e.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];n.label=1;case 1:return n.trys.push([1,4,,7]),[4,this.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return t=n.sent(),[4,this.localCredentials.setCredentials(t)];case 3:return n.sent(),[2,t];case 4:return(r=n.sent()).error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return n.sent(),[2,this.unAuthenticatedError(r.error_description)];case 6:return[2,Promise.reject(r)];case 7:return[2]}}))}))}))]}))}))},e.prototype.defaultRefreshTokenFunc=function(e,t){var r;return o(this,void 0,Promise,(function(){var o,s,a;return i(this,(function(i){switch(i.label){case 0:return void 0===e||""===e?(o="refresh token not found",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:o}),[2,this.unAuthenticatedError(o)]):(s=u.ApiUrls.AUTH_TOKEN_URL,"v2"===(null==t?void 0:t.version)&&(s=u.ApiUrlsV2.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:e}})]);case 1:return a=i.sent(),[2,n(n({},a),{version:(null==t?void 0:t.version)||"v1"})]}}))}))},e.prototype.getDeviceId=function(){return o(this,void 0,Promise,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(m)];case 1:return"string"==typeof(e=t.sent())&&e.length>=16&&e.length<=48?[3,3]:(e=(0,c.uuidv4)(),[4,this.storage.setItem(m,e)]);case 2:t.sent(),t.label=3;case 3:return this.deviceID=e,[2,e]}}))}))},e.prototype.unAuthenticatedError=function(e){var t={error:a.ErrorType.UNAUTHENTICATED,error_description:e};return Promise.reject(t)},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logDebugMessages&&console.log.apply(console,s(["[OAuth2Client]"],e,!1))},e.prototype._initialize=function(){return o(this,void 0,Promise,(function(){var e,t,r,n,o,s;return i(this,(function(i){switch(i.label){case 0:if(i.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),i.label=1;case 1:return i.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return s=i.sent(),e=s.data,t=s.error,(null==e?void 0:e.session)?(this._debug("#_initialize()","session obtained from getInitialSession",e.session),[4,this.localCredentials.setCredentials(null==e?void 0:e.session)]):[3,4];case 3:i.sent(),i.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),i.label=5;case 5:return i.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(e,t)];case 6:return i.sent(),[3,8];case 7:return r=i.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",r),[3,8];case 8:return t?(this._debug("#_initialize()","error from getInitialSession",t),[2,{error:t}]):[2,{error:null}];case 9:return n=i.sent(),this._debug("#_initialize()","exception during getInitialSession",n),[2,{error:n instanceof Error?n:new Error(String(n))}];case 10:return[3,13];case 11:return o=i.sent(),this._debug("#_initialize()","unexpected error",o),[2,{error:o instanceof Error?o:new Error(String(o))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}}))}))},e.prototype._acquireLock=function(e,t){return o(this,void 0,Promise,(function(){var r,n,a,u,c=this;return i(this,(function(l){switch(l.label){case 0:this._debug("#_acquireLock","begin",e),l.label=1;case 1:if(l.trys.push([1,,10,11]),this.lockAcquired)return r=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),n=o(c,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,r];case 1:return e.sent(),[4,t()];case 2:return[2,e.sent()]}}))})),this.pendingInLock.push(o(c,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,n];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}}))}))),[2,n];this._debug("#_acquireLock","acquiring lock for client",this.clientId),l.label=2;case 2:return l.trys.push([2,,8,9]),this.lockAcquired=!0,a=t(),this.pendingInLock.push(o(c,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,a];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}}))}))),[4,a];case 3:l.sent(),l.label=4;case 4:return this.pendingInLock.length?(u=s([],this.pendingInLock,!0),[4,Promise.all(u)]):[3,6];case 5:return l.sent(),this.pendingInLock.splice(0,u.length),[3,4];case 6:return[4,a];case 7:return[2,l.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}}))}))},e.prototype._getCredentials=function(){var e,t,r;return o(this,void 0,Promise,(function(){var n,o,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(n=i.sent())?void 0:n.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,n];if(!n)return s="credentials not found",null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];if(!_(n))return[3,12];if(!n.refresh_token)return[3,9];i.label=2;case 2:return i.trys.push([2,4,,8]),[4,this._refreshToken(n)];case 3:return n=i.sent(),[3,8];case 4:return o=i.sent(),"anonymous"!==n.scope?[3,6]:[4,this.anonymousLogin(n)];case 5:return n=i.sent(),[3,7];case 6:return null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:o.error_description}),[2,Promise.reject(o)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==n.scope?[3,11]:[4,this.anonymousLogin(n)];case 10:return n=i.sent(),[3,12];case 11:return s="no refresh token found in credentials",null===(r=this.onCredentialsError)||void 0===r||r.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];case 12:return[2,n]}}))}))},e.defaultRetry=2,e.minRetry=0,e.maxRetry=5,e.retryInterval=1e3,e}()},2344:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.weAppJwtDecodeAll=t.weappJwtDecode=t.base64_url_decode=t.weAtob=t.weBtoa=void 0;var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function o(e){var r=e.replace(/-/g,"+").replace(/_/g,"/");switch(r.length%4){case 0:break;case 2:r+="==";break;case 3:r+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(e){return decodeURIComponent((0,t.weAtob)(e).replace(/(.)/g,(function(e){var t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0".concat(t)),"%".concat(t)})))}(r)}catch(e){return(0,t.weAtob)(r)}}t.weBtoa=function(e){for(var t,n,o,i,s="",a=0,u=(e=String(e)).length%3;a<e.length;){if((n=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=r.charAt((t=n<<16|o<<8|i)>>18&63)+r.charAt(t>>12&63)+r.charAt(t>>6&63)+r.charAt(63&t)}return u?s.slice(0,u-3)+"===".substring(u):s},t.weAtob=function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!n.test(e))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var o,i,s="",a=0;a<e.length;)t=r.indexOf(e.charAt(a++))<<18|r.indexOf(e.charAt(a++))<<12|(o=r.indexOf(e.charAt(a++)))<<6|(i=r.indexOf(e.charAt(a++))),s+=64===o?String.fromCharCode(t>>16&255):64===i?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return s},t.base64_url_decode=o,t.weappJwtDecode=function(e,t){if("string"!=typeof e)throw new Error("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(o(e.split(".")[r]))}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}},t.weAppJwtDecodeAll=function(e){if("string"!=typeof e)throw new Error("Invalid token specified");try{var t=e.split(".").map((function(e,t){return 2===t?e:JSON.parse(o(e))}));return{claims:t[1],header:t[0],signature:t[2]}}catch(e){throw new Error("Invalid token specified: ".concat(e)?e.message:0)}}},5814:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getEncryptInfo=void 0;var o=n(r(1012)),i=r(2631);t.getEncryptInfo=function(e){var t=void 0===e?{}:e,r=t.publicKey,n=void 0===r?"":r,s=t.payload,a=void 0===s?{}:s;if(!n)return"";try{var u=(0,i.deepClone)(a),c=new o.default;return c.setPublicKey(n),c.encryptLong("object"==typeof u?JSON.stringify(u):u)}catch(e){console.error("encrypt error:",e)}return""}},8547:function(e,t){"use strict";var r=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},n=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.SinglePromise=void 0;var o=new Map,i=function(){function e(e){this.clientId=(null==e?void 0:e.clientId)||"",o=o||new Map}return e.prototype.run=function(e,t){return r(this,void 0,Promise,(function(){var i,s=this;return n(this,(function(a){return e="".concat(this.clientId,"_").concat(e),(i=o.get(e))||(i=new Promise((function(i,a){r(s,void 0,void 0,(function(){var r,s,u;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return n.sent(),r=t(),s=i,[4,r];case 2:return s.apply(void 0,[n.sent()]),[3,5];case 3:return u=n.sent(),a(u),[3,5];case 4:return o.delete(e),[7];case 5:return[2]}}))}))})),o.set(e,i)),[2,i]}))}))},e.prototype.runIdlePromise=function(){return Promise.resolve()},e}();t.SinglePromise=i},2631:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getPathName=t.deepClone=void 0,t.deepClone=function(e){var r=function(r){for(var n in e)e.hasOwnProperty(n)&&(r[n]=(0,t.deepClone)(e[n]));return r},n=null==e?"NullOrUndefined":Object.prototype.toString.call(e).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(n))return e.slice();switch(n){case"Object":return r(Object.create(Object.getPrototypeOf(e)));case"Array":return r([]);case"Date":return new Date(e.valueOf());case"RegExp":return new RegExp(e.source,(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":""));default:return e}},t.getPathName=function(e){var t=e.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return t&&t[2]||""}},7425:function(e,t){"use strict";function r(){if("undefined"==typeof globalThis)return!1;var e=globalThis.wx;if(void 0===e)return!1;if(void 0===globalThis.Page)return!1;if(!e.getDeviceInfo)return!1;if(!e.getStorageSync)return!1;if(!e.setStorageSync)return!1;if(!e.connectSocket)return!1;if(!e.request)return!1;try{if(!e.getDeviceInfo())return!1;if("qq"===e.getDeviceInfo().platform)return!1}catch(e){return!1}return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.isInMpWebView=t.isMp=void 0,t.isMp=r;var n=!1;function o(){n=n||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{r()||(n=n||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?o():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",o,!1))}catch(e){}t.isInMpWebView=function(){return n}},9639:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){if(this.params={},"string"==typeof e)this.parse(e);else if(e&&"object"==typeof e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&this.append(t,e[t])}return e.prototype.parse=function(e){var t=this;e.split("&").forEach((function(e){var r=e.split("=").map(decodeURIComponent),n=r[0],o=r[1];t.append(n,o)}))},e.prototype.append=function(e,t){this.params[e]?this.params[e]=this.params[e].concat([t]):this.params[e]=[t]},e.prototype.get=function(e){return this.params[e]?this.params[e][0]:null},e.prototype.getAll=function(e){return this.params[e]||[]},e.prototype.delete=function(e){delete this.params[e]},e.prototype.has=function(e){return Object.prototype.hasOwnProperty.call(this.params,e)},e.prototype.set=function(e,t){this.params[e]=[t]},e.prototype.toString=function(){var e=[],t=function(t){Object.prototype.hasOwnProperty.call(r.params,t)&&r.params[t].forEach((function(r){e.push("".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(r)))}))},r=this;for(var n in this.params)t(n);return e.join("&")},e}();t.default=r},873:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=void 0,t.uuidv4=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}},6511:function(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:function(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:function(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:function(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:function(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:function(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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},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,u=s(r(6765)),c=s(r(7195)),l=s(r(9850)),d=r(3994),h=r(1601),f=r(9770),p=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 y=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,u,c,l,h,p,v,y;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(),u=s.msgData,c=u.events,l=u.currEvent,this.sessionInfo={queryID:s.msgData.queryID,currentEventId:l-1,currentDocs:[]},c.length>0){for(h=0,p=c;h<p.length;h++)p[h].ID=l;this.handleServerEvents(s)}else this.sessionInfo.currentEventId=l,v=new f.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 y=o.sent(),this.handleWatchEstablishmentError(y,{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,u;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 u=o.sent(),this.handleWatchEstablishmentError(u,{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,u=this;return o(this,(function(c){return t="INIT_WATCH"===r.operationName,i=function(){u.closeWithError(new p.CloudSDKError({errCode:t?p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:e})),r.reject(e)},s=function(e){u.useRetryTicket(r.operationName)?t?(u.initWatchPromise=void 0,r.resolve(u.initWatch(e))):(u.rebuildWatchPromise=void 0,r.resolve(u.rebuildWatch(e))):i()},this.handleCommonError(e,{onSignError:function(){return s(!0)},onTimeoutError:function(){return s(!1)},onNotRetryableError:i,onCancelledError:r.reject,onUnknownError:function(){n(u,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 p.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 p.CloudSDKError({errCode:p.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,p.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 p.CloudSDKError({errCode:p.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 p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:t})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(e,t){if((0,p.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,p.isTimeoutError)(e))return void t.onTimeoutError(e);if((0,p.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 p.CloudSDKError({errCode:p.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,y,g,b,_;return o(this,(function(w){switch(w.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(m)}catch(e){return this.closeWithError(new p.CloudSDKError({errCode:p.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 m,g,b,_,w,E,I,S,O,A,T,P;return o(this,(function(o){switch(o.label){case 0:return m=a[r],s.currentEventId>=m.id?(!a[r-1]||m.id>a[r-1].id?console.warn("[realtime] duplicate event received, cur ".concat(s.currentEventId," but got ").concat(m.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!==m.id-1)return[3,2];switch(m.dataType){case"update":if(!m.doc)switch(m.queueType){case"update":case"dequeue":if(g=d.find((function(e){return e._id===m.docId})),g){if(b=(0,l.default)(g),m.updatedFields&&Object.keys(m.updatedFields).forEach((function(e){(0,u.default)(b,e,m.updatedFields[e])})),m.removedFields)for(_=0,w=m.removedFields;_<w.length;_++)E=w[_],(0,c.default)(b,E);m.doc=b}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 p.CloudSDKError({errCode:p.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,")")}),y.closeWithError(S),S}break;case"replace":if(!m.doc)throw S=new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '.concat(e.requestId,")")}),y.closeWithError(S),S;break;case"remove":(I=d.find((function(e){return e._id===m.docId})))?m.doc=I:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!m.doc)switch(m.queueType){case"dequeue":(I=d.find((function(e){return e._id===m.docId})))?m.doc=I:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw S=new p.CloudSDKError({errCode:p.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,")")}),y.closeWithError(S),S}}switch(m.queueType){case"init":h?d.push(m.doc):(h=!0,d=[m.doc]);break;case"enqueue":d.push(m.doc);break;case"dequeue":O=d.findIndex((function(e){return e._id===m.docId})),O>-1?d.splice(O,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":O=d.findIndex((function(e){return e._id===m.docId})),O>-1?d[O]=m.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!==m.id)&&(A=i([],d,!0),T=a.slice(0,r+1).filter((function(e){return e.id===m.id})),y.sessionInfo.currentEventId=m.id,y.sessionInfo.currentDocs=d,P=new f.Snapshot({id:m.id,docChanges:T,docs:A,msgType:n}),y.listener.onChange(P)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(y.sessionInfo.currentEventId," but got ").concat(m.id)),[4,y.rebuildWatch()];case 3:return o.sent(),[2,{value:void 0}];case 4:return[2]}}))},y=this,g=0,b=a.length,w.label=1;case 1:return g<b?[5,v(g,b)]:[3,4];case 2:if("object"==typeof(_=w.sent()))return[2,_.value];w.label=3;case 3:return g++,[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 m(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=y},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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.RealtimeWebSocketClient=void 0;var s=r(4151),a=r(3994),u=r(636),c=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,u,l,h,f,p,v=this;return i(this,(function(y){switch(y.label){case 0:s=!1,a=!1,u=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 c.TimeoutError("wsclient.send timedout")),e.label=2;case 2:return[2]}}))}))}),e.timeout)),y.label=1;case 1:return y.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:y.sent(),y.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:u,reject:l,skipOnMessage:e.skipOnMessage},this.wsResponseWait.set(e.msg.requestId,h)),y.label=4;case 4:return y.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(e.msg))];case 5:return y.sent(),e.waitResponse||u(void 0),[3,7];case 6:return(f=y.sent())&&(l(f),e.waitResponse&&this.wsResponseWait.delete(e.msg.requestId)),[3,7];case 7:return[3,9];case 8:return p=y.sent(),l(p),[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(u.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 c.CloudSDKError({errCode:c.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 c.CloudSDKError({errCode:c.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 u.CloseEventCode.ReconnectWebSocket:case u.CloseEventCode.NoRealtimeListeners:break;case u.CloseEventCode.HeartbeatPingError:case u.CloseEventCode.HeartbeatPongTimeoutError:case u.CloseEventCode.NormalClosure:case u.CloseEventCode.AbnormalClosure:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients((0,u.getWSCloseError)(e.code));break;case u.CloseEventCode.NoAuthentication:t.closeAllClients((0,u.getWSCloseError)(e.code,e.reason));break;default:t.maxReconnect>0?t.initWebSocketConnection(!0,t.maxReconnect):t.closeAllClients((0,u.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 c.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 u=0,l=Array.from(t.watchIdClientMap.entries());u<l.length;u++){l[u][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,u,c,d,h,f,p=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(p,void 0,void 0,(function(){var r,n,o,s,u;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 u=i.sent(),t(u),[3,4];case 4:return[2]}}))}))})),u=e&&this.logins.get(e),c=Date.now(),u?(u.loggedIn=!1,u.loggingInPromise=s,u.loginStartTS=c):(u={loggedIn:!1,loggingInPromise:s,loginStartTS:c},this.logins.set(e||"",u)),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===u&&h.loginStartTS===c)return u.loggedIn=!0,u.loggingInPromise=void 0,u.loginStartTS=void 0,u.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 f=v.sent(),u.loggedIn=!1,u.loggingInPromise=void 0,u.loginStartTS=void 0,u.loginResult=void 0,f;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(u.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,u.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(u.CloseEventCode.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),e?0:this.context.appConfig.realtimePingInterval)},e}();t.RealtimeWebSocketClient=h},636:function(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})}},3456:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,s=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},u=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.registerStorage=t.SupabaseFileAPILikeStorage=t.CloudbaseStorage=t.COMPONENT_NAME=void 0;var l,d=r(7957),h=r(2877),f=r(3388);!function(e){e.put="put",e.post="post"}(l||(l={}));var p=h.constants.getSdkName,v=h.constants.ERRORS,y=h.constants.COMMUNITY_SITE_URL,m=h.utils.isArray,g=h.utils.isString,b=h.utils.isPalinObject,_=h.utils.execCallback,w=h.helpers.catchErrorsDecorator;t.COMPONENT_NAME="storage";var E=function(e,t,r){return u(void 0,void 0,void 0,(function(){var n,o,s;return c(this,(function(a){switch(a.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-upload-info",data:[i({objectId:t.path},t.headers?{signedHeader:Object.keys(t.headers).reduce((function(e,r){var n;return i(i({},e),((n={})[r]=[t.headers[r]],n))}),{})}:{})]},r)];case 1:return n=a.sent(),o=(null===(s=n.data)||void 0===s?void 0:s[0])||{},[2,n=i(i({},n),{data:i(i({},o.code?i({},o):{}),{authorization:o.authorization,token:o.token,url:o.uploadUrl,fileId:o.cloudObjectId,cosFileId:o.cloudObjectMeta,download_url:o.downloadUrl})})]}}))}))},I=function(e,t,r){return u(void 0,void 0,void 0,(function(){var n,o;return c(this,(function(s){switch(s.label){case 0:return[4,e.gateWay({path:"storages",name:"get-objects-download-info",data:t.convertedFileList.map((function(e){return{cloudObjectId:e.fileid}}))},r)];case 1:return n=s.sent(),[2,n=i(i({},n),{data:{download_list:null===(o=n.data)||void 0===o?void 0:o.map((function(e){return{code:e.code||"SUCCESS",message:e.message,fileid:e.cloudObjectId,download_url:e.downloadUrl,fileID:e.cloudObjectId,tempFileURL:e.downloadUrl}}))}})]}}))}))},S=function(e,t,r){return u(void 0,void 0,void 0,(function(){var n,o;return c(this,(function(s){switch(s.label){case 0:return[4,e.gateWay({path:"storages",name:"delete-objects",data:t.fileList.map((function(e){return{cloudObjectId:e}}))},r)];case 1:return n=s.sent(),[2,n=i(i({},n),{data:{delete_list:null===(o=n.data)||void 0===o?void 0:o.map((function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,message:e.message}}))}})]}}))}))},O=function(e,t,r){return u(void 0,void 0,void 0,(function(){var n,o;return c(this,(function(s){switch(s.label){case 0:return[4,e.gateWay({path:"storages",name:"copy-objects",data:t.convertedFileList.map((function(e){return{srcPath:e.src_path,dstPath:e.dst_path,overwrite:e.overwrite,removeOriginal:e.remove_original}}))},r)];case 1:return n=s.sent(),[2,n=i(i({},n),{data:{copy_list:null===(o=n.data)||void 0===o?void 0:o.map((function(e){return{code:e.code||"SUCCESS",fileID:e.cloudObjectId,message:e.message}}))}})]}}))}))},A=t.CloudbaseStorage=function(){function e(){}var r,n,o,d,h,A,T,P,R,C,N,D,U,x,L,j;return e.prototype.isGateWay=function(){return"GATEWAY"===(this.config.endPointMode||"CLOUD_API")},e.prototype.uploadFile=function(e,r){return u(this,void 0,Promise,(function(){var n,o,s,a,u,d,h,f,y,m,b,w,E,I,S,O,A,T,P,R,C,N,D,U;return c(this,(function(c){switch(c.label){case 0:if(n=e.cloudPath,o=e.filePath,s=e.onUploadProgress,N=e.method,a=void 0===N?"put":N,D=e.headers,u=void 0===D?{}:D,d=e.fileContent,!g(n)||!o&&!d)throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".uploadFile] invalid params")}));return h={put:l.put,post:l.post}[a.toLocaleLowerCase()]||l.put,[4,this.getUploadMetadata({cloudPath:n,method:h,headers:h===l.put?u:void 0,customReqOpts:e.customReqOpts})];case 1:return f=c.sent(),y=f.data,m=f.requestId,b=y.url,w=y.authorization,E=y.token,I=y.fileId,S=y.cosFileId,O=y.download_url,T=i(i({},A={url:b,file:o,name:n,onUploadProgress:s,fileContent:d,fileId:I,requestId:m}),{method:l.put,headers:i(i({},u),{authorization:w,"x-cos-meta-fileid":S,"x-cos-security-token":E})}),P=i(i({},A),{method:l.post,data:{key:n,signature:w,"x-cos-meta-fileid":S,success_action_status:"201","x-cos-security-token":E}}),(U={})[l.put]={params:T,isSuccess:function(e){return e>=200&&e<300}},U[l.post]={params:P,isSuccess:function(e){return 201===e}},R=U,[4,this.request.upload(R[h].params)];case 2:return C=c.sent(),R[h].isSuccess(C.statusCode)?[2,_(r,null,{fileID:I,download_url:O,requestId:m})]:[2,_(r,new Error("[".concat(p(),"][").concat(v.OPERATION_FAIL,"][").concat(t.COMPONENT_NAME,"]:").concat(C.data)))]}}))}))},e.prototype.getUploadMetadata=function(e,r){return u(this,void 0,Promise,(function(){var n,o,i,s,a,u,d,h;return c(this,(function(c){switch(c.label){case 0:if(n=e.cloudPath,o=e.method,i=e.headers,!g(n))throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".getUploadMetadata] invalid cloudPath")}));s=this.request,a="storage.getUploadMetadata",c.label=1;case 1:return c.trys.push([1,6,,7]),u=void 0,d={path:n},o&&(d.method=o),o===l.put&&i&&(d.headers=i),this.isGateWay()?[4,E(s,d,e.customReqOpts)]:[3,3];case 2:return u=c.sent(),[3,5];case 3:return[4,s.send(a,d,e.customReqOpts)];case 4:u=c.sent(),c.label=5;case 5:return[2,_(r,null,u)];case 6:return h=c.sent(),[2,_(r,h)];case 7:return[2]}}))}))},e.prototype.deleteFile=function(e,r){return u(this,void 0,Promise,(function(){var n,o,i,s,a,u,l,d;return c(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!m(n)||0===n.length)throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".deleteFile] fileList must not be empty")}));for(o=0,i=n;o<i.length;o++)if(!(s=i[o])||!g(s))throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".deleteFile] fileID must be string")}));return a="storage.batchDeleteFile",u=this.request,l={},this.isGateWay()?[4,S(u,{fileList:n},e.customReqOpts)]:[3,2];case 1:return l=c.sent(),[3,4];case 2:return[4,u.send(a,{fileid_list:n},e.customReqOpts)];case 3:l=c.sent(),c.label=4;case 4:return l.code?[2,_(r,null,l)]:(d={fileList:l.data.delete_list,requestId:l.requestId},[2,_(r,null,d)])}}))}))},e.prototype.getTempFileURL=function(e,r){return u(this,void 0,Promise,(function(){var n,o,i,s,a,u,l,d;return c(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!m(n)||0===n.length)throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".getTempFileURL] fileList must not be empty")}));for(o=[],i=0,s=n;i<s.length;i++)if(a=s[i],b(a)){if(!Object.prototype.hasOwnProperty.call(a,"fileID"))throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".getTempFileURL] file info must include fileID")}));o.push({fileid:a.fileID,max_age:a.maxAge||7200})}else{if(!g(a))throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".getTempFileURL] invalid fileList")}));o.push({fileid:a})}return u="storage.batchGetDownloadUrl",l=this.request,d={},this.isGateWay()?[4,I(l,{convertedFileList:o},e.customReqOpts)]:[3,2];case 1:return d=c.sent(),[3,4];case 2:return[4,l.send(u,{file_list:o},e.customReqOpts)];case 3:d=c.sent(),c.label=4;case 4:return d.code?[2,_(r,null,d)]:[2,_(r,null,{fileList:d.data.download_list,requestId:d.requestId})]}}))}))},e.prototype.downloadFile=function(e,r){return u(this,void 0,Promise,(function(){var n,o,i,s,a,u;return c(this,(function(c){switch(c.label){case 0:if(n=e.fileID,!g(n))throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:n,maxAge:600}],customReqOpts:e.customReqOpts})];case 1:return o=c.sent(),"SUCCESS"!==(i=o.fileList[0]).code?[2,_(r,i)]:(s=this.request,a=encodeURI(i.download_url),[4,s.download({url:a,tempFilePath:e.tempFilePath})]);case 2:return u=c.sent(),[2,_(r,null,u)]}}))}))},e.prototype.copyFile=function(e,r){return u(this,void 0,Promise,(function(){var n,o,i,s,a,u,l,d,h;return c(this,(function(c){switch(c.label){case 0:if(!(n=e.fileList)||!m(n)||0===n.length)throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".copyFile] fileList must not be empty")}));for(o=[],i=0,s=n;i<s.length;i++){if(a=s[i],u=a.srcPath,l=a.dstPath,!u||!l||"string"!=typeof u||"string"!=typeof l)throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".copyFile] srcPath and dstPath may not be empty")}));if(u===l)throw new Error(JSON.stringify({code:v.INVALID_PARAMS,msg:"[".concat(t.COMPONENT_NAME,".copyFile] srcPath and dstPath can not be the same")}));o.push({src_path:u,dst_path:l,overwrite:a.overwrite,remove_original:a.removeOriginal})}return d=this.request,h={},this.isGateWay()?[4,O(d,{convertedFileList:o},e.customReqOpts)]:[3,2];case 1:return h=c.sent(),[3,4];case 2:return[4,d.send("storage.batchCopyFile",{file_list:o},e.customReqOpts)];case 3:h=c.sent(),c.label=4;case 4:return h.code?[2,_(r,null,h)]:[2,_(r,null,{fileList:h.data.copy_list,requestId:h.requestId})]}}))}))},e.prototype.getFileInfo=function(e){var t;return u(this,void 0,Promise,(function(){var r,n=this;return c(this,(function(o){switch(o.label){case 0:return[4,this.getTempFileURL(e)];case 1:return(null==(r=o.sent())?void 0:r.fileList)&&(null===(t=null==r?void 0:r.fileList)||void 0===t?void 0:t.length)>0?[4,Promise.all(r.fileList.map((function(e){return u(n,void 0,void 0,(function(){var t,r,n,o,i;return c(this,(function(s){switch(s.label){case 0:if("SUCCESS"!==e.code)return[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,message:e.message}];s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.request.fetch({url:e.tempFileURL,method:"HEAD"})];case 2:return t=s.sent(),r=t.header,Headers&&r instanceof Headers&&(r=Object.fromEntries(t.header.entries())),n=parseInt(r["content-length"])||0,o=r["content-type"]||"",[400,404].includes(Number(t.statusCode))?[2,{code:"FILE_NOT_FOUND",fileID:e.fileID,tempFileURL:e.tempFileURL,message:"file not found"}]:[2,{code:e.code,fileID:e.fileID,tempFileURL:e.tempFileURL,cloudId:e.fileID,fileName:e.fileID.split("/").pop(),contentType:o,mime:o.split(";")[0].trim(),size:n,etag:r.etag||"",lastModified:r["last-modified"]||"",cacheControl:r["cache-control"]||""}];case 3:return i=s.sent(),[2,{code:"FETCH_FILE_INFO_ERROR",fileID:e.fileID,tempFileURL:e.tempFileURL,message:i.message}];case 4:return[2]}}))}))})))]:[3,3];case 2:return[2,{fileList:o.sent(),requestId:r.requestId}];case 3:return[2,{fileList:[],requestId:r.requestId}]}}))}))},s([w({customInfo:{className:"Cloudbase",methodName:"uploadFile"},title:"上传文件失败",messages:["请确认以下各项:"," 1 - 调用 uploadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(y)]}),a("design:type",Function),a("design:paramtypes",[Object,"function"==typeof(r="undefined"!=typeof Function&&Function)?r:Object]),a("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],e.prototype,"uploadFile",null),s([w({customInfo:{className:"Cloudbase",methodName:"getUploadMetadata"},title:"获取上传元信息失败",messages:["请确认以下各项:"," 1 - 调用 getUploadMetadata() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(y)]}),a("design:type",Function),a("design:paramtypes",[Object,"function"==typeof(o="undefined"!=typeof Function&&Function)?o:Object]),a("design:returntype","function"==typeof(d="undefined"!=typeof Promise&&Promise)?d:Object)],e.prototype,"getUploadMetadata",null),s([w({customInfo:{className:"Cloudbase",methodName:"deleteFile"},title:"删除文件失败",messages:["请确认以下各项:"," 1 - 调用 deleteFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(y)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(h=void 0!==f.ICloudbaseDeleteFileParams&&f.ICloudbaseDeleteFileParams)?h:Object,"function"==typeof(A="undefined"!=typeof Function&&Function)?A:Object]),a("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],e.prototype,"deleteFile",null),s([w({customInfo:{className:"Cloudbase",methodName:"getTempFileURL"},title:"获取文件下载链接",messages:["请确认以下各项:"," 1 - 调用 getTempFileURL() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(y)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(P=void 0!==f.ICloudbaseGetTempFileURLParams&&f.ICloudbaseGetTempFileURLParams)?P:Object,"function"==typeof(R="undefined"!=typeof Function&&Function)?R:Object]),a("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],e.prototype,"getTempFileURL",null),s([w({customInfo:{className:"Cloudbase",methodName:"downloadFile"},title:"下载文件失败",messages:["请确认以下各项:"," 1 - 调用 downloadFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(y)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(N=void 0!==f.ICloudbaseDownloadFileParams&&f.ICloudbaseDownloadFileParams)?N:Object,"function"==typeof(D="undefined"!=typeof Function&&Function)?D:Object]),a("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],e.prototype,"downloadFile",null),s([w({customInfo:{className:"Cloudbase",methodName:"copyFile"},title:"批量复制文件",messages:["请确认以下各项:"," 1 - 调用 copyFile() 的语法或参数是否正确"," 2 - 当前域名是否在安全域名列表中:https://console.cloud.tencent.com/tcb/env/safety"," 3 - 云存储安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(y)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(x=void 0!==f.ICloudbaseCopyFileParams&&f.ICloudbaseCopyFileParams)?x:Object,"function"==typeof(L="undefined"!=typeof Function&&Function)?L:Object]),a("design:returntype","function"==typeof(j="undefined"!=typeof Promise&&Promise)?j:Object)],e.prototype,"copyFile",null),e}(),T=new A,P={name:t.COMPONENT_NAME,entity:{uploadFile:T.uploadFile,deleteFile:T.deleteFile,getTempFileURL:T.getTempFileURL,downloadFile:T.downloadFile,getUploadMetadata:T.getUploadMetadata,copyFile:T.copyFile,getFileInfo:T.getFileInfo,isGateWay:T.isGateWay}},R=function(e){function r(t){var r=e.call(this)||this;return r.shouldThrowOnError=!1,r.bucketId="",r.context=t,r}return o(r,e),Object.defineProperty(r.prototype,"config",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.config},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"request",{get:function(){var e;return null===(e=this.context)||void 0===e?void 0:e.request},enumerable:!1,configurable:!0}),r.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},r.prototype.from=function(e){return this.bucketId=e||"",this},r.prototype.upload=function(e,r,n){return u(this,void 0,Promise,(function(){var o,s,a,u,l,h,f,p,y;return c(this,(function(c){switch(c.label){case 0:o=i({upsert:!0},n),s=o.cacheControl,a=o.contentType,u=o.metadata,c.label=1;case 1:return c.trys.push([1,3,,4]),l=this._getCloudPath(e),h={cloudPath:l,filePath:r},(s||a||u)&&(f={},s&&(f["cache-control"]=s),a&&(f["content-type"]=a),u&&(f["x-cos-metadata-metadata"]=this.toBase64(JSON.stringify(u))),h.headers=f),[4,this.uploadFile(h)];case 2:if(!(p=c.sent()).fileID)throw new Error(JSON.stringify({code:v.OPERATION_FAIL,msg:"[".concat(t.COMPONENT_NAME,".update] no fileID returned")}));return[2,{data:{id:p.fileID,path:e,fullPath:e},error:null}];case 3:if(y=c.sent(),this.shouldThrowOnError)throw y;if((0,d.isStorageError)(y))return[2,{data:null,error:y}];throw y;case 4:return[2]}}))}))},r.prototype.uploadToSignedUrl=function(e,t,r,n){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.upload(e,r,n)]}))}))},r.prototype.createSignedUploadUrl=function(e){return u(this,void 0,Promise,(function(){var t,r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=this._getCloudPath(e),[4,this.getUploadMetadata({cloudPath:t})];case 1:return[2,{data:{signedUrl:(r=o.sent().data).url,token:r.token,path:e,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 d.StorageError?n:new d.StorageError(n.message)}];case 3:return[2]}}))}))},r.prototype.update=function(e,t,r){return u(this,void 0,Promise,(function(){return c(this,(function(n){return[2,this.upload(e,t,i(i({},r),{upsert:!0}))]}))}))},r.prototype.move=function(e,t){return u(this,void 0,Promise,(function(){var r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.copyFile({fileList:[{srcPath:this._getCloudPath(e),dstPath:this._getCloudPath(t),overwrite:!0,removeOriginal:!0}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new d.StorageError(r.fileList[0].message||"Move failed");return[2,{data:{message:"File moved from ".concat(e," to ").concat(t)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if((0,d.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},r.prototype.copy=function(e,t){return u(this,void 0,Promise,(function(){var r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.copyFile({fileList:[{srcPath:this._getCloudPath(e),dstPath:this._getCloudPath(t),overwrite:!0,removeOriginal:!1}]})];case 1:if((r=o.sent()).fileList[0].code&&"SUCCESS"!==r.fileList[0].code)throw new d.StorageError(r.fileList[0].message||"Copy failed");return[2,{data:{path:this._getCloudPath(t)},error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if((0,d.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},r.prototype.createSignedUrl=function(e,t,r){return u(this,void 0,Promise,(function(){var n,o,i,s,a,u,l;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),n=this._normalizeCloudId(e),[4,this.getTempFileURL({fileList:[{fileID:n,maxAge:t}]})];case 1:if("SUCCESS"!==(o=c.sent()).fileList[0].code)throw new d.StorageError("Failed to create signed URL: [".concat(o.fileList[0].code,"] ").concat(o.fileList[0].fileID));return i=o.fileList[0].download_url,s=[],void 0!==(null==r?void 0:r.download)&&("string"==typeof r.download?s.push("download=".concat(encodeURIComponent(r.download))):!0===r.download&&s.push("download=true")),(null==r?void 0:r.transform)&&(a=this._transformOptsToQueryString(r.transform))&&s.push(a),s.length>0&&(u=i.includes("?")?"&":"?",i="".concat(i).concat(u).concat(s.join("&"))),[2,{data:{signedUrl:i},error:null}];case 2:if(l=c.sent(),this.shouldThrowOnError)throw l;if((0,d.isStorageError)(l))return[2,{data:null,error:l}];throw l;case 3:return[2]}}))}))},r.prototype.createSignedUrls=function(e,t){return u(this,void 0,Promise,(function(){var r,n,o=this;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r=e.map((function(e){return{fileID:o._normalizeCloudId(e),maxAge:t}})),[4,this.getTempFileURL({fileList:r})];case 1:return[2,{data:i.sent().fileList.map((function(t,r){return{path:e[r],signedUrl:t.tempFileURL||"",error:"SUCCESS"===t.code?null:t.message}})),error:null}];case 2:if(n=i.sent(),this.shouldThrowOnError)throw n;if((0,d.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},r.prototype.download=function(e,t){return u(this,void 0,Promise,(function(){var r,n,o=this;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n={},[4,u(o,void 0,void 0,(function(){var r,n,o,i;return c(this,(function(s){switch(s.label){case 0:return[4,this.createSignedUrl(e,600,{transform:t})];case 1:if((r=s.sent()).error)throw r.error;return n=encodeURI(null===(i=r.data)||void 0===i?void 0:i.signedUrl),[4,this.request.reqClass.get({url:n,headers:{},responseType:"blob"})];case 2:if(!(o=s.sent().data))throw new d.StorageError("Download failed: no file content");return[2,new Blob([o])]}}))}))];case 1:return[2,(n.data=i.sent(),n.error=null,n)];case 2:if(r=i.sent(),this.shouldThrowOnError)throw r;if((0,d.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},r.prototype.info=function(e){return u(this,void 0,Promise,(function(){var t,r,n,o,i,s,a,u;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),t=e.startsWith("cloud://"),r=t?this._extractPathFromFileId(e):e,n=t?this._extractBucketFromFileId(e):this.bucketId,[4,this.getFileInfo({fileList:[this._normalizeCloudId(e)]})];case 1:if(o=c.sent(),"SUCCESS"!==(i=o.fileList[0]).code)throw new d.StorageError(i.message);return s=(new Date).toISOString(),a=(i.lastModified?new Date(i.lastModified):new Date).toISOString(),[2,{data:{id:i.fileID,version:"1",name:r,bucketId:n,updatedAt:a,createdAt:a,lastAccessedAt:s,size:i.size,cacheControl:i.cacheControl,contentType:i.contentType,etag:i.etag,lastModified:a,metadata:{}},error:null}];case 2:if(u=c.sent(),this.shouldThrowOnError)throw u;return[2,{data:null,error:u instanceof d.StorageError?u:new d.StorageError(u.message)}];case 3:return[2]}}))}))},r.prototype.exists=function(e){return u(this,void 0,Promise,(function(){var t,r,n;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getFileInfo({fileList:[this._normalizeCloudId(e)]})];case 1:if(t=o.sent(),"FILE_NOT_FOUND"===(r=t.fileList[0]).code)return[2,{data:!1,error:null}];if("SUCCESS"!==r.code)throw new d.StorageError(r.message);return[2,{data:!0,error:null}];case 2:if(n=o.sent(),this.shouldThrowOnError)throw n;if((0,d.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},r.prototype.getPublicUrl=function(e,t){return u(this,void 0,Promise,(function(){var r;return c(this,(function(n){switch(n.label){case 0:return[4,this.createSignedUrl(e,600,t)];case 1:return(r=n.sent()).data?[2,{data:{publicUrl:r.data.signedUrl}}]:[2,{data:null,error:r.error}]}}))}))},r.prototype.remove=function(e){return u(this,void 0,Promise,(function(){var t,r,n,o,i,s,a,u,l,h,f=this;return c(this,(function(c){switch(c.label){case 0:for(c.trys.push([0,3,,4]),t=10,r=[],n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return[4,Promise.all(r.map((function(e){return Promise.all(e.map((function(e){return f.info(e)})))})))];case 1:return o=c.sent(),i=new Map,o.flat().forEach((function(r,n){r.data&&i.set(e[Math.floor(n/t)*t+n%t],r.data)})),s=e.map((function(e){return f._normalizeCloudId(e)})),[4,this.deleteFile({fileList:s})];case 2:if(a=c.sent(),(u=a.fileList.filter((function(e){return"SUCCESS"!==e.code}))).length>0)throw new d.StorageError("Delete failed for ".concat(u.length," file(s)"));return l=(new Date).toISOString(),[2,{data:e.map((function(e){var t=i.get(e);return{name:null==t?void 0:t.name,id:null==t?void 0:t.id,bucket_id:null==t?void 0:t.bucketId,owner:void 0,updated_at:(null==t?void 0:t.updatedAt)||l,created_at:null==t?void 0:t.createdAt,last_accessed_at:(null==t?void 0:t.lastAccessedAt)||l,metadata:(null==t?void 0:t.metadata)||{},buckets:{id:null==t?void 0:t.bucketId,name:null==t?void 0:t.bucketId,owner:void 0,public:!1,created_at:"",updated_at:l}}})),error:null}];case 3:if(h=c.sent(),this.shouldThrowOnError)throw h;if((0,d.isStorageError)(h))return[2,{data:null,error:h}];throw h;case 4:return[2]}}))}))},r.prototype.list=function(){return u(this,void 0,void 0,(function(){return c(this,(function(e){throw new d.StorageError("Not implemented")}))}))},r.prototype._getCloudPath=function(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")},r.prototype._normalizeCloudId=function(e){var t;if(/^cloud:\/\//.test(e))return e;var r=this._getCloudPath(e);if(!this.bucketId)throw new d.StorageError("bucketId is not set");var n=(null===(t=this.config)||void 0===t?void 0:t.env)||"";return n?"cloud://".concat(n,".").concat(this.bucketId,"/").concat(r):void 0},r.prototype.toBase64=function(e){return"undefined"!=typeof Buffer?Buffer.from(e).toString("base64"):btoa(e)},r.prototype._transformOptsToQueryString=function(e){var t=["imageMogr2"];if(e.width||e.height){var r=e.width||"",n=e.height||"";"fill"===e.resize?t.push("thumbnail/".concat(r,"x").concat(n,"!")):"contain"===e.resize?t.push("thumbnail/".concat(r,"x").concat(n)):t.push("thumbnail/".concat(r,"x").concat(n,"^"))}if(e.format&&"origin"!==e.format&&t.push("format/".concat(e.format)),void 0!==e.quality){var o=Math.max(1,Math.min(100,e.quality));t.push("quality/".concat(o))}return t.join("/")},r.prototype._extractPathFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");return t.length<2?e:t.slice(1).join("/")},r.prototype._extractBucketFromFileId=function(e){var t=e.replace(/^cloud:\/\//,"").split("/");if(t.length<1)return"";var r=t[0],n=r.indexOf(".");return-1===n?r:r.substring(n+1)},r}(A);t.SupabaseFileAPILikeStorage=R;var C={name:"".concat(t.COMPONENT_NAME,"/supabase"),IIFE:!0,entity:function(){var e=new WeakMap;Object.defineProperty(this.prototype,"storage",{get:function(){if(e.has(this))return e.get(this);var t=this,r=new Proxy({},{get:function(e,r){return"config"===r?t.config:"request"===r?t.request:void 0}}),n=new R(r);return e.set(this,n),n},configurable:!0,enumerable:!0})}};try{cloudbase.registerComponent(P),cloudbase.registerComponent(C)}catch(e){}function N(e){try{e.registerComponent(P),e.registerComponent(C)}catch(e){console.warn(e)}}t.registerStorage=N;try{window.registerStorage=N}catch(e){}},7957: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.StorageUnknownError=t.StorageApiError=t.isStorageError=t.StorageError=void 0;var o=function(e){function t(t){var r=e.call(this,t)||this;return r.__isStorageError=!0,r.name="StorageError",r}return n(t,e),t}(Error);t.StorageError=o,t.isStorageError=function(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e};var i=function(e){function t(t,r,n){var o=e.call(this,t)||this;return o.name="StorageApiError",o.status=r,o.statusCode=n,o}return n(t,e),t.prototype.toJSON=function(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}},t}(o);t.StorageApiError=i;var s=function(e){function t(t,r){var n=e.call(this,t)||this;return n.name="StorageUnknownError",n.originalError=r,n}return n(t,e),t}(o);t.StorageUnknownError=s},2563: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.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(92)),c=r(962);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},92:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(2764),c=r(962),l=r(8464),d=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach((function(e){c.append(e,t[e])})),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,Promise,(function(){var t,r,n,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return s(this,void 0,Promise,(function(){var r,n,o,u,c,l,d,h,f,p,v,y,m,g=this;return a(this,(function(b){switch(b.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,l=void 0!==c&&c,d=e.signal,h=e.timeout,f=e.shouldThrowOnError,p=void 0===f||f,v=null!=h?h:this.timeout,d&&(d.aborted&&r.abort(),d.addEventListener("abort",(function(){return r.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(g.timeoutMsg),r.abort(new Error(g.timeoutMsg))}),v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then((function(e){return s(g,void 0,void 0,(function(){var t,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(y),p?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(y),p)return Promise.reject(e)}))];case 1:return m=b.sent(),[2,{data:l?m.body:(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,u=e.headers,d=void 0===u?{}:u,h=e.data,f=e.responseType,p=e.withCredentials,v=e.body,y=e.onUploadProgress,m=(0,c.formatUrl)((0,l.getProtocol)(),a,"get"===n?h:{}),g=new XMLHttpRequest;g.open(n,m),f&&(g.responseType=f),Object.keys(d).forEach((function(e){g.setRequestHeader(e,d[e])})),y&&g.upload.addEventListener("progress",y),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=g.status;try{e.data="blob"===f?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===f?g.response:g.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),g.abort()}),r.timeout)),s=(0,c.isFormData)(h)?h:"application/x-www-form-urlencoded"===d["content-type"]?(0,c.toQueryString)(h):v||(h?JSON.stringify(h):void 0),p&&(g.withCredentials=!0),g.send(s)}))},t}(u.AbstractSDKRequest);t.WebRequest=d,t.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage:localStorage}}},8464:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},3519:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},1778:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(8464),t),o(r(3519),t),t.OATUH_LOGINTYPE="constants"},9517: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=r(962),s=r(1778),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),d=s.findIndex((function(e){return u.test(e)}));if(-1!==d){var h=s.filter((function(e,t){return t>d}));h.unshift(s[d].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,d=void 0===a?{}:a,h=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=d.className||e.constructor.name,v=d.methodName||t,y=a.value,m=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex((function(e){return u.test(e)}));if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l({err:new Error,className:f,methodName:v,sourceLink:m});try{return y.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=p.map((function(e){return{type:"info",body:e}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=p.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,r,n,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(d=JSON.parse(s),c.subtitle=d,d.code&&(t?(t.code=d.code,t.message=d.msg):(r.code=d.code,r.message=d.msg),n=t||r,c.content=p.map((function(e){return{type:"info",body:e}})))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=p.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},3260:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(9517),t)},2877:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return o(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.langEvent=t.AbortController=t.jwt=t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var a=i(r(1778));t.constants=a;var u=i(r(2563));t.adapters=u;var c=i(r(6865));t.cache=c;var l=i(r(6940));t.events=l;var d=i(r(3991));t.langEvent=d;var h=i(r(962));t.utils=h;var f=i(r(3260));t.helpers=f;var p=s(r(829));t.AbortController=p.default;var v={decode:s(r(3107)).default};t.jwt=v},829:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,r){"abort"===t&&e.listeners.push(r)}}}return e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach((function(e){return e()})))},e}();t.default=r},6865:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(2764),u=r(962),c=r(1778),l=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),d=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();t.CloudbaseCache=d},6940:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(962),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++)c[o].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var l=new c;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},3991:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LANG_CHANGE_EVENT=t.bus=void 0;var n=r(6940);t.bus=new n.CloudbaseEventEmitter,t.LANG_CHANGE_EVENT="lang_change"},962:function(e,t,r){"use strict";var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(1778);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)}))},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,d=s;l<d.length;l++){var h=d[l],f=h.type,p=h.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},543:function(e,t,r){"use strict";r.r(t),r.d(t,{CollectionReference:function(){return Ve},Db:function(){return yt},DocumentReference:function(){return je},Query:function(){return We}});var n,o,i={};r.r(i),r.d(i,{LineString:function(){return G},MultiLineString:function(){return z},MultiPoint:function(){return Y},MultiPolygon:function(){return Q},Point:function(){return oe},Polygon:function(){return K}}),function(e){e.DocIDError="文档ID不合法",e.CollNameError="集合名称不合法",e.OpStrError="操作符不合法",e.DirectionError="排序字符不合法",e.IntergerError="must be integer",e.QueryParamTypeError="查询参数必须为对象",e.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a,u="Object",c="GeoPoint",l="GeoLineString",d="GeoPolygon",h="GeoMultiPoint",f="GeoMultiLineString",p="GeoMultiPolygon",v="Date",y="ServerDate",m=["desc","asc"],g=["<","<=","==",">=",">"];!function(e){e.lt="<",e.gt=">",e.lte="<=",e.gte=">=",e.eq="=="}(s||(s={})),(n={})[s.eq]="$eq",n[s.lt]="$lt",n[s.lte]="$lte",n[s.gt]="$gt",n[s.gte]="$gte",function(e){e.WHERE="WHERE",e.DOC="DOC"}(a||(a={}));var b,_=(b=function(e,t){return b=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])},b(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}b(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),w=[],E={},I=function(e){function t(t,r){if(r!==E)throw new TypeError("InternalSymbol cannot be constructed with new operator");return e.call(this,t)||this}return _(t,e),t.for=function(e){for(var r=0,n=w.length;r<n;r++)if(w[r].target===e)return w[r].instance;var o=new t(e,E);return w.push({target:e,instance:o}),o},t}((function(e){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:e}})})),S=I,O=S.for("UNSET_FIELD_NAME"),A=S.for("UPDATE_COMMAND"),T=S.for("QUERY_COMMAND"),P=S.for("LOGIC_COMMAND"),R=S.for("GEO_POINT"),C=S.for("SYMBOL_GEO_LINE_STRING"),N=S.for("SYMBOL_GEO_POLYGON"),D=S.for("SYMBOL_GEO_MULTI_POINT"),U=S.for("SYMBOL_GEO_MULTI_LINE_STRING"),x=S.for("SYMBOL_GEO_MULTI_POLYGON"),L=S.for("SERVER_DATE"),j=S.for("REGEXP"),k=function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()},M=function(e){return"object"===k(e)},q=function(e){return"number"===k(e)},W=function(e){return Array.isArray(e)},F=function(e){return"date"===k(e)},B=function(e){return"regexp"===k(e)},H=function(e){return e&&e._internalType instanceof I},G=function(){function e(e){if(!W(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(e.length<2)throw new Error('"points" must contain 2 points at least');e.forEach((function(e){if(!(e instanceof oe))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,r;if("LineString"!==e.type||!W(e.coordinates))return!1;try{for(var n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!q(i[0])||!q(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0},e.isClosed=function(e){var t=e.points[0],r=e.points[e.points.length-1];if(t.latitude===r.latitude&&t.longitude===r.longitude)return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return C},enumerable:!1,configurable:!0}),e}(),V=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},K=function(){function e(e){if(!W(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof G))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"));if(!G.isClosed(e))throw new Error("LineString ".concat(e.points.map((function(e){return e.toReadableString()}))," is not a closed cycle"))})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,r,n,o;if("Polygon"!==e.type||!W(e.coordinates))return!1;try{for(var i=V(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var u=(n=void 0,V(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!q(l[0])||!q(l[1]))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return!0},e.isCloseLineString=function(e){var t=e[0],r=e[e.length-1];return t[0]===r[0]&&t[1]===r[1]},Object.defineProperty(e.prototype,"_internalType",{get:function(){return x},enumerable:!1,configurable:!0}),e}(),Y=function(){function e(e){if(!W(e))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e));if(0===e.length)throw new Error('"points" must contain 1 point at least');e.forEach((function(e){if(!(e instanceof oe))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof e,"[]"))})),this.points=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))},t},e.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(e){return e.toJSON().coordinates}))}},e.validate=function(e){var t,r;if("MultiPoint"!==e.type||!W(e.coordinates))return!1;try{for(var n=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}(e.coordinates),o=n.next();!o.done;o=n.next()){var i=o.value;if(!q(i[0])||!q(i[1]))return!1}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return D},enumerable:!1,configurable:!0}),e}(),J=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(){function e(e){if(!W(e))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("Polygon must contain 1 linestring at least");e.forEach((function(e){if(!(e instanceof G))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof e,"[]"))})),this.lines=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))},t},e.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}},e.validate=function(e){var t,r,n,o;if("MultiLineString"!==e.type||!W(e.coordinates))return!1;try{for(var i=J(e.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(n=void 0,J(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!q(l[0])||!q(l[1]))return!1}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return U},enumerable:!1,configurable:!0}),e}(),$=function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Q=function(){function e(e){var t,r;if(!W(e))throw new TypeError('"polygons" must be of type Polygon[]. Received type '.concat(typeof e));if(0===e.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var n=$(e),o=n.next();!o.done;o=n.next()){var i=o.value;if(!(i instanceof K))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof i,"[]"))}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}this.polygons=e}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))},t},e.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(e){return e.lines.map((function(e){return e.points.map((function(e){return[e.longitude,e.latitude]}))}))}))}},e.validate=function(e){var t,r,n,o,i,s;if("MultiPolygon"!==e.type||!W(e.coordinates))return!1;try{for(var a=$(e.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var l=(n=void 0,$(c)),d=l.next();!d.done;d=l.next()){var h=d.value;try{for(var f=(i=void 0,$(h)),p=f.next();!p.done;p=f.next()){var v=p.value;if(!q(v[0])||!q(v[1]))return!1}}catch(e){i={error:e}}finally{try{p&&!p.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(o=l.return)&&o.call(l)}finally{if(n)throw n.error}}}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return!0},Object.defineProperty(e.prototype,"_internalType",{get:function(){return N},enumerable:!1,configurable:!0}),e}(),X=function(){function e(e){var t=(void 0===e?{}:e).offset,r=void 0===t?0:t;this.offset=r}return Object.defineProperty(e.prototype,"_internalType",{get:function(){return L},enumerable:!1,configurable:!0}),e.prototype.parse=function(){return{$date:{offset:this.offset}}},e}();function Z(e){return new X(e)}var ee,te=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},re=function(){function e(){}return e.formatResDocumentData=function(t){return t.map((function(t){return e.formatField(t)}))},e.formatField=function(t){var r=Object.keys(t),n={};return Array.isArray(t)&&(n=[]),r.forEach((function(r){var o,i=t[r];switch(e.whichType(i)){case c:o=new oe(i.coordinates[0],i.coordinates[1]);break;case l:o=new G(i.coordinates.map((function(e){return new oe(e[0],e[1])})));break;case d:o=new K(i.coordinates.map((function(e){return new G(e.map((function(e){var t=te(e,2),r=t[0],n=t[1];return new oe(r,n)})))})));break;case h:o=new Y(i.coordinates.map((function(e){return new oe(e[0],e[1])})));break;case f:o=new z(i.coordinates.map((function(e){return new G(e.map((function(e){var t=te(e,2),r=t[0],n=t[1];return new oe(r,n)})))})));break;case p:o=new Q(i.coordinates.map((function(e){return new K(e.map((function(e){return new G(e.map((function(e){var t=te(e,2),r=t[0],n=t[1];return new oe(r,n)})))})))})));break;case v:o=new Date(1e3*i.$timestamp);break;case u:case"Array":o=e.formatField(i);break;case y:o=new Date(i.$date);break;default:o=i}Array.isArray(n)?n.push(o):n[r]=o})),n},e.whichType=function(e){var t=Object.prototype.toString.call(e).slice(8,-1);if(t===v)return"BsonDate";if(t===u){if(e instanceof oe)return c;if(e instanceof Date)return v;if(e instanceof X)return y;e.$timestamp?t=v:e.$date?t=y:oe.validate(e)?t=c:G.validate(e)?t=l:K.validate(e)?t=d:Y.validate(e)?t=h:z.validate(e)?t=f:Q.validate(e)&&(t=p)}return t},e.generateDocId=function(){for(var e="",t=0;t<24;t++)e+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return e},e}(),ne=function(){function e(){}return e.isGeopoint=function(e,t){if("Number"!==re.whichType(t))throw new Error("Geo Point must be number type");var r=Math.abs(t);if("latitude"===e&&r>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===e&&r>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},e.isInteger=function(e,t){if(!Number.isInteger(t))throw new Error(e+o.IntergerError);return!0},e.isFieldOrder=function(e){if(-1===m.indexOf(e))throw new Error(o.DirectionError);return!0},e.isFieldPath=function(e){if(!/^[a-zA-Z0-9-_\.]/.test(e))throw new Error;return!0},e.isOperator=function(e){if(-1===g.indexOf(e))throw new Error(o.OpStrError);return!0},e.isCollName=function(e){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(e))throw new Error(o.CollNameError);return!0},e.isDocID=function(e){if(!/^([a-fA-F0-9]){24}$/.test(e))throw new Error(o.DocIDError);return!0},e}(),oe=function(){function e(e,t){ne.isGeopoint("longitude",e),ne.isGeopoint("latitude",t),this.longitude=e,this.latitude=t}return e.prototype.parse=function(e){var t;return(t={})[e]={type:"Point",coordinates:[this.longitude,this.latitude]},t},e.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},e.prototype.toReadableString=function(){return"[".concat(this.longitude,",").concat(this.latitude,"]")},e.validate=function(e){return"Point"===e.type&&W(e.coordinates)&&ne.isGeopoint("longitude",e.coordinates[0])&&ne.isGeopoint("latitude",e.coordinates[1])},Object.defineProperty(e.prototype,"_internalType",{get:function(){return R},enumerable:!1,configurable:!0}),e}(),ie=function(){var e=function(){};if(!Promise){e.promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e};!function(e){e.SET="set",e.REMOVE="remove",e.INC="inc",e.MUL="mul",e.PUSH="push",e.PULL="pull",e.PULL_ALL="pullAll",e.POP="pop",e.SHIFT="shift",e.UNSHIFT="unshift",e.ADD_TO_SET="addToSet",e.BIT="bit",e.RENAME="rename",e.MAX="max",e.MIN="min"}(ee||(ee={}));var se,ae=function(){function e(e,t,r){this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=r||O}return e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e}();function ue(e){return e&&e instanceof ae&&e._internalType===A}!function(e){e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor"}(se||(se={}));var ce=function(){function e(e,t,r){if(this._internalType=P,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=e,this.operands=t,this.fieldName=r||O,this.fieldName!==O)if(Array.isArray(t)){t=t.slice(),this.operands=t;for(var n=0,o=t.length;n<o;n++)(le(i=t[n])||pe(i))&&(t[n]=i._setFieldName(this.fieldName))}else{var i;(le(i=t)||pe(i))&&(t=i._setFieldName(this.fieldName))}}return e.prototype._setFieldName=function(t){var r=this.operands.map((function(r){return r instanceof e?r._setFieldName(t):r}));return new e(this.operator,r,t)},e.prototype.and=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new e(se.AND,n,this.fieldName)},e.prototype.or=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return n.unshift(this),new e(se.OR,n,this.fieldName)},e}();function le(e){return e&&e instanceof ce&&e._internalType===P}var de,he=function(){var e=function(t,r){return e=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])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();!function(e){e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",e.GEO_NEAR="geoNear",e.GEO_WITHIN="geoWithin",e.GEO_INTERSECTS="geoIntersects"}(de||(de={}));var fe=function(e){function t(t,r,n){var o=e.call(this,t,r,n)||this;return o.operator=t,o._internalType=T,o}return he(t,e),t.prototype.toJSON=function(){var e,t;switch(this.operator){case de.IN:case de.NIN:return(e={})["$"+this.operator]=this.operands,e;default:return(t={})["$"+this.operator]=this.operands[0],t}},t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t.prototype.eq=function(e){var r=new t(de.EQ,[e],this.fieldName);return this.and(r)},t.prototype.neq=function(e){var r=new t(de.NEQ,[e],this.fieldName);return this.and(r)},t.prototype.gt=function(e){var r=new t(de.GT,[e],this.fieldName);return this.and(r)},t.prototype.gte=function(e){var r=new t(de.GTE,[e],this.fieldName);return this.and(r)},t.prototype.lt=function(e){var r=new t(de.LT,[e],this.fieldName);return this.and(r)},t.prototype.lte=function(e){var r=new t(de.LTE,[e],this.fieldName);return this.and(r)},t.prototype.in=function(e){var r=new t(de.IN,e,this.fieldName);return this.and(r)},t.prototype.nin=function(e){var r=new t(de.NIN,e,this.fieldName);return this.and(r)},t.prototype.geoNear=function(e){if(!(e.geometry instanceof oe))throw new TypeError('"geometry" must be of type Point. Received type '.concat(typeof e.geometry));if(void 0!==e.maxDistance&&!q(e.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof e.maxDistance));if(void 0!==e.minDistance&&!q(e.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '.concat(typeof e.minDistance));var r=new t(de.GEO_NEAR,[e],this.fieldName);return this.and(r)},t.prototype.geoWithin=function(e){if(!(e.geometry instanceof Q||e.geometry instanceof K))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof e.geometry));var r=new t(de.GEO_WITHIN,[e],this.fieldName);return this.and(r)},t.prototype.geoIntersects=function(e){if(!(e.geometry instanceof oe||e.geometry instanceof G||e.geometry instanceof K||e.geometry instanceof Y||e.geometry instanceof z||e.geometry instanceof Q))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '.concat(typeof e.geometry));var r=new t(de.GEO_INTERSECTS,[e],this.fieldName);return this.and(r)},t}(ce);function pe(e){return e&&e instanceof fe&&e._internalType===T}function ve(e){return pe(e)}var ye={};for(var me in de)ye[me]="$"+me;for(var me in se)ye[me]="$"+me;for(var me in ee)ye[me]="$"+me;function ge(e){return ye[e]||"$"+e}ye[de.NEQ]="$ne",ye[ee.REMOVE]="$unset",ye[ee.SHIFT]="$pop",ye[ee.UNSHIFT]="$push";var be=function(){return be=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},be.apply(this,arguments)},_e=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},we=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))};function Ee(e){return Ie(e,[e])}function Ie(e,t){if(!H(e)){if(F(e))return{$date:+e};if(B(e))return{$regex:e.source,$options:e.flags};if(W(e))return e.map((function(e){if(t.indexOf(e)>-1)throw new Error("Cannot convert circular structure to JSON");return Ie(e,we(we([],_e(t),!1),[e],!1))}));if(M(e)){var r=be({},e);for(var n in r){if(t.indexOf(r[n])>-1)throw new Error("Cannot convert circular structure to JSON");r[n]=Ie(r[n],we(we([],_e(t),!1),[r[n]],!1))}return r}return e}switch(e._internalType){case R:return e.toJSON();case L:case j:return e.parse();default:return e.toJSON?e.toJSON():e}}var Se=function(){return Se=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},Se.apply(this,arguments)},Oe=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},Ae=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))};function Te(e,t,r,n){var o=Se({},e);for(var i in e)if(!/^\$/.test(i)){var s=e[i];if(s&&M(s)&&!t(s)){if(n.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Te(s,t,Ae(Ae([],Oe(r),!1),[i],!1),Ae(Ae([],Oe(n),!1),[s],!1));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o["".concat(i,".").concat(c)]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Pe(e){return Te(e,Ce,[],[e])}function Re(e,t,r){for(var n in t[r]||delete e[r],t)e[n]?W(e[n])?e[n].push(t[n]):M(e[n])?M(t[n])?Object.assign(e[n],t[n]):(console.warn("unmergable condition, query is object but condition is ".concat(k(t),", can only overwrite"),t,r),e[n]=t[n]):(console.warn("to-merge query is of type ".concat(k(e),", can only overwrite"),e,t,r),e[n]=t[n]):e[n]=t[n]}function Ce(e){return H(e)||F(e)||B(e)}function Ne(e){return Ee(e)}var De=function(){function e(){}return e.encode=function(t){return(new e).encodeUpdate(t)},e.prototype.encodeUpdate=function(e){return ue(e)?this.encodeUpdateCommand(e):"object"===k(e)?this.encodeUpdateObject(e):e},e.prototype.encodeUpdateCommand=function(e){if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");switch(e.operator){case ee.PUSH:case ee.PULL:case ee.PULL_ALL:case ee.POP:case ee.SHIFT:case ee.UNSHIFT:case ee.ADD_TO_SET:return this.encodeArrayUpdateCommand(e);default:return this.encodeFieldUpdateCommand(e)}},e.prototype.encodeFieldUpdateCommand=function(e){var t,r,n,o,i=ge(e.operator);return e.operator===ee.REMOVE?((t={})[i]=((r={})[e.fieldName]="",r),t):((n={})[i]=((o={})[e.fieldName]=e.operands[0],o),n)},e.prototype.encodeArrayUpdateCommand=function(e){var t,r,n,o,i,s,a,u,c,l,d=ge(e.operator);switch(e.operator){case ee.PUSH:var h=void 0;return h=W(e.operands)?{$each:e.operands.map(Ne)}:e.operands,(t={})[d]=((r={})[e.fieldName]=h,r),t;case ee.UNSHIFT:return h={$each:e.operands.map(Ne),$position:0},(n={})[d]=((o={})[e.fieldName]=h,o),n;case ee.POP:return(i={})[d]=((s={})[e.fieldName]=1,s),i;case ee.SHIFT:return(a={})[d]=((u={})[e.fieldName]=-1,u),a;default:return(c={})[d]=((l={})[e.fieldName]=Ne(e.operands),l),c}},e.prototype.encodeUpdateObject=function(e){var t=Pe(e);for(var r in t)if(!/^\$/.test(r)){var n=t[r];if(ue(n))t[r]=n._setFieldName(r),Re(t,this.encodeUpdateCommand(t[r]),r);else{t[r]=n=Ne(n);var o=new ae(ee.SET,[n],r);Re(t,this.encodeUpdateCommand(o),r)}}return t},e}(),Ue={};function xe(e){if(!yt.wsClientClass)throw new Error("to use realtime you must import realtime module first");var t=e.config.env;return Ue[t]||(Ue[t]=new yt.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:yt.createRequest(e.config)}}})),Ue[t]}var Le=function(){return Le=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},Le.apply(this,arguments)},je=function(){function e(e,t,r,n){void 0===n&&(n={});var o=this;this.watch=function(e){return xe(o._db).watch(Le(Le({},e),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=e,this._coll=t,this.id=r,this.request=yt.createRequest(this._db.config),this.projection=n}return e.prototype.create=function(e,t){t=t||ie();var r=Array.isArray(e),n={collectionName:this._coll,data:r?e.map((function(e){return Ee(e)})):Ee(e)};return!r&&this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(e){var n;e.code?t(0,e):t(0,r?{ids:(null===(n=e.data)||void 0===n?void 0:n.insertedIds)||[],requestId:e.requestId}:{id:e.data._id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.set=function(e,t){if(t=t||ie(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var r=!1,n=function(e){if("object"==typeof e)for(var t in e)e[t]instanceof ae?r=!0:"object"==typeof e[t]&&n(e[t])};if(n(e),r)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:Ee(e),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.update=function(e,t){if(t=t||ie(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var r={_id:this.id},n={collectionName:this._coll,data:De.encode(e),query:r,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",n).then((function(e){e.code?t(0,e):t(0,{updated:e.data.updated,upsertedId:e.data.upserted_id,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},e.prototype.remove=function(e){e=e||ie();var t={_id:this.id},r={collectionName:this._coll,query:t,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",r).then((function(t){t.code?e(0,t):e(0,{deleted:t.data.deleted,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},e.prototype.get=function(e){e=e||ie();var t={_id:this.id},r={collectionName:this._coll,query:t,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",r).then((function(t){if(t.code)e(0,t);else{var r=re.formatResDocumentData(t.data.list);e(0,{data:r,requestId:t.requestId})}})).catch((function(t){e(t)})),e.promise},e.prototype.field=function(t){for(var r in t)t[r]?t[r]=1:t[r]=0;return new e(this._db,this._coll,this.id,t)},e}(),ke=function(){function e(){}return e.encode=function(e){return(new Me).encodeQuery(e)},e}(),Me=function(){function e(){}return e.prototype.encodeQuery=function(e,t){var r;return Ce(e)?le(e)?this.encodeLogicCommand(e):pe(e)?this.encodeQueryCommand(e):((r={})[t]=this.encodeQueryObject(e),r):M(e)?this.encodeQueryObject(e):e},e.prototype.encodeRegExp=function(e){return{$regex:e.source,$options:e.flags}},e.prototype.encodeLogicCommand=function(e){var t,r,n,o,i,s,a,u=this;switch(e.operator){case se.NOR:case se.AND:case se.OR:var c=ge(e.operator),l=e.operands.map((function(t){return u.encodeQuery(t,e.fieldName)}));return(t={})[c]=l,t;case se.NOT:c=ge(e.operator);var d=e.operands[0];return B(d)?((r={})[e.fieldName]=((n={})[c]=this.encodeRegExp(d),n),r):(l=this.encodeQuery(d)[e.fieldName],(o={})[e.fieldName]=((i={})[c]=l,i),o);default:if(c=ge(e.operator),1===e.operands.length){var h=this.encodeQuery(e.operands[0]);return(s={})[c]=h,s}return l=e.operands.map(this.encodeQuery.bind(this)),(a={})[c]=l,a}},e.prototype.encodeQueryCommand=function(e){return ve(e),this.encodeComparisonCommand(e)},e.prototype.encodeComparisonCommand=function(e){var t,r,n,o,i,s,a,u,c;if(e.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var l=ge(e.operator);switch(e.operator){case de.EQ:case de.NEQ:case de.LT:case de.LTE:case de.GT:case de.GTE:case de.ELEM_MATCH:case de.EXISTS:case de.SIZE:case de.MOD:return(t={})[e.fieldName]=((r={})[l]=Ne(e.operands[0]),r),t;case de.IN:case de.NIN:case de.ALL:return(n={})[e.fieldName]=((o={})[l]=Ne(e.operands),o),n;case de.GEO_NEAR:var d=e.operands[0];return(i={})[e.fieldName]={$nearSphere:{$geometry:d.geometry.toJSON(),$maxDistance:d.maxDistance,$minDistance:d.minDistance}},i;case de.GEO_WITHIN:return d=e.operands[0],(s={})[e.fieldName]={$geoWithin:{$geometry:d.geometry.toJSON()}},s;case de.GEO_INTERSECTS:return d=e.operands[0],(a={})[e.fieldName]={$geoIntersects:{$geometry:d.geometry.toJSON()}},a;default:return(u={})[e.fieldName]=((c={})[l]=Ne(e.operands[0]),c),u}},e.prototype.encodeQueryObject=function(e){var t=Pe(e);for(var r in t){var n=t[r];if(le(n)){t[r]=n._setFieldName(r);var o=this.encodeLogicCommand(t[r]);this.mergeConditionAfterEncode(t,o,r)}else ve(n)?(t[r]=n._setFieldName(r),o=this.encodeComparisonCommand(t[r]),this.mergeConditionAfterEncode(t,o,r)):Ce(n)&&(t[r]=Ne(n))}return t},e.prototype.mergeConditionAfterEncode=function(e,t,r){for(var n in t[r]||delete e[r],t)e[n]?W(e[n])?e[n]=e[n].concat(t[n]):M(e[n])?M(t[n])?Object.assign(e,t):(console.warn("unmergable condition, query is object but condition is ".concat(k(t),", can only overwrite"),t,r),e[n]=t[n]):(console.warn("to-merge query is of type ".concat(k(e),", can only overwrite"),e,t,r),e[n]=t[n]):e[n]=t[n]},e}(),qe=function(){return qe=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},qe.apply(this,arguments)},We=function(){function e(e,t,r,n,o){var i=this;this.watch=function(e){return xe(i._db).watch(qe(qe({},e),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(e,t){return e[t.field]=t.direction,e}),{}):void 0}))},this._db=e,this._coll=t,this._fieldFilters=r,this._fieldOrders=n||[],this._queryOptions=o||{},this._request=yt.createRequest(this._db.config)}return e.prototype.get=function(e){e=e||ie();var t=[];this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)}));var r={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(r.query=this._fieldFilters),t.length>0&&(r.order=t),this._queryOptions.offset&&(r.offset=this._queryOptions.offset),this._queryOptions.limit?r.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:r.limit=100,this._queryOptions.projection&&(r.projection=this._queryOptions.projection),this._request.send("database.queryDocument",r).then((function(t){if(t.code)e(0,t);else{var r={data:re.formatResDocumentData(t.data.list),requestId:t.requestId};void 0!==t.total&&(r.total=t.total),void 0!==t.limit&&(r.limit=t.limit),void 0!==t.offset&&(r.offset=t.offset),e(0,r)}})).catch((function(t){e(t)})),e.promise},e.prototype.count=function(e){e=e||ie();var t={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(t.query=this._fieldFilters),this._request.send("database.countDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,total:t.data.total})})).catch((function(t){e(t)})),e.promise},e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(o.QueryParamTypeError);var r=Object.keys(t),n=r.some((function(e){return void 0!==t[e]}));if(r.length&&!n)throw Error(o.QueryParamValueError);return new e(this._db,this._coll,ke.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,r){ne.isFieldPath(t),ne.isFieldOrder(r);var n={field:t,direction:r},o=this._fieldOrders.concat(n);return new e(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},e.prototype.limit=function(t){ne.isInteger("limit",t);var r=qe({},this._queryOptions);return r.limit=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.skip=function(t){ne.isInteger("offset",t);var r=qe({},this._queryOptions);return r.offset=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.update=function(e,t){if(t=t||ie(),!e||"object"!=typeof e)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(e.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var r={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:!0,merge:!0,upsert:!1,data:De.encode(e)};return this._request.send("database.updateDocument",r).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,updated:e.data.updated,upsertId:e.data.upsert_id})})).catch((function(e){t(e)})),t.promise},e.prototype.field=function(t){for(var r in t)t[r]?"object"!=typeof t[r]&&(t[r]=1):t[r]=0;var n=qe({},this._queryOptions);return n.projection=t,new e(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.remove=function(e){e=e||ie(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var t={collectionName:this._coll,query:ke.encode(this._fieldFilters),queryType:a.WHERE,multi:!0};return this._request.send("database.deleteDocument",t).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,deleted:t.data.deleted})})).catch((function(t){e(t)})),e.promise},e}(),Fe=r(2701),Be=function(){function e(e,t){this._stages=[],e&&t&&(this._db=e,this._request=yt.createRequest(this._db.config),this._collectionName=t)}return e.prototype.end=function(){return e=this,t=void 0,n=function(){var e;return function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(t){switch(t.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(e=t.sent())&&e.data&&e.data.list?[2,{requestId:e.requestId,data:JSON.parse(e.data.list).map(Fe.EJSON.parse)}]:[2,e]}}))},new((r=void 0)||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}));var e,t,r,n},e.prototype.unwrap=function(){return this._stages},e.prototype.done=function(){return this._stages.map((function(e){var t,r=e.stageKey,n=e.stageValue;return(t={})[r]=JSON.parse(n),t}))},e.prototype._pipe=function(e,t){return this._stages.push({stageKey:"$".concat(e),stageValue:JSON.stringify(t)}),this},e.prototype.addFields=function(e){return this._pipe("addFields",e)},e.prototype.bucket=function(e){return this._pipe("bucket",e)},e.prototype.bucketAuto=function(e){return this._pipe("bucketAuto",e)},e.prototype.count=function(e){return this._pipe("count",e)},e.prototype.geoNear=function(e){return e.query&&(e.query=ke.encode(e.query)),e.distanceMultiplier&&"number"==typeof e.distanceMultiplier&&(e.distanceMultiplier=e.distanceMultiplier),e.near&&(e.near=new oe(e.near.longitude,e.near.latitude).toJSON()),this._pipe("geoNear",e)},e.prototype.group=function(e){return this._pipe("group",e)},e.prototype.limit=function(e){return this._pipe("limit",e)},e.prototype.match=function(e){return this._pipe("match",ke.encode(e))},e.prototype.project=function(e){return this._pipe("project",e)},e.prototype.lookup=function(e){return this._pipe("lookup",e)},e.prototype.replaceRoot=function(e){return this._pipe("replaceRoot",e)},e.prototype.sample=function(e){return this._pipe("sample",e)},e.prototype.skip=function(e){return this._pipe("skip",e)},e.prototype.sort=function(e){return this._pipe("sort",e)},e.prototype.sortByCount=function(e){return this._pipe("sortByCount",e)},e.prototype.unwind=function(e){return this._pipe("unwind",e)},e}(),He=Be,Ge=function(){var e=function(t,r){return e=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])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ve=function(e){function t(t,r){return e.call(this,t,r)||this}return Ge(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new je(this._db,this._coll,e)},t.prototype.add=function(e,t){return new je(this._db,this._coll,void 0).create(e,t)},t.prototype.aggregate=function(){return new He(this._db,this._coll)},t}(We),Ke={eq:function(e){return new fe(de.EQ,[e])},neq:function(e){return new fe(de.NEQ,[e])},lt:function(e){return new fe(de.LT,[e])},lte:function(e){return new fe(de.LTE,[e])},gt:function(e){return new fe(de.GT,[e])},gte:function(e){return new fe(de.GTE,[e])},in:function(e){return new fe(de.IN,e)},nin:function(e){return new fe(de.NIN,e)},all:function(e){return new fe(de.ALL,e)},elemMatch:function(e){return new fe(de.ELEM_MATCH,[e])},exists:function(e){return new fe(de.EXISTS,[e])},size:function(e){return new fe(de.SIZE,[e])},mod:function(e){return new fe(de.MOD,[e])},geoNear:function(e){return new fe(de.GEO_NEAR,[e])},geoWithin:function(e){return new fe(de.GEO_WITHIN,[e])},geoIntersects:function(e){return new fe(de.GEO_INTERSECTS,[e])},and:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=W(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.AND,r)},nor:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=W(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.NOR,r)},or:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=W(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.OR,r)},not:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=W(arguments[0])?arguments[0]:Array.from(arguments);return new ce(se.NOT,r)},set:function(e){return new ae(ee.SET,[e])},remove:function(){return new ae(ee.REMOVE,[])},inc:function(e){return new ae(ee.INC,[e])},mul:function(e){return new ae(ee.MUL,[e])},push:function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];if(M(t[0])&&t[0].hasOwnProperty("each")){var n=t[0];e={$each:n.each,$position:n.position,$sort:n.sort,$slice:n.slice}}else e=W(t[0])?t[0]:Array.from(t);return new ae(ee.PUSH,e)},pull:function(e){return new ae(ee.PULL,e)},pullAll:function(e){return new ae(ee.PULL_ALL,e)},pop:function(){return new ae(ee.POP,[])},shift:function(){return new ae(ee.SHIFT,[])},unshift:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=W(arguments[0])?arguments[0]:Array.from(arguments);return new ae(ee.UNSHIFT,r)},addToSet:function(e){return new ae(ee.ADD_TO_SET,e)},rename:function(e){return new ae(ee.RENAME,[e])},bit:function(e){return new ae(ee.BIT,[e])},max:function(e){return new ae(ee.MAX,[e])},min:function(e){return new ae(ee.MIN,[e])},expr:function(e){return{$expr:e}},jsonSchema:function(e){return{$jsonSchema:e}},text:function(e){return"string"===k(e)?{$search:e.search}:{$search:e.search,$language:e.language,$caseSensitive:e.caseSensitive,$diacriticSensitive:e.diacriticSensitive}},aggregate:{pipeline:function(){return new He},abs:function(e){return new Ye("abs",e)},add:function(e){return new Ye("add",e)},ceil:function(e){return new Ye("ceil",e)},divide:function(e){return new Ye("divide",e)},exp:function(e){return new Ye("exp",e)},floor:function(e){return new Ye("floor",e)},ln:function(e){return new Ye("ln",e)},log:function(e){return new Ye("log",e)},log10:function(e){return new Ye("log10",e)},mod:function(e){return new Ye("mod",e)},multiply:function(e){return new Ye("multiply",e)},pow:function(e){return new Ye("pow",e)},sqrt:function(e){return new Ye("sqrt",e)},subtract:function(e){return new Ye("subtract",e)},trunc:function(e){return new Ye("trunc",e)},arrayElemAt:function(e){return new Ye("arrayElemAt",e)},arrayToObject:function(e){return new Ye("arrayToObject",e)},concatArrays:function(e){return new Ye("concatArrays",e)},filter:function(e){return new Ye("filter",e)},in:function(e){return new Ye("in",e)},indexOfArray:function(e){return new Ye("indexOfArray",e)},isArray:function(e){return new Ye("isArray",e)},map:function(e){return new Ye("map",e)},range:function(e){return new Ye("range",e)},reduce:function(e){return new Ye("reduce",e)},reverseArray:function(e){return new Ye("reverseArray",e)},size:function(e){return new Ye("size",e)},slice:function(e){return new Ye("slice",e)},zip:function(e){return new Ye("zip",e)},and:function(e){return new Ye("and",e)},not:function(e){return new Ye("not",e)},or:function(e){return new Ye("or",e)},cmp:function(e){return new Ye("cmp",e)},eq:function(e){return new Ye("eq",e)},gt:function(e){return new Ye("gt",e)},gte:function(e){return new Ye("gte",e)},lt:function(e){return new Ye("lt",e)},lte:function(e){return new Ye("lte",e)},neq:function(e){return new Ye("ne",e)},cond:function(e){return new Ye("cond",e)},ifNull:function(e){return new Ye("ifNull",e)},switch:function(e){return new Ye("switch",e)},dateFromParts:function(e){return new Ye("dateFromParts",e)},dateFromString:function(e){return new Ye("dateFromString",e)},dayOfMonth:function(e){return new Ye("dayOfMonth",e)},dayOfWeek:function(e){return new Ye("dayOfWeek",e)},dayOfYear:function(e){return new Ye("dayOfYear",e)},isoDayOfWeek:function(e){return new Ye("isoDayOfWeek",e)},isoWeek:function(e){return new Ye("isoWeek",e)},isoWeekYear:function(e){return new Ye("isoWeekYear",e)},millisecond:function(e){return new Ye("millisecond",e)},minute:function(e){return new Ye("minute",e)},month:function(e){return new Ye("month",e)},second:function(e){return new Ye("second",e)},hour:function(e){return new Ye("hour",e)},week:function(e){return new Ye("week",e)},year:function(e){return new Ye("year",e)},literal:function(e){return new Ye("literal",e)},mergeObjects:function(e){return new Ye("mergeObjects",e)},objectToArray:function(e){return new Ye("objectToArray",e)},allElementsTrue:function(e){return new Ye("allElementsTrue",e)},anyElementTrue:function(e){return new Ye("anyElementTrue",e)},setDifference:function(e){return new Ye("setDifference",e)},setEquals:function(e){return new Ye("setEquals",e)},setIntersection:function(e){return new Ye("setIntersection",e)},setIsSubset:function(e){return new Ye("setIsSubset",e)},setUnion:function(e){return new Ye("setUnion",e)},concat:function(e){return new Ye("concat",e)},dateToString:function(e){return new Ye("dateToString",e)},indexOfBytes:function(e){return new Ye("indexOfBytes",e)},indexOfCP:function(e){return new Ye("indexOfCP",e)},split:function(e){return new Ye("split",e)},strLenBytes:function(e){return new Ye("strLenBytes",e)},strLenCP:function(e){return new Ye("strLenCP",e)},strcasecmp:function(e){return new Ye("strcasecmp",e)},substr:function(e){return new Ye("substr",e)},substrBytes:function(e){return new Ye("substrBytes",e)},substrCP:function(e){return new Ye("substrCP",e)},toLower:function(e){return new Ye("toLower",e)},toUpper:function(e){return new Ye("toUpper",e)},meta:function(e){return new Ye("meta",e)},addToSet:function(e){return new Ye("addToSet",e)},avg:function(e){return new Ye("avg",e)},first:function(e){return new Ye("first",e)},last:function(e){return new Ye("last",e)},max:function(e){return new Ye("max",e)},min:function(e){return new Ye("min",e)},push:function(e){return new Ye("push",e)},stdDevPop:function(e){return new Ye("stdDevPop",e)},stdDevSamp:function(e){return new Ye("stdDevSamp",e)},sum:function(e){return new Ye("sum",e)},let:function(e){return new Ye("let",e)}},project:{slice:function(e){return new Je("slice",e)},elemMatch:function(e){return new Je("elemMatch",e)}}},Ye=function(e,t){this["$"+e]=t},Je=function(e,t){this["$"+e]=t},ze=function(){function e(e){var t=e.regexp,r=e.options;if(!t)throw new TypeError("regexp must be a string");this.$regex=t,this.$options=r}return e.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(e.prototype,"_internalType",{get:function(){return j},enumerable:!1,configurable:!0}),e}();function $e(e){return new ze(e)}var Qe="insert document failed",Xe="DATABASE_TRANSACTION_CONFLICT",Ze=function(){return Ze=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},Ze.apply(this,arguments)},et=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},tt=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},rt="database.updateDocInTransaction",nt=function(){function e(e,t,r){this._coll=t,this.id=r,this._transaction=e,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.create=function(e){return et(this,void 0,void 0,(function(){var t,r,n,o;return tt(this,(function(i){switch(i.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,data:Fe.EJSON.stringify(Ee(e),{relaxed:!1})},this.id&&(t._id=this.id),[4,this._request.send("database.insertDocInTransaction",t)];case 1:if((r=i.sent()).code)throw r;if(n=Fe.EJSON.parse(r.inserted),1==(o=Fe.EJSON.parse(r.ok))&&1==n)return[2,Ze(Ze({},r),{ok:o,inserted:n})];throw new Error(Qe)}}))}))},e.prototype.get=function(){return et(this,void 0,void 0,(function(){var e,t;return tt(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",e)];case 1:if((t=r.sent()).code)throw t;return[2,{data:"null"!==t.data?re.formatField(Fe.EJSON.parse(t.data)):Fe.EJSON.parse(t.data),requestId:t.requestId}]}}))}))},e.prototype.set=function(e){return et(this,void 0,void 0,(function(){var t,r;return tt(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Fe.EJSON.stringify(Ee(e),{relaxed:!1}),upsert:!0},[4,this._request.send(rt,t)];case 1:if((r=n.sent()).code)throw r;return[2,Ze(Ze({},r),{updated:Fe.EJSON.parse(r.updated),upserted:r.upserted?JSON.parse(r.upserted):null})]}}))}))},e.prototype.update=function(e){return et(this,void 0,void 0,(function(){var t,r;return tt(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Fe.EJSON.stringify(De.encode(e),{relaxed:!1})},[4,this._request.send(rt,t)];case 1:if((r=n.sent()).code)throw r;return[2,Ze(Ze({},r),{updated:Fe.EJSON.parse(r.updated)})]}}))}))},e.prototype.delete=function(){return et(this,void 0,void 0,(function(){var e,t;return tt(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=r.sent()).code)throw t;return[2,Ze(Ze({},t),{deleted:Fe.EJSON.parse(t.deleted)})]}}))}))},e}(),ot=function(){return ot=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},ot.apply(this,arguments)},it=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},st=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},at="database.getInTransaction",ut=function(){function e(e,t,r,n,o){this._coll=t,this._transaction=e,this._fieldFilters=r,this._fieldOrders=n||[],this._queryOptions=o||{},this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return e.prototype.where=function(t){if("Object"!==Object.prototype.toString.call(t).slice(8,-1))throw Error(o.QueryParamTypeError);var r=Object.keys(t),n=r.some((function(e){return void 0!==t[e]}));if(r.length&&!n)throw Error(o.QueryParamValueError);return new e(this._transaction,this._coll,ke.encode(t),this._fieldOrders,this._queryOptions)},e.prototype.orderBy=function(t,r){ne.isFieldPath(t),ne.isFieldOrder(r);var n={field:t,direction:r},o=this._fieldOrders.concat(n);return new e(this._transaction,this._coll,this._fieldFilters,o,this._queryOptions)},e.prototype.limit=function(t){ne.isInteger("limit",t);var r=ot({},this._queryOptions);return r.limit=t,new e(this._transaction,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.skip=function(t){ne.isInteger("offset",t);var r=ot({},this._queryOptions);return r.offset=t,new e(this._transaction,this._coll,this._fieldFilters,this._fieldOrders,r)},e.prototype.field=function(t){for(var r in t)t[r]?"object"!=typeof t[r]&&(t[r]=1):t[r]=0;var n=ot({},this._queryOptions);return n.projection=t,new e(this._transaction,this._coll,this._fieldFilters,this._fieldOrders,n)},e.prototype.get=function(){return it(this,void 0,void 0,(function(){var e,t,r,n,o,i;return st(this,(function(s){switch(s.label){case 0:return e=[],this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)})),t={collectionName:this._coll,transactionId:this._transactionId},this._fieldFilters&&(t.query=this._fieldFilters),e.length>0&&(t.order=e),this._queryOptions.offset&&(t.offset=this._queryOptions.offset),this._queryOptions.limit?t.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:t.limit=100,this._queryOptions.projection&&(t.projection=this._queryOptions.projection),[4,this._request.send(at,t)];case 1:if((r=s.sent()).code)throw r;return n="null"!==r.data?Fe.EJSON.parse(r.data):null,o=n?Array.isArray(n)?re.formatResDocumentData(n):[re.formatField(n)]:[],i={data:o,requestId:r.requestId},void 0!==r.total&&(i.total=r.total),void 0!==r.limit&&(i.limit=r.limit),void 0!==r.offset&&(i.offset=r.offset),[2,i]}}))}))},e.prototype.count=function(){return it(this,void 0,void 0,(function(){var e,t,r,n;return st(this,(function(o){switch(o.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId},this._fieldFilters&&(e.query=this._fieldFilters),[4,this._request.send(at,e)];case 1:if((t=o.sent()).code)throw t;return r="null"!==t.data?Fe.EJSON.parse(t.data):null,n=Array.isArray(r)?r.length:r?1:0,[2,{requestId:t.requestId,total:void 0!==t.total?t.total:n}]}}))}))},e.prototype.update=function(e){return it(this,void 0,void 0,(function(){var t,r;return st(this,(function(n){switch(n.label){case 0:if(!e||"object"!=typeof e)throw new Error("参数必需是非空对象");if(e.hasOwnProperty("_id"))throw new Error("不能更新_id的值");return t={collectionName:this._coll,transactionId:this._transactionId,query:this._fieldFilters,data:Fe.EJSON.stringify(De.encode(e),{relaxed:!1})},[4,this._request.send("database.updateDocInTransaction",t)];case 1:if((r=n.sent()).code)throw r;return[2,ot(ot({},r),{updated:Fe.EJSON.parse(r.updated)})]}}))}))},e.prototype.remove=function(){return it(this,void 0,void 0,(function(){var e,t;return st(this,(function(r){switch(r.label){case 0:return Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation"),e={collectionName:this._coll,transactionId:this._transactionId,query:this._fieldFilters},[4,this._request.send("database.deleteDocInTransaction",e)];case 1:if((t=r.sent()).code)throw t;return[2,ot(ot({},t),{deleted:Fe.EJSON.parse(t.deleted)})]}}))}))},e}(),ct=function(){var e=function(t,r){return e=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])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),lt=function(e){function t(t,r){return e.call(this,t,r)||this}return ct(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),t.prototype.doc=function(e){if("string"!=typeof e&&"number"!=typeof e)throw new Error("docId必须为字符串或数字");return new nt(this._transaction,this._coll,e)},t.prototype.add=function(e){var t;return void 0!==e._id&&(t=e._id),new nt(this._transaction,this._coll,t).create(e)},t}(ut),dt=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},ht=function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ft=function(){function e(e){this._db=e,this._request=yt.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return e.prototype.init=function(){return dt(this,void 0,void 0,(function(){var e;return ht(this,(function(t){switch(t.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((e=t.sent()).code)throw e;return this.inited=!0,this._id=e.transactionId,[2]}}))}))},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new lt(this,e)},e.prototype.getTransactionId=function(){return this._id},e.prototype.getRequestMethod=function(){return this._request},e.prototype.commit=function(){return dt(this,void 0,void 0,(function(){var e,t;return ht(this,(function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.commitTransaction",e)];case 1:if((t=r.sent()).code)throw t;return this.commited=!0,[2,t]}}))}))},e.prototype.rollback=function(e){return dt(this,void 0,void 0,(function(){var t,r;return ht(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.abortTransaction",t)];case 1:if((r=n.sent()).code)throw r;return this.aborted=!0,this.abortReason=e,[2,r]}}))}))},e}();function pt(){return dt(this,void 0,void 0,(function(){var e;return ht(this,(function(t){switch(t.label){case 0:return[4,(e=new ft(this)).init()];case 1:return t.sent(),[2,e]}}))}))}function vt(e,t){return void 0===t&&(t=3),dt(this,void 0,void 0,(function(){var r,n,o,i,s=this;return ht(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(r=new ft(this)).init()];case 1:return a.sent(),[4,e(r)];case 2:if(n=a.sent(),!0===r.aborted)throw r.abortReason;return[4,r.commit()];case 3:return a.sent(),[2,n];case 4:if(o=a.sent(),!1===r.inited)throw o;return i=function(e){return dt(s,void 0,void 0,(function(){return ht(this,(function(t){switch(t.label){case 0:if(r.aborted||r.commited)return[3,5];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.rollback()];case 2:case 3:return t.sent(),[3,4];case 4:throw e;case 5:if(!0===r.aborted)throw r.abortReason;throw e}}))}))},t<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===Xe?[4,vt.bind(this)(e,--t)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}}))}))}var yt=function(){function e(e){this.config=e,this.Geo=i,this.serverDate=Z,this.command=Ke,this.RegExp=$e,this.startTransaction=pt,this.runTransaction=vt,this.logicCommand=ce,this.updateCommand=ae,this.queryCommand=fe}return e.createRequest=function(t){var r=new e.reqClass(t),n=r.send;return r.send=function(e,r){return t.instance&&(r.instance=t.instance),t.database&&(r.database=t.database),n.call(this,e,r)},r},e.prototype.collection=function(e){if(!e)throw new Error("Collection name is required");return new Ve(this,e)},e.prototype.createCollection=function(t){var r={collectionName:t};return e.createRequest(this.config).send("database.addCollection",r)},e}()},3388:function(e){e.exports={}},1012:function(e,t,r){"use strict";var n;if(r.r(t),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis,i="0123456789abcdefghijklmnopqrstuvwxyz";function k(e){return i.charAt(e)}function M(e,t){return e&t}function q(e,t){return e|t}function W(e,t){return e^t}function F(e,t){return e&~t}function B(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function H(e){for(var t=0;0!=e;)e&=e-1,++t;return t}var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function G(e){var t,r,n="";for(t=0;t+3<=e.length;t+=3)r=parseInt(e.substring(t,t+3),16),n+=s.charAt(r>>6)+s.charAt(63&r);for(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=s.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=s.charAt(r>>2)+s.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function V(e){var t,r="",n=0,o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t){var i=s.indexOf(e.charAt(t));i<0||(0==n?(r+=k(i>>2),o=3&i,n=1):1==n?(r+=k(o<<2|i>>4),o=15&i,n=2):2==n?(r+=k(o),r+=k(i>>2),o=3&i,n=3):(r+=k(o<<2|i>>4),r+=k(15&i),n=0))}return 1==n&&(r+=k(o<<2)),r}var a,u,c={decode:function(e){var t;if(void 0===a){var r="0123456789ABCDEF";for(a={},t=0;t<16;++t)a[r.charAt(t)]=t;for(r=r.toLowerCase(),t=10;t<16;++t)a[r.charAt(t)]=t;for(t=0;t<8;++t)a[" \f\n\r\t \u2028\u2029".charAt(t)]=-1}var n=[],o=0,i=0;for(t=0;t<e.length;++t){var s=e.charAt(t);if("="==s)break;if(-1!=(s=a[s])){if(void 0===s)throw new Error("Illegal character at offset "+t);o|=s,++i>=2?(n[n.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return n}},l={decode:function(e){var t;if(void 0===u){for(u=Object.create(null),t=0;t<64;++t)u["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)]=t;for(t=0;t<9;++t)u["= \f\n\r\t \u2028\u2029".charAt(t)]=-1}var r=[],n=0,o=0;for(t=0;t<e.length;++t){var i=e.charAt(t);if("="==i)break;if(-1!=(i=u[i])){if(void 0===i)throw new Error("Illegal character at offset "+t);n|=i,++o>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,o=0):n<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(e){var t=l.re.exec(e);if(t)if(t[1])e=t[1];else{if(!t[2])throw new Error("RegExp out of sync");e=t[2]}return l.decode(e)}},d=1e13;class K{constructor(e){this.buf=[+e||0]}mulAdd(e,t){var r,n,o=this.buf,i=o.length;for(r=0;r<i;++r)(n=o[r]*e+t)<d?t=0:n-=(t=0|n/d)*d,o[r]=n;t>0&&(o[r]=t)}sub(e){var t,r,n=this.buf,o=n.length;for(t=0;t<o;++t)(r=n[t]-e)<0?(r+=d,e=1):e=0,n[t]=r;for(;0===n[n.length-1];)n.pop()}toString(e){if(10!=(e||10))throw new Error("only base 10 is supported");for(var t=this.buf,r=t[t.length-1].toString(),n=t.length-2;n>=0;--n)r+=(d+t[n]).toString().substring(1);return r}valueOf(){for(var e=this.buf,t=0,r=e.length-1;r>=0;--r)t=t*d+e[r];return t}simplify(){var e=this.buf;return 1==e.length?e[0]:this}}var h,f=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,p=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Y(e,t){return e.length>t&&(e=e.substring(0,t)+"…"),e}class J{constructor(e,t){this.hexDigits="0123456789ABCDEF",e instanceof J?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=t)}get(e){if(void 0===e&&(e=this.pos++),e>=this.enc.length)throw new Error("Requesting byte offset "+e+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(e):this.enc[e]}hexByte(e){return this.hexDigits.charAt(e>>4&15)+this.hexDigits.charAt(15&e)}hexDump(e,t,r){for(var n="",o=e;o<t;++o)if(n+=this.hexByte(this.get(o)),!0!==r)switch(15&o){case 7:n+=" ";break;case 15:n+="\n";break;default:n+=" "}return n}isASCII(e,t){for(var r=e;r<t;++r){var n=this.get(r);if(n<32||n>176)return!1}return!0}parseStringISO(e,t){for(var r="",n=e;n<t;++n)r+=String.fromCharCode(this.get(n));return r}parseStringUTF(e,t){for(var r="",n=e;n<t;){var o=this.get(n++);r+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(n++)):String.fromCharCode((15&o)<<12|(63&this.get(n++))<<6|63&this.get(n++))}return r}parseStringBMP(e,t){for(var r,n,o="",i=e;i<t;)r=this.get(i++),n=this.get(i++),o+=String.fromCharCode(r<<8|n);return o}parseTime(e,t,r){var n=this.parseStringISO(e,t),o=(r?f:p).exec(n);return o?(r&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),n=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(n+=":"+o[5],o[6]&&(n+=":"+o[6],o[7]&&(n+="."+o[7]))),o[8]&&(n+=" UTC","Z"!=o[8]&&(n+=o[8],o[9]&&(n+=":"+o[9]))),n):"Unrecognized time: "+n}parseInteger(e,t){for(var r,n=this.get(e),o=n>127,i=o?255:0,s="";n==i&&++e<t;)n=this.get(e);if(0==(r=t-e))return o?-1:0;if(r>4){for(s=n,r<<=3;!(128&(+s^i));)s=+s<<1,--r;s="("+r+" bit)\n"}o&&(n-=256);for(var a=new K(n),u=e+1;u<t;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(e,t,r){for(var n=this.get(e),o="("+((t-e-1<<3)-n)+" bit)\n",i="",s=e+1;s<t;++s){for(var a=this.get(s),u=s==t-1?n:0,c=7;c>=u;--c)i+=a>>c&1?"1":"0";if(i.length>r)return o+Y(i,r)}return o+i}parseOctetString(e,t,r){if(this.isASCII(e,t))return Y(this.parseStringISO(e,t),r);var n=t-e,o="("+n+" byte)\n";n>(r/=2)&&(t=e+r);for(var i=e;i<t;++i)o+=this.hexByte(this.get(i));return n>r&&(o+="…"),o}parseOID(e,t,r){for(var n="",o=new K,i=0,s=e;s<t;++s){var a=this.get(s);if(o.mulAdd(128,127&a),i+=7,!(128&a)){if(""===n)if((o=o.simplify())instanceof K)o.sub(80),n="2."+o.toString();else{var u=o<80?o<40?0:1:2;n=u+"."+(o-40*u)}else n+="."+o.toString();if(n.length>r)return Y(n,r);o=new K,i=0}}return i>0&&(n+=".incomplete"),n}}class z{constructor(e,t,r,n,o){if(!(n instanceof $))throw new Error("Invalid tag value.");this.stream=e,this.header=t,this.length=r,this.tag=n,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(e){if(void 0===this.tag)return null;void 0===e&&(e=1/0);var t=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(t)?"false":"true";case 2:return this.stream.parseInteger(t,t+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(t,t+r,e);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(t,t+r,e);case 6:return this.stream.parseOID(t,t+r,e);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(t,t+r),e);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(t,t+r),e);case 30:return Y(this.stream.parseStringBMP(t,t+r),e);case 23:case 24:return this.stream.parseTime(t,t+r,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(e){void 0===e&&(e="");var t=e+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(t+="+"),t+=this.length,this.tag.tagConstructed?t+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(t+=" (encapsulates)"),t+="\n",null!==this.sub){e+=" ";for(var r=0,n=this.sub.length;r<n;++r)t+=this.sub[r].toPrettyString(e)}return t}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(e){var t=e.get(),r=127&t;if(r==t)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(e.pos-1));if(0===r)return null;t=0;for(var n=0;n<r;++n)t=256*t+e.get();return t}getHexStringValue(){var e=this.toHexString(),t=2*this.header,r=2*this.length;return e.substr(t,r)}static decode(e){var t;t=e instanceof J?e:new J(e,0);var r=new J(t),n=new $(t),o=z.decodeLength(t),i=t.pos,s=i-r.pos,a=null,u=function(){var e=[];if(null!==o){for(var r=i+o;t.pos<r;)e[e.length]=z.decode(t);if(t.pos!=r)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var n=z.decode(t);if(n.tag.isEOC())break;e[e.length]=n}o=i-t.pos}catch(e){throw new Error("Exception while decoding undefined length content: "+e)}return e};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=t.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(e){a=null}if(null===a){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+i);t.pos=i+Math.abs(o)}return new z(r,s,o,n,a)}}class ${constructor(e){var t=e.get();if(this.tagClass=t>>6,this.tagConstructed=!!(32&t),this.tagNumber=31&t,31==this.tagNumber){var r=new K;do{t=e.get(),r.mulAdd(128,127&t)}while(128&t);this.tagNumber=r.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var v=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],y=(1<<26)/v[v.length-1];class Q{constructor(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}toString(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(o=!0,i=k(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(o=!0),o&&(i+=k(r));return o?i:"0"}negate(){var e=X();return Q.ZERO.subTo(this,e),e}abs(){return this.s<0?this.negate():this}compareTo(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+ie(this[this.t-1]^this.s&this.DM)}mod(e){var t=X();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(Q.ZERO)>0&&e.subTo(t,t),t}modPowInt(e,t){var r;return r=e<256||t.isEven()?new g(t):new b(t),this.exp(e,r)}clone(){var e=X();return this.copyTo(e),e}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var e=this.t,t=[];t[0]=this.s;var r,n=this.DB-e*this.DB%8,o=0;if(e-- >0)for(n<this.DB&&(r=this[e]>>n)!=(this.s&this.DM)>>n&&(t[o++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this[e]&(1<<n)-1)<<8-n,r|=this[--e]>>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&r&&(r|=-256),0==o&&(128&this.s)!=(128&r)&&++o,(o>0||r!=this.s)&&(t[o++]=r);return t}equals(e){return 0==this.compareTo(e)}min(e){return this.compareTo(e)<0?this:e}max(e){return this.compareTo(e)>0?this:e}and(e){var t=X();return this.bitwiseTo(e,M,t),t}or(e){var t=X();return this.bitwiseTo(e,q,t),t}xor(e){var t=X();return this.bitwiseTo(e,W,t),t}andNot(e){var t=X();return this.bitwiseTo(e,F,t),t}not(){for(var e=X(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e}shiftLeft(e){var t=X();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}shiftRight(e){var t=X();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}getLowestSetBit(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+B(this[e]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=H(this[r]^t);return e}testBit(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)}setBit(e){return this.changeBit(e,q)}clearBit(e){return this.changeBit(e,F)}flipBit(e){return this.changeBit(e,W)}add(e){var t=X();return this.addTo(e,t),t}subtract(e){var t=X();return this.subTo(e,t),t}multiply(e){var t=X();return this.multiplyTo(e,t),t}divide(e){var t=X();return this.divRemTo(e,t,null),t}remainder(e){var t=X();return this.divRemTo(e,null,t),t}divideAndRemainder(e){var t=X(),r=X();return this.divRemTo(e,t,r),[t,r]}modPow(e,t){var r,n,o=e.bitLength(),i=oe(1);if(o<=0)return i;r=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new g(t):t.isEven()?new _(t):new b(t);var s=[],a=3,u=r-1,c=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=X();for(n.sqrTo(s[1],l);a<=c;)s[a]=X(),n.mulTo(l,s[a-2],s[a]),a+=2}var d,h,f=e.t-1,p=!0,v=X();for(o=ie(e[f])-1;f>=0;){for(o>=u?d=e[f]>>o-u&c:(d=(e[f]&(1<<o+1)-1)<<u-o,f>0&&(d|=e[f-1]>>this.DB+o-u)),a=r;!(1&d);)d>>=1,--a;if((o-=a)<0&&(o+=this.DB,--f),p)s[d].copyTo(i),p=!1;else{for(;a>1;)n.sqrTo(i,v),n.sqrTo(v,i),a-=2;a>0?n.sqrTo(i,v):(h=i,i=v,v=h),n.mulTo(v,s[d],i)}for(;f>=0&&!(e[f]&1<<o);)n.sqrTo(i,v),h=i,i=v,v=h,--o<0&&(o=this.DB-1,--f)}return n.revert(i)}modInverse(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return Q.ZERO;for(var r=e.clone(),n=this.clone(),o=oe(1),i=oe(0),s=oe(0),a=oe(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(e,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(e,i),i.rShiftTo(1,i);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),t&&o.subTo(s,o),i.subTo(a,i)):(n.subTo(r,n),t&&s.subTo(o,s),a.subTo(i,a))}return 0!=n.compareTo(Q.ONE)?Q.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a}pow(e){return this.exp(e,new m)}gcd(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var o=t.getLowestSetBit(),i=r.getLowestSetBit();if(i<0)return t;for(o<i&&(i=o),i>0&&(t.rShiftTo(i,t),r.rShiftTo(i,r));t.signum()>0;)(o=t.getLowestSetBit())>0&&t.rShiftTo(o,t),(o=r.getLowestSetBit())>0&&r.rShiftTo(o,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return i>0&&r.lShiftTo(i,r),r}isProbablePrime(e){var t,r=this.abs();if(1==r.t&&r[0]<=v[v.length-1]){for(t=0;t<v.length;++t)if(r[0]==v[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<v.length;){for(var n=v[t],o=t+1;o<v.length&&n<y;)n*=v[o++];for(n=r.modInt(n);t<o;)if(n%v[t++]==0)return!1}return r.millerRabin(e)}copyTo(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}fromInt(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0}fromString(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,o=!1,i=0;--n>=0;){var s=8==r?255&+e[n]:ne(e,n);s<0?"-"==e.charAt(n)&&(o=!0):(o=!1,0==i?this[this.t++]=s:i+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,(i+=r)>=this.DB&&(i-=this.DB))}8==r&&128&+e[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&Q.ZERO.subTo(this,this)}clamp(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t}dlShiftTo(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}drShiftTo(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s}lShiftTo(e,t){for(var r=e%this.DB,n=this.DB-r,o=(1<<n)-1,i=Math.floor(e/this.DB),s=this.s<<r&this.DM,a=this.t-1;a>=0;--a)t[a+i+1]=this[a]>>n|s,s=(this[a]&o)<<r;for(a=i-1;a>=0;--a)t[a]=0;t[i]=s,t.t=this.t+i+1,t.s=this.s,t.clamp()}rShiftTo(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,o=this.DB-n,i=(1<<n)-1;t[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)t[s-r-1]|=(this[s]&i)<<o,t[s-r]=this[s]>>n;n>0&&(t[this.t-r-1]|=(this.s&i)<<o),t.t=this.t-r,t.clamp()}}subTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}multiplyTo(e,t){var r=this.abs(),n=e.abs(),o=r.t;for(t.t=o+n.t;--o>=0;)t[o]=0;for(o=0;o<n.t;++o)t[o+r.t]=r.am(0,n[o],t,o,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&Q.ZERO.subTo(t,t)}squareTo(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}divRemTo(e,t,r){var n=e.abs();if(!(n.t<=0)){var o=this.abs();if(o.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=X());var i=X(),s=this.s,a=e.s,u=this.DB-ie(n[n.t-1]);u>0?(n.lShiftTo(u,i),o.lShiftTo(u,r)):(n.copyTo(i),o.copyTo(r));var c=i.t,l=i[c-1];if(0!=l){var d=l*(1<<this.F1)+(c>1?i[c-2]>>this.F2:0),h=this.FV/d,f=(1<<this.F1)/d,p=1<<this.F2,v=r.t,y=v-c,m=null==t?X():t;for(i.dlShiftTo(y,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),Q.ONE.dlShiftTo(c,m),m.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--y>=0;){var g=r[--v]==l?this.DM:Math.floor(r[v]*h+(r[v-1]+p)*f);if((r[v]+=i.am(0,g,r,y,0,c))<g)for(i.dlShiftTo(y,m),r.subTo(m,r);r[v]<--g;)r.subTo(m,r)}null!=t&&(r.drShiftTo(c,t),s!=a&&Q.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),s<0&&Q.ZERO.subTo(r,r)}}}invDigit(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(e,t){if(e>4294967295||e<1)return Q.ONE;var r=X(),n=X(),o=t.convert(this),i=ie(e)-1;for(o.copyTo(r);--i>=0;)if(t.sqrTo(r,n),(e&1<<i)>0)t.mulTo(n,o,r);else{var s=r;r=n,n=s}return t.revert(r)}chunkSize(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}toRadix(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=oe(r),o=X(),i=X(),s="";for(this.divRemTo(n,o,i);o.signum()>0;)s=(r+i.intValue()).toString(e).substr(1)+s,o.divRemTo(n,o,i);return i.intValue().toString(e)+s}fromRadix(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),o=!1,i=0,s=0,a=0;a<e.length;++a){var u=ne(e,a);u<0?"-"==e.charAt(a)&&0==this.signum()&&(o=!0):(s=t*s+u,++i>=r&&(this.dMultiply(n),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(t,i)),this.dAddOffset(s,0)),o&&Q.ZERO.subTo(this,this)}fromNumber(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(Q.ONE.shiftLeft(e-1),q,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(Q.ONE.shiftLeft(e-1),this);else{var n=[],o=7&e;n.length=1+(e>>3),t.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}}bitwiseTo(e,t,r){var n,o,i=Math.min(e.t,this.t);for(n=0;n<i;++n)r[n]=t(this[n],e[n]);if(e.t<this.t){for(o=e.s&this.DM,n=i;n<this.t;++n)r[n]=t(this[n],o);r.t=this.t}else{for(o=this.s&this.DM,n=i;n<e.t;++n)r[n]=t(o,e[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()}changeBit(e,t){var r=Q.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r}addTo(e,t){for(var r=0,n=0,o=Math.min(e.t,this.t);r<o;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()}dMultiply(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}}multiplyLowerTo(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(var o=r.t-this.t;n<o;++n)r[n+this.t]=this.am(0,e[n],r,n,0,this.t);for(o=Math.min(e.t,t);n<o;++n)this.am(0,e[n],r,n,0,t-n);r.clamp()}multiplyUpperTo(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r[this.t+n-t]=this.am(t-n,e[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)}modInt(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r}millerRabin(e){var t=this.subtract(Q.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>v.length&&(e=v.length);for(var o=X(),i=0;i<e;++i){o.fromInt(v[Math.floor(Math.random()*v.length)]);var s=o.modPow(n,this);if(0!=s.compareTo(Q.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(Q.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0}square(){var e=X();return this.squareTo(e),e}gcda(e,t){var r=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(r.compareTo(n)<0){var o=r;r=n,n=o}var i=r.getLowestSetBit(),s=n.getLowestSetBit();if(s<0)t(r);else{i<s&&(s=i),s>0&&(r.rShiftTo(s,r),n.rShiftTo(s,n));var a=()=>{(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),r.compareTo(n)>=0?(r.subTo(n,r),r.rShiftTo(1,r)):(n.subTo(r,n),n.rShiftTo(1,n)),r.signum()>0?setTimeout(a,0):(s>0&&n.lShiftTo(s,n),setTimeout((function(){t(n)}),0))};setTimeout(a,10)}}fromNumberAsync(e,t,r,n){if("number"==typeof t)if(e<2)this.fromInt(1);else{this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(Q.ONE.shiftLeft(e-1),q,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(Q.ONE.shiftLeft(e-1),o),o.isProbablePrime(t)?setTimeout((function(){n()}),0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&e;s.length=1+(e>>3),t.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var m=function(){function e(){}return e.prototype.convert=function(e){return e},e.prototype.revert=function(e){return e},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},e.prototype.sqrTo=function(e,t){e.squareTo(t)},e}(),g=function(){function e(e){this.m=e}return e.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),b=function(){function e(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}return e.prototype.convert=function(e){var t=X();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(Q.ZERO)>0&&this.m.subTo(t,t),t},e.prototype.revert=function(e){var t=X();return e.copyTo(t),this.reduce(t),t},e.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}(),_=function(){function e(e){this.m=e,this.r2=X(),this.q3=X(),Q.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e)}return e.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=X();return e.copyTo(t),this.reduce(t),t},e.prototype.revert=function(e){return e},e.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},e.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},e.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},e}();function X(){return new Q(null)}function Z(e,t){return new Q(e,t)}function ee(e,t,r,n,o,i){for(;--i>=0;){var s=t*this[e++]+r[n]+o;o=Math.floor(s/67108864),r[n++]=67108863&s}return o}function te(e,t,r,n,o,i){for(var s=32767&t,a=t>>15;--i>=0;){var u=32767&this[e],c=this[e++]>>15,l=a*u+c*s;o=((u=s*u+((32767&l)<<15)+r[n]+(1073741823&o))>>>30)+(l>>>15)+a*c+(o>>>30),r[n++]=1073741823&u}return o}function re(e,t,r,n,o,i){for(var s=16383&t,a=t>>14;--i>=0;){var u=16383&this[e],c=this[e++]>>14,l=a*u+c*s;o=((u=s*u+((16383&l)<<14)+r[n]+o)>>28)+(l>>14)+a*c,r[n++]=268435455&u}return o}void 0!==o&&"Microsoft Internet Explorer"==(null==o?void 0:o.appName)?(Q.prototype.am=te,h=30):"Netscape"!=(null==o?void 0:o.appName)?(Q.prototype.am=ee,h=26):(Q.prototype.am=re,h=28),Q.prototype.DB=h,Q.prototype.DM=(1<<h)-1,Q.prototype.DV=1<<h,Q.prototype.FV=Math.pow(2,52),Q.prototype.F1=52-h,Q.prototype.F2=2*h-52;var w,E,I=[];for(w="0".charCodeAt(0),E=0;E<=9;++E)I[w++]=E;for(w="a".charCodeAt(0),E=10;E<36;++E)I[w++]=E;for(w="A".charCodeAt(0),E=10;E<36;++E)I[w++]=E;function ne(e,t){var r=I[e.charCodeAt(t)];return null==r?-1:r}function oe(e){var t=X();return t.fromInt(e),t}function ie(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}Q.ZERO=oe(0),Q.ONE=oe(1);class se{constructor(){this.i=0,this.j=0,this.S=[]}init(e){var t,r,n;for(t=0;t<256;++t)this.S[t]=t;for(r=0,t=0;t<256;++t)r=r+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[r],this.S[r]=n;this.i=0,this.j=0}next(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]}}var S,O,A=null;if(null==A){A=[],O=0;var T,P,R=void 0;if("undefined"!=typeof window&&null!==(T=window)&&void 0!==T&&T.crypto&&null!==(P=window)&&void 0!==P&&P.crypto.getRandomValues){var C,N=new Uint32Array(256);for(null===(C=window)||void 0===C||C.crypto.getRandomValues(N),R=0;R<N.length;++R)A[O++]=255&N[R]}var D,U,x,L=function(e){var t,r,n;if(this.count=this.count||0,this.count>=256||O>=256){if("undefined"!=typeof window)if(null!==(t=window)&&void 0!==t&&t.removeEventListener)null===(n=window)||void 0===n||n.removeEventListener("mousemove",L,!1);else if(null!==(r=window)&&void 0!==r&&r.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",L)}}else try{var i=e.x+e.y;A[O++]=255&i,this.count+=1}catch(e){}};if("undefined"!=typeof window)if(null!==(D=window)&&void 0!==D&&D.addEventListener)null===(x=window)||void 0===x||x.addEventListener("mousemove",L,!1);else if(null!==(U=window)&&void 0!==U&&U.attachEvent){var j;null===(j=window)||void 0===j||j.attachEvent("onmousemove",L)}}function ae(){if(null==S){for(S=new se;O<256;){var e=Math.floor(65536*Math.random());A[O++]=255&e}for(S.init(A),O=0;O<A.length;++O)A[O]=0;O=0}return S.next()}class ue{constructor(){}nextBytes(e){for(var t=0;t<e.length;++t)e[t]=ae()}}function ce(e,t){if(t<e.length+11)return console.error("Message too long for RSA"),null;for(var r=[],n=e.length-1;n>=0&&t>0;){var o=e.charCodeAt(n--);o<128?r[--t]=o:o>127&&o<2048?(r[--t]=63&o|128,r[--t]=o>>6|192):(r[--t]=63&o|128,r[--t]=o>>6&63|128,r[--t]=o>>12|224)}r[--t]=0;for(var i=new ue,s=[];t>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);r[--t]=s[0]}return r[--t]=2,r[--t]=0,new Q(r)}class le{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(e){return e.modPowInt(this.e,this.n)}doPrivate(e){if(null==this.p||null==this.q)return e.modPow(this.d,this.n);for(var t=e.mod(this.p).modPow(this.dmp1,this.p),r=e.mod(this.q).modPow(this.dmq1,this.q);t.compareTo(r)<0;)t=t.add(this.p);return t.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)}setPublic(e,t){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Z(e,16),this.e=parseInt(t,16)):console.error("Invalid RSA public key")}encrypt(e){var t=ce(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n}encryptLong(e){var t=this,r=(this.n.bitLength()+7>>3)-11;try{var n="";return e.length>r?(e.match(/.{1,117}/g).forEach((function(e){var r=t.encrypt(e);n+=r})),G(n)):G(this.encrypt(e))}catch(e){return!1}}decryptLong(e){var t=this,r=this.n.bitLength()+7>>3;e=V(e);try{if(e.length>r){var n="";return e.match(/.{1,256}/g).forEach((function(e){var r=t.decrypt(e);n+=r})),n}return this.decrypt(e)}catch(e){return!1}}setPrivate(e,t,r){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Z(e,16),this.e=parseInt(t,16),this.d=Z(r,16)):console.error("Invalid RSA private key")}setPrivateEx(e,t,r,n,o,i,s,a){null!=e&&null!=t&&e.length>0&&t.length>0?(this.n=Z(e,16),this.e=parseInt(t,16),this.d=Z(r,16),this.p=Z(n,16),this.q=Z(o,16),this.dmp1=Z(i,16),this.dmq1=Z(s,16),this.coeff=Z(a,16)):console.error("Invalid RSA private key")}generate(e,t){var r=new ue,n=e>>1;this.e=parseInt(t,16);for(var o=new Q(t,16);;){for(;this.p=new Q(e-n,1,r),0!=this.p.subtract(Q.ONE).gcd(o).compareTo(Q.ONE)||!this.p.isProbablePrime(10););for(;this.q=new Q(n,1,r),0!=this.q.subtract(Q.ONE).gcd(o).compareTo(Q.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q,this.q=i}var s=this.p.subtract(Q.ONE),a=this.q.subtract(Q.ONE),u=s.multiply(a);if(0==u.gcd(o).compareTo(Q.ONE)){this.n=this.p.multiply(this.q),this.d=o.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(e){var t=Z(e,16),r=this.doPrivate(t);return null==r?null:de(r,this.n.bitLength()+7>>3)}generateAsync(e,t,r){var n=new ue,o=e>>1;this.e=parseInt(t,16);var i=new Q(t,16),s=this,a=()=>{var t=()=>{if(s.p.compareTo(s.q)<=0){var e=s.p;s.p=s.q,s.q=e}var t=s.p.subtract(Q.ONE),n=s.q.subtract(Q.ONE),o=t.multiply(n);0==o.gcd(i).compareTo(Q.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(t),s.dmq1=s.d.mod(n),s.coeff=s.q.modInverse(s.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},u=()=>{s.q=X(),s.q.fromNumberAsync(o,1,n,(function(){s.q.subtract(Q.ONE).gcda(i,(function(e){0==e.compareTo(Q.ONE)&&s.q.isProbablePrime(10)?setTimeout(t,0):setTimeout(u,0)}))}))},c=()=>{s.p=X(),s.p.fromNumberAsync(e-o,1,n,(function(){s.p.subtract(Q.ONE).gcda(i,(function(e){0==e.compareTo(Q.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)}))}))};setTimeout(c,0)};setTimeout(a,0)}}function de(e,t){for(var r=e.toByteArray(),n=0;n<r.length&&0==r[n];)++n;if(r.length-n!=t-1||2!=r[n])return null;for(++n;0!=r[n];)if(++n>=r.length)return null;for(var o="";++n<r.length;){var i=255&r[n];i<128?o+=String.fromCharCode(i):i>191&&i<224?(o+=String.fromCharCode((31&i)<<6|63&r[n+1]),++n):(o+=String.fromCharCode((15&i)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return o}class he extends le{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),e&&("string"==typeof e?this.parseKey(e):(this.hasPrivateKeyProperty(e)||this.hasPublicKeyProperty(e))&&this.parsePropertiesFrom(e))}parseKey(e){try{var t=0,r=0,n=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e)?c.decode(e):l.unarmor(e),o=z.decode(n);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){t=o.sub[1].getHexStringValue(),this.n=Z(t,16),r=o.sub[2].getHexStringValue(),this.e=parseInt(r,16);var i=o.sub[3].getHexStringValue();this.d=Z(i,16);var s=o.sub[4].getHexStringValue();this.p=Z(s,16);var a=o.sub[5].getHexStringValue();this.q=Z(a,16);var u=o.sub[6].getHexStringValue();this.dmp1=Z(u,16);var d=o.sub[7].getHexStringValue();this.dmq1=Z(d,16);var h=o.sub[8].getHexStringValue();this.coeff=Z(h,16)}else{if(2!==o.sub.length)return!1;var f=o.sub[1].sub[0];t=f.sub[0].getHexStringValue(),this.n=Z(t,16),r=f.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(e){return!1}}hasPublicKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")}hasPrivateKeyProperty(e){return(e=e||{}).hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")}parsePropertiesFrom(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)}}(n=function(e){e=e||{},this.default_key_size=parseInt(e.default_key_size,10)||1024,this.default_public_exponent=e.default_public_exponent||"010001",this.log=e.log||!1,this.key=null}).prototype.setKey=function(e){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new he(e)},n.prototype.setPrivateKey=function(e){this.setKey(e)},n.prototype.setPublicKey=function(e){this.setKey(e)},n.prototype.decrypt=function(e){try{return this.getKey().decrypt(V(e))}catch(e){return!1}},n.prototype.encrypt=function(e){try{return G(this.getKey().encrypt(e))}catch(e){return!1}},n.prototype.encryptLong=function(e){try{for(var t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",n=0,o=/null$/g;o.test(r)&&(n++,t=this.getKey().encryptLong(e)||"",r=this.getKey().decryptLong(t)||"",!(n>10)););return t}catch(e){return!1}},n.prototype.getKey=function(e){if(!this.key){if(this.key=new he,e&&"[object Function]"==={}.toString.call(e))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,e);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.version="3.1.4"}t.default=n},8182: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.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var a,u=s(r(4274)),c=r(3616);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(a=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,c.isArray)(e)?e:[e];r<o.length;r++){var i=o[r],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:n({isMatch:s},a(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:n({},u.genAdapter()),runtime:a.WEB}}},4274:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=r(2764),c=r(3616),l=r(2946),d=function(e){function t(t){var r=e.call(this)||this,n=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,r=e.file,n=e.name,o=e.method,s=e.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(t).forEach((function(e){c.append(e,t[e])})),c.append("key",n),c.append("file",r),this.request(i(i({},e),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:a,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return s(this,void 0,void 0,(function(){var t,r,n,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=s.sent().data,r=window.URL.createObjectURL(new Blob([t])),n=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return s(this,void 0,void 0,(function(){var r,n,o,u,c,l,d,h,f,p,v,y,m,g=this;return a(this,(function(b){switch(b.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,u=void 0!==o&&o,c=e.stream,l=void 0!==c&&c,d=e.signal,h=e.timeout,f=e.shouldThrowOnError,p=void 0===f||f,v=null!=h?h:this.timeout,d&&(d.aborted&&r.abort(),d.addEventListener("abort",(function(){return r.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(g.timeoutMsg),r.abort(new Error(g.timeoutMsg))}),v)),[4,fetch(n,i(i({},e),{signal:r.signal})).then((function(e){return s(g,void 0,void 0,(function(){var t,r,n;return a(this,(function(o){switch(o.label){case 0:return clearTimeout(y),p?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(y),p)return Promise.reject(e)}))];case 1:return m=b.sent(),[2,{data:l?m.body:(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers}]}}))}))},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,s,a=e.url,u=e.headers,d=void 0===u?{}:u,h=e.data,f=e.responseType,p=e.withCredentials,v=e.body,y=e.onUploadProgress,m=(0,c.formatUrl)((0,l.getProtocol)(),a,"get"===n?h:{}),g=new XMLHttpRequest;g.open(n,m),f&&(g.responseType=f),Object.keys(d).forEach((function(e){g.setRequestHeader(e,d[e])})),y&&g.upload.addEventListener("progress",y),g.onreadystatechange=function(){var e={};if(4===g.readyState){var t=g.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};t.forEach((function(e){var t=e.split(": "),n=t.shift().toLowerCase(),o=t.join(": ");r[n]=o})),e.header=r,e.statusCode=g.status;try{e.data="blob"===f?g.response:JSON.parse(g.responseText)}catch(t){e.data="blob"===f?g.response:g.responseText}clearTimeout(i),o(e)}},t&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),g.abort()}),r.timeout)),s=(0,c.isFormData)(h)?h:"application/x-www-form-urlencoded"===d["content-type"]?(0,c.toQueryString)(h):v||(h?JSON.stringify(h):void 0),p&&(g.withCredentials=!0),g.send(s)}))},t}(u.AbstractSDKRequest);t.WebRequest=d,t.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage:localStorage}}},2946:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var r="@cloudbase/js-sdk";t.setSdkName=function(e){r=e},t.getSdkName=function(){return r};var n="https:";t.setProtocol=function(e){n=e},t.getProtocol=function(){return n},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},6205:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},794:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(r(2946),t),o(r(6205),t),t.OATUH_LOGINTYPE="constants"},7718: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{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=r(3616),s=r(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,s=t.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),d=s.findIndex((function(e){return u.test(e)}));if(-1!==d){var h=s.filter((function(e,t){return t>d}));h.unshift(s[d].replace(l,"".concat(r,".").concat(n)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,a=e.customInfo,d=void 0===a?{}:a,h=e.title,f=e.messages,p=void 0===f?[]:f;return function(e,t,a){if(s.IS_DEBUG_MODE){var f=d.className||e.constructor.name,v=d.methodName||t,y=a.value,m=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex((function(e){return u.test(e)}));if(-1!==r){var n=c.exec(t[r+1]||"");e=n?n[0]:""}return e}();a.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l({err:new Error,className:f,methodName:v,sourceLink:m});try{return y.apply(this,e)}catch(e){var n=e,o=e.message,s=e.error,a=e.error_description,u={title:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(r?(r.code=c.code,r.msg=c.msg):(e.code=c.code,e.message=c.msg),n=r||e,u.content=p.map((function(e){return{type:"info",body:e}})))}throw s&&a&&(u.subtitle=a,r?(r.code=s,r.msg=a):(e.code=s,e.message=a),n=r||e,u.content=p.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(u),n}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){var t,r,n,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:t=l({err:new Error,className:f,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,y.apply(this,e)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,s=r.message,a=r.error,u=r.error_description,c={title:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:r}]},s&&/^\{.*\}$/.test(s)&&(d=JSON.parse(s),c.subtitle=d,d.code&&(t?(t.code=d.code,t.message=d.msg):(r.code=d.code,r.message=d.msg),n=t||r,c.content=p.map((function(e){return{type:"info",body:e}})))),a&&u&&(c.subtitle=u,t?(t.code=a,t.msg=u):(r.code=a,r.message=u),n=t||r,c.content=p.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(c),n;case 4:return[2]}}))}))}}}}},141:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(7718),t)},6197:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{u(n.next(e))}catch(e){i(e)}}function a(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var a=r(2764),u=r(3616),c=r(794),l=function(e){function t(t){var r=e.call(this)||this;return r.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),r}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(a.AbstractStorage),d=function(){function e(e){this.keys={};var t=e.persistence,r=e.platformInfo,n=void 0===r?{}:r,o=e.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(c.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new l(t.root));case"none":return new l(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(n))}catch(e){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,r){return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var r;return i(this,void 0,void 0,(function(){var n;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(n=o.sent())&&n.indexOf(t)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();t.CloudbaseCache=d},9689:function(e,t,r){"use strict";var n,o=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),i=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var s=r(3616),a=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=a;var u=function(e){function t(t,r){var n=e.call(this,"error",{error:t,data:r})||this;return n.error=t,n}return o(t,e),t}(a);t.IErrorEvent=u;var c=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,r){r[e]=r[e]||[],r[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,r){if(null==r?void 0:r[e]){var n=r[e].indexOf(t);-1!==n&&r[e].splice(n,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,s.isInstanceOf)(e,u))return console.error(e.error),this;var r=(0,s.isString)(e)?new a(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,c=this.listeners[n]?i([],this.listeners[n],!0):[];o<c.length;o++)c[o].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=c;var l=new c;t.addEventListener=function(e,t){l.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),l.fire(e,t)},t.removeEventListener=function(e,t){l.off(e,t)}},3616:function(e,t,r){"use strict";var n=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=r(794);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)}))},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach((function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))})),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise((function(t,r){e=function(e,n){return e?r(e):t(n)}}));return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,s=void 0===i?[]:i,a=e.printTrace,u=void 0!==a&&a,c=e.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,d=s;l<d.length;l++){var h=d[l],f=h.type,p=h.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach((function(e){var r=e.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(t[n]?Array.isArray(t[n])?t[n].push(o):t[n]=[t[n],o]:t[n]=o)})),t},t.parseCaptcha=function(e){var r={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(r=(0,t.parseQueryString)(i))}var s=r.token,a=n(r,["token"]);return/^data:/.test(e)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:s?{state:a.state,token:s,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},9515:function(e,t,r){var n=r(8761)(r(7772),"DataView");e.exports=n},9612:function(e,t,r){var n=r(2118),o=r(6909),i=r(8138),s=r(4174),a=r(7942);function u(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])}}u.prototype.clear=n,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,e.exports=u},235:function(e,t,r){var n=r(3945),o=r(1846),i=r(8028),s=r(6018),a=r(4769);function u(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])}}u.prototype.clear=n,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,e.exports=u},326:function(e,t,r){var n=r(8761)(r(7772),"Map");e.exports=n},6738:function(e,t,r){var n=r(2411),o=r(6417),i=r(6928),s=r(9493),a=r(4150);function u(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])}}u.prototype.clear=n,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,e.exports=u},2760:function(e,t,r){var n=r(8761)(r(7772),"Promise");e.exports=n},2143:function(e,t,r){var n=r(8761)(r(7772),"Set");e.exports=n},6571:function(e,t,r){var n=r(235),o=r(5243),i=r(2858),s=r(4417),a=r(8605),u=r(1418);function c(e){var t=this.__data__=new n(e);this.size=t.size}c.prototype.clear=o,c.prototype.delete=i,c.prototype.get=s,c.prototype.has=a,c.prototype.set=u,e.exports=c},857:function(e,t,r){var n=r(7772).Symbol;e.exports=n},9162:function(e,t,r){var n=r(7772).Uint8Array;e.exports=n},3215:function(e,t,r){var n=r(8761)(r(7772),"WeakMap");e.exports=n},2517:function(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:function(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:function(e,t,r){var n=r(6473),o=r(9631),i=r(6152),s=r(3226),a=r(9045),u=r(7598),c=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&&u(e),f=r||l||d||h,p=f?n(e.length,String):[],v=p.length;for(var y in e)!t&&!c.call(e,y)||f&&("length"==y||d&&("offset"==y||"parent"==y)||h&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||a(y,v))||p.push(y);return p}},343:function(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:function(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:function(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:function(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:function(e,t,r){var n=r(752),o=r(249);e.exports=function(e,t){return e&&n(t,o(t),e)}},5906:function(e,t,r){var n=r(752),o=r(8582);e.exports=function(e,t){return e&&n(t,o(t),e)}},3940:function(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:function(e,t,r){var n=r(6571),o=r(2517),i=r(91),s=r(7993),a=r(5906),u=r(2175),c=r(1522),l=r(7680),d=r(9987),h=r(3483),f=r(6939),p=r(940),v=r(9917),y=r(8222),m=r(8725),g=r(6152),b=r(3226),_=r(4714),w=r(9259),E=r(3679),I=r(249),S=r(8582),O="[object Arguments]",A="[object Function]",T="[object Object]",P={};P[O]=P["[object Array]"]=P["[object ArrayBuffer]"]=P["[object DataView]"]=P["[object Boolean]"]=P["[object Date]"]=P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Map]"]=P["[object Number]"]=P[T]=P["[object RegExp]"]=P["[object Set]"]=P["[object String]"]=P["[object Symbol]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P["[object Error]"]=P[A]=P["[object WeakMap]"]=!1,e.exports=function e(t,r,R,C,N,D){var U,x=1&r,L=2&r,j=4&r;if(R&&(U=N?R(t,C,N,D):R(t)),void 0!==U)return U;if(!w(t))return t;var k=g(t);if(k){if(U=v(t),!x)return c(t,U)}else{var M=p(t),q=M==A||"[object GeneratorFunction]"==M;if(b(t))return u(t,x);if(M==T||M==O||q&&!N){if(U=L||q?{}:m(t),!x)return L?d(t,a(U,t)):l(t,s(U,t))}else{if(!P[M])return N?t:{};U=y(t,M,x)}}D||(D=new n);var W=D.get(t);if(W)return W;D.set(t,U),E(t)?t.forEach((function(n){U.add(e(n,r,R,n,t,D))})):_(t)&&t.forEach((function(n,o){U.set(o,e(n,r,R,o,t,D))}));var F=k?void 0:(j?L?f:h:L?S:I)(t);return o(F||t,(function(n,o){F&&(n=t[o=n]),i(U,o,e(n,r,R,o,t,D))})),U}},9413:function(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:function(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:function(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:function(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:function(e,t,r){var n=r(3366),o=r(5125);e.exports=function(e){return o(e)&&"[object Arguments]"==n(e)}},4511:function(e,t,r){var n=r(940),o=r(5125);e.exports=function(e){return o(e)&&"[object Map]"==n(e)}},6840:function(e,t,r){var n=r(1049),o=r(7394),i=r(9259),s=r(7035),a=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,l=u.toString,d=c.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:function(e,t,r){var n=r(940),o=r(5125);e.exports=function(e){return o(e)&&"[object Set]"==n(e)}},5522:function(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:function(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:function(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:function(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,u){if(!s(e))return e;for(var c=-1,l=(t=o(t,e)).length,d=l-1,h=e;null!=h&&++c<l;){var f=a(t[c]),p=r;if("__proto__"===f||"constructor"===f||"prototype"===f)return e;if(c!=d){var v=h[f];void 0===(p=u?u(v,f,h):void 0)&&(p=s(v)?v:i(t[c+1])?[]:{})}n(h,f,p),h=h[f]}return e}},9872:function(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:function(e){e.exports=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}},1054:function(e,t,r){var n=r(857),o=r(343),i=r(6152),s=r(4795),a=n?n.prototype:void 0,u=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 u?u.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}},7826:function(e){e.exports=function(e){return function(t){return e(t)}}},9078:function(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:function(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:function(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:function(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:function(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:function(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:function(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:function(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:function(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:function(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,u=t.length;++a<u;){var c=t[a],l=i?i(r[c],e[c],c,r,e):void 0;void 0===l&&(l=e[c]),s?o(r,c,l):n(r,c,l)}return r}},7680:function(e,t,r){var n=r(752),o=r(633);e.exports=function(e,t){return n(e,o(e),t)}},9987:function(e,t,r){var n=r(752),o=r(2680);e.exports=function(e,t){return n(e,o(e),t)}},4019:function(e,t,r){var n=r(7772)["__core-js_shared__"];e.exports=n},3043:function(e,t,r){var n=r(8761),o=function(){try{var e=n(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=o},1242:function(e,t,r){var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=n},3483:function(e,t,r){var n=r(1897),o=r(633),i=r(249);e.exports=function(e){return n(e,i,o)}},6939:function(e,t,r){var n=r(1897),o=r(2680),i=r(8582);e.exports=function(e){return n(e,i,o)}},7937:function(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:function(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:function(e,t,r){var n=r(241)(Object.getPrototypeOf,Object);e.exports=n},2107:function(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:function(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:function(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:function(e,t,r){var n=r(9515),o=r(326),i=r(2760),s=r(2143),a=r(3215),u=r(3366),c=r(7035),l="[object Map]",d="[object Promise]",h="[object Set]",f="[object WeakMap]",p="[object DataView]",v=c(n),y=c(o),m=c(i),g=c(s),b=c(a),_=u;(n&&_(new n(new ArrayBuffer(1)))!=p||o&&_(new o)!=l||i&&_(i.resolve())!=d||s&&_(new s)!=h||a&&_(new a)!=f)&&(_=function(e){var t=u(e),r="[object Object]"==t?e.constructor:void 0,n=r?c(r):"";if(n)switch(n){case v:return p;case y:return l;case m:return d;case g:return h;case b:return f}return t}),e.exports=_},8109:function(e){e.exports=function(e,t){return null==e?void 0:e[t]}},2118:function(e,t,r){var n=r(9191);e.exports=function(){this.__data__=n?n(null):{},this.size=0}},6909:function(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},8138:function(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:function(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:function(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:function(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:function(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 u=e.constructor;switch(t){case"[object ArrayBuffer]":return n(e);case"[object Boolean]":case"[object Date]":return new u(+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 u;case"[object Number]":case"[object String]":return new u(e);case"[object RegExp]":return i(e);case"[object Symbol]":return s(e)}}},8725:function(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:function(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:function(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:function(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},7394:function(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:function(e){var t=Object.prototype;e.exports=function(e){var r=e&&e.constructor;return e===("function"==typeof r&&r.prototype||t)}},3945:function(e){e.exports=function(){this.__data__=[],this.size=0}},1846:function(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:function(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]}},6018:function(e,t,r){var n=r(2218);e.exports=function(e){return n(this.__data__,e)>-1}},4769:function(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:function(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:function(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:function(e,t,r){var n=r(7937);e.exports=function(e){return n(this,e).get(e)}},9493:function(e,t,r){var n=r(7937);e.exports=function(e){return n(this,e).has(e)}},4150:function(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:function(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:function(e,t,r){var n=r(8761)(Object,"create");e.exports=n},4248:function(e,t,r){var n=r(241)(Object.keys,Object);e.exports=n},2966:function(e){e.exports=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}},4146:function(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:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},241:function(e){e.exports=function(e,t){return function(r){return e(t(r))}}},2721:function(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:function(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:function(e,t,r){var n=r(235);e.exports=function(){this.__data__=new n,this.size=0}},2858:function(e){e.exports=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}},4417:function(e){e.exports=function(e){return this.__data__.get(e)}},8605:function(e){e.exports=function(e){return this.__data__.has(e)}},1418:function(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:function(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:function(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:function(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:function(e,t,r){var n=r(8874);e.exports=function(e){return n(e,5)}},1225:function(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},9631:function(e,t,r){var n=r(5183),o=r(5125),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,u=n(function(){return arguments}())?n:function(e){return o(e)&&s.call(e,"callee")&&!a.call(e,"callee")};e.exports=u},6152:function(e){var t=Array.isArray;e.exports=t},7878:function(e,t,r){var n=r(1049),o=r(1158);e.exports=function(e){return null!=e&&o(e.length)&&!n(e)}},3226:function(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,u=(a?a.isBuffer:void 0)||o;e.exports=u},1049:function(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:function(e){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},4714:function(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:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5125:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},3679:function(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:function(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:function(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:function(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:function(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:function(e){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},733:function(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:function(e,t,r){var n=r(2857);e.exports=function(e,t,r){return null==e?e:n(e,t,r)}},981:function(e){e.exports=function(){return[]}},6330:function(e){e.exports=function(){return!1}},6188:function(e,t,r){var n=r(1054);e.exports=function(e){return null==e?"":n(e)}},7195:function(e,t,r){var n=r(9078);e.exports=function(e,t){return null==e||n(e,t)}},2764:function(e){"use strict";e.exports=require("@cloudbase/adapter-interface")},7917:function(e){"use strict";e.exports=require("@cloudbase/adapter-wx_mp")},8630:function(e){"use strict";e.exports=require("@cloudbase/wx-cloud-client-sdk")},766:function(e){"use strict";e.exports=require("@mattiasbuelens/web-streams-adapter")},2701:function(e){"use strict";e.exports=require("bson")},3107:function(e){"use strict";e.exports=require("jwt-decode")},6282:function(e){"use strict";e.exports=require("text-encoding-shim")},8775:function(e){"use strict";e.exports=require("web-streams-polyfill")}},n={};function o(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}t=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},o.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var i=Object.create(null);o.r(i);var s={};e=e||[null,t({}),t([]),t(t)];for(var a=2&n&&r;"object"==typeof a&&!~e.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((function(e){s[e]=function(){return r[e]}}));return s.default=function(){return r},o.d(i,s),i},o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e};var i=o(8795);module.exports=i}();
2
+ !function(){var t,e,n={7756:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},a=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},u=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.AI=void 0;var c=n(9737),l=s(n(5305)),d=n(1689),h=n(2877),f=l.MODELS,p=function(){function t(t,e,n){var o=this;this.req=t,this.baseUrl=e,this.modelRequest=function(t){var e=t.url,n=t.data,i=t.headers,s=t.stream,c=t.timeout;return a(o,void 0,void 0,(function(){var t,o,a,l,d,h,f;return u(this,(function(u){switch(u.label){case 0:return t={"Content-Type":"application/json"},s&&Object.assign(t,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:r(r((d={},d[null===(h=this.i18n)||void 0===h?void 0:h.LANG_HEADER_KEY]=null===(f=this.i18n)||void 0===f?void 0:f.lang,d),t),i),body:JSON.stringify(n),url:e,stream:s,timeout:c})];case 1:return o=u.sent(),a=o.data,l=o.header,[2,this.handleResponseData(a,l)]}}))}))},this.botRequest=function(t){var e=t.method,n=t.url,i=t.data,s=void 0===i?{}:i,c=t.headers,l=t.stream,d=t.timeout;return a(o,void 0,void 0,(function(){var t,o,i,a,h,f,p,v;return u(this,(function(u){switch(u.label){case 0:return"get"!==e?[3,2]:(t=this.handleResponseData,[4,this.req.fetch({url:"".concat(n,"?").concat((y=s,Object.entries(y).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})).join("&"))),method:e,headers:c,stream:l,timeout:d})]);case 1:return[2,t.apply(this,[u.sent().data])];case 2:return o={"Content-Type":"application/json"},l&&Object.assign(o,{Accept:"text/event-stream"}),[4,this.req.fetch({url:n,body:JSON.stringify(s),headers:r(r((f={},f[null===(p=this.i18n)||void 0===p?void 0:p.LANG_HEADER_KEY]=null===(v=this.i18n)||void 0===v?void 0:v.lang,f),o),c),stream:l,method:e,timeout:d})];case 3:return i=u.sent(),a=i.data,h=i.header,[2,this.handleResponseData(a,h)]}var y}))}))},this.aiBaseUrl="".concat(e,"/ai"),this.aiBotBaseUrl="".concat(e,"/aibot"),this.bot=new c.Bot(this.botRequest,this.aiBotBaseUrl),this.i18n=n,h.langEvent.bus.on(h.langEvent.LANG_CHANGE_EVENT,(function(t){var e;o.i18n=(null===(e=t.data)||void 0===e?void 0:e.i18n)||o.i18n}))}return t.prototype.handleResponseData=function(t,e){var n,r;return a(this,void 0,void 0,(function(){var o,i;return u(this,(function(s){switch(s.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),"object"==typeof t&&t&&"then"in t?[4,t]:[3,2];case 1:if("object"==typeof(i=s.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));return[2,t];case 2:return(null===(r=null===(n=null==e?void 0:e.get)||void 0===n?void 0:n.call(e,"content-type"))||void 0===r?void 0:r.includes("application/json"))?[4,(0,d.readableStream2JsonObject)(t)]:[3,4];case 3:if("object"==typeof(i=s.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));s.label=4;case 4:return[2,t]}}))}))},t.prototype.createModel=function(t,e){var n,r=f[t];if(r)n=new r(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==e?void 0:e.defaultModelSubUrl)?e.defaultModelSubUrl:"/chat/completions";n=new l.DefaultSimpleModel(this.modelRequest,this.aiBaseUrl,"".concat(t).concat(o))}return new l.ReactModel(n)},t.prototype.registerModel=function(t,e){null==f[t]?f[t]=e:console.warn("AI model ".concat(t," already exists!"))},t.prototype.createImageModel=function(t){return new l.DefaultImageModel(this.modelRequest,this.aiBaseUrl,t)},t.prototype.registerFunctionTool=function(t){l.toolMap.has(t.name)&&console.warn("AI function tool ".concat(t.name," already exists and will be overwritten!")),l.toolMap.set(t.name,t.fn)},t}();e.AI=p},9737:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.Bot=void 0;var a=n(1689),u=function(){function t(t,e){this.baseUrl=e;var n=arguments[2];this.req="string"==typeof n?function(e){var o=e.headers,i=void 0===o?{}:o,a=s(e,["headers"]);return t(r(r({},a),{headers:r(r({},i),{Authorization:"Bearer ".concat(n)})}))}:t}return t.prototype.list=function(t,e){return this.req({method:"get",url:this.join("bots"),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.create=function(t,e){var n=t.botInfo;return this.req({method:"post",url:this.join("bots"),data:n,timeout:null==e?void 0:e.timeout})},t.prototype.get=function(t,e){var n=t.botId;return this.req({method:"get",url:this.join("bots/".concat(n)),timeout:null==e?void 0:e.timeout})},t.prototype.update=function(t,e){var n=t.botId,r=t.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(n)),data:r,timeout:null==e?void 0:e.timeout})},t.prototype.delete=function(t,e){var n=t.botId;return this.req({method:"delete",url:this.join("bots/".concat(n)),timeout:null==e?void 0:e.timeout})},t.prototype.getChatRecords=function(t,e){return this.req({method:"get",url:this.join("bots/".concat(t.botId,"/records")),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.sendFeedback=function(t,e){var n=t.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(n.botId,"/feedback")),data:n,timeout:null==e?void 0:e.timeout})},t.prototype.getFeedback=function(t,e){return this.req({method:"get",url:this.join("bots/".concat(t.botId,"/feedback")),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.uploadFiles=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/files")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.createConversation=function(t,e){var n=t.botId,r=s(t,["botId"]);return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.req({method:"post",url:this.join("bots/".concat(n,"/conversation")),data:r,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getConversation=function(t,e){var n=t.pageSize,a=void 0===n?10:n,u=t.pageNumber,c=void 0===u?1:u,l=t.botId,d=s(t,["pageSize","pageNumber","botId"]);return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(o){if(c<1)throw new Error("pageNumber must be greater than 0");return t=a*(c-1),n=a,[2,this.req({method:"get",url:this.join("bots/".concat(l,"/conversation")),data:r(r({},d),{offset:t,limit:n}),timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.deleteConversation=function(t,e){var n=t.botId,r=t.conversationId,a=s(t,["botId","conversationId"]);return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.req({method:"delete",url:this.join("bots/".concat(n,"/conversation/").concat(r)),data:a,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.speechToText=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/speech-to-text")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.textToSpeech=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/text-to-speech")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getTextToSpeechResult=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.req({method:"get",url:this.join("bots/".concat(t.botId,"/text-to-speech")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getRecommendQuestions=function(t,e){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/recommend-questions")),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,new c(n)]}}))}))},t.prototype.generateBot=function(t,e){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,new c(n)]}}))}))},t.prototype.getPreview=function(t,e){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,new c(n)]}}))}))},t.prototype.generateImage=function(t,e){return this.req({method:"post",url:this.join("generate-image"),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.sendMessage=function(t,e){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/send-message")),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,new c(n)]}}))}))},t.prototype.join=function(t){return"".concat(this.baseUrl,"/").concat(t)},t}();e.Bot=u;var c=function(){function t(t){var e=(0,a.toPolyfillReadable)(t);this._eventSourceStream=e.pipeThrough(new a.TextDecoderStream).pipeThrough((0,a.createEventSourceParserTransformStream)())}return Object.defineProperty(t.prototype,"teeedStream",{get:function(){var t=this._eventSourceStream.tee(),e=t[0],n=t[1];return this._eventSourceStream=n,e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"eventSourceStream",{get:function(){return(0,a.createAsyncIterable)(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataStream",{get:function(){return(0,a.createAsyncIterable)(this.eventSourceStream.pipeThrough(new a.TransformStream({transform:function(t,e){try{var n=JSON.parse(t.data);e.enqueue(n)}catch(n){"[DONE]"!==t.data?console.warn("Error when transforming event source data to json",n,t):e.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textStream",{get:function(){return(0,a.createAsyncIterable)(this.dataStream.pipeThrough(new a.TransformStream({transform:function(t,e){var n;e.enqueue(null!==(n=null==t?void 0:t.content)&&void 0!==n?n:"")}})))},enumerable:!1,configurable:!0}),t}()},9964:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createParser=void 0;var r=n(6298);Object.defineProperty(e,"createParser",{enumerable:!0,get:function(){return r.createParser}})},6298:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createParser=void 0,e.createParser=function(t){var e,r,o,i,s,a,u;return c(),{feed:function(t){r=r?r+t:t,e&&function(t){return n.every((function(e,n){return t.charCodeAt(n)===e}))}(r)&&(r=r.slice(n.length)),e=!1;for(var s=r.length,a=0,u=!1;a<s;){u&&("\n"===r[a]&&(a+=1),u=!1);for(var c=-1,d=i,h=void 0,f=o;c<0&&f<s;f++)":"===(h=r[f])&&d<0?d=f-a:"\r"===h?(u=!0,c=f-a):"\n"===h&&(c=f-a);if(c<0){o=s-a,i=d;break}o=0,i=-1,l(r,a,d,c),a+=c+1}a===s?r="":a>0&&(r=r.slice(a))},reset:c};function c(){e=!0,r="",o=0,i=-1,s=void 0,a=void 0,u=""}function l(e,n,r,o){if(0===o)return u.length>0&&(t({type:"event",id:s,event:a||void 0,data:u.slice(0,-1)}),u="",s=void 0),void(a=void 0);var i,c=r<0,l=e.slice(n,n+(c?o:r)),d=n+(i=c?o:" "===e[n+r+1]?r+2:r+1),h=o-i,f=e.slice(d,d+h).toString();if("data"===l)u+=f?"".concat(f,"\n"):"\n";else if("event"===l)a=f;else if("id"!==l||f.includes("\0")){if("retry"===l){var p=parseInt(f,10);Number.isNaN(p)||t({type:"reconnect-interval",value:p})}}else s=f}};var n=[239,187,191]},5337:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},a=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},u=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},l=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.registerAi=e.models=e.createAI=e.createAi=e.Bot=e.AI=void 0;var d=n(7756);Object.defineProperty(e,"AI",{enumerable:!0,get:function(){return d.AI}});var h=n(9737);Object.defineProperty(e,"Bot",{enumerable:!0,get:function(){return h.Bot}});var f=s(n(5305)),p=s(n(1689));e.utils=p,f.MODELS;var v=l(f,["MODELS"]);e.models=v;function y(t){var e=t.env,n=t.baseUrl,o=t.req,i=t.getAccessToken,s=t.handleReqInstance,a=t.i18n;return new d.AI(function(){if(null==s){if(null==i)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return function(t){var e=t.getAccessToken,n=t.req;return{download:n.download,post:n.post,upload:n.upload,fetch:function(t){return u(void 0,void 0,void 0,(function(){var o,i,s,a,u;return c(this,(function(c){switch(c.label){case 0:if("function"!=typeof n.fetch)throw new Error("req.fetch is not a function");return o=t.token,i=t.headers,s=void 0===i?{}:i,a=l(t,["token","headers"]),null==o?[3,1]:(u=o,[3,3]);case 1:return[4,e()];case 2:u=c.sent().accessToken,c.label=3;case 3:return[2,n.fetch(r({headers:r({Authorization:"Bearer ".concat(u)},s)},a))]}}))}))}}}({req:o,getAccessToken:i})}return s({req:o})}(),function(){if(null!=n)return n;if(null==e)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(e,".api.tcloudbasegateway.com/v1")}(),a)}e.createAI=y;var m=y;e.createAi=m;var g={name:"ai",entity:{ai:function(t){var e,n=this,r=this.request;if(null==r.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");return y({req:r,baseUrl:null!==(e=null==t?void 0:t.baseUrl)&&void 0!==e?e:function(){var t=n.getEndPointWithKey("GATEWAY"),e=t.BASE_URL,r=t.PROTOCOL;return"".concat(r).concat(e)}(),handleReqInstance:function(t){return t.req},i18n:this.config.i18n})}}};function b(t){try{t.registerComponent(g)}catch(t){console.warn(t)}}e.registerAi=b,a(n(4669),e);try{window.registerAi=b}catch(t){}},5476:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.ArkSimpleModel=void 0;var s=n(1689);function a(t){var e=t.messages,n=t.model,o=t.temperature,i=t.tools,s=t.top_p;return r(r({},t),{messages:e,model:n,tools:i,top_p:s,temperature:o})}var u=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="ark/api/v3/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return o(this,void 0,Promise,(function(){var n,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(t,e){var o=t.choices.map((function(t){var e=t.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(e)),n?r(r({},t),{finish_reason:"tool_calls",delta:e}):t})),i=r(r({},t),{choices:o});e.enqueue(r(r({},i),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},t}();e.ArkSimpleModel=u},7265:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.DSSimpleModel=void 0;var s=n(1689);function a(t){var e=t.messages,n=t.model,o=t.temperature,i=t.tools,s=t.top_p;return r(r({},t),{messages:e,model:n,tools:i,top_p:s,temperature:o})}var u=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return o(this,void 0,Promise,(function(){var n,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(t,e){var o=t.choices.map((function(t){var e=Object.assign(t.delta,{role:"assistant"});return null==n&&(n=(0,s.isToolCallAssistantMessage)(e)),r(r({},t),n?{finish_reason:"tool_calls",delta:e}:{delta:e})})),i=r(r({},t),{choices:o});e.enqueue(r(r({},i),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},t}();e.DSSimpleModel=u},2102:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.DeepSeekSimpleModel=void 0;var s=n(1689),a=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="deepseek/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},t),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return o(this,void 0,Promise,(function(){var n,o,a,u,c;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},t),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=i.sent(),a=(0,s.toPolyfillReadable)(o),u=(0,s.intoStandardStream)(a),c=u.pipeThrough(new s.TransformStream({transform:function(t,e){var o=t.choices.map((function(t){var e=t.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(e)),n?r(r({},t),{finish_reason:"tool_calls",delta:e}):t})),i=r(r({},t),{choices:o});e.enqueue(r(r({},i),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(c)]}}))}))},t}();e.DeepSeekSimpleModel=a},8017:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.DefaultSimpleModel=void 0;var s=n(1689),a=function(){function t(t,e,n){void 0===n&&(n=""),this.req=t,this.baseUrl=e,this.subUrl=n}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},t),{stream:!1}),stream:!1})];case 1:return e=n.sent(),[2,r(r({},e),{rawResponse:e})]}}))}))},t.prototype.doStream=function(t){return o(this,void 0,Promise,(function(){var e,n,o,a,u;return i(this,(function(i){switch(i.label){case 0:return e=null,[4,this.req({url:this.url,data:r(r({},t),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,s.toPolyfillReadable)(n),a=(0,s.intoStandardStream)(o),u=a.pipeThrough(new s.TransformStream({transform:function(t,n){var o=t.choices.map((function(t){var n=t.delta;return null==e&&(e=(0,s.isToolCallAssistantMessage)(n)),e?r(r({},t),{finish_reason:"tool_calls",delta:n}):t})),i=r(r({},t),{choices:o});n.enqueue(r(r({},i),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(u)]}}))}))},t}();e.DefaultSimpleModel=a},7239:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.HunYuanSimpleModel=void 0;var s=n(1689),a=n(8586),u=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="hunyuan",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return o(this,void 0,Promise,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},(0,a.processInput)(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=i.sent(),o=(0,a.titleCaseToSnakeCase)(n.Response),[2,r(r({},o),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return o(this,void 0,Promise,(function(){var n,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},t),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(t,e){var o=(0,a.titleCaseToSnakeCase)(t),i=o.choices.map((function(t){var e=t.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(e)),n?r(r({},t),{finish_reason:"tool_calls",delta:e}):t})),u=r(r({},o),{choices:i});e.enqueue(r(r({},u),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},t}();e.HunYuanSimpleModel=u},8586:function(t,e){"use strict";var n=this&&this.__assign||function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.titleCaseToSnakeCase=e.processInput=void 0,e.processInput=function(t){var e=t.messages,r=t.model,o=t.temperature,i=t.tool_choice,s=t.tools,a=t.top_p;return n(n({},t),{messages:(e.forEach((function(t){"tool_calls"in t&&t.tool_calls.filter((function(t){return"function"!==t.type})).forEach((function(e){return console.warn("`type` in tool_call is not 'function'",e,t)}))})),e),model:r,tools:function(){if(s)return s.forEach((function(t){"function"!==t.type&&console.warn("`type` in tool is not 'function'",t)})),s}(),top_p:a,tool_choice:i,temperature:o})},e.titleCaseToSnakeCase=function t(e){return"object"!=typeof e||null==e?e:Array.isArray(e)?e.map((function(e){return t(e)})):Object.entries(e).reduce((function(e,n){var r,o=n[0],i=n[1];return e["_"===(r=o.replace(/[A-Z]/g,(function(t){return"_".concat(t.toLowerCase())}))).charAt(0)?r.slice(1):r]="object"==typeof i?t(i):i,e}),{})}},9301:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.HunYuanBetaSimpleModel=void 0;var s=n(1689),a=n(8586),u=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return o(this,void 0,Promise,(function(){var n,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(t,e){var o=t.choices.map((function(t){var e=t.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(e)),n?r(r({},t),{finish_reason:"tool_calls",delta:e}):t})),i=r(r({},t),{choices:o});e.enqueue(r(r({},i),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},t}();e.HunYuanBetaSimpleModel=u},5720:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.HunYuanExpSimpleModel=void 0;var s=n(1689),a=n(8586),u=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-exp/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(t)),{stream:!1}),stream:!1})];case 1:return e=n.sent(),[2,r(r({},e),{rawResponse:e})]}}))}))},t.prototype.doStream=function(t){return o(this,void 0,Promise,(function(){var e,n,o,u,c;return i(this,(function(i){switch(i.label){case 0:return e=null,[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(t)),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,s.toPolyfillReadable)(n),u=(0,s.intoStandardStream)(o),c=u.pipeThrough(new s.TransformStream({transform:function(t,n){var o=t.choices.map((function(t){var n=t.delta;return null==e&&(e=(0,s.isToolCallAssistantMessage)(n)),e?r(r({},t),{finish_reason:"tool_calls",delta:n}):t})),i=r(r({},t),{choices:o});n.enqueue(r(r({},i),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(c)]}}))}))},t}();e.HunYuanExpSimpleModel=u},1586:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.HunYuanOpenSimpleModel=void 0;var s=n(1689),a=n(8586),u=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-open/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return o(this,void 0,Promise,(function(){var n,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,a.processInput)(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(t,e){var o=t.choices.map((function(t){var e=t.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(e)),n?r(r({},t),{finish_reason:"tool_calls",delta:e}):t})),i=r(r({},t),{choices:o});e.enqueue(r(r({},i),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},t}();e.HunYuanOpenSimpleModel=u},3925:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.MoonshotSimpleModel=void 0;var s=n(1689);function a(t){var e=t.messages,n=t.model,o=t.temperature,i=t.tools,s=t.top_p;return r(r({},t),{messages:e,model:n,tools:i,top_p:s,temperature:o})}var u=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="moonshot/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return o(this,void 0,Promise,(function(){var n,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(t,e){var o=t.choices.map((function(t){var e=t.delta;return null==n&&(n=(0,s.isToolCallAssistantMessage)(e)),n?r(r({},t),{finish_reason:"tool_calls",delta:e}):t})),i=r(r({},t),{choices:o});e.enqueue(r(r({},i),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},t}();e.MoonshotSimpleModel=u},4532:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.YiSimpleModel=void 0;var s=n(1689);function a(t){var e=t.messages,n=t.model,o=t.temperature,i=t.tools,s=t.top_p;return r(r({},t),{messages:e,model:n,tools:i,top_p:s,temperature:o})}var u=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="01-ai/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},a(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return o(this,void 0,Promise,(function(){var n,o,u,c,l;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},a(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=i.sent(),u=(0,s.toPolyfillReadable)(o),c=(0,s.intoStandardStream)(u),l=c.pipeThrough(new s.TransformStream({transform:function(t,e){var o,i,a,u,c,l;if((null===(a=null===(i=null===(o=null==t?void 0:t.choices)||void 0===o?void 0:o[0])||void 0===i?void 0:i.delta)||void 0===a?void 0:a.content)||(null===(l=null===(c=null===(u=null==t?void 0:t.choices)||void 0===u?void 0:u[0])||void 0===c?void 0:c.delta)||void 0===l?void 0:l.tool_calls)){var d=t.choices.map((function(t){var e=Object.assign(t.delta,{role:"assistant"});return null==n&&(n=(0,s.isToolCallAssistantMessage)(e)),r(r({},t),n?{finish_reason:"tool_calls",delta:e}:{delta:e})})),h=r(r({},t),{choices:d});e.enqueue(r(r({},h),{rawResponse:t}))}}})),[2,(0,s.createAsyncIterable)(l)]}}))}))},t}();e.YiSimpleModel=u},7173:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.ZhiPuSimpleModel=void 0;var s=n(1689);function a(t){var e=t.messages,n=t.model,o=t.temperature,i=t.tool_choice,s=t.tools,a=t.top_p;return r(r({},t),{messages:e,model:n,temperature:o,tool_choice:(i&&"auto"!==i&&console.warn("`tool_choice` is not 'auto'"),i),tools:s,top_p:a})}var u=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return o(this,void 0,Promise,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=a(t),[4,this.req({url:this.url,data:r(r({},n),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return o=i.sent(),[2,r(r({},o),{rawResponse:o})]}}))}))},t.prototype.doStream=function(t,e){return o(this,void 0,Promise,(function(){var n,o,u,c,l,d;return i(this,(function(i){switch(i.label){case 0:return n=a(t),o=null,[4,this.req({url:this.url,data:r(r({},n),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return u=i.sent(),c=(0,s.toPolyfillReadable)(u),l=(0,s.intoStandardStream)(c),d=l.pipeThrough(new s.TransformStream({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==o&&(o=(0,s.isToolCallAssistantMessage)(e)),o?r(r({},t),{finish_reason:"tool_calls",delta:e}):t})),i=r(r({},t),{choices:n});e.enqueue(r(r({},i),{rawResponse:t}))}})),[2,(0,s.createAsyncIterable)(d)]}}))}))},t}();e.ZhiPuSimpleModel=u},8328:function(t,e){"use strict";var n=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.DefaultImageModel=void 0;var o=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.provider=n,this.defaultGenerateImageSubUrl="images/generations",this.generateImageSubUrlConfig={"hunyuan-image":{"hunyuan-image-v3.0-v1.0.4":"images/ar/generations","hunyuan-image-v3.0-v1.0.1":"images/ar/generations"}},this.generateImage=this.generateImageImpl.bind(this)}return t.prototype.generateImageImpl=function(t){var e;return n(this,void 0,Promise,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:return n=this.defaultGenerateImageSubUrl,"object"==typeof t&&t&&"model"in t&&"string"==typeof t.model&&(o=null===(e=this.generateImageSubUrlConfig[this.provider])||void 0===e?void 0:e[t.model])&&(n=o),[4,this.req({url:this.getGenerateUrl(n),data:t,stream:!1})];case 1:return[2,r.sent()]}}))}))},t.prototype.getGenerateUrl=function(t){return"".concat(this.baseUrl,"/").concat(this.provider,"/").concat(t)},t}();e.DefaultImageModel=o},5305:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toolMap=e.ReactModel=e.DefaultImageModel=e.DefaultSimpleModel=e.HunYuanOpenSimpleModel=e.HunYuanExpSimpleModel=e.MoonshotSimpleModel=e.YiSimpleModel=e.DSSimpleModel=e.ArkSimpleModel=e.HunYuanSimpleModel=e.HunYuanBetaSimpleModel=e.ZhiPuSimpleModel=e.MODELS=void 0;var r=n(7173);Object.defineProperty(e,"ZhiPuSimpleModel",{enumerable:!0,get:function(){return r.ZhiPuSimpleModel}});var o=n(9301);Object.defineProperty(e,"HunYuanBetaSimpleModel",{enumerable:!0,get:function(){return o.HunYuanBetaSimpleModel}});var i=n(7239);Object.defineProperty(e,"HunYuanSimpleModel",{enumerable:!0,get:function(){return i.HunYuanSimpleModel}});var s=n(5476);Object.defineProperty(e,"ArkSimpleModel",{enumerable:!0,get:function(){return s.ArkSimpleModel}});var a=n(7265);Object.defineProperty(e,"DSSimpleModel",{enumerable:!0,get:function(){return a.DSSimpleModel}});var u=n(4532);Object.defineProperty(e,"YiSimpleModel",{enumerable:!0,get:function(){return u.YiSimpleModel}});var c=n(3925);Object.defineProperty(e,"MoonshotSimpleModel",{enumerable:!0,get:function(){return c.MoonshotSimpleModel}});var l=n(5720);Object.defineProperty(e,"HunYuanExpSimpleModel",{enumerable:!0,get:function(){return l.HunYuanExpSimpleModel}});var d=n(1586);Object.defineProperty(e,"HunYuanOpenSimpleModel",{enumerable:!0,get:function(){return d.HunYuanOpenSimpleModel}});var h=n(2102),f=n(8017);Object.defineProperty(e,"DefaultSimpleModel",{enumerable:!0,get:function(){return f.DefaultSimpleModel}});var p=n(8328);Object.defineProperty(e,"DefaultImageModel",{enumerable:!0,get:function(){return p.DefaultImageModel}}),e.MODELS={hunyuan:i.HunYuanSimpleModel,"hunyuan-beta":o.HunYuanBetaSimpleModel,ark:s.ArkSimpleModel,dashscope:a.DSSimpleModel,"01-ai":u.YiSimpleModel,moonshot:c.MoonshotSimpleModel,zhipu:r.ZhiPuSimpleModel,"hunyuan-exp":l.HunYuanExpSimpleModel,"hunyuan-open":d.HunYuanOpenSimpleModel,deepseek:h.DeepSeekSimpleModel};var v=n(1443);Object.defineProperty(e,"ReactModel",{enumerable:!0,get:function(){return v.ReactModel}}),Object.defineProperty(e,"toolMap",{enumerable:!0,get:function(){return v.toolMap}})},1443:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},a=this&&this.__asyncValues||function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,o){!function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)}(r,o,(e=t[n](e)).done,e.value)}))}}},u=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.toolMap=e.ReactModel=void 0;var c=n(1689);function l(t){var e,n=t.onStepFinish,o=t.abortSignal,i=t.maxSteps,a=t.topP,u=t.toolChoice,l=s(t,["onStepFinish","abortSignal","maxSteps","topP","toolChoice"]);if(null!=i&&i<1)throw new Error("`maxSteps` muse be greater than 0.");return[{onStepFinish:n,abortSignal:o,maxSteps:i},r(r({},l),{tools:null===(e=l.tools)||void 0===e?void 0:e.map((function(t){return"fn"in t?(0,c.functionToolToModelTool)(t):t})),top_p:null!=a?a:l.top_p,tool_choice:null!=u?u:l.tool_choice})]}var d=function(){function t(t){this.model=t}return t.prototype.generateText=function(t,e){var n,r;return o(this,void 0,Promise,(function(){var o,s,a,c,d,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N,D,U=this;return i(this,(function(i){switch(i.label){case 0:return o=[],s={completion_tokens:0,prompt_tokens:0,total_tokens:0},a=l(t),c=a[0],d=c.onStepFinish,m=c.maxSteps,g=void 0===m?10:m,b=a[1],[4,(_=function(){return U.model.doGenerate(b,e)})()];case 1:w=i.sent(),E=1,w.rawResponse&&o.push(w.rawResponse),I=null,i.label=2;case 2:if(!(E<g&&null!=(I=h(w))))return[3,9];S=v(w.usage),y(s,S),i.label=3;case 3:return i.trys.push([3,7,,8]),[4,p(I)];case 4:return O=i.sent(),A=w.choices[0],[4,null==d?void 0:d({finishReason:A.finish_reason,messages:b.messages.slice(),text:A.message.content,toolCall:I,toolResult:O,stepUsage:S,totalUsage:Object.assign({},s)})];case 5:return i.sent(),f(b.messages,A.message,O),[4,_()];case 6:return(w=i.sent()).rawResponse&&o.push(w.rawResponse),E+=1,[3,8];case 7:return T=i.sent(),[2,{text:"",messages:b.messages,usage:s,error:T,rawResponses:o}];case 8:return[3,2];case 9:return P=null===(n=null==w?void 0:w.choices)||void 0===n?void 0:n[0],R=null==P?void 0:P.message,C=null!==(r=null==R?void 0:R.content)&&void 0!==r?r:"",N=R?u(u([],b.messages,!0),[R],!1):b.messages,D=v(w.usage),y(s,D),[4,null==d?void 0:d({finishReason:P.finish_reason,messages:N.slice(),text:C,toolCall:h(w),toolResult:null,stepUsage:D,totalUsage:Object.assign({},s)})];case 10:return i.sent(),[2,{text:C,messages:N,usage:s,rawResponses:o}]}}))}))},t.prototype.streamText=function(t,e){var n;return o(this,void 0,Promise,(function(){var r,s,d,h,v,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N,D,U,x,L,j,k,M,q,W,B,F,G,H,V,K,Y,J=this;return i(this,(function(z){switch(z.label){case 0:return r={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=l(t),d=s[0],h=d.onStepFinish,v=d.maxSteps,m=void 0===v?10:v,g=s[1],[4,(b=function(){return J.model.doStream(g,e)})()];case 1:_=z.sent(),w=1,E=null,I=function(){var t=_.tee(),e=t[0],n=t[1];return _=(0,c.createAsyncIterable)(e),function(t){var e,n,r,s,u,l,d,h,f,p;return o(this,void 0,Promise,(function(){var o,v,y,m,g,b,_,w,E,I,S,O,A;return i(this,(function(i){switch(i.label){case 0:o={completion_tokens:0,prompt_tokens:0,total_tokens:0},v=(0,c.createAsyncIterable)(t),m={role:"assistant",content:"",tool_calls:[y={id:"",function:{name:"",arguments:""},type:""}]},i.label=1;case 1:i.trys.push([1,6,7,12]),g=!0,b=a(v),i.label=2;case 2:return[4,b.next()];case 3:if(_=i.sent(),e=_.done)return[3,5];s=_.value,g=!1;try{if(!(E=null==(w=s)?void 0:w.choices[0]))return[2,null];if(I=E.finish_reason,S=E.delta,"tool_calls"!==I)return[2,null];if(!S)return[3,4];if(S.content&&(m.content+=S.content),!("tool_calls"in S))return[3,4];(null==(O=null===(u=null==S?void 0:S.tool_calls)||void 0===u?void 0:u[0])?void 0:O.id)&&(y.id=O.id),(null==O?void 0:O.type)&&(y.type=O.type),(null===(l=null==O?void 0:O.function)||void 0===l?void 0:l.name)&&(y.function.name=O.function.name),(null===(d=null==O?void 0:O.function)||void 0===d?void 0:d.arguments)&&(y.function.arguments+=O.function.arguments),(null===(h=null==w?void 0:w.usage)||void 0===h?void 0:h.completion_tokens)&&(o.completion_tokens=w.usage.completion_tokens),(null===(f=null==w?void 0:w.usage)||void 0===f?void 0:f.prompt_tokens)&&(o.prompt_tokens=w.usage.prompt_tokens),(null===(p=null==w?void 0:w.usage)||void 0===p?void 0:p.total_tokens)&&(o.total_tokens=w.usage.total_tokens)}finally{g=!0}i.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return A=i.sent(),n={error:A},[3,12];case 7:return i.trys.push([7,,10,11]),g||e||!(r=b.return)?[3,9]:[4,r.call(b)];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,{message:m,usage:o}]}}))}))}(n)},z.label=2;case 2:return(S=w<m)?[4,I()]:[3,4];case 3:S=null!=(E=z.sent()),z.label=4;case 4:if(!S)return[3,11];O=E.message,A=E.usage,y(r,A),T=null===(n=O.tool_calls)||void 0===n?void 0:n[0],z.label=5;case 5:return z.trys.push([5,9,,10]),[4,p(T)];case 6:return P=z.sent(),[4,null==h?void 0:h({finishReason:"tool_calls",messages:g.messages.slice(),text:O.content,toolCall:T,toolResult:P,stepUsage:A,totalUsage:Object.assign({},r)})];case 7:return z.sent(),f(g.messages,O,P),[4,b()];case 8:return _=z.sent(),[3,10];case 9:return R=z.sent(),C=_.tee(),N=C[0],D=C[1],[2,{messages:Promise.resolve(g.messages),dataStream:(0,c.createAsyncIterable)(N),textStream:(0,c.createAsyncIterable)(D.pipeThrough(new c.TransformStream({transform:function(t,e){var n,r,o,i=null===(o=null===(r=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:Promise.resolve(r),error:R}];case 10:return[3,2];case 11:return[4,I()];case 12:return(E=z.sent())?(U=E.message,x=E.usage,y(r,x),L=u(u([],g.messages,!0),[U],!1),h({messages:L.slice(),finishReason:"tool_call",stepUsage:x,text:U.content,toolCall:U.tool_calls[0],totalUsage:Object.assign({},r)}),j=_.tee(),k=j[0],M=j[1],[2,{messages:Promise.resolve(u(u([],g.messages,!0),[U],!1)),dataStream:(0,c.createAsyncIterable)(k),textStream:(0,c.createAsyncIterable)(M.pipeThrough(new c.TransformStream({transform:function(t,e){var n,r,o,i=null===(o=null===(r=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:Promise.resolve(r)}]):(q=(0,c.createPromise)(),W=(0,c.createPromise)(),B={role:"assistant",content:""},F="",G={completion_tokens:0,prompt_tokens:0,total_tokens:0},H=_.pipeThrough(new c.TransformStream({transform:function(t,e){var n,r,o,i,s,a,u,c,l=null===(o=null===(r=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof l&&(B.content+=l);var d=null===(s=null===(i=null==t?void 0:t.choices)||void 0===i?void 0:i[0])||void 0===s?void 0:s.finish_reason;d&&(F=d),(null===(a=null==t?void 0:t.usage)||void 0===a?void 0:a.completion_tokens)&&(G.completion_tokens=t.usage.completion_tokens),(null===(u=null==t?void 0:t.usage)||void 0===u?void 0:u.prompt_tokens)&&(G.prompt_tokens=t.usage.prompt_tokens),(null===(c=null==t?void 0:t.usage)||void 0===c?void 0:c.total_tokens)&&(G.total_tokens=t.usage.total_tokens),e.enqueue(t)},flush:function(){q.res(u(u([],g.messages,!0),[B],!1)),y(r,G),W.res(Object.assign({},r)),null==h||h({messages:u(u([],g.messages,!0),[B],!1),finishReason:F,text:B.content,stepUsage:G,totalUsage:Object.assign({},r)})}})),V=H.tee(),K=V[0],Y=V[1],[2,{messages:q.promise,dataStream:(0,c.createAsyncIterable)(K),textStream:(0,c.createAsyncIterable)(Y.pipeThrough(new c.TransformStream({transform:function(t,e){var n,r,o,i=null===(o=null===(r=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:W.promise}])}}))}))},t}();function h(t){var e,n=null===(e=null==t?void 0:t.choices)||void 0===e?void 0:e[0];if(!n)return null;var r=n.finish_reason,o=n.message;return"tool_calls"!==r?null:o&&(0,c.isToolCallAssistantMessage)(o)?o.tool_calls[0]:null}function f(t,e,n){t.push(e,{role:"tool",tool_call_id:e.tool_calls[0].id,content:JSON.stringify(n)})}function p(t){return e.toolMap.get(t.function.name)(JSON.parse(t.function.arguments))}function v(t){var e,n,r;return{completion_tokens:null!==(e=null==t?void 0:t.completion_tokens)&&void 0!==e?e:0,prompt_tokens:null!==(n=null==t?void 0:t.prompt_tokens)&&void 0!==n?n:0,total_tokens:null!==(r=null==t?void 0:t.total_tokens)&&void 0!==r?r:0}}function y(t,e){t.completion_tokens+=e.completion_tokens,t.prompt_tokens+=e.prompt_tokens,t.total_tokens+=e.total_tokens}e.ReactModel=d,e.toolMap=new Map},4669:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SimpleChatModel=void 0;e.SimpleChatModel=function(){}},1689:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},i=this&&this.__asyncValues||function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,o){!function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)}(r,o,(e=t[n](e)).done,e.value)}))}}};Object.defineProperty(e,"__esModule",{value:!0}),e.functionToolToModelTool=e.isToolCallAssistantMessage=e.createPromise=e.readableStream2JsonObject=e.intoTextStream=e.intoStandardStream=e.createAsyncIterable=e.TextDecoderStream=e.toPolyfillReadable=e.createEventSourceParserTransformStream=e.TransformStream=e.ReadableStream=void 0;var s=n(8775),a=n(766),u=n(9964),c=n(6282);e.ReadableStream=s.ReadableStream,e.TransformStream=s.TransformStream,e.createEventSourceParserTransformStream=function(){var t;return new e.TransformStream({start:function(e){t=(0,u.createParser)((function(t){"event"===t.type&&e.enqueue(t)}))},transform:function(e){t.feed(e)}})},e.toPolyfillReadable=(0,a.createReadableStreamWrapper)(e.ReadableStream);var l=function(){function t(t,n){void 0===t&&(t="utf-8"),void 0===n&&(n={});var r=this;this.transform=new e.TransformStream({transform:function(t,e){var n=r.handle.decode(new Uint8Array(t),{stream:!0});n&&e.enqueue(n)},flush:function(t){var e=r.handle.decode();e&&t.enqueue(e),t.terminate()}}),this.handle=new c.TextDecoder(t,n)}return Object.defineProperty(t.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),t}();function d(t){var e=t;return e[Symbol.asyncIterator]=function(){var e=t.getReader();return{next:function(){return r(this,void 0,Promise,(function(){var t,n,r;return o(this,(function(o){switch(o.label){case 0:return[4,e.read()];case 1:return t=o.sent(),n=t.done,r=t.value,[2,n?{done:!0,value:void 0}:{done:!1,value:r}]}}))}))}}},e}function h(t){return d((0,e.toPolyfillReadable)(t).pipeThrough(new l))}e.TextDecoderStream=l,e.createAsyncIterable=d,e.intoStandardStream=function(t){return d(t.pipeThrough(new l).pipeThrough((0,e.createEventSourceParserTransformStream)()).pipeThrough(new e.TransformStream({transform:function(t,e){try{var n=JSON.parse(t.data);e.enqueue(n)}catch(n){"[DONE]"!==t.data?console.warn("Error when transforming event source data to json",n,t):e.terminate()}}})))},e.intoTextStream=h,e.readableStream2JsonObject=function(t){var e,n,s,a;return r(this,void 0,void 0,(function(){var r,u,c,l,d,f;return o(this,(function(o){switch(o.label){case 0:r=h(t),u="",o.label=1;case 1:o.trys.push([1,6,7,12]),c=!0,l=i(r),o.label=2;case 2:return[4,l.next()];case 3:if(d=o.sent(),e=d.done)return[3,5];a=d.value,c=!1;try{u+=a}finally{c=!0}o.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return f=o.sent(),n={error:f},[3,12];case 7:return o.trys.push([7,,10,11]),c||e||!(s=l.return)?[3,9]:[4,s.call(l)];case 8:o.sent(),o.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,JSON.parse(u)]}}))}))},e.createPromise=function(){var t,e;return{promise:new Promise((function(n,r){t=n,e=r})),res:t,rej:e}},e.isToolCallAssistantMessage=function(t){var e;return"assistant"===t.role&&"tool_calls"in t&&null!=(null===(e=t.tool_calls)||void 0===e?void 0:e[0])},e.functionToolToModelTool=function(t){return{type:"function",function:{description:t.description,name:t.name,parameters:t.parameters}}}},5378:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.generateApis=e.generateCallApis=e.callApi=void 0;var s=n(794);function a(t,e){var n,a,u,c;return o(this,void 0,Promise,(function(){var o,l,d,h,f,p,v,y,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N;return i(this,(function(i){switch(i.label){case 0:l=(o=t||{}).name,d=o.body,h=o.path,f=void 0===h?"":h,p=o.method,v=void 0===p?"POST":p,y=o.headers,m=void 0===y?{}:y,g=(t||{}).token,b={};try{b=JSON.parse(d)}catch(t){b=d||{}}if(!l)throw new Error(JSON.stringify({code:s.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return _="",E=(w=this).gatewayOrigin,I=w.getAccessToken,S=w.env,E?_="".concat(E,"/v1"):this.getEndPointWithKey?(O=this.getEndPointWithKey("GATEWAY"),A=O.BASE_URL,T=O.PROTOCOL,_="".concat(T).concat(A)):_="https://".concat(S,".api.tcloudbasegateway.com/v1"),P="".concat(_,"/apis/").concat(l),R=f.startsWith("/")?f:"/".concat(f),I?[4,I()]:[3,2];case 1:C=i.sent().accessToken,m.Authorization="Bearer ".concat(C),i.label=2;case 2:if(N=["GET","HEAD"].includes(null===(n=null==v?void 0:v.toUpperCase)||void 0===n?void 0:n.call(v)))try{R="".concat(R).concat(R.includes("?")?"&":"?").concat(Object.keys(b).map((function(t){return"".concat(t,"=").concat(b[t])})).join("&"))}catch(t){}return[4,this.request.fetch(r(r(r({url:"".concat(P).concat(R),method:v||"POST",headers:r({"Content-Type":"application/json; charset=utf-8"},m)},N?{}:{body:JSON.stringify(b)}),{token:(null===(a=null==g?void 0:g.trim)||void 0===a?void 0:a.call(g))||(null===(c=null===(u=m.Authorization)||void 0===u?void 0:u.replace)||void 0===c?void 0:c.call(u,/^Bearer /,""))||null}),e))];case 3:return[4,i.sent().data];case 4:return[2,i.sent()]}}))}))}e.callApi=a;var u=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function c(t){var e=this;return new Proxy({},{get:function(n,s){if("string"!=typeof s)throw new Error("[apis] method must be string");var c=s.toLocaleUpperCase();if(!u.includes(c))throw new Error("[apis] invalid method: ".concat(s));return function(n,s){return o(e,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,a.call(this,r({name:t,method:("REQUEST"===c?n.method:c)||"POST"},n),s)];case 1:return[2,e.sent()]}}))}))}}})}e.generateCallApis=c,e.generateApis=function(t){var e=this;return Object.keys(t||{}).forEach((function(n){void 0!==t[n]&&(e[n]=t[n])})),new Proxy({},{get:function(t,n){if("string"==typeof n)return c.call(e,n)}})}},1944:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.registerApis=e.generateApis=void 0;var i=n(5378);Object.defineProperty(e,"generateApis",{enumerable:!0,get:function(){return i.generateApis}});var s="apis",a={name:s,IIFE:!0,entity:function(){Object.defineProperty(this.prototype,s,{get:function(){return i.generateApis.call(this)},configurable:!0,enumerable:!0})}};function u(t){try{t.registerComponent(a)}catch(t){console.warn(t)}}e.registerApis=u;try{cloudbase.registerComponent(a)}catch(t){}o(n(2026),e);try{window.registerApis=u}catch(t){}},2026:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},7922:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.OAUTH2_LOGINTYPE_PREFIX=e.LOGINTYPE=e.getBaseEndPoint=e.setRegionLevelEndpoint=e.setGatewayEndPointWithEnv=e.getEndPointInfo=e.setEndPointInfo=e.DEFAULT_PROTOCOL=e.DATA_VERSION=e.getSdkName=e.setSdkName=e.getSdkVersion=e.setSdkVersion=void 0;var o=n(2877),i=o.constants.setSdkName,s=o.constants.setProtocol,a="",u="@cloudbase/js-sdk";e.setSdkVersion=function(t){a=t},e.getSdkVersion=function(){return a},e.setSdkName=function(t){u=t,i(t)},e.getSdkName=function(){return u},e.DATA_VERSION="2020-01-10";var c,l=[],d=["env","endPointKey","region"];function h(t){return l.find((function(e){return d.filter((function(e){return null!=t[e]})).every((function(n){return e[n]===t[n]}))}))}function f(t){var n,o;t.protocol&&!/:$/.test(t.protocol)&&(t.protocol="".concat(t.protocol,":"));var i=h(t);i?(null!=t.baseUrl&&(i.baseUrl=t.baseUrl),null!=t.protocol&&(i.protocol=t.protocol)):l.push(r(r({},t),{protocol:null!==(n=t.protocol)&&void 0!==n?n:e.DEFAULT_PROTOCOL})),"CLOUD_API"===t.endPointKey&&s(null!==(o=t.protocol)&&void 0!==o?o:e.DEFAULT_PROTOCOL)}function p(t,e,n){return h({env:t,endPointKey:e,region:n})}e.DEFAULT_PROTOCOL="https:",e.setEndPointInfo=f,e.getEndPointInfo=p,e.setGatewayEndPointWithEnv=function(t,e,n){var r="//".concat(t,".api.tcloudbasegateway.com/v1");n&&(r="//".concat(t,".api.intl.tcloudbasegateway.com/v1")),f({endPointKey:"GATEWAY",env:t,baseUrl:r,protocol:e})},e.setRegionLevelEndpoint=function(t,e,n){f({env:t,region:e,baseUrl:"//".concat(t,".").concat(e||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:n,endPointKey:"CLOUD_API"})},e.getBaseEndPoint=function(t,e){void 0===e&&(e="CLOUD_API");var n=p(t,e||"CLOUD_API"),r=n.protocol,o=n.baseUrl;return"".concat(r).concat(o).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]},(c=e.LOGINTYPE||(e.LOGINTYPE={})).NULL="NULL",c.ANONYMOUS="ANONYMOUS",c.WECHAT="WECHAT",c.WECHAT_PUBLIC="WECHAT-PUBLIC",c.WECHAT_OPEN="WECHAT-OPEN",c.CUSTOM="CUSTOM",c.EMAIL="EMAIL",c.USERNAME="USERNAME",c.PHONE="PHONE",e.OAUTH2_LOGINTYPE_PREFIX="OAUTH2"},6950:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__decorate||function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.cloudbase=e.LANGS=e.getBaseEndPoint=void 0;var u=n(2877),c=n(4276),l=n(1985),d=n(6938),h=n(901),f=n(7922),p=n(3509),v=n(7922);Object.defineProperty(e,"getBaseEndPoint",{enumerable:!0,get:function(){return v.getBaseEndPoint}});var y=n(3509);Object.defineProperty(e,"LANGS",{enumerable:!0,get:function(){return y.LANGS}});var m=u.adapters.useAdapters,g=u.adapters.useDefaultAdapter,b=u.constants.ERRORS,_=u.constants.COMMUNITY_SITE_URL,w=u.utils.printWarn,E=u.helpers.catchErrorsDecorator,I={timeout:15e3,persistence:"local"},S=6e5,O={},A=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=(0,f.getSdkVersion)()}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return l.Platform},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return(0,d.getCacheByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return(0,d.getLocalCache)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return(0,h.getRequestByEnvId)(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),t.prototype.init=function(e){var n,o,i;if(void 0===e&&(e={env:""}),e.endPointMode=e.endPointMode||"GATEWAY",l.Platform.adapter||this.useDefaultAdapter(),!(e=this.dealNodeAdapterConfig(e)).env)throw new Error(JSON.stringify({code:b.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(e);var s={timeout:e.timeout||15e3,timeoutMsg:"[".concat((0,f.getSdkName)(),"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s"),auth:e.auth};this.requestClient=new l.Platform.adapter.reqClass(s),this.cloudbaseConfig=r(r(r({},I),e),{i18n:(0,p.i18nProxy)(l.Platform,e)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var a=this.cloudbaseConfig,u=a.env,c=a.persistence,v=a.debug,y=a.timeout,m=a.oauthClient,g=a.i18n;(0,d.initCache)({env:u,persistence:c,debug:v,platformInfo:this.platform}),(0,f.setRegionLevelEndpoint)(u,e.region||""),(0,f.setGatewayEndPointWithEnv)(u,f.DEFAULT_PROTOCOL,e.intl);var _=new t(this.cloudbaseConfig);return(0,h.initRequest)({env:u,region:e.region||"",timeout:y,oauthClient:m,_fromApp:_,i18n:g,endPointMode:e.endPointMode,auth:e.auth}),_.requestClient=this.requestClient,null===(n=null==this?void 0:this.fire)||void 0===n||n.call(this,"cloudbase_init",_),this.try2InitAuth(_),(null===(o=l.Platform.adapter)||void 0===o?void 0:o.nodeTool)&&(null===(i=l.Platform.adapter)||void 0===i||i.nodeTool(_,this.cloudbaseConfig)),_},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,(0,d.initCache)({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.updateLang=function(t){var e;t&&t!==(null===(e=this.cloudbaseConfig.i18n)||void 0===e?void 0:e.lang)&&(this.cloudbaseConfig.i18n.lang=t)},t.prototype.registerExtension=function(t){O[t.name]=t},t.prototype.invokeExtension=function(t,e){return s(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:if(!(n=O[t]))throw new Error(JSON.stringify({code:b.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,n.invoke(e,this)];case 1:return[2,r.sent()]}}))}))},t.prototype.useAdapters=function(t,e){var n=m(t,e)||{},r=n.adapter,o=n.runtime;r&&(l.Platform.adapter=r),o&&(l.Platform.runtime=o)},t.prototype.registerHook=function(e){(0,c.registerHook)(t,e)},t.prototype.registerComponent=function(e){(0,c.registerComponent)(t,e)},t.prototype.registerVersion=function(t){(0,f.setSdkVersion)(t),this.version=t},t.prototype.registerSdkName=function(t){(0,f.setSdkName)(t)},t.prototype.isInitialized=function(t){return void 0===t&&(t=this.cloudbaseConfig),["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some((function(e){return t.env.toLowerCase()===e.toLowerCase()}))&&w(b.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(t.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==t?void 0:t.env)},t.prototype.registerEndPoint=function(t,e){(0,f.setEndPointInfo)({baseUrl:t,protocol:e,env:this.config.env,endPointKey:"CLOUD_API"})},t.prototype.registerEndPointWithKey=function(t){(0,f.setEndPointInfo)({env:this.config.env,endPointKey:t.key,baseUrl:t.url,protocol:t.protocol})},t.prototype.getEndPointWithKey=function(t){var e=(0,f.getEndPointInfo)(this.config.env,t);return{BASE_URL:e.baseUrl,PROTOCOL:e.protocol}},t.prototype.parseCaptcha=function(t){return u.utils.parseCaptcha(t)},t.prototype.useDefaultAdapter=function(){var t=g.bind(this)(),e=t.adapter,n=t.runtime;l.Platform.adapter=e,l.Platform.runtime=n},t.prototype.formatTimeout=function(t){switch(!0){case t>S:return w(b.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),S;case t<100:return w(b.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},t.prototype.try2InitAuth=function(t){try{t.auth()}catch(t){console.log("try2InitAuth error:",t)}},t.prototype.dealNodeAdapterConfig=function(t){return t},o([E({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(_)]}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",t)],t.prototype,"init",null),o([E({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(_)]}),i("design:type",Function),i("design:paramtypes",[String,Object]),i("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}();e.cloudbase=new A,e.cloudbase.useAdapters((0,l.getWxDefaultAdapter)()),e.default=e.cloudbase},1985:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e},a=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.getWxDefaultAdapter=e.Platform=void 0;var u=s(n(7917)),c=n(2764);e.Platform={},e.getWxDefaultAdapter=function(){return u.WxRequest.prototype.upload=function(t){var e=this,n=this;return new Promise((function(o){var i=t.url,s=t.file,a=t.data,u=t.headers,c=wx.getFileSystemManager(),l=wx.request({url:i,method:t.method,header:r({"content-type":" "},u),data:c.readFileSync(s),timeout:e._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&(null==a?void 0:a.success_action_status)&&(e.statusCode=parseInt(a.success_action_status,10)),o(e)},fail:function(t){o(t)},complete:function(t){if((null==t?void 0:t.errMsg)&&n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{l.abort()}catch(t){}}}})}))},u.default.genAdapter=function(t){return{root:{globalThis:{}},reqClass:u.WxRequest,wsClass:u.WxMpWebSocket,captchaOptions:{openURIWithCallback:function(e){var n=t.EventBus,o={},i=e;console.log("openURIWithCallback",e);var s=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(s){i=s[1],console.log("openURIWithCallback url",i);var c=s[2];c&&(o=(0,u.parseQueryString)(c))}console.log("openURIWithCallback queryObj",o);var l=o.token,d=a(o,["token"]);return/^data:/.test(i)&&!l?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(e)}):l?new Promise((function(t){console.log("wait for captcha..."),n.$emit("CAPTCHA_DATA_CHANGE",r(r({},d),{token:l,url:i})),n.$once("RESOLVE_CAPTCHA_DATA",(function(e){t(e)}))})):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:u.wxMpStorage,primaryStorage:c.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},u.default}},6938:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.getLocalCache=e.getCacheByEnvId=e.initCache=void 0;var o=n(2877).cache.CloudbaseCache,i={},s={};e.initCache=function(t){var e=t.env,n=t.platformInfo,a={userInfoKey:"".concat("user_info","_").concat(e)};i[e]=i[e]||new o(r(r({},t),{keys:a,platformInfo:n})),s[e]=s[e]||new o(r(r({},t),{keys:a,platformInfo:n,persistence:"local"}))},e.getCacheByEnvId=function(t){return i[t]},e.getLocalCache=function(t){return s[t]}},4276:function(t,e,n){"use strict";var r=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.registerHook=e.registerComponent=void 0;var o=n(2877).constants.ERRORS,i={};function s(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=s(t[o],e[o]))}return t}e.registerComponent=function(t,e){var n=e.name,a=e.namespace,u=e.entity,c=e.injectEvents,l=e.IIFE,d=void 0!==l&&l;if(i[n]||a&&t[a])throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(d){if(!u||"function"!=typeof u)throw new Error(JSON.stringify({code:o.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));u.call(t)}if(i[n]=e,a?t.prototype[a]=u:s(t.prototype,u),c){var h=c.bus,f=c.events;if(!h||!f||0===f.length)return;var p=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=r(r([],t.prototype.events[n].events,!0),f,!0):t.prototype.events[n]={bus:h,events:f},t.prototype.fire=function(t,e){p(t,e);for(var n=0,r=Object.keys(this.events);n<r.length;n++){var o=r[n],i=this.events[o],s=i.bus;if(i.events.includes(t)){s.fire(t,e);break}}}}},e.registerHook=function(t,e){var n=e.entity,i=e.target;if(Object.prototype.hasOwnProperty.call(t,i))throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:".concat(i," is not exist")}));var s=t.prototype[i];if("function"!=typeof s)throw new Error(JSON.stringify({code:o.INVALID_OPERATION,msg:"target:".concat(i," is not a function which is the only type supports hook")}));t.prototype[i]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,r([this],t,!1)),s.call.apply(s,r([this],t,!1))}}},3509:function(t,e,n){"use strict";var r;Object.defineProperty(e,"__esModule",{value:!0}),e.i18nProxy=e.t=e.langMap=e.LANG_HEADER_KEY=e.LANGS=void 0;var o,i=n(2877);!function(t){t.ZH="zh-CN",t.EN="en-US"}(o=e.LANGS||(e.LANGS={})),e.LANG_HEADER_KEY="Accept-Language",e.langMap=((r={})[o.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code","错误信息":"error message","未实现":"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs","请求超时":"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},r),e.t=function(t,n){var r;return(null===(r=e.langMap[n])||void 0===r?void 0:r[t])||t},e.i18nProxy=function(t,n){var r,s,a=function(t){return"lang_".concat(t.clientId||t.env)}(n),u=(t.adapter||{}).localStorage,c=n.lang||(null===(r=null==u?void 0:u.getItem)||void 0===r?void 0:r.call(u,a))||o.ZH;return null===(s=null==u?void 0:u.setItem)||void 0===s||s.call(u,a,c),new Proxy({t:function(t){return(0,e.t)(t,c)},LANG_HEADER_KEY:e.LANG_HEADER_KEY,lang:c},{get:function(t,e){var n;return"lang"===e&&(null===(n=null==u?void 0:u.getItem)||void 0===n?void 0:n.call(u,a))||t[e]},set:function(t,n,r){var o;return"lang"===n&&r!==t[n]&&(t[n]=r,t.t=function(t){return(0,e.t)(t,r)},null===(o=null==u?void 0:u.setItem)||void 0===o||o.call(u,a,r),i.langEvent.bus.fire(i.langEvent.LANG_CHANGE_EVENT,{i18n:t})),t[n]=r,!0}})}},901:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.getRequestByEnvId=e.initRequest=e.CloudbaseRequest=void 0;var a=n(7922),u=n(2877),c=n(6938),l=n(1985),d=u.constants.ERRORS,h=u.utils.genSeqId,f=u.utils.isFormData,p=u.utils.formatUrl,v=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function y(t,e,n){var o=t[e];t[e]=function(e){var i={},s={};n.forEach((function(n){var r=n.call(t,e),o=r.data,a=r.headers;Object.assign(i,o),Object.assign(s,a)}));var a=e.data;return a&&(f(a)?Object.keys(i).forEach((function(t){a.append(t,i[t])})):e.data=r(r({},a),i)),e.headers=r(r({},e.headers||{}),s),o.call(t,e)}}function m(){var t=h();return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat((0,a.getSdkVersion)()),"x-seqid":t}}}var g=function(){function t(t){var e=this;this.throwWhenRequestFail=!1,this.config=t;var n={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"],auth:t.auth};this.reqClass=new l.Platform.adapter.reqClass(n),this.throwWhenRequestFail=t.throw||!1,this.localCache=(0,c.getLocalCache)(this.config.env),"GATEWAY"!==this.config.endPointMode&&(y(this.reqClass,"post",[m]),y(this.reqClass,"upload",[m]),y(this.reqClass,"download",[m])),u.langEvent.bus.on(u.langEvent.LANG_CHANGE_EVENT,(function(t){var n;e.config.i18n=(null===(n=t.data)||void 0===n?void 0:n.i18n)||e.config.i18n}))}return t.prototype.getAccessToken=function(t){return void 0===t&&(t=null),o(this,void 0,void 0,(function(){var e,n,r;return i(this,(function(o){switch(o.label){case 0:if(null!=t)return[2,t];if(!(e=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return n=e.oauthInstance,r=n.oauth2client,[4,this.getOauthAccessTokenV2(r)];case 1:return[2,o.sent().accessToken]}}))}))},t.prototype.getDefaultHeaders=function(){var t,e,n;return(t={})[null===(e=this.config.i18n)||void 0===e?void 0:e.LANG_HEADER_KEY]=null===(n=this.config.i18n)||void 0===n?void 0:n.lang,t["X-SDK-Version"]="@cloudbase/js-sdk/".concat((0,a.getSdkVersion)()),t},t.prototype.post=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.reqClass.post(r(r({},t),{headers:r(r({},t.headers),this.getDefaultHeaders()),customReqOpts:e}))];case 1:return[2,n.sent()]}}))}))},t.prototype.upload=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(r(r({},t),{headers:r(r({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(r(r({},t),{headers:r(r({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(t){return void 0===t&&(t="CLOUD_API"),(0,a.getBaseEndPoint)(this.config.env,t)},t.prototype.getOauthAccessTokenV2=function(t){return o(this,void 0,Promise,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,t.getAccessToken()];case 1:return e=r.sent(),[4,t.getCredentials()];case 2:return n=r.sent(),[2,{accessToken:e,accessTokenExpire:new Date(n.expires_at).getTime()}]}}))}))},t.prototype.request=function(t,e,n,s){var u,c;return o(this,void 0,Promise,(function(){var o,l,d,h,f,y,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N,D,U;return i(this,(function(i){switch(i.label){case 0:if(i.trys.push([0,4,,5]),o="x-tcb-trace_".concat(this.config.env),l="application/x-www-form-urlencoded",d=r({action:t,dataVersion:a.DATA_VERSION,env:this.config.env},e),-1!==v.indexOf(t))return[3,2];if(!(h=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return f=h.oauthInstance,y=f.oauth2client,m=d,[4,this.getOauthAccessTokenV2(y)];case 1:m.access_token=i.sent().accessToken,i.label=2;case 2:return"storage.uploadFile"===t?(g=new FormData,Object.keys(g).forEach((function(t){Object.prototype.hasOwnProperty.call(g,t)&&void 0!==g[t]&&g.append(t,d[t])})),l="multipart/form-data"):(l="application/json;charset=UTF-8",g={},Object.keys(d).forEach((function(t){void 0!==d[t]&&(g[t]=d[t])}))),b={headers:r(r({"content-type":l},this.getDefaultHeaders()),null==n?void 0:n.headers)},(null==n?void 0:n.onUploadProgress)&&(b.onUploadProgress=n.onUploadProgress),this.config.region&&(b.headers["X-TCB-Region"]=this.config.region),(_=this.localCache.getStore(o))&&(b.headers["X-TCB-Trace"]=_),w=void 0!==(null==n?void 0:n.parse)?n.parse:e.parse,E=void 0!==(null==n?void 0:n.inQuery)?n.inQuery:e.inQuery,I=void 0!==(null==n?void 0:n.search)?n.search:e.search,S=r(r({},(null==n?void 0:n.defaultQuery)||{}),{env:this.config.env}),w&&(S.parse=!0),E&&(S=r(r({},E),S)),O=(null==n?void 0:n.endPointMode)||this.config.endPointMode||"CLOUD_API",A=(0,a.getEndPointInfo)(this.config.env,O),T=A.baseUrl,P=A.protocol,"GATEWAY"===O&&/^((database)\.)|(auth\.wsWebSign)/.test(t)&&(R=(0,a.getEndPointInfo)(this.config.env,"CLOUD_API"),T="".concat(R.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),C=void 0,C=n.pathname?p(P,"".concat(null===(u=(0,a.getBaseEndPoint)(this.config.env,O))||void 0===u?void 0:u.replace(/^https?:/,""),"/").concat(n.pathname),S):p(P,T,S),I&&(C+=I),[4,this.post(r({url:C,data:g},b),s)];case 3:if(N=i.sent(),(D=null===(c=N.header)||void 0===c?void 0:c["x-tcb-trace"])&&this.localCache.setStore(o,D),200!==Number(N.status)&&200!==Number(N.statusCode)||!N.data)throw new Error("network request error");return[2,N];case 4:U=i.sent();try{U.requestId=U.requestId||(null==n?void 0:n.headers["x-request-id"])||(null==n?void 0:n.headers["X-Request-Id"])||""}catch(t){}throw U;case 5:return[2]}}))}))},t.prototype.fetch=function(t){var e,n,u,c,l,d,h,f;return o(this,void 0,Promise,(function(){var p,v,y,m,g,b,_,w,E=this;return i(this,(function(I){switch(I.label){case 0:p=t.token,v=t.headers,y=void 0===v?{}:v,m=t.withCredentials,g=void 0===m||m,b=s(t,["token","headers","withCredentials"]),_=function(){return o(E,void 0,void 0,(function(){var t,e,n,o;return i(this,(function(i){switch(i.label){case 0:return t={},g?(e=t,n="Bearer ".concat,[4,this.getAccessToken(p)]):[3,2];case 1:e.Authorization=n.apply("Bearer ",[i.sent()]),i.label=2;case 2:return o=r({headers:r(r(r({"X-SDK-Version":"@cloudbase/js-sdk/".concat((0,a.getSdkVersion)())},t),this.getDefaultHeaders()),y),withCredentials:g},b),[2,this.reqClass.fetch(o)]}}))}))},I.label=1;case 1:return I.trys.push([1,3,,6]),[4,_()];case 2:return[2,I.sent()];case 3:w=I.sent();try{w.requestId=w.requestId||y["x-request-id"]||y["X-Request-Id"]||""}catch(t){}if("ACCESS_TOKEN_EXPIRED"!==(null==w?void 0:w.code))return[3,5];if("function"!=typeof(null===(c=null===(u=null===(n=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===n?void 0:n.oauthInstance)||void 0===u?void 0:u.authApi)||void 0===c?void 0:c.refreshTokenForce))throw w;return[4,null===(f=null===(h=null===(d=null===(l=this.config)||void 0===l?void 0:l._fromApp)||void 0===d?void 0:d.oauthInstance)||void 0===h?void 0:h.authApi)||void 0===f?void 0:f.refreshTokenForce()];case 4:return I.sent(),[2,_()];case 5:throw w;case 6:return[2]}}))}))},t.prototype.send=function(t,e,n,s){return void 0===e&&(e={}),void 0===n&&(n={}),o(this,void 0,Promise,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return[4,this.request(t,e,r(r({},n),{onUploadProgress:e.onUploadProgress}),s)];case 1:if((o=i.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:d.OPERATION_FAIL,msg:"[".concat(o.data.code,"] ").concat(o.data.message)}));return[2,o.data]}}))}))},t.prototype.gateWay=function(t,e){var n;return o(this,void 0,void 0,(function(){var o,s,c,l,h,f,p,v,y,m,g,b,_,w,E,I,S,O,A;return i(this,(function(i){switch(i.label){case 0:if(o=t.url,s=t.name,c=t.data,l=t.path,h=void 0===l?"":l,f=t.method,p=t.header,v=void 0===p?{}:p,!(s&&h||o))throw new Error(JSON.stringify({code:d.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"}));try{y=c?JSON.stringify(c):""}catch(t){throw new Error(JSON.stringify({code:d.INVALID_PARAMS,msg:"[gateWay] invalid data"}))}if(m=u.utils.generateRequestId(),g=(0,a.getEndPointInfo)(this.config.env,"GATEWAY"),b=g.baseUrl,_=g.protocol,w="".concat(_).concat(b).concat(o||"/".concat(h,"/").concat(s)),E=["GET","HEAD"].includes(null===(n=null==f?void 0:f.toUpperCase)||void 0===n?void 0:n.call(f)))try{I={};try{I=JSON.parse(c)}catch(t){I=c||{}}w="".concat(w).concat(w.includes("?")?"&":"?").concat(Object.keys(I).map((function(t){return"".concat(t,"=").concat(I[t])})).join("&"))}catch(t){}return[4,this.fetch(r(r({method:f||"POST",headers:r({"Content-Type":"application/json; charset=utf-8","X-Request-Id":m},v)},E?{}:{body:y}),{url:w,customReqOpts:e}))];case 1:return S=i.sent(),O=[r({requestId:m},S)],A={},[4,S.data];case 2:return[2,r.apply(void 0,O.concat([(A.data=i.sent(),A)]))]}}))}))},t}();e.CloudbaseRequest=g;var b={};e.initRequest=function(t){b[t.env]=new g(r(r({},t),{throw:!0}))},e.getRequestByEnvId=function(t){return b[t]}},3548:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.useAuthAdapter=void 0;var s=n(1019),a=function(){function t(t){var e,n;try{this.localStorage=(null==t?void 0:t.localStorage)||((null===(n=null===(e=null==t?void 0:t.adapter)||void 0===e?void 0:e.root)||void 0===n?void 0:n.globalThis)||globalThis).localStorage}catch(e){this.localStorage=(null==t?void 0:t.localStorage)||{}}}return t.prototype.getItem=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.localStorage.getItem(t)]}))}))},t.prototype.removeItem=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this.localStorage.removeItem(t),[2]}))}))},t.prototype.setItem=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(n){return this.localStorage.setItem(t,e),[2]}))}))},t.prototype.getItemSync=function(t){return this.localStorage.getItem(t)},t.prototype.setItemSync=function(t,e){this.localStorage.setItem(t,e)},t.prototype.removeItemSync=function(t){this.localStorage.removeItem(t)},t}(),u=/^[^:]+:\/\/[^/]+(\/[^?#]+)/,c=function(t,e){var n,r,o,i,s=null===(n=null==e?void 0:e.headers)||void 0===n?void 0:n["x-request-id"];return t||(t={}),((null==t?void 0:t.code)||(null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.error_code))&&(t={error:t.code||t.data.error,error_description:t.data.error_description||t.message||t.code||t.data.error_code,request_id:t.requestId,error_code:null===(o=t.data)||void 0===o?void 0:o.error_code}),(null==t?void 0:t.request_id)||(t.request_id=t.request_id||s),(null==t?void 0:t.error)?(t.error_uri=(i=null==e?void 0:e.url,u.test(i)?RegExp.$1:i),t):(null==t?void 0:t.data)||{}};e.useAuthAdapter=function(t){return t.adapter&&"default"!==t.adapter.type?function(t,e){var n=r({},t);try{if(!(null==t?void 0:t.storage)&&(null==e?void 0:e.localStorage)&&(n.storage=new a({localStorage:e.localStorage,adapter:e})),!t.captchaOptions&&(null==e?void 0:e.captchaOptions)&&(n.captchaOptions=e.captchaOptions),!t.baseRequest&&!t.request&&(null==e?void 0:e.reqClass)){var s={timeout:1e4,restrictedMethods:["get","post","upload","download","request"],auth:t.auth},u=new e.reqClass(s);n.baseRequest=function(t,e){var n,s,a,l,d;return o(this,void 0,void 0,(function(){var o,h,f,p;return i(this,(function(i){switch(i.label){case 0:if(o={},h=(null===(n=e.method)||void 0===n?void 0:n.toLocaleLowerCase())||"post","function"!=typeof(f=null===(a=null===(s=null==u?void 0:u[h])||void 0===s?void 0:s.bind)||void 0===a?void 0:a.call(s,u)))throw new Error("invalid 【".concat(h,"】 request method"));i.label=1;case 1:return i.trys.push([1,3,,4]),(null===(l=e.headers)||void 0===l?void 0:l["content-type"])&&!(null===(d=e.headers)||void 0===d?void 0:d["content-type"].includes("application/json"))||["string","undefined"].includes(typeof e.body)||(e.data=e.data||e.body,e.body=JSON.stringify(e.body)),[4,f(r({url:t},e))];case 2:return o=i.sent(),o=c(o,r(r({},e),{url:t})),[3,4];case 3:throw p=i.sent(),o=r(r({},null==p?void 0:p.data),p);case 4:if(null==o?void 0:o.error)throw o;return[2,o]}}))}))}}}catch(t){console.error("user adapter generate fail:",t)}return n}(t,t.adapter):function(t,e){var n=r({},t),u={};if((null==e?void 0:e.captchaOptions)&&(n.captchaOptions=e.captchaOptions),!s.adapterForWxMp.isMatch()||t.storage&&t.baseRequest)return n;try{var l=s.adapterForWxMp.genAdapter({}),d=l.localStorage,h=l.reqClass;if(d&&(u.storage=new a({localStorage:d,adapter:e})),h){var f=new h({timeout:1e4,restrictedMethods:["get","post","upload","download","request"]});u.request=function(t){return function(e,n){return o(this,void 0,void 0,(function(){return i(this,(function(o){return[2,new Promise((function(o,i){var s=Object.assign({},n);s.body&&"string"!=typeof s.body&&(s.body=JSON.stringify(s.body));var a=wx.request({url:e,data:s.body,timeout:t._timeout,method:s.method||"GET",header:s.headers,success:function(t){(t=c(t,r(r({},n),{url:e}))).error&&i(t),o(t)},fail:function(t){i({error:"unreachable",error_description:t.message})},complete:function(e){if(e&&e.errMsg&&t._timeout&&-1!==t._restrictedMethods.indexOf("request")&&"request:fail timeout"===e.errMsg){console.warn(t._timeoutMsg);try{a.abort()}catch(t){}}}})}))]}))}))}}(f)}return n.captchaOptions&&(u.baseRequest=u.request,u.request=void 0),r(r({},n),u)}catch(t){console.error("adapter generate fail:",t)}return n}(t,t.adapter)}},9895:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__decorate||function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},a=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},u=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},c=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},l=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};Object.defineProperty(e,"__esModule",{value:!0}),e.registerAuth=e.AuthError=e.AuthErrorCategory=e.AnonymousAuthProvider=e.CustomAuthProvider=e.WeixinAuthProvider=e.Auth=e.generateAuthInstance=e.LoginState=e.User=void 0;var d=n(6722),h=n(3548),f=n(1019),p=n(5266),v=n(916);Object.defineProperty(e,"WeixinAuthProvider",{enumerable:!0,get:function(){return v.WeixinAuthProvider}}),Object.defineProperty(e,"CustomAuthProvider",{enumerable:!0,get:function(){return v.CustomAuthProvider}}),Object.defineProperty(e,"AnonymousAuthProvider",{enumerable:!0,get:function(){return v.AnonymousAuthProvider}});var y=n(2877),m=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},g=e.User=function(){function t(t){var e=t.cache,n=t.oauthInstance;this.cache=e,this.oauthInstance=n,this.setUserInfo()}var e,n,r;return t.prototype.checkLocalInfo=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){return this.uid=this.getLocalUserInfo("uid"),this.gender=this.getLocalUserInfo("gender"),this.picture=this.getLocalUserInfo("picture"),this.email=this.getLocalUserInfo("email"),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),this.username=this.getLocalUserInfo("username"),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}))}))},t.prototype.checkLocalInfoAsync=function(){return u(this,void 0,void 0,(function(){var t,e,n,r;return c(this,(function(o){switch(o.label){case 0:return t=this,[4,this.getLocalUserInfoAsync("uid")];case 1:return t.uid=o.sent(),e=this,[4,this.getLocalUserInfoAsync("gender")];case 2:return e.gender=o.sent(),this.picture=this.getLocalUserInfo("picture"),n=this,[4,this.getLocalUserInfoAsync("email")];case 3:return n.email=o.sent(),this.emailVerified=this.getLocalUserInfo("email_verified"),this.phoneNumber=this.getLocalUserInfo("phone_number"),r=this,[4,this.getLocalUserInfoAsync("username")];case 4:return r.username=o.sent(),this.name=this.getLocalUserInfo("name"),this.birthdate=this.getLocalUserInfo("birthdate"),this.zoneinfo=this.getLocalUserInfo("zoneinfo"),this.locale=this.getLocalUserInfo("locale"),this.sub=this.getLocalUserInfo("sub"),this.createdFrom=this.getLocalUserInfo("created_from"),this.providers=this.getLocalUserInfo("providers"),[2]}}))}))},t.prototype.update=function(t){return u(this,void 0,Promise,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.setUserProfile(i({},t))];case 1:return e=n.sent(),this.setLocalUserInfo(e),[2]}}))}))},t.prototype.updateUserBasicInfo=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.updateUserBasicInfo(i({},t))];case 1:return e.sent(),[4,this.refresh()];case 2:return e.sent(),[2]}}))}))},t.prototype.updatePassword=function(t,e){return this.oauthInstance.authApi.updatePasswordByOld({old_password:e,new_password:t})},t.prototype.updateUsername=function(t){return"string"!=typeof t&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),this.update({username:t})},t.prototype.refresh=function(t){return u(this,void 0,Promise,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,this.oauthInstance.authApi.getUserInfo(t)];case 1:if("INVALID_ACCESS_TOKEN"===(e=n.sent()).code)throw this.setLocalUserInfo({}),e;return this.setLocalUserInfo(e),[2,e]}}))}))},t.prototype.getLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey,n=this.cache.getStore(e);return t?n[t]:n||{}},t.prototype.setLocalUserInfo=function(t){var e=this.cache.keys.userInfoKey;this.cache.setStore(e,t),this.setUserInfo()},t.prototype.getLocalUserInfoAsync=function(t){return u(this,void 0,Promise,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return e=this.cache.keys.userInfoKey,[4,this.cache.getStoreAsync(e)];case 1:return[2,n.sent()[t]]}}))}))},t.prototype.setUserInfo=function(){var t=this,e=this.cache.keys.userInfoKey,n=this.cache.getStore(e);["uid","email","name","gender","picture","email_verified","phone_number","birthdate","zoneinfo","locale","sub","created_from","providers","username","created_at","open_id"].forEach((function(e){t[e]=n[e]}))},s([(0,f.catchErrorsDecorator)({title:"更新用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.update() 的语法或参数是否正确"," 2 - 用户信息中是否包含非法值","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(e=void 0!==d.authModels&&d.authModels.UserProfile)?e:Object]),a("design:returntype","function"==typeof(n="undefined"!=typeof Promise&&Promise)?n:Object)],t.prototype,"update",null),s([(0,f.catchErrorsDecorator)({title:"更新密码失败",messages:["请确认以下各项:"," 1 - 调用 User.updatePassword() 的语法或参数是否正确"," 3 - 新密码中是否包含非法字符","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String,String]),a("design:returntype",void 0)],t.prototype,"updatePassword",null),s([(0,f.catchErrorsDecorator)({title:"更新用户名失败",messages:["请确认以下各项:"," 1 - 调用 User.updateUsername() 的语法或参数是否正确"," 2 - 当前环境是否开通了用户名密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype",void 0)],t.prototype,"updateUsername",null),s([(0,f.catchErrorsDecorator)({title:"刷新本地用户信息失败",messages:["请确认以下各项:"," 1 - 调用 User.refresh() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(r="undefined"!=typeof Promise&&Promise)?r:Object)],t.prototype,"refresh",null),t}();(0,v.applyUserV1Compat)(g);var b=function(){function t(t){var e=t.envId,n=t.cache,r=t.oauthInstance;e||(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"envId is not defined"),this.cache=n,this.oauthInstance=r,this.user=new g({cache:this.cache,oauthInstance:r})}return t.prototype.checkLocalState=function(){var t;this.oauthLoginState=null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync(),this.user.checkLocalInfo()},t.prototype.checkLocalStateAsync=function(){var t;return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.getLoginState()];case 1:return e.sent(),[4,this.user.checkLocalInfoAsync()];case 2:return e.sent(),[2]}}))}))},t}();e.LoginState=b;var _=function(t){function e(e){var n=t.call(this)||this;return n.listeners=new Map,n.hasListenerSetUp=!1,n.config=e,n.oauthInstance=e.oauthInstance,n.cache=e.cache,n.init(),n.setAccessKey(),n}var n,r,h,v,g,_,w,E,I,S,O,A,T,P,R,C,N,D,U,x;return o(e,t),e.prototype.signInAnonymously=function(t){return u(this,void 0,Promise,(function(){var e,n,r,o,s;return c(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.authApi.signInAnonymously(t)];case 1:return a.sent(),[4,this.createLoginState()];case 2:return e=a.sent(),[4,this.getSession()];case 3:return n=a.sent().data,r=(void 0===n?{}:n).session,[2,i(i({},e),{data:{user:r.user,session:r},error:null})];case 4:return o=a.sent(),(s=new d.AuthError(o,{method:"signInAnonymously"})).category===d.AuthErrorCategory.PROVIDER_NOT_ENABLED?(console.error(s.helpMessage),console.error("[CloudBase Auth] 提示:匿名登录需要在控制台开启「匿名登录」。\n 如果您需要使用用户名密码登录,请改用 auth.signInWithPassword({ username, password })。\n 不要在匿名登录失败后自动回退到密码登录,这两种方式的使用场景不同。")):(console.warn("[CloudBase Auth] signInAnonymously 失败 [".concat(s.category,"]: ").concat(s.message)),s.loginMethodHint&&console.warn(s.loginMethodHint)),[2,{data:{},error:s}];case 5:return[2]}}))}))},e.prototype.signUp=function(t){return u(this,void 0,Promise,(function(){var e,n,r=this;return c(this,(function(o){switch(o.label){case 0:return t.phone_number||t.verification_code||t.verification_token||t.provider_token?(t.phone_number&&(t.phone_number=this.formatPhone(t.phone_number)),[4,this.oauthInstance.authApi.signUp(t)]):[3,2];case 1:return o.sent(),[2,this.createLoginState()];case 2:return o.trys.push([2,4,,5]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)})];case 3:return e=o.sent(),[2,{data:{verifyOtp:function(n){var o=n.token,s=n.messageId,a=void 0===s?e.verification_id:s;return u(r,void 0,Promise,(function(){var n,r,s,u,l;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.verify({verification_id:a||e.verification_id,verification_code:String(o)})];case 1:return n=c.sent(),e.is_user?[4,this.signIn({username:t.email||this.formatPhone(t.phone),verification_token:n.verification_token})]:[3,3];case 2:return c.sent(),[3,6];case 3:return delete(r=JSON.parse(JSON.stringify(t))).email,delete r.phone,[4,this.oauthInstance.authApi.signUp(i(i(i({},r),t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)}),{verification_token:n.verification_token,verification_code:o}))];case 4:return c.sent(),[4,this.createLoginState()];case 5:c.sent(),c.label=6;case 6:return[4,this.getSession()];case 7:return s=c.sent().data,[2,{data:{user:(u=(void 0===s?{}:s).session).user,session:u},error:null}];case 8:return l=c.sent(),[2,{data:{},error:new d.AuthError(l,{method:"signUp"})}];case 9:return[2]}}))}))}},error:null}];case 4:return n=o.sent(),[2,{data:{},error:new d.AuthError(n,{method:"signUp"})}];case 5:return[2]}}))}))},e.prototype.signOut=function(t){var e,n;return u(this,void 0,Promise,(function(){var r,o,s;return c(this,(function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),r=this.cache.keys.userInfoKey,[4,this.oauthInstance.authApi.signOut(t)];case 1:return o=a.sent(),[4,this.cache.removeStoreAsync(r)];case 2:return a.sent(),this.setAccessKey(),null===(e=this.config.eventBus)||void 0===e||e.fire(d.EVENTS.LOGIN_STATE_CHANGED,{eventType:d.LOGIN_STATE_CHANGED_TYPE.SIGN_OUT}),null===(n=this.config.eventBus)||void 0===n||n.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT}),[2,i(i({},o),{data:{},error:null})];case 3:return s=a.sent(),[2,{data:{},error:new d.AuthError(s,{method:"signOut"})}];case 4:return[2]}}))}))},e.prototype.onAuthStateChange=function(t){var e=this;this.hasListenerSetUp||(this.setupListeners(),this.hasListenerSetUp=!0);var n=Math.random().toString(36);return this.listeners.has(n)||this.listeners.set(n,new Set),this.listeners.get(n).add(t),{data:{subscription:{id:n,callback:t,unsubscribe:function(){var r=e.listeners.get(n);r&&(r.delete(t),0===r.size&&e.listeners.delete(n))}}}}},e.prototype.signInWithPassword=function(t){return u(this,void 0,Promise,(function(){var e,n,r,o;return c(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),this.validateAtLeastOne(t,[["username"],["email"],["phone"]],"You must provide either username, email, or phone"),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),[4,this.signIn(i({username:t.username||t.email||this.formatPhone(t.phone),password:t.password},t.is_encrypt?{isEncrypt:!0,version:"v2"}:{}))];case 1:return s.sent(),[4,this.getSession()];case 2:return e=s.sent().data,[2,{data:{user:(n=(void 0===e?{}:e).session).user,session:n},error:null}];case 3:return r=s.sent(),(o=new d.AuthError(r,{method:"signInWithPassword"})).category===d.AuthErrorCategory.PROVIDER_NOT_ENABLED?console.error(o.helpMessage):o.category===d.AuthErrorCategory.INVALID_CREDENTIALS||o.category===d.AuthErrorCategory.USER_NOT_FOUND?console.warn(o.helpMessage):console.warn("[CloudBase Auth] signInWithPassword 失败 [".concat(o.category,"]: ").concat(o.message)),o.loginMethodHint&&console.info(o.loginMethodHint),[2,{data:{},error:o}];case 4:return[2]}}))}))},e.prototype.signInWithIdToken=function(t){return u(this,void 0,Promise,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.validateParams(t,{token:{required:!0,message:"Token is required"}}),[4,this.signInWithProvider({provider_token:t.token})];case 1:return o.sent(),[4,this.getSession()];case 2:return e=o.sent().data,[2,{data:{user:(n=(void 0===e?{}:e).session).user,session:n},error:null}];case 3:return r=o.sent(),[2,{data:{},error:new d.AuthError(r,{method:"signInWithIdToken"})}];case 4:return[2]}}))}))},e.prototype.signInWithOtp=function(t){var e,n,r,o;return u(this,void 0,Promise,(function(){var s,a,l=this;return c(this,(function(h){switch(h.label){case 0:if(!(null===(e=t.options)||void 0===e?void 0:e.emailRedirectTo)&&(void 0===(null===(n=t.options)||void 0===n?void 0:n.shouldCreateUser)||(null===(r=t.options)||void 0===r?void 0:r.shouldCreateUser)))return[2,this.signUp({email:t.email,phone:t.phone})];h.label=1;case 1:return h.trys.push([1,3,,4]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),[4,this.getVerification(i({email_redirect_to:null===(o=t.options)||void 0===o?void 0:o.emailRedirectTo},t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)}))];case 2:return s=h.sent(),[2,{data:{user:null,session:null,verifyOtp:function(e){var n=e.token,r=e.messageId,o=void 0===r?s.verification_id:r;return u(l,void 0,Promise,(function(){return c(this,(function(e){return[2,this.verifyOtp({email:t.email,phone:t.phone,token:String(n),messageId:o})]}))}))}},error:null}];case 3:return a=h.sent(),[2,{data:{},error:new d.AuthError(a,{method:"signInWithOtp"})}];case 4:return[2]}}))}))},e.prototype.verifyOAuth=function(t){return u(this,void 0,Promise,(function(){var e,n,r,o,s,a,u,l,h;return c(this,(function(c){switch(c.label){case 0:e={},c.label=1;case 1:return c.trys.push([1,7,,8]),n=(null==t?void 0:t.code)||y.utils.getQuery("code"),r=(null==t?void 0:t.state)||y.utils.getQuery("state"),n?r?(o=(0,p.getBrowserSession)(r),e.type=null==o?void 0:o.type,(s=(null==t?void 0:t.provider)||(null==o?void 0:o.provider)||y.utils.getQuery("provider"))?[4,this.grantProviderToken({provider_id:s,provider_redirect_uri:location.origin+location.pathname,provider_code:n})]:[2,{data:e,error:new d.AuthError({message:"Provider is required"})}]):[2,{data:{},error:new d.AuthError({message:"State is required"})}]:[2,{data:{},error:new d.AuthError({message:"Code is required"})}];case 2:return a=c.sent().provider_token,u=void 0,o.type!==d.OAUTH_TYPE.BIND_IDENTITY?[3,4]:[4,this.oauthInstance.authApi.toBindIdentity({provider_token:a,provider:s,fireEvent:!0})];case 3:return u=c.sent(),[3,6];case 4:return[4,this.signInWithIdToken({token:a})];case 5:(u=c.sent()).data=i(i({},e),u.data),c.label=6;case 6:return(l=new URLSearchParams(null===location||void 0===location?void 0:location.search)).delete("code"),l.delete("state"),u.data.redirectUrl=(0,p.addUrlSearch)(void 0===(null==o?void 0:o.search)?"?".concat(l.toString()):null==o?void 0:o.search,(null==o?void 0:o.hash)||location.hash),(0,p.removeBrowserSession)(r),[2,u];case 7:return h=c.sent(),[2,{data:e,error:new d.AuthError(h,{method:"verifyOAuth"})}];case 8:return[2]}}))}))},e.prototype.signInWithOAuth=function(t){var e,n,r,o,i;return u(this,void 0,Promise,(function(){var s,a,u,l,h,f,v,y,g;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),s=(null===(e=t.options)||void 0===e?void 0:e.redirectTo)||location.href,a=new URL(s),u=a.origin+a.pathname,l=(null===(n=t.options)||void 0===n?void 0:n.state)||"prd-".concat(t.provider,"-").concat(Math.random().toString(36).slice(2)),[4,this.genProviderRedirectUri({provider_id:t.provider,provider_redirect_uri:u,state:l})];case 1:return h=c.sent().uri,f=decodeURIComponent(h),v=f,(null===(r=t.options)||void 0===r?void 0:r.queryParams)&&(y=new URL(f),Object.entries(t.options.queryParams).forEach((function(t){var e=t[0],n=t[1];y.searchParams.set(e,n)})),v=y.toString()),(0,p.saveToBrowserSession)(l,{provider:t.provider,search:a.search,hash:a.hash,type:(null===(o=t.options)||void 0===o?void 0:o.type)||d.OAUTH_TYPE.SIGN_IN}),m()&&!(null===(i=t.options)||void 0===i?void 0:i.skipBrowserRedirect)&&window.location.assign(v),[2,{data:{url:v,provider:t.provider},error:null}];case 2:return g=c.sent(),[2,{data:{},error:new d.AuthError(g,{method:"signInWithOAuth"})}];case 3:return[2]}}))}))},e.prototype.getClaims=function(){return u(this,void 0,Promise,(function(){var t,e;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getAccessToken()];case 1:return t=n.sent().accessToken,[2,{data:(0,d.weAppJwtDecodeAll)(t),error:null}];case 2:return e=n.sent(),[2,{data:{},error:new d.AuthError(e,{method:"getClaims"})}];case 3:return[2]}}))}))},e.prototype.resetPasswordForEmail=function(t,e){return u(this,void 0,Promise,(function(){var n,r,o,i,s,a,l=this;return c(this,(function(h){switch(h.label){case 0:return h.trys.push([0,2,,3]),this.validateParams({emailOrPhone:t},{emailOrPhone:{required:!0,message:"Email or phone is required"}}),n=(e||{}).redirectTo,r=t.includes("@"),o=void 0,r?o={email:t}:(i=this.formatPhone(t),o={phone_number:i}),[4,this.getVerification(o)];case 1:return s=h.sent(),[2,{data:{updateUser:function(e){return u(l,void 0,Promise,(function(){var o,i,a,u;return c(this,(function(c){switch(c.label){case 0:this.validateParams(e,{nonce:{required:!0,message:"Nonce is required"},password:{required:!0,message:"Password is required"}}),c.label=1;case 1:return c.trys.push([1,5,,6]),[4,this.verify({verification_id:s.verification_id,verification_code:e.nonce})];case 2:return o=c.sent(),[4,this.oauthInstance.authApi.resetPassword({email:r?t:void 0,phone_number:r?void 0:t,new_password:e.password,verification_token:o.verification_token})];case 3:return c.sent(),null===(u=this.config.eventBus)||void 0===u||u.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.PASSWORD_RECOVERY}),[4,this.signInWithPassword({email:r?t:void 0,phone:r?void 0:t,password:e.password})];case 4:return i=c.sent(),n&&m()&&window.location.assign(n),[2,i];case 5:return a=c.sent(),[2,{data:{},error:new d.AuthError(a,{method:"resetPasswordForEmail"})}];case 6:return[2]}}))}))}},error:null}];case 2:return a=h.sent(),[2,{data:{},error:new d.AuthError(a,{method:"resetPasswordForEmail"})}];case 3:return[2]}}))}))},e.prototype.resetPasswordForOld=function(t){return u(this,void 0,void 0,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.authApi.updatePasswordByOld({old_password:t.old_password,new_password:t.new_password})];case 1:return o.sent(),[4,this.getSession()];case 2:return e=o.sent().data,[2,{data:{user:(n=(void 0===e?{}:e).session).user,session:n},error:null}];case 3:return r=o.sent(),[2,{data:{},error:new d.AuthError(r,{method:"resetPasswordForOld"})}];case 4:return[2]}}))}))},e.prototype.verifyOtp=function(t){return u(this,void 0,Promise,(function(){var e,n,r,o,i;return c(this,(function(s){switch(s.label){case 0:return s.trys.push([0,6,,7]),e=t.type,n=String(t.token),this.validateParams(t,{token:{required:!0,message:"Token is required"},messageId:{required:!0,message:"messageId is required"}}),["phone_change","email_change"].includes(e)?[4,this.verify({verification_id:t.messageId,verification_code:n})]:[3,2];case 1:return s.sent(),[3,4];case 2:return[4,this.signInWithUsername({verificationInfo:{verification_id:t.messageId,is_user:!0},verificationCode:n,username:t.email||this.formatPhone(t.phone)||"",loginType:t.email?"email":"phone"})];case 3:s.sent(),s.label=4;case 4:return[4,this.getSession()];case 5:return r=s.sent().data,[2,{data:{user:(o=(void 0===r?{}:r).session).user,session:o},error:null}];case 6:return i=s.sent(),[2,{data:{},error:new d.AuthError(i,{method:"verifyOtp"})}];case 7:return[2]}}))}))},e.prototype.getSession=function(){return u(this,void 0,Promise,(function(){var t,e,n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(t=o.sent())&&"accessKey"!==t.scope?[4,this.getUser(!1)]:[2,{data:{session:null,user:null},error:null}];case 2:return e=o.sent().data,n=(void 0===e?{}:e).user,[2,{data:{session:i(i({},t),{user:n}),user:n},error:null}];case 3:return r=o.sent(),[2,{data:{},error:new d.AuthError(r,{method:"getSession"})}];case 4:return[2]}}))}))},e.prototype.refreshSession=function(t){return u(this,void 0,Promise,(function(){var e,n,r,o,s;return c(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return(e=a.sent()).refresh_token=t||e.refresh_token,[4,this.oauthInstance.oauth2client.refreshToken(e)];case 2:return n=a.sent(),[4,this.getUser(!1)];case 3:return r=a.sent().data,[2,{data:{user:o=(void 0===r?{}:r).user,session:i(i({},n),{user:o})},error:null}];case 4:return s=a.sent(),[2,{data:{},error:new d.AuthError(s,{method:"refreshSession"})}];case 5:return[2]}}))}))},e.prototype.getUser=function(t){return void 0===t&&(t=!0),u(this,void 0,Promise,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,this.oauthInstance.oauth2client.getCredentials()];case 1:return(e=o.sent())&&"accessKey"!==e.scope?(n=this.convertToUser,[4,this.getCurrentUser(t)]):[2,{data:{user:null},error:null}];case 2:return[2,{data:{user:n.apply(this,[o.sent()])},error:null}];case 3:return r=o.sent(),[2,{data:{user:null},error:new d.AuthError(r,{method:"getUser"})}];case 4:return[2]}}))}))},e.prototype.refreshUser=function(){return u(this,void 0,Promise,(function(){var t,e,n;return c(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.currentUser.refresh()];case 1:return r.sent(),[4,this.getSession()];case 2:return t=r.sent().data,[2,{data:{user:(e=(void 0===t?{}:t).session).user,session:e},error:null}];case 3:return n=r.sent(),[2,{data:{},error:new d.AuthError(n,{method:"refreshUser"})}];case 4:return[2]}}))}))},e.prototype.updateUser=function(t){var e;return u(this,void 0,Promise,(function(){var n,r,o,s,a,h,f,p,v,y,m,g,b=this;return c(this,(function(_){switch(_.label){case 0:if(_.trys.push([0,8,,9]),!Object.keys(t).some((function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]})))throw new d.AuthError({message:"At least one field must be provided for update"});return n=t.email,r=t.phone,o=l(t,["email","phone"]),a=void 0!==r,h={},(s=void 0!==n)||a?(f=void 0,s?(f={email:t.email},p="email_change"):(v=this.formatPhone(t.phone),f={phone_number:v},p="phone_change"),[4,this.getVerification(f)]):[3,4];case 1:return y=_.sent(),Object.keys(o).length>0?[4,this.updateUserBasicInfo(o)]:[3,3];case 2:_.sent(),_.label=3;case 3:return h={messageId:y.verification_id,verifyOtp:function(e){return u(b,void 0,Promise,(function(){var n,r,o;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,11,,12]),e.email&&t.email===e.email?[4,this.verifyOtp({type:"email_change",email:t.email,token:e.token,messageId:y.verification_id})]:[3,3];case 1:return i.sent(),[4,this.updateUserBasicInfo({email:t.email})];case 2:return i.sent(),[3,9];case 3:return e.phone&&t.phone===e.phone?[4,this.verifyOtp({type:"phone_change",phone:t.phone,token:e.token,messageId:y.verification_id})]:[3,6];case 4:return i.sent(),[4,this.updateUserBasicInfo({phone:this.formatPhone(t.phone)})];case 5:return i.sent(),[3,9];case 6:return[4,this.verifyOtp({type:p,email:s?t.email:void 0,phone:s?void 0:t.phone,token:e.token,messageId:y.verification_id})];case 7:return i.sent(),[4,this.updateUserBasicInfo(t)];case 8:i.sent(),i.label=9;case 9:return[4,this.getUser(!1)];case 10:return n=i.sent().data.user,null===(o=this.config.eventBus)||void 0===o||o.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:{user:n},error:null}];case 11:return r=i.sent(),[2,{data:{},error:new d.AuthError(r,{method:"updateUser"})}];case 12:return[2]}}))}))}},[3,6];case 4:return[4,this.updateUserBasicInfo(t)];case 5:_.sent(),_.label=6;case 6:return[4,this.getUser(!1)];case 7:return m=_.sent().data.user,null===(e=this.config.eventBus)||void 0===e||e.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.USER_UPDATED}),[2,{data:i({user:m},h),error:null}];case 8:return g=_.sent(),[2,{data:{},error:new d.AuthError(g,{method:"updateUser"})}];case 9:return[2]}}))}))},e.prototype.getUserIdentities=function(){var t;return u(this,void 0,Promise,(function(){var e,n;return c(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.oauthInstance.authApi.getProviders()];case 1:return e=r.sent(),[2,{data:{identities:null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.filter((function(t){return!!t.bind}))},error:null}];case 2:return n=r.sent(),[2,{data:{},error:new d.AuthError(n,{method:"getUserIdentities"})}];case 3:return[2]}}))}))},e.prototype.linkIdentity=function(t){return u(this,void 0,Promise,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.signInWithOAuth({provider:t.provider,options:{type:d.OAUTH_TYPE.BIND_IDENTITY}})];case 1:return n.sent(),[2,{data:{provider:t.provider},error:null}];case 2:return e=n.sent(),[2,{data:{},error:new d.AuthError(e,{method:"linkIdentity"})}];case 3:return[2]}}))}))},e.prototype.unlinkIdentity=function(t){return u(this,void 0,Promise,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.validateParams(t,{provider:{required:!0,message:"Provider is required"}}),[4,this.oauthInstance.authApi.unbindProvider({provider_id:t.provider})];case 1:return n.sent(),[2,{data:{},error:null}];case 2:return e=n.sent(),[2,{data:{},error:new d.AuthError(e,{method:"unlinkIdentity"})}];case 3:return[2]}}))}))},e.prototype.reauthenticate=function(){return u(this,void 0,Promise,(function(){var t,e,n,r,o=this;return c(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,this.getUser(!1)];case 1:return t=s.sent().data.user,this.validateAtLeastOne(t,[["email","phone"]],"You must provide either an email or phone number"),e=t.email?{email:t.email}:{phone_number:this.formatPhone(t.phone)},[4,this.getVerification(e)];case 2:return n=s.sent(),[2,{data:{updateUser:function(t){return u(o,void 0,Promise,(function(){var r,o,s,a,u;return c(this,(function(c){switch(c.label){case 0:this.validateParams(t,{nonce:{required:!0,message:"Nonce is required"}}),c.label=1;case 1:return c.trys.push([1,9,,10]),t.password?[4,this.verify({verification_id:n.verification_id,verification_code:t.nonce})]:[3,5];case 2:return r=c.sent(),[4,this.oauthInstance.authApi.sudo({verification_token:r.verification_token})];case 3:return o=c.sent(),[4,this.oauthInstance.authApi.setPassword({new_password:t.password,sudo_token:o.sudo_token})];case 4:return c.sent(),[3,7];case 5:return[4,this.signInWithUsername(i(i({verificationInfo:n,verificationCode:t.nonce},e),{loginType:e.email?"email":"phone"}))];case 6:c.sent(),c.label=7;case 7:return[4,this.getSession()];case 8:return s=c.sent().data,[2,{data:{user:(a=(void 0===s?{}:s).session).user,session:a},error:null}];case 9:return u=c.sent(),[2,{data:{},error:new d.AuthError(u,{method:"reauthenticate"})}];case 10:return[2]}}))}))}},error:null}];case 3:return r=s.sent(),[2,{data:{},error:new d.AuthError(r,{method:"reauthenticate"})}];case 4:return[2]}}))}))},e.prototype.resend=function(t){return u(this,void 0,Promise,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateAtLeastOne(t,[["email"],["phone"]],"You must provide either an email or phone number"),e="signup"===t.type?"ANY":"USER",n={target:e},"email"in t&&(n.email=t.email),"phone"in t&&(n.phone_number=this.formatPhone(t.phone)),[4,this.oauthInstance.authApi.getVerification(n)];case 1:return[2,{data:{messageId:o.sent().verification_id},error:null}];case 2:return r=o.sent(),[2,{data:{},error:new d.AuthError(r,{method:"resend"})}];case 3:return[2]}}))}))},e.prototype.setSession=function(t){var e;return u(this,void 0,Promise,(function(){var n,r,o;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),this.validateParams(t,{access_token:{required:!0,message:"Access token is required"},refresh_token:{required:!0,message:"Refresh token is required"}}),[4,this.oauthInstance.oauth2client.refreshToken(t,{throwError:!0})];case 1:return i.sent(),[4,this.getSession()];case 2:return n=i.sent().data,r=(void 0===n?{}:n).session,null===(e=this.config.eventBus)||void 0===e||e.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,{data:{user:r.user,session:r},error:null}];case 3:return o=i.sent(),[2,{data:{},error:new d.AuthError(o,{method:"setSession"})}];case 4:return[2]}}))}))},e.prototype.exchangeCodeForSession=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){return[2]}))}))},e.prototype.deleteUser=function(t){return u(this,void 0,Promise,(function(){var e,n;return c(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),this.validateParams(t,{password:{required:!0,message:"Password is required"}}),[4,this.oauthInstance.authApi.sudo(t)];case 1:return e=r.sent().sudo_token,[4,this.oauthInstance.authApi.deleteMe({sudo_token:e})];case 2:return r.sent(),[2,{data:{},error:null}];case 3:return n=r.sent(),[2,{data:{},error:new d.AuthError(n,{method:"deleteUser"})}];case 4:return[2]}}))}))},e.prototype.toDefaultLoginPage=function(t){return void 0===t&&(t={}),u(this,void 0,Promise,(function(){var e,n,r,o,i;return c(this,(function(s){try{return e=t.config_version||"env",n=Object.keys(t.query||{}).map((function(e){return"".concat(e,"=").concat(t.query[e])})).join("&"),f.adapterForWxMp.isMatch()?wx.navigateTo({url:"/packages/$wd_system/pages/login/index".concat(n?"?".concat(n):"")}):(r=t.redirect_uri||window.location.href,o=new URL(r),i="".concat(o.origin,"/__auth/?app_id=").concat(t.app_id||"","&env_id=").concat(this.config.env,"&client_id=").concat(this.config.clientId||this.config.env,"&config_version=").concat(e,"&redirect_uri=").concat(encodeURIComponent(r)).concat(n?"&".concat(n):""),window.location.href=i),[2,{data:{},error:null}]}catch(t){return[2,{data:{},error:new d.AuthError(t,{method:"toDefaultLoginPage"})}]}return[2]}))}))},e.prototype.signInWithCustomTicket=function(t){return u(this,void 0,Promise,(function(){var e,n,r,o;return c(this,(function(s){switch(s.label){case 0:t&&this.setCustomSignFunc(t),s.label=1;case 1:return s.trys.push([1,5,,6]),[4,this.oauthInstance.authApi.signInWithCustomTicket()];case 2:return s.sent(),[4,this.createLoginState()];case 3:return e=s.sent(),[4,this.getSession()];case 4:return n=s.sent().data,r=(void 0===n?{}:n).session,[2,i(i({},e),{data:{user:r.user,session:r},error:null})];case 5:return o=s.sent(),[2,{data:{},error:new d.AuthError(o,{method:"signInWithCustomTicket"})}];case 6:return[2]}}))}))},e.prototype.signInWithOpenId=function(t){var e=(void 0===t?{}:t).useWxCloud,n=void 0===e||e;return u(this,void 0,Promise,(function(){var t,e,r,o,s,a,l=this;return c(this,(function(h){switch(h.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");t=wx.getAccountInfoSync().miniProgram,e=function(e){return u(l,void 0,void 0,(function(){var r,o;return c(this,(function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},n)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:r.provider_token},n)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[4,this.oauthInstance.oauth2client.setCredentials(o)];case 6:return i.sent(),[2]}}))}))},h.label=1;case 1:return h.trys.push([1,5,,6]),[4,new Promise((function(t,n){wx.login({success:function(r){return u(l,void 0,void 0,(function(){var o;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e(r.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return o=i.sent(),n(o),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,n(e)}})}))];case 2:return h.sent(),[4,this.createLoginState()];case 3:return r=h.sent(),[4,this.getSession()];case 4:return o=h.sent().data,s=(void 0===o?{}:o).session,[2,i(i({},r),{data:{user:s.user,session:s},error:null})];case 5:return a=h.sent(),[2,{data:{},error:new d.AuthError(a,{method:"signInWithOpenId"})}];case 6:return[2]}}))}))},e.prototype.signInWithPhoneAuth=function(t){var e=t.phoneCode,n=void 0===e?"":e,r=t.useWxCloud,o=void 0!==r&&r;return u(this,void 0,Promise,(function(){var t,e,r,s,a,u,l,h,p;return c(this,(function(c){switch(c.label){case 0:return f.adapterForWxMp.isMatch()?(t=wx.getAccountInfoSync().miniProgram,e={provider_params:{provider_code_type:"phone",code:n,appid:t.appId},provider_id:t.appId},[4,wx.login()]):[2,{data:{},error:new d.AuthError({message:"wx api undefined"})}];case 1:r=c.sent().code,e.provider_code=r,c.label=2;case 2:return c.trys.push([2,5,,6]),[4,this.oauthInstance.authApi.grantProviderToken(e,o)];case 3:if((s=c.sent()).error_code)throw s;return[4,this.oauthInstance.authApi.signInWithProvider({provider_token:s.provider_token},o)];case 4:if(null==(a=c.sent())?void 0:a.error_code)throw a;return[3,6];case 5:return u=c.sent(),[2,{data:{},error:new d.AuthError(u,{method:"signInWithPhoneAuth"})}];case 6:return[4,this.createLoginState()];case 7:return l=c.sent(),[4,this.getSession()];case 8:return h=c.sent().data,p=(void 0===h?{}:h).session,[2,i(i({},l),{data:{user:p.user,session:p},error:null})]}}))}))},e.prototype.bindPhoneNumber=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.editContact(t)]}))}))},e.prototype.unbindProvider=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.unbindProvider(t)]}))}))},e.prototype.bindEmail=function(t){return this.oauthInstance.authApi.editContact(t)},e.prototype.verify=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.verify(t)]}))}))},e.prototype.getVerification=function(t,e){return u(this,void 0,Promise,(function(){return c(this,(function(n){return t.phone_number&&(t.phone_number=this.formatPhone(t.phone_number)),[2,this.oauthInstance.authApi.getVerification(t,e)]}))}))},Object.defineProperty(e.prototype,"currentUser",{get:function(){if("async"!==this.cache.mode){var t=this.hasLoginState();return t&&t.user||null}(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getCurrentUser instead")},enumerable:!1,configurable:!0}),e.prototype.getCurrentUser=function(t){return void 0===t&&(t=!0),u(this,void 0,Promise,(function(){var e,n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),t?[4,this.getLoginState()]:[3,3];case 1:return(e=o.sent())?[4,e.user.refresh()]:[3,3];case 2:o.sent(),o.label=3;case 3:return[3,5];case 4:return o.sent(),[3,5];case 5:return[4,this.getLoginState()];case 6:return(n=o.sent())?(r=n.user.getLocalUserInfo(),[4,n.user.checkLocalInfoAsync()]):[3,8];case 7:return o.sent(),[2,i(i({},n.user),r)];case 8:return[2,null]}}))}))},e.prototype.signInAnonymouslyInWx=function(t){var e=(void 0===t?{}:t).useWxCloud;return u(this,void 0,Promise,(function(){var t,n,r=this;return c(this,(function(o){switch(o.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,n=function(n){return u(r,void 0,void 0,(function(){var r,o;return c(this,(function(i){switch(i.label){case 0:r=void 0,o=void 0,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:n,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}},e)];case 2:if((null==(r=i.sent())?void 0:r.error_code)||!r.provider_token)throw r;return[4,this.oauthInstance.authApi.signInAnonymously({provider_token:r.provider_token},e)];case 3:if(null==(o=i.sent())?void 0:o.error_code)throw o;return[3,5];case 4:throw i.sent();case 5:return[2]}}))}))},[4,new Promise((function(t,e){wx.login({success:function(o){return u(r,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,n(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return r=i.sent(),e(r),[3,3];case 3:return[2]}}))}))},fail:function(t){var n=new Error(null==t?void 0:t.errMsg);n.code=null==t?void 0:t.errno,e(n)}})}))];case 1:return o.sent(),[2,this.createLoginState(void 0,{asyncRefreshUser:!0})]}}))}))},e.prototype.bindOpenId=function(){return u(this,void 0,Promise,(function(){var t,e,n=this;return c(this,(function(r){switch(r.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");return t=wx.getAccountInfoSync().miniProgram,e=function(e){return u(n,void 0,void 0,(function(){var n;return c(this,(function(r){switch(r.label){case 0:n=void 0,r.label=1;case 1:return r.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_id:null==t?void 0:t.appId,provider_code:e,provider_params:{provider_code_type:"open_id",appid:null==t?void 0:t.appId}})];case 2:if((null==(n=r.sent())?void 0:n.error_code)||!n.provider_token)throw n;return[4,this.oauthInstance.authApi.bindWithProvider({provider_token:n.provider_token})];case 3:return r.sent(),[3,5];case 4:throw r.sent();case 5:return[2]}}))}))},[4,new Promise((function(t,r){wx.login({success:function(o){return u(n,void 0,void 0,(function(){var n;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e(o.code)];case 1:return i.sent(),t(!0),[3,3];case 2:return n=i.sent(),r(n),[3,3];case 3:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,r(e)}})}))];case 1:return r.sent(),[2]}}))}))},e.prototype.signInWithUnionId=function(){return u(this,void 0,Promise,(function(){var t=this;return c(this,(function(e){switch(e.label){case 0:if(!f.adapterForWxMp.isMatch())throw Error("wx api undefined");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,new Promise((function(e,n){var r=wx.getAccountInfoSync().miniProgram;wx.login({success:function(o){return u(t,void 0,void 0,(function(){var t,i,s,a,u;return c(this,(function(c){switch(c.label){case 0:t=null==r?void 0:r.appId,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,this.oauthInstance.authApi.grantProviderToken({provider_code:o.code,provider_id:t,provider_params:{provider_code_type:"union_id",appid:null==r?void 0:r.appId}})];case 2:return i=c.sent(),(s=i.provider_token)?[4,this.oauthInstance.authApi.signInWithProvider({provider_id:t,provider_token:s})]:(n(i),[2]);case 3:return(null==(a=c.sent())?void 0:a.error_code)?(n(a),[2]):(e(!0),[3,5]);case 4:return u=c.sent(),n(u),[3,5];case 5:return[2]}}))}))},fail:function(t){var e=new Error(null==t?void 0:t.errMsg);e.code=null==t?void 0:t.errno,n(e)}})}))];case 2:return e.sent(),[3,4];case 3:throw e.sent();case 4:return[2,this.createLoginState()]}}))}))},e.prototype.signInWithSms=function(t){var e=t.verificationInfo,n=void 0===e?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,i=t.phoneNum,s=void 0===i?"":i,a=t.bindInfo,l=void 0===a?void 0:a;return u(this,void 0,Promise,(function(){return c(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:l,username:s,loginType:"sms"})]}catch(t){throw t}return[2]}))}))},e.prototype.signInWithEmail=function(t){var e=t.verificationInfo,n=void 0===e?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,i=t.bindInfo,s=void 0===i?void 0:i,a=t.email,l=void 0===a?"":a;return u(this,void 0,Promise,(function(){return c(this,(function(t){try{return[2,this.signInWithUsername({verificationInfo:n,verificationCode:o,bindInfo:s,username:l,loginType:"email"})]}catch(t){throw t}return[2]}))}))},e.prototype.setCustomSignFunc=function(t){this.oauthInstance.authApi.setCustomSignFunc(t)},e.prototype.signIn=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signIn(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},e.prototype.setPassword=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.setPassword(t)]}))}))},e.prototype.isUsernameRegistered=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,f.throwError)(f.ERRORS.INVALID_PARAMS,"username must be a string"),[4,this.oauthInstance.authApi.checkIfUserExist({username:t})];case 1:return[2,e.sent().exist]}}))}))},e.prototype.hasLoginState=function(){var t;if("async"!==this.cache.mode)return(null===(t=this.oauthInstance)||void 0===t?void 0:t.authApi.hasLoginStateSync())?new b({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance}):null;(0,f.printWarn)(f.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getLoginState instead")},e.prototype.getLoginState=function(){return u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:t=null,e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.oauthInstance.authApi.getLoginState()];case 2:return t=e.sent(),[3,4];case 3:return e.sent(),[2,null];case 4:return t?[2,new b({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})]:[2,null]}}))}))},e.prototype.getUserInfo=function(){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.getCurrentUser()]}))}))},e.prototype.getWedaUserInfo=function(){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.getWedaUserInfo()]}))}))},e.prototype.updateUserBasicInfo=function(t){return u(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,this.getLoginState()];case 1:return(e=n.sent())?[4,e.user.updateUserBasicInfo(t)]:[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.getAuthHeader=function(){return console.error("Auth.getAuthHeader API 已废弃"),{}},e.prototype.bindWithProvider=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.bindWithProvider(t)]}))}))},e.prototype.queryUser=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.queryUserProfile(t)]}))}))},e.prototype.getAccessToken=function(){return u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.oauthInstance.oauth2client.getAccessToken()];case 1:return[2,{accessToken:t.sent(),env:this.config.env}]}}))}))},e.prototype.grantProviderToken=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.grantProviderToken(t)]}))}))},e.prototype.patchProviderToken=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.patchProviderToken(t)]}))}))},e.prototype.signInWithProvider=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithProvider(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},e.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.signInWithWechat(t)];case 1:return e.sent(),[2,this.createLoginState(t)]}}))}))},e.prototype.grantToken=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.authApi.grantToken(t)];case 1:return e.sent(),[2,this.createLoginState()]}}))}))},e.prototype.genProviderRedirectUri=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.genProviderRedirectUri(t)]}))}))},e.prototype.resetPassword=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.resetPassword(t)]}))}))},e.prototype.deviceAuthorize=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.deviceAuthorize(t)]}))}))},e.prototype.sudo=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.sudo(t)]}))}))},e.prototype.deleteMe=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.deleteMe(t)]}))}))},e.prototype.getProviders=function(){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.getProviders()]}))}))},e.prototype.loginScope=function(){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.loginScope()]}))}))},e.prototype.loginGroups=function(){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.loginGroups()]}))}))},e.prototype.onLoginStateChanged=function(t){var e;return u(this,void 0,void 0,(function(){var n,r=this;return c(this,(function(o){switch(o.label){case 0:return null===(e=this.config.eventBus)||void 0===e||e.on(d.EVENTS.LOGIN_STATE_CHANGED,(function(e){return u(r,void 0,void 0,(function(){var n,r,o;return c(this,(function(s){switch(s.label){case 0:return(null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.eventType)===d.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR?[3,2]:[4,this.getLoginState()];case 1:return r=s.sent(),[3,3];case 2:r={},s.label=3;case 3:return n=r,t.call(this,i(i({},e),n)),[2]}}))}))})),[4,this.getLoginState()];case 1:return n=o.sent(),t.call(this,n),[2]}}))}))},e.prototype.refreshTokenForce=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.refreshTokenForce(t)]}))}))},e.prototype.getCredentials=function(){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.getCredentials()]}))}))},e.prototype.setCredentials=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.oauthInstance.oauth2client.setCredentials(t)];case 1:return e.sent(),[2]}}))}))},e.prototype.getProviderSubType=function(){return u(this,void 0,Promise,(function(){return c(this,(function(t){return[2,this.oauthInstance.authApi.getProviderSubType()]}))}))},e.prototype.createCaptchaData=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.createCaptchaData(t)]}))}))},e.prototype.verifyCaptchaData=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.verifyCaptchaData(t)]}))}))},e.prototype.getMiniProgramQrCode=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramCode(t)]}))}))},e.prototype.getMiniProgramQrCodeStatus=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.getMiniProgramQrCodeStatus(t)]}))}))},e.prototype.modifyPassword=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.modifyPassword(t)]}))}))},e.prototype.modifyPasswordWithoutLogin=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.modifyPasswordWithoutLogin(t)]}))}))},e.prototype.getUserBehaviorLog=function(t){return u(this,void 0,Promise,(function(){return c(this,(function(e){return[2,this.oauthInstance.authApi.getUserBehaviorLog(t)]}))}))},e.prototype.signInWithUsername=function(t){var e=t.verificationInfo,n=void 0===e?{verification_id:"",is_user:!1}:e,r=t.verificationCode,o=void 0===r?"":r,s=t.username,a=void 0===s?"":s,l=t.bindInfo,d=void 0===l?void 0:l,h=t.loginType,f=void 0===h?"":h;return u(this,void 0,Promise,(function(){var t,e,r,s,u,l,h;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,8,,9]),[4,this.oauthInstance.authApi.verify({verification_id:n.verification_id,verification_code:o})];case 1:if(null==(t=c.sent())?void 0:t.error_code)throw t;return e=t.verification_token,r=this.formatPhone(a),s={phone_number:r},"email"===f&&(s={email:r=a}),n.is_user?[4,this.oauthInstance.authApi.signIn({username:r,verification_token:e})]:[3,5];case 2:if(null==(u=c.sent())?void 0:u.error_code)throw u;return d?[4,this.oauthInstance.authApi.bindWithProvider({provider_token:null==d?void 0:d.providerToken})]:[3,4];case 3:if(null==(l=c.sent())?void 0:l.error_code)throw l;c.label=4;case 4:return[3,7];case 5:return[4,this.oauthInstance.authApi.signUp(i(i({},s),{verification_token:e,provider_token:null==d?void 0:d.providerId}))];case 6:if(null==(h=c.sent())?void 0:h.error_code)throw h;c.label=7;case 7:return[2,this.createLoginState()];case 8:throw c.sent();case 9:return[2]}}))}))},e.prototype.createLoginState=function(t,e){var n,r;return u(this,void 0,Promise,(function(){var o;return c(this,(function(i){switch(i.label){case 0:return[4,(o=new b({envId:this.config.env,cache:this.cache,oauthInstance:this.oauthInstance})).checkLocalStateAsync()];case 1:return i.sent(),(null==e?void 0:e.userInfo)?(o.user.setLocalUserInfo(e.userInfo),[3,5]):[3,2];case 2:return(null==e?void 0:e.asyncRefreshUser)?(o.user.refresh(t),[3,5]):[3,3];case 3:return[4,o.user.refresh(t)];case 4:i.sent(),i.label=5;case 5:return null===(n=this.config.eventBus)||void 0===n||n.fire(d.EVENTS.LOGIN_STATE_CHANGED,{eventType:d.LOGIN_STATE_CHANGED_TYPE.SIGN_IN}),null===(r=this.config.eventBus)||void 0===r||r.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.SIGNED_IN}),[2,o]}}))}))},e.prototype.setAccessKey=function(){var t,e;return u(this,void 0,void 0,(function(){var n,r;return c(this,(function(o){if(n="",r="",this.config.accessKey?(n=this.config.accessKey,r="accessKey"):(null===(t=this.config.auth)||void 0===t?void 0:t.secretId)&&(null===(e=this.config.auth)||void 0===e?void 0:e.secretKey)&&(n="",r=d.DEFAULT_NODE_ACCESS_SCOPE),!r)return[2];try{this.oauthInstance.oauth2client.setAccessKeyCredentials({access_token:n,token_type:"Bearer",scope:r,expires_at:new Date(+new Date+ +new Date),expires_in:+new Date+ +new Date})}catch(t){console.warn("accessKey error: ",t)}return[2]}))}))},e.prototype.formatPhone=function(t){return!/\s+/.test(t)&&/^\+\d{1,3}\d+/.test(t)?t.replace(/^(\+\d{1,2})(\d+)$/,"$1 $2"):/^\+\d{1,3}\s+/.test(t)?t:"+86 ".concat(t)},e.prototype.notifyListeners=function(t,e,n){this.listeners.forEach((function(r){r.forEach((function(r){try{r(t,e,n)}catch(t){console.error("Error in auth state change callback:",t)}}))}))},e.prototype.setupListeners=function(){var t,e=this;null===(t=this.config.eventBus)||void 0===t||t.on(d.EVENTS.AUTH_STATE_CHANGED,(function(t){return u(e,void 0,void 0,(function(){var e,n,r,o,i;return c(this,(function(s){switch(s.label){case 0:return e=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.event,n=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.info,[4,this.getSession()];case 1:return r=s.sent().data.session,this.notifyListeners(e,r,n),[2]}}))}))}))},e.prototype.convertToUser=function(t){var e,n,r,o,i,s;if(!t)return null;var a=(null==t?void 0:t.email)||"",u=(null==t?void 0:t.phone_number)||"",c=(null==t?void 0:t.sub)||(null==t?void 0:t.uid)||"";return{id:c,aud:"authenticated",role:null===(n=null===(e=t.groups)||void 0===e?void 0:e.map)||void 0===n?void 0:n.call(e,(function(t){return"string"==typeof t?t:t.id})),email:a||"",email_confirmed_at:(null==t||t.email_verified,t.created_at),phone:u,phone_confirmed_at:u?t.created_at:void 0,confirmed_at:t.created_at,last_sign_in_at:t.last_sign_in_at,app_metadata:{provider:(null===(r=t.loginType)||void 0===r?void 0:r.toLowerCase())||"cloudbase",providers:[(null===(o=t.loginType)||void 0===o?void 0:o.toLowerCase())||"cloudbase"]},user_metadata:{name:null==t?void 0:t.name,picture:null==t?void 0:t.picture,username:null==t?void 0:t.username,gender:null==t?void 0:t.gender,locale:null==t?void 0:t.locale,uid:t.uid,nickName:t.nickName||(null==t?void 0:t.name),avatarUrl:t.avatarUrl||t.picture,location:t.location,hasPassword:null!==(i=t.hasPassword)&&void 0!==i?i:"SET"===t.password,open_id:null==t?void 0:t.open_id},identities:(null===(s=null==t?void 0:t.providers)||void 0===s?void 0:s.map((function(e){return{id:e.id||"",identity_id:e.id||"",user_id:c,identity_data:{provider_id:e.id,provider_user_id:e.provider_user_id,name:e.name},provider:e.id||"cloudbase",created_at:t.created_at,updated_at:t.updated_at,last_sign_in_at:t.last_sign_in_at}})))||[],created_at:t.created_at,updated_at:t.updated_at,is_anonymous:"anonymous"===t.name}},e.prototype.validateParams=function(t,e){for(var n=0,r=Object.entries(e);n<r.length;n++){var o=r[n],i=o[0],s=o[1];if(s.required&&(void 0===(null==t?void 0:t[i])||null===(null==t?void 0:t[i])||""===(null==t?void 0:t[i])))throw new d.AuthError({message:s.message})}},e.prototype.validateAtLeastOne=function(t,e,n){if(!e.some((function(e){return e.some((function(e){return void 0!==(null==t?void 0:t[e])&&null!==(null==t?void 0:t[e])&&""!==(null==t?void 0:t[e])}))})))throw new d.AuthError({message:n})},e.prototype.init=function(){var t;return u(this,void 0,Promise,(function(){return c(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.oauthInstance.oauth2client.localCredentials.getCredentials()];case 1:return e.sent()&&(null===(t=this.config.eventBus)||void 0===t||t.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.INITIAL_SESSION})),[3,3];case 2:return e.sent(),[3,3];case 3:return[2,{error:null}]}}))}))},s([(0,f.catchErrorsDecorator)({title:"绑定手机号失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindPhoneNumber() 的语法或参数是否正确"," 2 - 当前环境是否开通了短信验证码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(n=void 0!==d.authModels&&d.authModels.BindPhoneRequest)?n:Object]),a("design:returntype",Promise)],e.prototype,"bindPhoneNumber",null),s([(0,f.catchErrorsDecorator)({title:"解除三方绑定失败",messages:["请确认以下各项:"," 1 - 调用 auth().unbindProvider() 的语法或参数是否正确"," 2 - 当前账户是否已经与此登录方式解绑","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(r=void 0!==d.authModels&&d.authModels.UnbindProviderRequest)?r:Object]),a("design:returntype","function"==typeof(h="undefined"!=typeof Promise&&Promise)?h:Object)],e.prototype,"unbindProvider",null),s([(0,f.catchErrorsDecorator)({title:"绑定邮箱地址失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindEmail() 的语法或参数是否正确"," 2 - 当前环境是否开通了邮箱密码登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(v=void 0!==d.authModels&&d.authModels.BindEmailRequest)?v:Object]),a("design:returntype",void 0)],e.prototype,"bindEmail",null),s([(0,f.catchErrorsDecorator)({title:"验证码验证失败",messages:["请确认以下各项:"," 1 - 调用 auth().verify() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(g=void 0!==d.authModels&&d.authModels.VerifyRequest)?g:Object]),a("design:returntype","function"==typeof(_="undefined"!=typeof Promise&&Promise)?_:Object)],e.prototype,"verify",null),s([(0,f.catchErrorsDecorator)({title:"获取验证码失败",messages:["请确认以下各项:"," 1 - 调用 auth().getVerification() 的语法或参数是否正确"," 2 - 当前环境是否开通了手机验证码/邮箱登录","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(w=void 0!==d.authModels&&d.authModels.GetVerificationRequest)?w:Object,Object]),a("design:returntype","function"==typeof(E="undefined"!=typeof Promise&&Promise)?E:Object)],e.prototype,"getVerification",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 调用 auth().getCurrentUser() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(I="undefined"!=typeof Promise&&Promise)?I:Object)],e.prototype,"getCurrentUser",null),s([(0,f.catchErrorsDecorator)({title:"小程序匿名登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了匿名登录"," 2 - 调用 auth().signInAnonymouslyInWx() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(S="undefined"!=typeof Promise&&Promise)?S:Object)],e.prototype,"signInAnonymouslyInWx",null),s([(0,f.catchErrorsDecorator)({title:"小程序绑定OpenID失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序openId静默登录"," 2 - 调用 auth().bindOpenId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(O="undefined"!=typeof Promise&&Promise)?O:Object)],e.prototype,"bindOpenId",null),s([(0,f.catchErrorsDecorator)({title:"小程序unionId静默登录失败",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序unionId静默登录"," 2 - 调用 auth().signInWithUnionId() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(A="undefined"!=typeof Promise&&Promise)?A:Object)],e.prototype,"signInWithUnionId",null),s([(0,f.catchErrorsDecorator)({title:"短信验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了小程序短信验证码登陆"," 2 - 调用 auth().signInWithSms() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(T="undefined"!=typeof Promise&&Promise)?T:Object)],e.prototype,"signInWithSms",null),s([(0,f.catchErrorsDecorator)({title:"邮箱验证码登陆",messages:["请确认以下各项:"," 1 - 当前环境是否开启了邮箱登陆"," 2 - 调用 auth().signInWithEmail() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[Object]),a("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P:Object)],e.prototype,"signInWithEmail",null),s([(0,f.catchErrorsDecorator)({title:"获取用户是否被占用失败",messages:["请确认以下各项:"," 1 - 调用 auth().isUsernameRegistered() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[String]),a("design:returntype","function"==typeof(R="undefined"!=typeof Promise&&Promise)?R:Object)],e.prototype,"isUsernameRegistered",null),s([(0,f.catchErrorsDecorator)({title:"获取本地登录态失败",messages:["请确认以下各项:"," 1 - 调用 auth().getLoginState() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype",Promise)],e.prototype,"getLoginState",null),s([(0,f.catchErrorsDecorator)({title:"获取用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(C="undefined"!=typeof Promise&&Promise)?C:Object)],e.prototype,"getUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"获取微搭插件用户信息失败",messages:["请确认以下各项:"," 1 - 是否已登录"," 2 - 调用 auth().getWedaUserInfo() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N:Object)],e.prototype,"getWedaUserInfo",null),s([(0,f.catchErrorsDecorator)({title:"绑定第三方登录方式失败",messages:["请确认以下各项:"," 1 - 调用 auth().bindWithProvider() 的语法或参数是否正确"," 2 - 此账户是否已经绑定此第三方","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",["function"==typeof(D=void 0!==d.authModels&&d.authModels.BindWithProviderRequest)?D:Object]),a("design:returntype","function"==typeof(U="undefined"!=typeof Promise&&Promise)?U:Object)],e.prototype,"bindWithProvider",null),s([(0,f.catchErrorsDecorator)({title:"获取身份源类型",messages:["请确认以下各项:"," 1 - 调用 auth().getProviderSubType() 的语法或参数是否正确","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f.COMMUNITY_SITE_URL)]}),a("design:type",Function),a("design:paramtypes",[]),a("design:returntype","function"==typeof(x="undefined"!=typeof Promise&&Promise)?x:Object)],e.prototype,"getProviderSubType",null),e}(v.AuthV1Compat);function w(t,e){var n,r,o,s,a=this,l=t.region,p=void 0===l?"ap-shanghai":l,v=t.i18n,y=t.accessKey,m=t.useWxCloud,g=(null==e?void 0:e.platform)||f.useDefaultAdapter.bind(e)(),b=g.runtime,w=g.adapter,E=e||{},I=E.env,S=E.clientId,O=E.debug,A=E.cache,T=E.app,P=(e||{}).apiOrigin;P||(P="https://".concat(I,".").concat(p,".tcb-api.tencentcloudapi.com"));var R,C={env:I,clientId:S,i18n:v,accessKey:y,useWxCloud:m,eventBus:new f.CloudbaseEventEmitter},N=new d.CloudbaseOAuth((0,h.useAuthAdapter)(i(i({},C),{apiOrigin:P,apiPath:(null==t?void 0:t.apiPath)||d.AUTH_API_PREFIX,storage:null==t?void 0:t.storage,baseRequest:null==t?void 0:t.baseRequest,request:null==t?void 0:t.request,anonymousSignInFunc:null==t?void 0:t.anonymousSignInFunc,captchaOptions:null==t?void 0:t.captchaOptions,wxCloud:null==t?void 0:t.wxCloud,adapter:w,onCredentialsError:(R=C.eventBus,function(t){R.fire(d.EVENTS.LOGIN_STATE_CHANGED,i(i({},t),{eventType:d.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR}))}),headers:i({"X-SDK-Version":"@cloudbase/js-sdk/".concat(t.sdkVersion)},t.headers||{}),detectSessionInUrl:t.detectSessionInUrl,debug:O,auth:null===(r=null===(n=e.app)||void 0===n?void 0:n.config)||void 0===r?void 0:r.auth}))),D=new _(i(i({},C),{region:p,persistence:t.persistence,debug:O,cache:A||new f.CloudbaseCache({persistence:t.persistence,keys:{userInfoKey:"user_info_".concat(I)},platformInfo:g}),runtime:b||"web",_fromApp:T,oauthInstance:N,auth:null===(s=null===(o=e.app)||void 0===o?void 0:o.config)||void 0===s?void 0:s.auth}));return N.initializeSession((function(t,e){return u(a,void 0,void 0,(function(){return c(this,(function(n){return t?(t.type===d.OAUTH_TYPE.SIGN_IN?e?C.eventBus.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.SIGNED_IN,info:i(i({},t),{error:e})}):t.user&&D.createLoginState({},{userInfo:t.user}):t.type===d.OAUTH_TYPE.BIND_IDENTITY&&C.eventBus.fire(d.EVENTS.AUTH_STATE_CHANGED,{event:d.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:i(i({},t),{error:e})}),[2]):[2]}))}))})),{authInstance:D,oauthInstance:N}}e.Auth=_,e.generateAuthInstance=w;var E="auth";function I(t,e){for(var n=[],r=0;r<=t.length;r++)n[r]=[r];for(var o=0;o<=e.length;o++)n[0][o]=o;for(r=1;r<=t.length;r++)for(o=1;o<=e.length;o++){var i=t[r-1].toLowerCase()===e[o-1].toLowerCase()?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+i)}return n[t.length][e.length]}var S={name:"auth",namespace:E,entity:function(t){var e=function(t){var e;if(this.authInstance&&!t)return this.authInstance;t=t||{region:"",persistence:"local",apiPath:d.AUTH_API_PREFIX};var n=this.platform.adapter,r=t.persistence||n.primaryStorage;r&&r!==this.config.persistence&&this.updateConfig({persistence:r});var o=w(i(i({wxCloud:this.config.wxCloud,storage:this.config.storage},t),{persistence:this.config.persistence,i18n:this.config.i18n,accessKey:this.config.accessKey,useWxCloud:this.config.useWxCloud,sdkVersion:this.version,detectSessionInUrl:null===(e=this.config.auth)||void 0===e?void 0:e.detectSessionInUrl}),{env:this.config.env,clientId:this.config.clientId,apiOrigin:this.request.getBaseEndPoint(this.config.endPointMode||"CLOUD_API"),platform:this.platform,cache:this.cache,app:this,debug:this.config.debug}),s=o.authInstance,a=o.oauthInstance;return this.oauthInstance=a,this.authInstance=s,this.authInstance},n=e.call(this,t);Object.assign(e,n),Object.setPrototypeOf(e,Object.getPrototypeOf(n));var r="undefined"!=typeof Proxy?new Proxy(e,{get:function(t,e,n){var r=Reflect.get(t,e,n);if(void 0!==r||"string"!=typeof e)return r;var o=function(t,e){for(var n=null,r=1/0,o=0,i=e;o<i.length;o++){var s=i[o];if(!s.startsWith("_")&&"constructor"!==s){var a=I(t,s);a<r&&(r=a,n=s)}}return n}(e,Object.getOwnPropertyNames(Object.getPrototypeOf(t)).concat(Object.keys(t)).filter((function(e){return"function"==typeof t[e]})));return o&&console.warn("[CloudBase Auth] auth.".concat(e," is not a function. Did you mean: auth.").concat(o,"() ?")),r}}):e;return this[E]=r,r}};try{cloudbase.registerComponent(S)}catch(t){}var O=n(6722);Object.defineProperty(e,"AuthErrorCategory",{enumerable:!0,get:function(){return O.AuthErrorCategory}}),Object.defineProperty(e,"AuthError",{enumerable:!0,get:function(){return O.AuthError}}),e.registerAuth=function(t){try{t.registerComponent(S)}catch(t){console.warn(t)}}},1019:function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.adapterForWxMp=e.CloudbaseCache=e.CloudbaseEventEmitter=e.catchErrorsDecorator=e.COMMUNITY_SITE_URL=e.ERRORS=e.throwError=e.printWarn=void 0;var o=n(3616);Object.defineProperty(e,"printWarn",{enumerable:!0,get:function(){return o.printWarn}}),Object.defineProperty(e,"throwError",{enumerable:!0,get:function(){return o.throwError}});var i=n(794);Object.defineProperty(e,"ERRORS",{enumerable:!0,get:function(){return i.ERRORS}}),Object.defineProperty(e,"COMMUNITY_SITE_URL",{enumerable:!0,get:function(){return i.COMMUNITY_SITE_URL}});var s=n(141);Object.defineProperty(e,"catchErrorsDecorator",{enumerable:!0,get:function(){return s.catchErrorsDecorator}});var a=n(9689);Object.defineProperty(e,"CloudbaseEventEmitter",{enumerable:!0,get:function(){return a.CloudbaseEventEmitter}});var u=n(6197);Object.defineProperty(e,"CloudbaseCache",{enumerable:!0,get:function(){return u.CloudbaseCache}});var c=n(7917);Object.defineProperty(e,"adapterForWxMp",{enumerable:!0,get:function(){return r(c).default}});var l=n(8182);Object.defineProperty(e,"useDefaultAdapter",{enumerable:!0,get:function(){return l.useDefaultAdapter}})},5266:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.removeUrlParams=e.addUrlSearch=e.removeBrowserSession=e.getBrowserSession=e.saveToBrowserSession=void 0,e.saveToBrowserSession=function(t,e){try{sessionStorage.setItem(t,JSON.stringify(e))}catch(t){console.error("Failed to save to browser session:",t)}},e.getBrowserSession=function(t){try{return JSON.parse(sessionStorage.getItem(t))}catch(t){return console.error("Failed to get browser session:",t),null}},e.removeBrowserSession=function(t){try{return sessionStorage.removeItem(t),!0}catch(t){return console.error("Failed to remove browser session:",t),null}},e.addUrlSearch=function(t,e){if(void 0!==t){var n=new URL(window.location.href);return n.search=t,n.hash=e||n.hash,window.history.replaceState({},"",n.href),n.href}},e.removeUrlParams=function(t){if("undefined"!=typeof window)try{var e=new URL(window.location.href);t.forEach((function(t){e.searchParams.delete(t)})),window.history.replaceState({},"",e.href)}catch(t){console.error("Failed to remove URL params:",t)}}},916:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.applyUserV1Compat=e.AuthV1Compat=e.AnonymousAuthProvider=e.CustomAuthProvider=e.WeixinAuthProvider=void 0;var s=n(6722),a=n(1019),u=function(){function t(t){}return t.prototype.signInWithRedirect=function(){throw new Error("[v1 兼容] WeixinAuthProvider.signInWithRedirect() 在当前版本中无法实现。 建议使用 auth.signInWithOAuth({ provider: 'providerId' }) 替代。")},t.prototype.getRedirectResult=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(t){throw new Error("[v1 兼容] WeixinAuthProvider.getRedirectResult() 在当前版本中无法实现。 建议使用 auth.verifyOAuth({ code, state, provider }) 替代。")}))}))},t.prototype.getLinkRedirectResult=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(t){throw new Error("[v1 兼容] WeixinAuthProvider.getLinkRedirectResult() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")}))}))},t}();e.WeixinAuthProvider=u;var c=function(){function t(t){this.authInstance=t.authInstance}return t.prototype.signIn=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.authInstance.signInWithCustomTicket((function(){return Promise.resolve(t)}))];case 1:return e.sent(),[2]}}))}))},t}();e.CustomAuthProvider=c;var l=function(){function t(t){this.authInstance=t.authInstance}return t.prototype.signIn=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.authInstance.signInAnonymously({})];case 1:return t.sent(),[2]}}))}))},t}();e.AnonymousAuthProvider=l;var d=function(){function t(){}return t.prototype.weixinAuthProvider=function(t){return new u({authInstance:this,appid:t.appid,scope:t.scope})},t.prototype.customAuthProvider=function(){return new c({authInstance:this})},t.prototype.anonymousAuthProvider=function(){return new l({authInstance:this})},t.prototype.signUpWithEmailAndPassword=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(n){switch(n.label){case 0:return"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signUp({email:t,password:e})];case 1:return[2,n.sent()]}}))}))},t.prototype.signInWithEmailAndPassword=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(n){switch(n.label){case 0:return"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:t,password:e})];case 1:return n.sent(),[2,this.createLoginState()]}}))}))},t.prototype.sendPasswordResetEmail=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"email must be a string"),[4,this.getVerification({email:t})];case 1:return e.sent(),[2]}}))}))},t.prototype.signInWithUsernameAndPassword=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(n){switch(n.label){case 0:return"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"username must be a string"),"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),[4,this.signIn({username:t,password:e})];case 1:return n.sent(),[2,this.createLoginState()]}}))}))},t.prototype.sendPhoneCode=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),e=this.formatPhone(t),[4,this.getVerification({phone_number:e})];case 1:return n.sent(),[2,!0]}}))}))},t.prototype.signUpWithPhoneCode=function(t,e,n){return o(this,void 0,Promise,(function(){var o;return i(this,(function(i){switch(i.label){case 0:return"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),o=this.formatPhone(t),[4,this.signUp(r({phone_number:o,verification_code:e},n?{password:n}:{}))];case 1:return i.sent(),[2,this.createLoginState()]}}))}))},t.prototype.signInWithPhoneCodeOrPassword=function(t){return o(this,void 0,Promise,(function(){var e,n,r,o;return i(this,(function(i){switch(i.label){case 0:return e=t.phoneNumber,n=t.phoneCode,r=t.password,"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),o=this.formatPhone(e),r?[4,this.signIn({username:o,password:r})]:[3,2];case 1:return i.sent(),[3,5];case 2:return n?[4,this.signIn({username:o,verification_token:n})]:[3,4];case 3:return i.sent(),[3,5];case 4:(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode or password must be provided"),i.label=5;case 5:return[2,this.createLoginState()]}}))}))},t.prototype.forceResetPwdByPhoneCode=function(t){return o(this,void 0,Promise,(function(){var e,n,r,o;return i(this,(function(i){switch(i.label){case 0:return e=t.phoneNumber,n=t.phoneCode,r=t.password,"string"!=typeof e&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneNumber must be a string"),"string"!=typeof n&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"phoneCode must be a string"),"string"!=typeof r&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"password must be a string"),o=this.formatPhone(e),[4,this.resetPassword({phone_number:o,new_password:r,verification_token:n})];case 1:return i.sent(),[4,this.signIn({username:o,password:r})];case 2:return i.sent(),[2,this.createLoginState()]}}))}))},t.prototype.shouldRefreshAccessToken=function(t){throw new Error("[v1 兼容] shouldRefreshAccessToken() 在当前版本中无法实现。 建议使用 auth.onAuthStateChange(callback) 来监听 TOKEN_REFRESHED 事件替代。")},t.prototype.onLoginStateExpired=function(t){var e=this;this.onLoginStateChanged((function(n){(null==n?void 0:n.eventType)===s.LOGIN_STATE_CHANGED_TYPE.CREDENTIALS_ERROR&&t.call(e)}))},t.prototype.onAccessTokenRefreshed=function(t){var e=this;this.onAuthStateChange((function(n){n===s.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED&&t.call(e)}))},t.prototype.onAnonymousConverted=function(t){var e=this;this.onAuthStateChange((function(n){n===s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&t.call(e)}))},t.prototype.onLoginTypeChanged=function(t){var e=this;this.onAuthStateChange((function(n){n!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_IN&&n!==s.AUTH_STATE_CHANGED_TYPE.SIGNED_OUT||t.call(e)}))},t}();e.AuthV1Compat=d,e.applyUserV1Compat=function(t){t.prototype.linkWithTicket=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(t){throw new Error("[v1 兼容] User.linkWithTicket() 在当前版本中无法实现。 建议使用 auth.signInWithCustomTicket(() => Promise.resolve(ticket)) 替代。")}))}))},t.prototype.linkWithRedirect=function(t){throw new Error("[v1 兼容] User.linkWithRedirect() 在当前版本中无法实现。 建议使用 auth.linkIdentity({ provider: 'providerId' }) 替代。")},t.prototype.updateEmail=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return"string"!=typeof t&&(0,a.throwError)(a.ERRORS.INVALID_PARAMS,"newEmail must be a string"),[4,this.updateUserBasicInfo({email:t})];case 1:return e.sent(),[2]}}))}))},t.prototype.linkWithPhoneNumber=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(t){throw new Error("[v1 兼容] User.linkWithPhoneNumber() 在当前版本中无法实现。 建议使用 auth.bindPhoneNumber({ phone_number, verification_token, sudo_token }) 替代。")}))}))},t.prototype.updatePhoneNumber=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(t){throw new Error("[v1 兼容] User.updatePhoneNumber() 在当前版本中无法实现。 建议使用 auth.updateUser({ phone: newPhoneNumber }) 替代。")}))}))},t.prototype.unlink=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(t){throw new Error("[v1 兼容] User.unlink() 在当前版本中无法实现。 建议使用 auth.unlinkIdentity({ provider: loginType }) 替代。")}))}))}}},3198:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var u=n(543),c=n(2701),l={filterRes:function(t){return delete t.header,delete t.statusCode,t},flattenResData:function(t){if("object"==typeof t.data&&null!==t.data){var e=i(i({},t),t.data);return delete e.data,e}return t},safeParseEJSON:function(t){if("string"!=typeof t)return t;try{return c.EJSON.parse(t)}catch(e){return t}},buildQueryParams:function(t){return Object.entries(t).filter((function(t){t[0];var e=t[1];return null!=e&&""!==e})).map((function(t){var e=t[0],n=t[1],r="object"==typeof n?JSON.stringify(n):String(n);return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r))})).join("&")},getUrlPrefix:function(t){var e=(null==t?void 0:t.instance)||"(default)",n=(null==t?void 0:t.database)||"(default)";return"/database/instances/".concat(e,"/databases/").concat(n)},"database.queryDocument":function(t){var e,n,r,o,u,d;return s(this,void 0,Promise,(function(){var s,h,f,p;return a(this,(function(a){switch(a.label){case 0:return s=!!(null===(n=null===(e=t.query)||void 0===e?void 0:e._id)||void 0===n?void 0:n.$eq),h=l.buildQueryParams(i({projection:t.projection,transactionId:t.transactionId},s?{}:{offset:null!==(r=t.offset)&&void 0!==r?r:0,limit:null!==(o=t.limit)&&void 0!==o?o:100,order:t.order,query:t.query?c.EJSON.stringify(t.query,{relaxed:!1}):void 0})),f="".concat(l.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents?").concat(h),s&&(f="".concat(l.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/").concat((null===(u=t.query._id)||void 0===u?void 0:u.$eq)||t.query._id,"?").concat(h)),[4,this.gateWay({url:f,method:"GET"})];case 1:return(p=a.sent()).data=l.safeParseEJSON(JSON.stringify(p.data)),!s||p.code||(null===(d=p.data)||void 0===d?void 0:d.code)?[2,l.filterRes(p)]:[2,i(i({},p),{data:{list:[p.data]}})]}}))}))},"database.addDocument":function(t){var e,n,r;return s(this,void 0,Promise,(function(){var o;return a(this,(function(s){switch(s.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents"),method:"POST",data:i({data:Array.isArray(t.data)?t.data:[t.data]},t.transactionId&&{transactionId:t.transactionId})})];case 1:return o=s.sent(),Array.isArray(t.data)?o=i(i({},o),{data:i({ids:(null===(e=o.data)||void 0===e?void 0:e.insertedIds)||[]},o.data)}):(null===(r=null===(n=o.data)||void 0===n?void 0:n.insertedIds)||void 0===r?void 0:r[0])&&(o=i(i({},o),{data:i({_id:o.data.insertedIds[0]},o.data)})),[2,l.filterRes(o)]}}))}))},"database.updateDocument":function(t){return s(this,void 0,Promise,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents"),method:"PATCH",data:i({query:t.query,data:t.data,multi:!!t.multi,upsert:!!t.upsert,replaceMode:!!t.replaceMode},t.transactionId&&{transactionId:t.transactionId})})];case 1:return e=n.sent(),[2,l.filterRes(e)]}}))}))},"database.deleteDocument":function(t){return s(this,void 0,Promise,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/remove"),method:"POST",data:i({query:t.query,multi:!!t.multi},t.transactionId&&{transactionId:t.transactionId})})];case 1:return e=n.sent(),[2,l.filterRes(e)]}}))}))},"database.countDocument":function(t){return s(this,void 0,Promise,(function(){var e,n;return a(this,(function(r){switch(r.label){case 0:return e=l.buildQueryParams({count:!0,query:t.query?c.EJSON.stringify(t.query,{relaxed:!1}):void 0}),[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents?").concat(e),method:"GET"})];case 1:return n=r.sent(),[2,l.filterRes(n)]}}))}))},"database.addCollection":function(t){return s(this,void 0,Promise,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/collections"),method:"POST",data:{collectionName:t.collectionName}})];case 1:return e=n.sent(),[2,l.filterRes(e)]}}))}))},"database.aggregate":function(t){var e;return s(this,void 0,Promise,(function(){var n,r;return a(this,(function(o){switch(o.label){case 0:return n=t.stages.map((function(t){var e,n;try{var r="string"==typeof t.stageValue?JSON.parse(t.stageValue):t.stageValue;return(e={})[t.stageKey]=c.EJSON.serialize(r),e}catch(e){return(n={})[t.stageKey]=t.stageValue,n}})),[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/collections/").concat(t.collectionName,"/documents/aggregations"),method:"POST",data:{pipeline:n}})];case 1:return r=o.sent(),Array.isArray(null===(e=r.data)||void 0===e?void 0:e.list)&&(r.data.list=JSON.stringify(r.data.list.map((function(t){return JSON.stringify(t)})))),[2,l.filterRes(r)]}}))}))},"database.startTransaction":function(t){return s(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/transactions"),method:"POST"})];case 1:return e=n.sent(),[2,l.filterRes(l.flattenResData(e))]}}))}))},"database.commitTransaction":function(t){return s(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/transactions/").concat(t.transactionId,"/commit"),method:"POST"})];case 1:return e=n.sent(),[2,l.filterRes(e)]}}))}))},"database.abortTransaction":function(t){return s(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/transactions/").concat(t.transactionId,"/rollback"),method:"POST"})];case 1:return e=n.sent(),[2,l.filterRes(e)]}}))}))},"database.getInTransaction":function(t){var e;return s(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return[4,l["database.queryDocument"].call(this,t)];case 1:return"object"==typeof(n=r.sent()).data&&null!==n.data?(null===(e=n.data)||void 0===e?void 0:e.code)?[2,l.flattenResData(n)]:[2,i(i({},n),{data:JSON.stringify(n.data)})]:[2,n]}}))}))},"database.updateDocInTransaction":function(t){return s(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return t.data=l.safeParseEJSON(t.data),[4,l["database.updateDocument"].call(this,t)];case 1:return e=n.sent(),[2,l.flattenResData(e)]}}))}))},"database.deleteDocInTransaction":function(t){return s(this,void 0,void 0,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,l["database.deleteDocument"].call(this,t)];case 1:return e=n.sent(),[2,l.flattenResData(e)]}}))}))},"database.insertDocInTransaction":function(t){var e;return s(this,void 0,Promise,(function(){var n,r;return a(this,(function(o){switch(o.label){case 0:return t.data=l.safeParseEJSON(t.data),[4,l["database.addDocument"].call(this,t)];case 1:return"object"==typeof(n=o.sent()).data&&null!==n.data?(r=!!(null===(e=n.data)||void 0===e?void 0:e._id),n=i(i(i({},n),{inserted:r?1:0,ok:r?1:0}),n.data)):n=i({inserted:0,ok:0},n),delete n.data,[2,n]}}))}))},"database.runCommands":function(t){return s(this,void 0,Promise,(function(){var e;return a(this,(function(n){switch(n.label){case 0:return[4,this.gateWay({url:"".concat(l.getUrlPrefix(t),"/commands"),method:"POST",data:i({commands:c.EJSON.serialize(t.commands)},t.transactionId&&{transactionId:t.transactionId})})];case 1:"object"==typeof(e=n.sent()).data&&null!==e.data&&(delete(e=i(i({},e),e.data)).data,delete e.request_id);try{e=c.EJSON.deserialize(e)}catch(t){}return[2,l.filterRes(e)]}}))}))}},d={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,r=e.runtime,c=function(t){function e(e){return t.call(this,e)||this}return o(e,t),e.prototype.send=function(e,n){return s(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:return r=null,"GATEWAY"===this.config.endPointMode&&l[e]?[4,l[e].call(this,n)]:[3,2];case 1:return r=o.sent(),[3,4];case 2:return[4,t.prototype.send.call(this,e,n)];case 3:r=o.sent(),o.label=4;case 4:return[2,r]}}))}))},e}(this.request.constructor);return u.Db.reqClass=c,u.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},u.Db.runtime=r,this.wsClientClass&&(u.Db.wsClass=n.wsClass,u.Db.wsClientClass=this.wsClientClass),u.Db.ws||(u.Db.ws=null),new(function(t){function e(e){return t.call(this,e)||this}return o(e,t),e.prototype.runCommands=function(t){return s(this,void 0,Promise,(function(){return a(this,(function(e){return[2,u.Db.createRequest(this.config).send("database.runCommands",t)]}))}))},e}(u.Db))(i(i(i({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(d)}catch(t){}function h(t){try{t.registerComponent(d)}catch(t){console.warn(t)}}e.registerDatabase=h;try{window.registerDatabase=h}catch(t){}},8795:function(t,e,n){"use strict";var r=(this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}})(n(6950)),o=n(9895),i=n(1060),s=n(3456),a=n(7209),u=n(3645),c=n(5337),l=n(9253),d=n(9126),h=n(1944),f=n(3198);r.default.registerVersion("3.4.8");try{(0,o.registerAuth)(r.default),(0,i.registerFunctions)(r.default),(0,s.registerStorage)(r.default),(0,f.registerDatabase)(r.default),(0,a.registerRealtime)(r.default),(0,u.registerModel)(r.default),(0,c.registerAi)(r.default),(0,l.registerCloudrun)(r.default),(0,d.registerMySQL)(r.default),(0,h.registerApis)(r.default)}catch(t){}try{window.cloudbase=r.default}catch(t){}e.default=r.default,t.exports=r.default},9253:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerCloudrun=e.requestContainer=void 0;var s=n(2877).constants.ERRORS,a="cloudrun",u=function(){function t(){}return t.prototype.callContainer=function(t,e){return o(this,void 0,void 0,(function(){var n,o,u;return i(this,(function(i){switch(i.label){case 0:if(n=t.name,o=t.data,!n)throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(a,".callContainer] invalid name")}));try{u=o?JSON.stringify(o):""}catch(t){throw new Error(JSON.stringify({code:s.INVALID_PARAMS,msg:"[".concat(a,".callContainer] invalid data")}))}return[4,c.call(this,r(r({},t),{data:u}),e)];case 1:return[2,i.sent()]}}))}))},t}();function c(t,e){var n;return o(this,void 0,void 0,(function(){var o,s,a,u,c,l,d,h,f,p,v,y,m,g,b;return i(this,(function(i){switch(i.label){case 0:if(o=t.name,s=t.data,a=t.path,u=void 0===a?"":a,c=t.method,l=t.header,d=void 0===l?{}:l,h=this.getEndPointWithKey("GATEWAY"),f=h.BASE_URL,p=h.PROTOCOL,v="".concat(p).concat(f,"/cloudrun/").concat(o),y=u.startsWith("/")?u:"/".concat(u),m=["GET","HEAD"].includes(null===(n=null==c?void 0:c.toUpperCase)||void 0===n?void 0:n.call(c)))try{g={};try{g=JSON.parse(s)}catch(t){g=s||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(g).map((function(t){return"".concat(t,"=").concat(g[t])})).join("&"))}catch(t){}return[4,this.request.fetch(r(r({method:c||"POST",headers:Object.assign({},{"Content-Type":"application/json; charset=utf-8"},d)},m?{}:{body:s}),{url:"".concat(v).concat(y),customReqOpts:e}))];case 1:return b=i.sent(),"node-sdk"===(null==e?void 0:e.from)?[2,b]:[4,b.data];case 2:return[2,i.sent()]}}))}))}e.requestContainer=c;var l=new u,d={name:a,entity:{callContainer:l.callContainer}};try{cloudbase.registerComponent(d)}catch(t){}function h(t){try{t.registerComponent(d)}catch(t){console.warn(t)}}e.registerCloudrun=h;try{window.registerCloudrun=h}catch(t){}},1060:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__decorate||function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerFunctions=void 0;var u=n(3388),c=n(2877),l=n(9253),d=c.constants.getSdkName,h=c.constants.ERRORS,f=c.constants.COMMUNITY_SITE_URL,p=c.utils.execCallback,v=c.helpers.catchErrorsDecorator,y="functions",m=new(function(){function t(){}var e,n,m;return t.prototype.callFunction=function(t,e,n){var o,i,u;return s(this,void 0,void 0,(function(){var s,f,v,m,g,b,_,w,E,I,S,O,A,T,P,R,C,N,D,U,x,L,j;return a(this,(function(a){switch(a.label){case 0:if(s=t.name,f=t.data,v=t.query,m=t.parse,g=t.search,b=t.type,_=t.path,w=void 0===_?"":_,E=t.method,I=t.header,S=void 0===I?{}:I,!s)throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(y,".callFunction] invalid function name")}));try{O=f?JSON.stringify(f):""}catch(t){throw new Error(JSON.stringify({code:h.INVALID_PARAMS,msg:"[".concat(y,".callFunction] invalid data")}))}return"cloudrun"!==b?[3,2]:(A=c.utils.generateRequestId(),[4,l.requestContainer.call(this,{name:s,data:O,path:w,method:E,header:r(r({},S),{"X-Request-Id":A})})]);case 1:return[2,{result:L=a.sent(),requestId:A}];case 2:P=(T=this).request,R=T.config,C="functions.invokeFunction",N={inQuery:v,parse:m,search:g,function_name:s,request_data:O},D={},U=!("GATEWAY"!==R.endPointMode||(k=s,"lcap-common-service"===k||"lcap-datasource-test"===k||k.startsWith("lcap-data")||k.startsWith("lowcode-datasource")||"cloudbase_module"===k)||function(t){return"lowcode-wx-datasource"===t}(s)),a.label=3;case 3:return a.trys.push([3,8,,9]),U?[4,P.gateWay(r(r({},t),{path:"functions"}),n)]:[3,5];case 4:return x=a.sent(),D=r({requestId:x.requestId},(null===(o=x.data)||void 0===o?void 0:o.code)?x.data:{data:{response_data:x.data}}),[3,7];case 5:return[4,P.send(C,N,{endPointMode:"CLOUD_API",defaultQuery:(null===(i=null==f?void 0:f.params)||void 0===i?void 0:i.action)?{action:null===(u=null==f?void 0:f.params)||void 0===u?void 0:u.action}:{}},n)];case 6:D=a.sent(),a.label=7;case 7:if(D.code)return[2,p(e,null,D)];if(L=D.data.response_data,m||U)return[2,p(e,null,{result:L,requestId:D.requestId})];try{return L=JSON.parse(D.data.response_data),[2,p(e,null,{result:L,requestId:D.requestId})]}catch(t){p(e,new Error("[".concat(d(),"][").concat(h.INVALID_PARAMS,"][").concat(y,".callFunction] response data must be json")))}return[3,9];case 8:return j=a.sent(),p(e,j),[3,9];case 9:return[2]}var k}))}))},o([v({customInfo:{className:"Cloudbase",methodName:"callFunction"},title:"函数调用失败",messages:["请确认以下各项:"," 1 - 调用 callFunction() 的语法或参数是否正确"," 2 - 当前环境下是否存在此函数"," 3 - 函数安全规则是否限制了当前登录状态访问","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(f)]}),i("design:type",Function),i("design:paramtypes",["function"==typeof(e=void 0!==u.ICallFunctionOptions&&u.ICallFunctionOptions)?e:Object,"function"==typeof(n="undefined"!=typeof Function&&Function)?n:Object,"function"==typeof(m=void 0!==u.ICustomReqOpts&&u.ICustomReqOpts)?m:Object]),i("design:returntype",Promise)],t.prototype,"callFunction",null),t}()),g={name:y,entity:{callFunction:m.callFunction}};try{cloudbase.registerComponent(g)}catch(t){}e.registerFunctions=function(t){try{t.registerComponent(g)}catch(t){console.warn(t)}}},3645:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerModel=e.lazyGetEntity=void 0;var u=n(8630),c=n(2877).events.CloudbaseEventEmitter,l="models",d=new WeakMap;function h(t){return new Proxy({},{get:function(e,n){var o=t.getEndPointWithKey("GATEWAY"),i=o.BASE_URL,c=o.PROTOCOL,l=r(r({},t),{BASE_URL:i,PROTOCOL:c}),h=d.get(l);return h||(h=function(t){var e=this,n=t.callFunction.bind(t),o=t.request.fetch.bind(t.request),i=t.getEndPointWithKey("GATEWAY"),c=i.BASE_URL,l=i.PROTOCOL,d="".concat(l).concat(c,"/model"),h="".concat(l).concat(c,"/sql"),f=(0,u.generateHTTPClient)(n,(function(t){return s(e,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,o(r(r({},t),{headers:r({"Content-Type":"application/json"},t.headers)}))];case 1:return[4,e.sent().data];case 2:return[2,e.sent()]}}))}))}),d,{sqlBaseUrl:h});return f}(t),d.set(l,h)),h[n]}})}e.lazyGetEntity=h;var f="cloudbase_init",p=new c;p.on(f,(function(t){var e=t.data;Object.assign(e,{models:h(e)})}));var v={name:l,namespace:l,entity:new Proxy({},{get:function(t,e){console.warn("【deprecated】Accessing Cloudbase.prototype.models.".concat(e,"."))}}),injectEvents:{bus:p,events:[f]}};try{cloudbase.registerComponent(v)}catch(t){}function y(t){try{t.registerComponent(v)}catch(t){console.warn(t)}}e.registerModel=y;try{window.registerModel=y}catch(t){}i(n(8630),e)},9126:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||o(e,t,n)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.registerMySQL=void 0;var u=n(8630);function c(t,e,n){var o=this,i=t.request.fetch.bind(t.request),c=e||{},l=c.instance,d=void 0===l?n?void 0:"default":l,h=c.database,f=void 0===h?n?void 0:t.config.env:h,p=function(t,e){return s(o,void 0,void 0,(function(){var n,o,s,u;return a(this,(function(a){switch(a.label){case 0:return n={},e.headers instanceof Headers?e.headers.forEach((function(t,e){n[e]=t})):n=e.headers||{},[["X-Db-Instance",d],["Accept-Profile",f],["Content-Profile",f]].forEach((function(t){var e=t[0],r=t[1];n[e]||n[e.toLocaleLowerCase()]||!r||(n[e]=r)})),[4,i(r(r({url:t.toString()},e),{headers:r({"Content-Type":"application/json"},n),shouldThrowOnError:!1}))];case 1:o=a.sent(),s={},a.label=2;case 2:return a.trys.push([2,4,,5]),[4,o.data];case 3:return s=a.sent(),[3,5];case 4:if(!(u=a.sent()).message.includes("Unexpected end of JSON input"))throw u;return[3,5];case 5:return[2,{ok:(null==o?void 0:o.statusCode)>=200&&(null==o?void 0:o.statusCode)<300,status:(null==o?void 0:o.statusCode)||200,statusText:(null==o?void 0:o.statusMessage)||"OK",json:function(){return Promise.resolve(s||{})},text:function(){return Promise.resolve("string"==typeof s?s:JSON.stringify(s||{}))},headers:null==o?void 0:o.header}]}}))}))},v=t.getEndPointWithKey("GATEWAY"),y=v.BASE_URL,m=v.PROTOCOL,g="".concat(m).concat(y,"/rdb/rest");return n?(0,u.generatePGClient)(t,{pgBaseUrl:g,fetch:p}):(0,u.generateMySQLClient)(t,{mysqlBaseUrl:g,fetch:p})}var l={name:"mysql",entity:{mysql:function(t){return c(this,t,!1)(t)}}},d={name:"rdb",entity:{rdb:function(t){return c(this,t,!0)(t)}}};try{cloudbase.registerComponent(l),cloudbase.registerComponent(d)}catch(t){}function h(t){try{t.registerComponent(l),t.registerComponent(d)}catch(t){console.warn(t)}}e.registerMySQL=h;try{window.registerMySQL=h}catch(t){}i(n(8630),e)},5413:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Auth=void 0;var u=n(4949),c=n(5257),l=n(2962),d=n(2631),h=a(n(9639)),f=n(8308);function p(t,e){var r;return o(this,void 0,void 0,(function(){var s,a=this;return i(this,(function(u){s=function(){return o(a,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,1,,6]),[2,n(5814)];case 1:t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,Promise.resolve().then(n.t.bind(n,5814,23))];case 3:return[2,t.sent()];case 4:return t.sent(),[2];case 5:return[3,6];case 6:return[2]}}))}))};try{if(((null===(r=null==e?void 0:e.root)||void 0===r?void 0:r.globalThis)||globalThis).IS_MP_BUILD)return[2];if(t)return[2,s()]}catch(e){if(t)return[2,s()]}return[2]}))}))}var v=function(){function t(t){var e=t.request,n=t.credentialsClient;if(!n){var o={apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,storage:t.storage,env:t.env,baseRequest:t.baseRequest,anonymousSignInFunc:t.anonymousSignInFunc,wxCloud:t.wxCloud,onCredentialsError:t.onCredentialsError,headers:t.headers||{},i18n:t.i18n,debug:t.debug};n=new c.OAuth2Client(o)}if(!e){var i=n.request.bind(n),s=new l.Captcha(r({env:t.env,clientId:t.clientId,request:i,storage:t.storage,adapter:t.adapter,oauthInstance:this},t.captchaOptions));e=s.request.bind(s)}this.config={env:t.env,apiOrigin:t.apiOrigin,apiPath:t.apiPath,clientId:t.clientId,request:e,credentialsClient:n,storage:t.storage||c.defaultStorage,adapter:t.adapter}}return t.parseParamsToSearch=function(t){return Object.keys(t).forEach((function(e){t[e]||delete t[e]})),new h.default(t).toString()},t.prototype.getParamsByVersion=function(t,e){var n,r=(0,d.deepClone)(t),o=(null===(n={v2:u.ApiUrlsV2}[null==r?void 0:r.version])||void 0===n?void 0:n[e])||u.ApiUrls[e];return r&&delete r.version,{params:r,url:o}},t.prototype.signIn=function(t){return o(this,void 0,Promise,(function(){var e,n,o,s;return i(this,(function(i){switch(i.label){case 0:return e=t.version||"v1",(n=this.getParamsByVersion(t,"AUTH_SIGN_IN_URL")).params.query&&delete n.params.query,[4,this.getEncryptParams(n.params)];case 1:return o=i.sent(),[4,this.config.request(n.url,{method:"POST",body:o})];case 2:return s=i.sent(),[4,this.config.credentialsClient.setCredentials(r(r({},s),{version:e}))];case 3:return i.sent(),[2,Promise.resolve(s)]}}))}))},t.prototype.signInAnonymously=function(t,e){return void 0===t&&(t={}),void 0===e&&(e=!1),o(this,void 0,Promise,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",body:t,useWxCloud:e})];case 1:return n=r.sent(),[4,this.config.credentialsClient.setCredentials(n)];case 2:return r.sent(),[2,Promise.resolve(n)]}}))}))},t.prototype.signUp=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_UP_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signOut=function(t){return o(this,void 0,Promise,(function(){var e,n,r,o;return i(this,(function(i){switch(i.label){case 0:if(e={},!t)return[3,6];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.config.request(u.ApiUrls.AUTH_SIGNOUT_URL,{method:"POST",withCredentials:!0,body:t})];case 2:return e=i.sent(),[3,4];case 3:return(n=i.sent()).error!==u.ErrorType.UNAUTHENTICATED&&console.log("sign_out_error",n),[3,4];case 4:return[4,this.config.credentialsClient.setCredentials()];case 5:return i.sent(),[2,e];case 6:return[4,this.config.credentialsClient.getAccessToken()];case 7:return r=i.sent(),[4,this.config.request(u.ApiUrls.AUTH_REVOKE_URL,{method:"POST",body:{token:r}})];case 8:return o=i.sent(),[4,this.config.credentialsClient.setCredentials()];case 9:return i.sent(),[2,Promise.resolve(o)]}}))}))},t.prototype.revokeAllDevices=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_REVOKE_ALL_URL,{method:"DELETE",withCredentials:!0})];case 1:return t.sent(),[2]}}))}))},t.prototype.revokeDevice=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.config.request(u.ApiUrls.AUTHORIZED_DEVICES_DELETE_URL+t.device_id,{method:"DELETE",withCredentials:!0})];case 1:return e.sent(),[2]}}))}))},t.prototype.getVerification=function(t,e){return o(this,void 0,Promise,(function(){var n,r;return i(this,(function(o){switch(o.label){case 0:return n=!1,"CUR_USER"!==t.target?[3,1]:(n=!0,[3,3]);case 1:return[4,this.hasLoginState()];case 2:o.sent()&&(n=!0),o.label=3;case 3:return(r=(0,d.deepClone)(t)).phone_number&&!/^\+\d{1,3}\s+\d+/.test(r.phone_number)&&(r.phone_number="+86 ".concat(r.phone_number)),[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:r,withCaptcha:(null==e?void 0:e.withCaptcha)||!1,withCredentials:n})]}}))}))},t.prototype.verify=function(t){return o(this,void 0,Promise,(function(){var e,n;return i(this,(function(o){switch(o.label){case 0:return e=this.getParamsByVersion(t,"VERIFY_URL"),[4,this.config.request(e.url,{method:"POST",body:e.params})];case 1:return n=o.sent(),"v2"!==(null==t?void 0:t.version)?[3,3]:[4,this.config.credentialsClient.setCredentials(r(r({},n),{version:"v2"}))];case 2:o.sent(),o.label=3;case 3:return[2,n]}}))}))},t.prototype.genProviderRedirectUri=function(e){return o(this,void 0,Promise,(function(){var n,r,o,a,c;return i(this,(function(i){return n=e.provider_redirect_uri,r=e.other_params,o=void 0===r?{}:r,a=s(e,["provider_redirect_uri","other_params"]),n&&!a.redirect_uri&&(a.redirect_uri=n),c="".concat(u.ApiUrls.PROVIDER_URI_URL,"?").concat(t.parseParamsToSearch(a)),Object.keys(o).forEach((function(t){var e=o[t];("sign_out_uri"!==t||(null==e?void 0:e.length)>0)&&(c+="&other_params[".concat(t,"]=").concat(encodeURIComponent(e)))})),[2,this.config.request(c,{method:"GET"})]}))}))},t.prototype.grantProviderToken=function(t,e){return void 0===e&&(e=!1),o(this,void 0,Promise,(function(){return i(this,(function(n){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"POST",body:t,useWxCloud:e})]}))}))},t.prototype.patchProviderToken=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.PROVIDER_TOKEN_URL,{method:"PATCH",body:t})]}))}))},t.prototype.signInWithProvider=function(t,e){return void 0===e&&(e=!1),o(this,void 0,Promise,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=this.getParamsByVersion(t,"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(n.url,{method:"POST",body:n.params,useWxCloud:e})];case 1:return o=i.sent(),[4,this.config.credentialsClient.setCredentials(r(r({},o),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return i.sent(),[2,Promise.resolve(o)]}}))}))},t.prototype.toBindIdentity=function(t){var e,n;return o(this,void 0,void 0,(function(){var r,o,s,a;return i(this,(function(i){switch(i.label){case 0:return(o=t.credentials)?[3,2]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 1:o=i.sent(),i.label=2;case 2:r=o,i.label=3;case 3:return i.trys.push([3,5,,6]),[4,this.bindWithProvider({provider_token:t.provider_token},r)];case 4:return i.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY,provider:t.provider},error:null},[3,6];case 5:return a=i.sent(),s={data:{type:u.OAUTH_TYPE.BIND_IDENTITY},error:new f.AuthError(a)},[3,6];case 6:return t.fireEvent&&(null===(n=null===(e=this.config.eventBus)||void 0===e?void 0:e.fire)||void 0===n||n.call(e,u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.BIND_IDENTITY,info:s})),[2,s]}}))}))},t.prototype.getInitialSession=function(){return o(this,void 0,Promise,(function(){var t,e,n,o,s,a,c,l,d,h,p,v,y,m,g;return i(this,(function(i){switch(i.label){case 0:t={},i.label=1;case 1:if(i.trys.push([1,12,,13]),"undefined"==typeof window||"undefined"==typeof document)return[2,{data:null,error:null}];if(e=new URLSearchParams(null===location||void 0===location?void 0:location.search),n=e.get("code"),o=e.get("state"),!n||!o)return[2,{data:null,error:null}];s=null;try{s=JSON.parse(sessionStorage.getItem(o)||"null")}catch(t){}return t={type:null==s?void 0:s.type},a=e.get("error"),c=e.get("error_description"),a||c?[2,{data:t,error:new f.AuthError({message:c||a||"Unknown error from OAuth provider"})}]:(l=(null==s?void 0:s.provider)||e.get("provider"))?(d=location.origin+location.pathname,[4,this.grantProviderToken({provider_id:l,provider_redirect_uri:d,provider_code:n})]):[2,{data:t,error:new f.AuthError({message:"Provider is required for OAuth verification"})}];case 2:return h=i.sent().provider_token,p=void 0,v=null,y=void 0,s.type!==u.OAUTH_TYPE.BIND_IDENTITY?[3,5]:[4,this.config.credentialsClient.localCredentials.getCredentials()];case 3:return p=i.sent(),[4,this.toBindIdentity({provider:l,provider_token:h,credentials:p})];case 4:return y=i.sent(),[3,11];case 5:return s.type!==u.OAUTH_TYPE.SIGN_IN?[3,11]:(y=this.getParamsByVersion({provider:l},"AUTH_SIGN_IN_WITH_PROVIDER_URL"),[4,this.config.request(y.url,{method:"POST",body:{provider_token:h}})]);case 6:p=i.sent(),i.label=7;case 7:return i.trys.push([7,9,,10]),[4,this.getUserInfo({credentials:p})];case 8:return v=i.sent(),[3,10];case 9:return m=i.sent(),console.error("get user info error",m),[3,10];case 10:y={data:r(r({},t),{session:p,user:v}),error:null},i.label=11;case 11:e.delete("code"),e.delete("state"),e.delete("provider"),this.restoreUrlState(void 0===(null==s?void 0:s.search)?"?".concat(e.toString()):s.search,(null==s?void 0:s.hash)||location.hash);try{sessionStorage.removeItem(o)}catch(t){}return[2,y];case 12:return g=i.sent(),[2,{data:t,error:new f.AuthError(g)}];case 13:return[2]}}))}))},t.prototype.signInCustom=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_CUSTOM,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.signInWithWechat=function(t){return void 0===t&&(t={}),o(this,void 0,Promise,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.config.request(u.ApiUrls.AUTH_SIGN_IN_WITH_WECHAT_URL,{method:"POST",body:t})];case 1:return e=n.sent(),[4,this.config.credentialsClient.setCredentials(e)];case 2:return n.sent(),[2,Promise.resolve(e)]}}))}))},t.prototype.bindWithProvider=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(n){return[2,this.config.request(u.ApiUrls.PROVIDER_BIND_URL,{method:"POST",body:t,withCredentials:!0,getCredentials:e?function(){return e}:void 0})]}))}))},t.prototype.getUserProfile=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.getUserInfo(t)]}))}))},t.prototype.getUserInfo=function(t){var e,n,r;return void 0===t&&(t={}),o(this,void 0,Promise,(function(){var o,s,a,u,c;return i(this,(function(i){switch(i.label){case 0:return o=this.getParamsByVersion(t,"USER_ME_URL"),(null===(e=o.params)||void 0===e?void 0:e.query)&&(s=new h.default(o.params.query),o.url+="?".concat(s.toString())),[4,this.config.request(o.url,{method:"GET",withCredentials:!0,getCredentials:t.credentials?function(){return t.credentials}:void 0})];case 1:if((a=i.sent()).sub&&(a.uid=a.sub),null===(n=a.providers)||void 0===n?void 0:n.length)try{"undefined"!=typeof wx&&wx.getAccountInfoSync&&(u=null===(r=wx.getAccountInfoSync().miniProgram)||void 0===r?void 0:r.appId,(null==(c=a.providers.find((function(t){return t.id===u})))?void 0:c.provider_user_id)&&(a.open_id=c.provider_user_id))}catch(t){}return[2,a]}}))}))},t.prototype.getWedaUserInfo=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.config.request(u.ApiUrls.WEDA_USER_URL,{method:"GET",withCredentials:!0})];case 1:return[2,t.sent()]}}))}))},t.prototype.deleteMe=function(e){return o(this,void 0,Promise,(function(){var n,r;return i(this,(function(o){return n=this.getParamsByVersion(e,"USER_ME_URL"),r="".concat(n.url,"?").concat(t.parseParamsToSearch(n.params)),[2,this.config.request(r,{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.hasLoginState=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.config.credentialsClient.getAccessToken()];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.hasLoginStateSync=function(){return this.config.credentialsClient.getCredentialsSync()},t.prototype.getLoginState=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.credentialsClient.getCredentialsAsync()]}))}))},t.prototype.transByProvider=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.USER_TRANS_BY_PROVIDER_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.grantToken=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){return e=this.getParamsByVersion(t,"AUTH_TOKEN_URL"),[2,this.config.request(e.url,{method:"POST",body:e.params})]}))}))},t.prototype.getProviders=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.PROVIDER_LIST,{method:"GET",withCredentials:!0})]}))}))},t.prototype.unbindProvider=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_UNBIND_URL,"/").concat(t.provider_id),{method:"DELETE",withCredentials:!0})]}))}))},t.prototype.checkPassword=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request("".concat(u.ApiUrls.CHECK_PWD_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.editContact=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request("".concat(u.ApiUrls.BIND_CONTACT_URL),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.setPassword=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request("".concat(u.ApiUrls.AUTH_SET_PASSWORD),{method:"PATCH",withCredentials:!0,body:t})]}))}))},t.prototype.updatePasswordByOld=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.sudo({password:t.old_password})];case 1:return e=n.sent(),[2,this.setPassword({sudo_token:e.sudo_token,new_password:t.new_password})]}}))}))},t.prototype.sudo=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request("".concat(u.ApiUrls.SUDO_URL),{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.sendVerificationCodeToCurrentUser=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return t.target="CUR_USER",[2,this.config.request(u.ApiUrls.VERIFICATION_URL,{method:"POST",body:t,withCredentials:!0,withCaptcha:!0})]}))}))},t.prototype.changeBoundProvider=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request("".concat(u.ApiUrls.PROVIDER_LIST,"/").concat(t.provider_id,"/trans"),{method:"POST",body:{provider_trans_token:t.trans_token},withCredentials:!0})]}))}))},t.prototype.setUserProfile=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.USER_PRIFILE_URL,{method:"PATCH",body:t,withCredentials:!0})]}))}))},t.prototype.updateUserBasicInfo=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.queryUserProfile=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){return e=new h.default(t),[2,this.config.request("".concat(u.ApiUrls.USER_QUERY_URL,"?").concat(e.toString()),{method:"GET",withCredentials:!0})]}))}))},t.prototype.setCustomSignFunc=function(t){this.getCustomSignTicketFn=t},t.prototype.signInWithCustomTicket=function(){return o(this,void 0,Promise,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return(t=this.getCustomSignTicketFn)?[4,t()]:[2,Promise.reject({error:"failed_precondition",error_description:"please use setCustomSignFunc to set custom sign function"})];case 1:return e=n.sent(),[2,this.signInCustom({provider_id:"custom",ticket:e})]}}))}))},t.prototype.resetPassword=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.AUTH_RESET_PASSWORD,{method:"POST",body:t})]}))}))},t.prototype.authorize=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.AUTHORIZE_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.authorizeDevice=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.AUTHORIZE_DEVICE_URL,{method:"POST",withCredentials:!0,body:t})]}))}))},t.prototype.deviceAuthorize=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.AUTH_GET_DEVICE_CODE,{method:"POST",body:t})]}))}))},t.prototype.authorizeInfo=function(e){return o(this,void 0,Promise,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n="".concat(u.ApiUrls.AUTHORIZE_INFO_URL,"?").concat(t.parseParamsToSearch(e)),r=!0,o=!1,[4,this.hasLoginState()];case 1:return i.sent()&&(o=!0,r=!1),[2,this.config.request(n,{method:"GET",withBasicAuth:r,withCredentials:o})]}}))}))},t.prototype.checkUsername=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.CHECK_USERNAME,{method:"GET",body:t,withCredentials:!0})]}))}))},t.prototype.checkIfUserExist=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){return e=new h.default(t),[2,this.config.request("".concat(u.ApiUrls.CHECK_IF_USER_EXIST,"?").concat(e.toString()),{method:"GET"})]}))}))},t.prototype.loginScope=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.credentialsClient.getScope()]}))}))},t.prototype.loginGroups=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.credentialsClient.getGroups()]}))}))},t.prototype.refreshTokenForce=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return[4,this.config.credentialsClient.getCredentials()];case 1:return e=n.sent(),[4,this.config.credentialsClient.refreshToken(r(r({},e),{version:(null==t?void 0:t.version)||"v1"}))];case 2:return[2,n.sent()]}}))}))},t.prototype.getCredentials=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.config.credentialsClient.getCredentials()]}))}))},t.prototype.getPublicKey=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrlsV2.AUTH_PUBLIC_KEY,{method:"POST",body:{}})]}))}))},t.prototype.getEncryptParams=function(t){return o(this,void 0,Promise,(function(){var e,n,r,o,s,a;return i(this,(function(i){switch(i.label){case 0:return e=t.isEncrypt,delete t.isEncrypt,n=(0,d.deepClone)(t),[4,p(e,this.config.adapter)];case 1:if(!(r=i.sent()))return[2,t];o="",s="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(a=i.sent(),o=a.public_key,s=a.public_key_thumbprint,!o||!s)throw a;return[3,5];case 4:throw i.sent();case 5:return[2,{params:r.getEncryptInfo({publicKey:o,payload:n}),public_key_thumbprint:s}]}}))}))},t.prototype.getProviderSubType=function(){return o(this,void 0,Promise,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.GET_PROVIDER_TYPE,{method:"POST",body:{provider_id:"weda"}})]}))}))},t.prototype.verifyCaptchaData=function(t){var e=t.token,n=t.key;return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.VERIFY_CAPTCHA_DATA_URL,{method:"POST",body:{token:e,key:n},withCredentials:!1})]}))}))},t.prototype.createCaptchaData=function(t){var e=t.state,n=t.redirect_uri,r=void 0===n?void 0:n;return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,this.config.request(u.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:r},withCredentials:!1})]}))}))},t.prototype.getMiniProgramCode=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE,{method:"POST",body:t})]}))}))},t.prototype.getMiniProgramQrCodeStatus=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.config.request(u.ApiUrls.GET_MINIPROGRAM_QRCODE_STATUS,{method:"POST",body:t})]}))}))},t.prototype.getUserBehaviorLog=function(t){return o(this,void 0,Promise,(function(){var e,n;return i(this,(function(r){return e={LOGIN:"query[action]=USER_LOGIN",MODIFY:"ne_query[action]=USER_LOGIN"},n="".concat(u.ApiUrls.GET_USER_BEHAVIOR_LOG,"?").concat(e[t.type],"&limit=").concat(t.limit).concat(t.page_token?"&page_token=".concat(t.page_token):""),[2,this.config.request(n,{method:"GET",withCredentials:!0})]}))}))},t.prototype.modifyPassword=function(t){return o(this,void 0,Promise,(function(){var e,n,r,o,s,a;return i(this,(function(i){switch(i.label){case 0:return e="",n="",[4,p(!0,this.config.adapter)];case 1:if(!(r=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),e=o.public_key,n=o.public_key_thumbprint,!e||!n)throw o;return[3,5];case 4:throw i.sent();case 5:return s=t.password?r.getEncryptInfo({publicKey:e,payload:t.password}):"",a=r.getEncryptInfo({publicKey:e,payload:t.new_password}),[2,this.config.request(u.ApiUrls.USER_BASIC_EDIT_URL,{method:"POST",withCredentials:!0,body:{user_id:t.user_id,encrypt_password:s,encrypt_new_password:a,public_key_thumbprint:n}})]}}))}))},t.prototype.modifyPasswordWithoutLogin=function(t){return o(this,void 0,Promise,(function(){var e,n,r,o,s,a;return i(this,(function(i){switch(i.label){case 0:return e="",n="",[4,p(!0,this.config.adapter)];case 1:if(!(r=i.sent()))throw new Error("do not support encrypt, a encrypt util required.");i.label=2;case 2:return i.trys.push([2,4,,5]),[4,this.getPublicKey()];case 3:if(o=i.sent(),e=o.public_key,n=o.public_key_thumbprint,!e||!n)throw o;return[3,5];case 4:throw i.sent();case 5:return s=t.password?r.getEncryptInfo({publicKey:e,payload:t.password}):"",a=r.getEncryptInfo({publicKey:e,payload:t.new_password}),[2,this.config.request(u.ApiUrlsV2.AUTH_RESET_PASSWORD,{method:"POST",body:{username:t.username,password:s,new_password:a,public_key_thumbprint:n}})]}}))}))},t.prototype.restoreUrlState=function(t,e){if(void 0!==t)try{var n=new URL(window.location.href);n.search=t,n.hash=e||"",window.history.replaceState(null,"",n.toString()),window.location.replace(n.toString())}catch(t){}},t}();e.Auth=v},8308:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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.AuthError=e.AuthErrorCategory=void 0;var i,s=n(4949);!function(t){t.PROVIDER_NOT_ENABLED="PROVIDER_NOT_ENABLED",t.INVALID_CREDENTIALS="INVALID_CREDENTIALS",t.USER_NOT_FOUND="USER_NOT_FOUND",t.USER_STATUS_ABNORMAL="USER_STATUS_ABNORMAL",t.SERVICE_ERROR="SERVICE_ERROR",t.INVALID_PARAMS="INVALID_PARAMS",t.AUTH_METHOD_MISMATCH="AUTH_METHOD_MISMATCH",t.UNKNOWN="UNKNOWN"}(i=e.AuthErrorCategory||(e.AuthErrorCategory={}));var a="https://tcb.cloud.tencent.com/dev?envId=#/identity/login-manage",u="https://docs.cloudbase.net/api-reference/webv3-next/initialization",c=function(t){function e(e,n){var r,o=this,c=e.error_description||e.message;return(o=t.call(this,c)||this).__isAuthError=!0,o.name="AuthError",o.status=e.error,o.code=e.error_code,o.requestId=e.requestId,o.category=function(t,e){if(!t&&!e)return i.UNKNOWN;try{var n=(t||"").toLowerCase();return e===s.ErrorType.FAILED_PRECONDITION||e===s.ErrorType.PROVIDER_NOT_ENABLED||e===s.ErrorType.LOGIN_METHOD_DISABLED||n.includes("身份源")||n.includes("开启")||n.includes("identity provider")||n.includes("provider not enabled")||n.includes("login method")||n.includes("登录方式")||n.includes("not enabled")||n.includes("未开启")||n.includes("未启用")||n.includes("请联系开发者")||n.includes("anonymous login is not enabled")||n.includes("匿名登录未开启")?i.PROVIDER_NOT_ENABLED:e===s.ErrorType.INVALID_PASSWORD||e===s.ErrorType.INVALID_GRANT||e===s.ErrorType.INVALID_VERIFICATION_CODE||e===s.ErrorType.INVALID_USERNAME_OR_PASSWORD||e===s.ErrorType.INVALID_CREDENTIALS||e===s.ErrorType.WRONG_PASSWORD||e===s.ErrorType.UNAUTHENTICATED||e===s.ErrorType.INVALID_TWO_FACTOR||e===s.ErrorType.INVALID_TWO_FACTOR_RECOVERY||e===s.ErrorType.PASSWORD_NOT_SET||n.includes("密码不正确")||n.includes("password")||n.includes("invalid_password")||n.includes("凭据")||n.includes("credentials")||n.includes("验证码")||n.includes("verification")||n.includes("invalid_verification_code")||n.includes("invalid_username_or_password")||n.includes("username or password")||n.includes("用户名或密码")||n.includes("wrong password")||n.includes("incorrect password")?i.INVALID_CREDENTIALS:e===s.ErrorType.NOT_FOUND||e===s.ErrorType.USER_NOT_FOUND||n.includes("用户不存在")||n.includes("not found")||n.includes("user not found")||n.includes("不存在")||n.includes("no such user")||n.includes("user does not exist")?i.USER_NOT_FOUND:e===s.ErrorType.USER_BLOCKED||e===s.ErrorType.USER_PENDING||e===s.ErrorType.UNDER_REVIEW||e===s.ErrorType.INVALID_STATUS||n.includes("被封禁")||n.includes("blocked")||n.includes("pending")||n.includes("审核")||n.includes("review")||n.includes("locked")||n.includes("已锁定")?i.USER_STATUS_ABNORMAL:e===s.ErrorType.SERVER_ERROR||e===s.ErrorType.UNAVAILABLE||e===s.ErrorType.TEMPORARILY_UNAVAILABLE||e===s.ErrorType.INTERNAL||e===s.ErrorType.UNREACHABLE||e===s.ErrorType.DEADLINE_EXCEEDED||e===s.ErrorType.DATA_LOSS||n.includes("network")||n.includes("timeout")||n.includes("服务")||n.includes("timed out")||n.includes("超时")?i.SERVICE_ERROR:e===s.ErrorType.INVALID_ARGUMENT||e===s.ErrorType.INVALID_REQUEST||e===s.ErrorType.INVALID_SCOPE||e===s.ErrorType.INVALID_REQUEST_URI||e===s.ErrorType.INVALID_REQUEST_OBJECT?i.INVALID_PARAMS:e===s.ErrorType.PERMISSION_DENIED||e===s.ErrorType.ACCESS_DENIED||e===s.ErrorType.UNAUTHORIZED_CLIENT?i.PROVIDER_NOT_ENABLED:i.UNKNOWN}catch(t){return e}}(c,o.status),o.helpMessage=function(t,e){var n=(null==e?void 0:e.method)||"signIn",r={signInWithPassword:"「用户名密码登录」",signInAnonymously:"「匿名登录」",signInWithOtp:"「短信验证码登录」或「邮箱验证码登录」",signUp:"「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"对应的第三方身份源",signInWithIdToken:"对应的第三方身份源",signInWithOpenId:"「微信小程序 OpenID 登录」",signInWithPhoneAuth:"「微信小程序手机号授权登录」",signInWithCustomTicket:"「自定义登录」"}[n]||"对应的登录方式";switch(t){case i.PROVIDER_NOT_ENABLED:return"[CloudBase Auth] 登录方式未开启\n\n"+" 当前调用的 ".concat(n,"() 所需的登录方式尚未在云开发控制台启用。\n")+" 需要开启的登录方式:".concat(r,"\n")+"\n 请按以下步骤开启:\n"+" 1. 打开云开发控制台:".concat(a,"\n")+" 2. 选择对应的云开发环境\n 3. 进入「登录授权」页面,在「登录方式」或「身份源列表」中开启所需的登录方式\n\n 各登录方法与所需登录方式的对应关系:\n - signInWithPassword → 「用户名密码登录」\n - signInAnonymously → 「匿名登录」\n - signInWithOtp/signUp → 「短信验证码登录」或「邮箱验证码登录」\n - signInWithOAuth/signInWithIdToken → 对应的第三方身份源\n\n 如使用 CLI/MCP 工具,可通过 auth 工具查询和配置身份源状态。\n"+" 更多帮助请参考文档:".concat(u);case i.INVALID_CREDENTIALS:return"[CloudBase Auth] 凭据验证失败\n\n"+" 调用 ".concat(n,"() 时凭据校验未通过。\n")+"\n 请按优先级逐项排查:\n 1. 确认用户名/邮箱/手机号是否拼写正确、格式完整\n 2. 确认密码是否正确(注意大小写、特殊字符、前后空格)\n 3. 确认用户账号确实存在(可通过 auth.isUsernameRegistered() 检查)\n 4. 确认凭据参数来源可靠(环境变量、配置文件中的值是否已正确设置)\n 5. 如使用加密登录(is_encrypt: true),请确认公钥版本正确\n\n 如忘记密码,可通过 auth.resetPasswordForEmail() 重置密码。\n\n 提示:如果是 AI agent / 自动化测试场景,请确认 ENV_ID、USERNAME、PASSWORD\n 等环境变量已正确传入,且对应用户已在目标环境中注册。";case i.USER_NOT_FOUND:return"[CloudBase Auth] 用户不存在\n\n 请检查以下项目:\n 1. 确认用户名/邮箱/手机号是否正确\n 2. 确认是在正确的云开发环境(envId)下操作\n 3. 如果是新用户,请先通过 auth.signUp() 注册\n"+" 4. 也可在云开发控制台手动创建用户:".concat(a,"\n")+"\n 提示:不同环境(开发/测试/生产)的用户库是隔离的,请确认 envId 正确。";case i.USER_STATUS_ABNORMAL:return"[CloudBase Auth] 用户状态异常\n\n 当前用户账号可能处于以下状态之一:\n - 账号已被封禁\n - 账号正在审核中\n - 账号已被锁定(多次密码错误)\n\n"+" 请联系管理员在云开发控制台检查用户状态:".concat(a);case i.SERVICE_ERROR:return"[CloudBase Auth] 服务异常\n\n 请检查以下项目:\n 1. 网络连接是否正常\n 2. 云开发环境是否正常运行\n 3. 稍后重试,如持续失败请联系技术支持\n\n 提示:如果是超时错误,请检查网络环境和请求频率。";case i.INVALID_PARAMS:return"[CloudBase Auth] 参数错误\n\n 请检查传入的参数是否符合要求,参考 API 文档确认各参数的格式和约束。\n"+" 文档地址:".concat(u);case i.AUTH_METHOD_MISMATCH:return"[CloudBase Auth] 登录方式不匹配\n\n"+" 调用 ".concat(n,"() 时遇到错误,可能原因:\n")+" - 匿名登录失败后尝试了用户名密码登录,但凭据不正确或用户不存在\n - 应使用匿名登录但传入了密码参数\n - 应使用密码登录但未传入正确的凭据\n\n 建议:\n 1. 明确当前场景需要的登录方式:\n - 无需用户注册 → auth.signInAnonymously()\n - 有用户名和密码 → auth.signInWithPassword({ username, password })\n - 第三方平台 → auth.signInWithOAuth({ provider })\n 2. 不要在同一流程中混合使用不同的登录方式\n 3. 每种登录方式需要在控制台开启对应的身份源\n"+" 4. 控制台地址:".concat(a);default:return"[CloudBase Auth] 操作失败\n\n 如果问题持续存在,建议:\n"+" 1. 检查云开发控制台的认证配置:".concat(a,"\n")+" 2. 到官方问答社区提问:https://cnb.cool/tencent/cloud/cloudbase/community/-/issues\n"+" 3. 查阅文档:".concat(u)}}(o.category,n),o.loginMethodHint=(r=null==n?void 0:n.method)&&{signInWithPassword:"当前使用「用户名密码登录」,需确保:\n ✓ 控制台已开启「用户名密码登录」\n ✓ 用户已注册且凭据正确\n 如果不需要用户系统,建议改用 auth.signInAnonymously()",signInAnonymously:"当前使用「匿名登录」,需确保:\n ✓ 控制台已开启「匿名登录」\n 注意:匿名用户无需用户名密码,适用于快速体验或临时访问场景",signInWithOtp:"当前使用「OTP 验证码登录」,需确保:\n ✓ 控制台已开启「短信验证码登录」或「邮箱验证码登录」",signInWithOAuth:"当前使用「第三方 OAuth 登录」,需确保:\n ✓ 控制台已配置并开启对应的第三方身份源"}[r]||"",o}return o(e,t),e}(Error);e.AuthError=c},4949:function(t,e){"use strict";var n,r,o,i;Object.defineProperty(e,"__esModule",{value:!0}),e.DEFAULT_NODE_ACCESS_SCOPE=e.OAUTH_TYPE=e.EVENTS=e.AUTH_STATE_CHANGED_TYPE=e.LOGIN_STATE_CHANGED_TYPE=e.ErrorType=e.VerificationUsages=e.ApiUrlsV2=e.ApiUrls=e.AUTH_API_PREFIX=void 0,e.AUTH_API_PREFIX="/auth",(i=e.ApiUrls||(e.ApiUrls={})).AUTH_SIGN_UP_URL="/v1/signup",i.AUTH_TOKEN_URL="/v1/token",i.AUTH_REVOKE_URL="/v1/revoke",i.WEDA_USER_URL="/v1/plugin/weda/userinfo",i.AUTH_RESET_PASSWORD="/v1/reset",i.AUTH_GET_DEVICE_CODE="/v1/device/code",i.CHECK_USERNAME="/v1/checkUsername",i.CHECK_IF_USER_EXIST="/v1/checkIfUserExist",i.GET_PROVIDER_TYPE="/v1/mgr/provider/providerSubType",i.AUTH_SIGN_IN_URL="/v1/signin",i.AUTH_SIGN_IN_ANONYMOUSLY_URL="/v1/signin/anonymously",i.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v1/signin/with/provider",i.AUTH_SIGN_IN_WITH_WECHAT_URL="/v1/signin/wechat/noauth",i.AUTH_SIGN_IN_CUSTOM="/v1/signin/custom",i.PROVIDER_TOKEN_URL="/v1/provider/token",i.PROVIDER_URI_URL="/v1/provider/uri",i.USER_ME_URL="/v1/user/me",i.AUTH_SIGNOUT_URL="/v1/user/signout",i.USER_QUERY_URL="/v1/user/query",i.USER_PRIFILE_URL="/v1/user/profile",i.USER_BASIC_EDIT_URL="/v1/user/basic/edit",i.USER_TRANS_BY_PROVIDER_URL="/v1/user/trans/by/provider",i.PROVIDER_LIST="/v1/user/provider",i.PROVIDER_BIND_URL="/v1/user/provider/bind",i.PROVIDER_UNBIND_URL="/v1/user/provider",i.CHECK_PWD_URL="/v1/user/sudo",i.SUDO_URL="/v1/user/sudo",i.BIND_CONTACT_URL="/v1/user/contact",i.AUTH_SET_PASSWORD="/v1/user/password",i.AUTHORIZE_DEVICE_URL="/v1/user/device/authorize",i.AUTHORIZE_URL="/v1/user/authorize",i.AUTHORIZE_INFO_URL="/v1/user/authorize/info",i.AUTHORIZED_DEVICES_DELETE_URL="/v1/user/authorized/devices/",i.AUTH_REVOKE_ALL_URL="/v1/user/revoke/all",i.GET_USER_BEHAVIOR_LOG="/v1/user/security/history",i.VERIFICATION_URL="/v1/verification",i.VERIFY_URL="/v1/verification/verify",i.CAPTCHA_DATA_URL="/v1/captcha/data",i.VERIFY_CAPTCHA_DATA_URL="/v1/captcha/data/verify",i.GET_CAPTCHA_URL="/v1/captcha/init",i.GET_MINIPROGRAM_QRCODE="/v1/qrcode/generate",i.GET_MINIPROGRAM_QRCODE_STATUS="/v1/qrcode/get/status",(o=e.ApiUrlsV2||(e.ApiUrlsV2={})).AUTH_SIGN_IN_URL="/v2/signin/username",o.AUTH_TOKEN_URL="/v2/token",o.USER_ME_URL="/v2/user/me",o.VERIFY_URL="/v2/signin/verificationcode",o.AUTH_SIGN_IN_WITH_PROVIDER_URL="/v2/signin/with/provider",o.AUTH_PUBLIC_KEY="/v2/signin/publichkey",o.AUTH_RESET_PASSWORD="/v2/signin/password/update",(r=e.VerificationUsages||(e.VerificationUsages={})).REGISTER="REGISTER",r.SIGN_IN="SIGN_IN",r.PASSWORD_RESET="PASSWORD_RESET",r.EMAIL_ADDRESS_CHANGE="EMAIL_ADDRESS_CHANGE",r.PHONE_NUMBER_CHANGE="PHONE_NUMBER_CHANGE",(n=e.ErrorType||(e.ErrorType={})).UNREACHABLE="unreachable",n.LOCAL="local",n.CANCELLED="cancelled",n.UNKNOWN="unknown",n.UNAUTHENTICATED="unauthenticated",n.RESOURCE_EXHAUSTED="resource_exhausted",n.FAILED_PRECONDITION="failed_precondition",n.INVALID_ARGUMENT="invalid_argument",n.DEADLINE_EXCEEDED="deadline_exceeded",n.NOT_FOUND="not_found",n.ALREADY_EXISTS="already_exists",n.PERMISSION_DENIED="permission_denied",n.ABORTED="aborted",n.OUT_OF_RANGE="out_of_range",n.UNIMPLEMENTED="unimplemented",n.INTERNAL="internal",n.UNAVAILABLE="unavailable",n.DATA_LOSS="data_loss",n.INVALID_PASSWORD="invalid_password",n.PASSWORD_NOT_SET="password_not_set",n.INVALID_STATUS="invalid_status",n.USER_PENDING="user_pending",n.USER_BLOCKED="user_blocked",n.INVALID_VERIFICATION_CODE="invalid_verification_code",n.TWO_FACTOR_REQUIRED="two_factor_required",n.INVALID_TWO_FACTOR="invalid_two_factor",n.INVALID_TWO_FACTOR_RECOVERY="invalid_two_factor_recovery",n.UNDER_REVIEW="under_review",n.INVALID_REQUEST="invalid_request",n.UNAUTHORIZED_CLIENT="unauthorized_client",n.ACCESS_DENIED="access_denied",n.UNSUPPORTED_RESPONSE_TYPE="unsupported_response_type",n.INVALID_SCOPE="invalid_scope",n.INVALID_GRANT="invalid_grant",n.SERVER_ERROR="server_error",n.TEMPORARILY_UNAVAILABLE="temporarily_unavailable",n.INTERACTION_REQUIRED="interaction_required",n.LOGIN_REQUIRED="login_required",n.ACCOUNT_SELECTION_REQUIRED="account_selection_required",n.CONSENT_REQUIRED="consent_required",n.INVALID_REQUEST_URI="invalid_request_uri",n.INVALID_REQUEST_OBJECT="invalid_request_object",n.REQUEST_NOT_SUPPORTED="request_not_supported",n.REQUEST_URI_NOT_SUPPORTED="request_uri_not_supported",n.REGISTRATION_NOT_SUPPORTED="registration_not_supported",n.CAPTCHA_REQUIRED="captcha_required",n.CAPTCHA_INVALID="captcha_invalid",n.PROVIDER_NOT_ENABLED="provider_not_enabled",n.LOGIN_METHOD_DISABLED="login_method_disabled",n.INVALID_USERNAME_OR_PASSWORD="invalid_username_or_password",n.INVALID_CREDENTIALS="invalid_credentials",n.WRONG_PASSWORD="wrong_password",n.USER_NOT_FOUND="user_not_found",e.LOGIN_STATE_CHANGED_TYPE={SIGN_OUT:"sign_out",SIGN_IN:"sign_in",CREDENTIALS_ERROR:"credentials_error"},e.AUTH_STATE_CHANGED_TYPE={SIGNED_OUT:"SIGNED_OUT",SIGNED_IN:"SIGNED_IN",INITIAL_SESSION:"INITIAL_SESSION",PASSWORD_RECOVERY:"PASSWORD_RECOVERY",TOKEN_REFRESHED:"TOKEN_REFRESHED",USER_UPDATED:"USER_UPDATED",BIND_IDENTITY:"BIND_IDENTITY"},e.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",AUTH_STATE_CHANGED:"authStateChanged"},e.OAUTH_TYPE={SIGN_IN:"sign_in",BIND_IDENTITY:"bind_identity"},e.DEFAULT_NODE_ACCESS_SCOPE="node-sdk-scope"},3538:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},2084:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.openURIWithCallback=void 0;var s=n(9689),a=n(3616),u=function(t,e){var n;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];clearTimeout(n),n=setTimeout((function(){return t.apply(null,r)}),e)}},c=new s.CloudbaseEventEmitter,l="resolveCaptchaData",d="padding:10px 8px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer;flex:1;white-space:nowrap;margin-left:10px",h="width:100%;padding:10px;background:#007bff;color:#fff;border:none;border-radius:4px;cursor:pointer",f="background:#6c757d;cursor:not-allowed";e.openURIWithCallback=function(t,e){return o(void 0,void 0,Promise,(function(){var n,s,p,v;return i(this,(function(y){return n=(0,a.parseCaptcha)(t),s=n.captchaData,p=n.state,v=n.token,function(t){var e=t.oauthInstance,n=t.captchaState,s="captcha-image",a=function(){return o(void 0,void 0,void 0,(function(){var t,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,e.createCaptchaData({state:n.state})];case 1:return t=i.sent(),n=r(r({},n),{captchaData:t.data,token:t.token}),document.getElementById(s).src=t.data,[3,3];case 2:return o=i.sent(),console.error("刷新图形验证码失败",o),[3,3];case 3:return[2]}}))}))},p=function(t,e,n){var r=document.createElement(t);return e&&(r.style.cssText=e),n&&(r.textContent=n),r},v=p("div","position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:999"),y=p("div","position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:320px;padding:20px;background:#fff;border-radius:8px;box-shadow:0 0 10px rgba(0,0,0,0.2);z-index:1000");y.appendChild(p("p","margin-bottom:15px","请输入你看到的字符:"));var m=p("div","display:flex;align-items:center;justify-content:space-between;margin-bottom:15px"),g=p("img","width:100%;height:auto;border:1px solid #eee");g.id=s,g.src=n.captchaData,m.appendChild(g);var b=p("button",d,"刷新");b.onclick=u((function(){return o(void 0,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:b.textContent="加载中...",b.disabled=!0,b.style.cssText="".concat(d,";").concat(f),t.label=1;case 1:return t.trys.push([1,,3,4]),[4,a()];case 2:return t.sent(),[3,4];case 3:return b.textContent="刷新",b.disabled=!1,b.style.cssText=d,[7];case 4:return[2]}}))}))}),500),m.appendChild(b),y.appendChild(m);var _=p("input","width:100%;padding:14px 16px;margin-bottom:15px;box-sizing:border-box;border:2px solid #e8ecf4;border-radius:10px;font-size:15px");_.type="text",_.placeholder="输入字符",_.maxLength=4,y.appendChild(_);var w=p("div","color:#dc3545;font-size:12px;margin-bottom:10px;display:none;padding:8px;background:#f8d7da;border:1px solid #f5c6cb;border-radius:4px");y.appendChild(w);var E=function(t){w.textContent=t,w.style.display="block"},I=p("button",h,"确定");I.onclick=u((function(){return o(void 0,void 0,void 0,(function(){var t,r,o,s;return i(this,(function(i){switch(i.label){case 0:if(!(t=_.value.trim()))return E("请输入字符"),[2];w.style.display="none",I.textContent="验证中...",I.disabled=!0,I.style.cssText="".concat(h,";").concat(f),i.label=1;case 1:return i.trys.push([1,3,5,6]),[4,e.verifyCaptchaData({token:n.token,key:t})];case 2:return r=i.sent(),c.fire(l,r),console.log("图形验证码校验成功"),document.body.removeChild(v),document.body.removeChild(y),[3,6];case 3:return o=i.sent(),console.error("图形验证码校验失败",o),s=o.error_description||"图形验证码校验失败",E(s),_.value="",_.focus(),[4,a()];case 4:return i.sent(),[3,6];case 5:return I.textContent="确定",I.disabled=!1,I.style.cssText=h,[7];case 6:return[2]}}))}))}),500),y.appendChild(I),document.body.appendChild(v),document.body.appendChild(y)}({oauthInstance:e,captchaState:{captchaData:s,state:p,token:v}}),[2,new Promise((function(t){console.log("等待图形验证码校验结果..."),c.on(l,(function(e){t(null==e?void 0:e.data)}))}))]}))}))}},2962:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Captcha=void 0;var i=n(4949),s=n(5257),a=n(7425),u=n(2084),c=function(){function t(t){t.openURIWithCallback||(t.openURIWithCallback=this.getDefaultOpenURIWithCallback()),t.storage||(t.storage=s.defaultStorage),this.config=t,this.tokenSectionName="captcha_".concat(t.clientId||t.env)}return t.prototype.isMatch=function(){var t,e,n;return(null===(n=null===(e=null===(t=this.config)||void 0===t?void 0:t.adapter)||void 0===e?void 0:e.isMatch)||void 0===n?void 0:n.call(e))||(0,a.isMp)()},t.prototype.request=function(t,e){return r(this,void 0,Promise,(function(){var n,r,s,a;return o(this,(function(o){switch(o.label){case 0:return e||(e={}),e.method||(e.method="GET"),n="".concat(e.method,":").concat(t),r=t,e.withCaptcha?[4,this.appendCaptchaTokenToURL(t,n,!1)]:[3,2];case 1:r=o.sent(),o.label=2;case 2:return o.trys.push([2,4,,7]),[4,this.config.request(r,e)];case 3:return s=o.sent(),[3,7];case 4:return(a=o.sent()).error!==i.ErrorType.CAPTCHA_REQUIRED&&a.error!==i.ErrorType.CAPTCHA_INVALID?[3,6]:[4,this.appendCaptchaTokenToURL(t,n,a.error===i.ErrorType.CAPTCHA_INVALID)];case 5:return t=o.sent(),[2,this.config.request(t,e)];case 6:return[2,Promise.reject(a)];case 7:return[2,s]}}))}))},t.prototype.getDefaultOpenURIWithCallback=function(){var t=this;return function(e){return(0,u.openURIWithCallback)(e,t.config.oauthInstance)}},t.prototype.getCaptchaToken=function(t,e){return r(this,void 0,Promise,(function(){var n,r,s,a;return o(this,(function(o){switch(o.label){case 0:return t?[3,2]:[4,this.findCaptchaToken()];case 1:if(n=o.sent())return[2,n];o.label=2;case 2:return[4,this.config.request(i.ApiUrls.CAPTCHA_DATA_URL,{method:"POST",body:{state:e,redirect_uri:""},withCredentials:!1})];case 3:return r=o.sent(),s="".concat(r.data,"?state=").concat(encodeURIComponent(e),"&token=").concat(encodeURIComponent(r.token)),[4,this.config.openURIWithCallback(s)];case 4:return a=o.sent(),this.saveCaptchaToken(a),[2,a.captcha_token]}}))}))},t.prototype.appendCaptchaTokenToURL=function(t,e,n){return r(this,void 0,Promise,(function(){var r;return o(this,(function(o){switch(o.label){case 0:return[4,this.getCaptchaToken(n,e)];case 1:return r=o.sent(),t.indexOf("?")>0?t+="&captcha_token=".concat(r):t+="?captcha_token=".concat(r),[2,t]}}))}))},t.prototype.saveCaptchaToken=function(t){return r(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return t.expires_at=new Date(Date.now()+1e3*(t.expires_in-10)),e=JSON.stringify(t),[4,this.config.storage.setItem(this.tokenSectionName,e)];case 1:return n.sent(),[2]}}))}))},t.prototype.findCaptchaToken=function(){return r(this,void 0,Promise,(function(){var t,e;return o(this,(function(n){switch(n.label){case 0:return[4,this.config.storage.getItem(this.tokenSectionName)];case 1:if(null==(t=n.sent()))return[3,5];n.label=2;case 2:return n.trys.push([2,3,,5]),(null==(e=JSON.parse(t))?void 0:e.expires_at)&&(e.expires_at=new Date(e.expires_at)),e.expires_at<new Date?[2,null]:[2,e.captcha_token];case 3:return n.sent(),[4,this.config.storage.removeItem(this.tokenSectionName)];case 4:return n.sent(),[2,null];case 5:return[2,null]}}))}))},t}();e.Captcha=c},6722:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseOAuth=e.AUTH_STATE_CHANGED_TYPE=e.EVENTS=e.LOGIN_STATE_CHANGED_TYPE=e.DEFAULT_NODE_ACCESS_SCOPE=e.OAUTH_TYPE=e.AUTH_API_PREFIX=e.weAppJwtDecodeAll=e.authModels=e.AuthErrorCategory=e.AuthError=e.Auth=void 0;var a=n(5257),u=n(5413),c=n(4949),l=n(5413);Object.defineProperty(e,"Auth",{enumerable:!0,get:function(){return l.Auth}});var d=n(8308);Object.defineProperty(e,"AuthError",{enumerable:!0,get:function(){return d.AuthError}}),Object.defineProperty(e,"AuthErrorCategory",{enumerable:!0,get:function(){return d.AuthErrorCategory}}),e.authModels=s(n(3538));var h=n(2344);Object.defineProperty(e,"weAppJwtDecodeAll",{enumerable:!0,get:function(){return h.weAppJwtDecodeAll}});var f=n(4949);Object.defineProperty(e,"AUTH_API_PREFIX",{enumerable:!0,get:function(){return f.AUTH_API_PREFIX}}),Object.defineProperty(e,"OAUTH_TYPE",{enumerable:!0,get:function(){return f.OAUTH_TYPE}}),Object.defineProperty(e,"DEFAULT_NODE_ACCESS_SCOPE",{enumerable:!0,get:function(){return f.DEFAULT_NODE_ACCESS_SCOPE}}),Object.defineProperty(e,"LOGIN_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.LOGIN_STATE_CHANGED_TYPE}}),Object.defineProperty(e,"EVENTS",{enumerable:!0,get:function(){return f.EVENTS}}),Object.defineProperty(e,"AUTH_STATE_CHANGED_TYPE",{enumerable:!0,get:function(){return f.AUTH_STATE_CHANGED_TYPE}});var p=function(){function t(t){var e=t.apiOrigin,n=t.apiPath,o=void 0===n?c.AUTH_API_PREFIX:n,i=t.clientId,s=t.env,l=t.storage,d=t.request,h=t.baseRequest,f=t.anonymousSignInFunc,p=t.wxCloud,v=t.adapter,y=t.onCredentialsError,m=t.headers,g=t.i18n,b=t.useWxCloud,_=t.eventBus,w=t.detectSessionInUrl,E=t.debug;if(this.detectSessionInUrl=null!=w&&w,this.oauth2client=new a.OAuth2Client({apiOrigin:e,apiPath:o,clientId:i,env:s,storage:l,baseRequest:h||d,anonymousSignInFunc:f,wxCloud:p,onCredentialsError:y,headers:m||{},i18n:g,useWxCloud:b,eventBus:_,debug:E}),this.authApi=new u.Auth(r(r({credentialsClient:this.oauth2client},t),{request:d?this.oauth2client.request.bind(this.oauth2client):void 0,adapter:v})),w)this.oauth2client.setGetInitialSession(this.authApi.getInitialSession.bind(this.authApi));else try{var I=new URL(window.location.href),S=I.searchParams.get("code"),O=I.searchParams.get("state"),A=JSON.parse(sessionStorage.getItem(O)||"null");S&&O&&(null==A?void 0:A.hash)&&(I.hash=A.hash,window.history.replaceState(null,"",I.toString()),window.location.replace(I.toString()))}catch(t){}}return t.prototype.initializeSession=function(t){this.detectSessionInUrl?(this.oauth2client.setOnInitialSessionObtained(t),this.oauth2client.initialize()):this.oauth2client.initialize(Promise.resolve({error:null}))},t}();e.CloudbaseOAuth=p},6877:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Syntax=e.ErrorType=void 0;var r,o=n(4949);Object.defineProperty(e,"ErrorType",{enumerable:!0,get:function(){return o.ErrorType}}),(r=e.Syntax||(e.Syntax={})).CLIENT_ID="client_id",r.CLIENT_SECRET="client_secret",r.RESPONSE_TYPE="response_type",r.SCOPE="scope",r.STATE="state",r.REDIRECT_URI="redirect_uri",r.ERROR="error",r.ERROR_DESCRIPTION="error_description",r.ERROR_URI="error_uri",r.GRANT_TYPE="grant_type",r.CODE="code",r.ACCESS_TOKEN="access_token",r.TOKEN_TYPE="token_type",r.EXPIRES_IN="expires_in",r.USERNAME="username",r.PASSWORD="password",r.REFRESH_TOKEN="refresh_token"},5257:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},s=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.OAuth2Client=e.defaultStorage=e.generateRequestId=e.toResponseError=e.defaultRequest=void 0;var a=n(6877),u=n(4949),c=n(873),l=n(2631),d=n(8547),h=n(2344),f=n(7425),p=n(2877),v="x-request-id",y="x-device-id",m="device_id";function g(){return(0,c.uuidv4)()}e.defaultRequest=function(t,e){return o(this,void 0,Promise,(function(){var n,r,o,s,u;return i(this,(function(i){switch(i.label){case 0:n=null,r=null,i.label=1;case 1:return i.trys.push([1,4,,5]),(o=Object.assign({},e)).method||(o.method="GET"),o.body&&"string"!=typeof o.body&&(o.body=JSON.stringify(o.body)),[4,fetch(t,o)];case 2:return[4,i.sent().json()];case 3:return(null==(s=i.sent())?void 0:s.error)?(r=s).error_uri=new URL(t).pathname:n=s,[3,5];case 4:return u=i.sent(),r={error:a.ErrorType.UNREACHABLE,error_description:u.message,error_uri:new URL(t).pathname},[3,5];case 5:if(r)throw r;return[2,n]}}))}))},e.toResponseError=function(t,e){var n,r=e||{};if(t instanceof Error)n={error:r.error||a.ErrorType.LOCAL,error_description:r.error_description||t.message,error_uri:r.error_uri,details:r.details||t.stack};else{var o=t||{};n={error:r.error||o.error||a.ErrorType.LOCAL,error_description:r.error_description||o.error_description,error_uri:r.error_uri||o.error_uri,details:r.details||o.details}}return n},e.generateRequestId=g;var b=function(){function t(t){this._env=(null==t?void 0:t.env)||""}return t.prototype.getItem=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,window.localStorage.getItem("".concat(t).concat(this._env))]}))}))},t.prototype.removeItem=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return window.localStorage.removeItem("".concat(t).concat(this._env)),[2]}))}))},t.prototype.setItem=function(t,e){return o(this,void 0,Promise,(function(){return i(this,(function(n){return window.localStorage.setItem("".concat(t).concat(this._env),e),[2]}))}))},t.prototype.getItemSync=function(t){return window.localStorage.getItem("".concat(t).concat(this._env))},t.prototype.removeItemSync=function(t){window.localStorage.removeItem("".concat(t).concat(this._env))},t.prototype.setItemSync=function(t,e){window.localStorage.setItem("".concat(t).concat(this._env),e)},t}();function _(t){var e=!0;return(null==t?void 0:t.expires_at)&&(null==t?void 0:t.access_token)&&(e=t.expires_at<new Date),e}e.defaultStorage=new b;var w=function(){function t(t){this.credentials=null,this.accessKeyCredentials=null,this.singlePromise=null,this.tokenSectionName=t.tokenSectionName,this.storage=t.storage,this.clientId=t.clientId,this.singlePromise=new d.SinglePromise({clientId:this.clientId}),this.credentials=t.credentials||null}return t.prototype.getStorageCredentialsSync=function(){var t=null,e=this.storage.getItemSync(this.tokenSectionName);if(null!=e)try{(null==(t=JSON.parse(e))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at))}catch(e){this.storage.removeItem(this.tokenSectionName),t=null}return t},t.prototype.setCredentials=function(t){return o(this,void 0,Promise,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return(null==t?void 0:t.expires_in)?((null==t?void 0:t.expires_at)||(t.expires_at=new Date(Date.now()+1e3*(t.expires_in-30))),this.storage?(e=JSON.stringify(t),[4,this.storage.setItem(this.tokenSectionName,e)]):[3,2]):[3,3];case 1:n.sent(),n.label=2;case 2:return this.credentials=t,[3,6];case 3:return this.storage?[4,this.storage.removeItem(this.tokenSectionName)]:[3,5];case 4:n.sent(),n.label=5;case 5:this.credentials=null,n.label=6;case 6:return[2]}}))}))},t.prototype.setAccessKeyCredentials=function(t){this.accessKeyCredentials=t,t.scope===u.DEFAULT_NODE_ACCESS_SCOPE&&(this.credentials=t)},t.prototype.getCredentials=function(){return o(this,void 0,Promise,(function(){var t=this;return i(this,(function(e){return[2,this.singlePromise.run("getCredentials",(function(){return o(t,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return _(this.credentials)?[4,this.getStorageCredentials()]:[3,2];case 1:if(t=n.sent(),e=t.credentials,t.isAccessKeyCredentials)return[2,e];this.credentials=e,n.label=2;case 2:return[2,this.credentials]}}))}))}))]}))}))},t.prototype.getStorageCredentials=function(){return o(this,void 0,Promise,(function(){var t=this;return i(this,(function(e){return[2,this.singlePromise.run("_getStorageCredentials",(function(){return o(t,void 0,void 0,(function(){var t,e,n;return i(this,(function(r){switch(r.label){case 0:return t=null,e=!1,[4,this.storage.getItem(this.tokenSectionName)];case 1:if(!(n=r.sent()))return[3,6];r.label=2;case 2:return r.trys.push([2,3,,5]),(null==(t=JSON.parse(n))?void 0:t.expires_at)&&(t.expires_at=new Date(t.expires_at)),[3,5];case 3:return r.sent(),[4,this.storage.removeItem(this.tokenSectionName)];case 4:return r.sent(),t=null,[3,5];case 5:return[3,7];case 6:t=this.accessKeyCredentials||null,e=!0,r.label=7;case 7:return[2,{credentials:t,isAccessKeyCredentials:e}]}}))}))}))]}))}))},t}();e.OAuth2Client=function(){function t(n){var r,o=this;this.initializePromise=null,this.lockAcquired=!1,this.pendingInLock=[],this.singlePromise=null,n.clientSecret||(n.clientSecret=""),!n.clientId&&n.env&&(n.clientId=n.env),this.apiOrigin=n.apiOrigin,this.apiPath=n.apiPath||u.AUTH_API_PREFIX,this.clientId=n.clientId,this.i18n=n.i18n,this.eventBus=n.eventBus,this.singlePromise=new d.SinglePromise({clientId:this.clientId}),this.retry=this.formatRetry(n.retry,t.defaultRetry),n.baseRequest?this.baseRequest=n.baseRequest:this.baseRequest=e.defaultRequest,this.tokenInURL=n.tokenInURL,this.headers=n.headers,this.storage=n.storage||e.defaultStorage,this.localCredentials=new w({tokenSectionName:"credentials_".concat(n.clientId),storage:this.storage,clientId:n.clientId}),this.clientSecret=n.clientSecret,n.clientId&&(this.basicAuth="Basic ".concat((0,h.weBtoa)("".concat(n.clientId,":").concat(this.clientSecret)))),this.wxCloud=n.wxCloud;try{(0,f.isMp)()&&(this.useWxCloud=n.useWxCloud,void 0===this.wxCloud&&n.env&&(wx.cloud.init({env:n.env}),this.wxCloud=wx.cloud))}catch(t){}this.refreshTokenFunc=n.refreshTokenFunc||this.defaultRefreshTokenFunc,this.anonymousSignInFunc=n.anonymousSignInFunc,this.onCredentialsError=n.onCredentialsError,this.getInitialSession=n.getInitialSession,this.onInitialSessionObtained=n.onInitialSessionObtained,this.logDebugMessages=null!==(r=n.debug)&&void 0!==r&&r,p.langEvent.bus.on(p.langEvent.LANG_CHANGE_EVENT,(function(t){var e;o.i18n=(null===(e=t.data)||void 0===e?void 0:e.i18n)||o.i18n}))}return t.prototype.setGetInitialSession=function(t){this.getInitialSession=t},t.prototype.setOnInitialSessionObtained=function(t){this.onInitialSessionObtained=t},t.prototype.initialize=function(t){return o(this,void 0,Promise,(function(){var e=this;return i(this,(function(n){switch(n.label){case 0:return this.initializePromise?[4,this.initializePromise]:[3,2];case 1:case 3:case 5:return[2,n.sent()];case 2:return void 0===t?[3,4]:(this.initializePromise=t,[4,this.initializePromise]);case 4:return this.initializePromise=o(e,void 0,void 0,(function(){var t=this;return i(this,(function(e){switch(e.label){case 0:return[4,this._acquireLock(-1,(function(){return o(t,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._initialize()];case 1:return[2,t.sent()]}}))}))}))];case 1:return[2,e.sent()]}}))})),[4,this.initializePromise]}}))}))},t.prototype.setCredentials=function(t){return o(this,void 0,Promise,(function(){var e=this;return i(this,(function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[2,this._acquireLock(-1,(function(){return o(e,void 0,void 0,(function(){return i(this,(function(e){return[2,this.localCredentials.setCredentials(t)]}))}))}))]}}))}))},t.prototype.setAccessKeyCredentials=function(t){return this.localCredentials.setAccessKeyCredentials(t)},t.prototype.getAccessToken=function(){return o(this,void 0,Promise,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,this.initializePromise];case 1:return n.sent(),[4,this.getCredentials()];case 2:return(null==(t=n.sent())?void 0:t.scope)===u.DEFAULT_NODE_ACCESS_SCOPE||(null==t?void 0:t.access_token)?[2,Promise.resolve(t.access_token)]:(e={error:a.ErrorType.UNAUTHENTICATED},[2,Promise.reject(e)])}}))}))},t.prototype.request=function(e,n){var s,u;return o(this,void 0,Promise,(function(){var o,c,l,d,h,f,p,m,b;return i(this,(function(i){switch(i.label){case 0:return n||(n={}),o=this.formatRetry(n.retry,this.retry),n.headers=r(r({},n.headers),((b={})[null===(s=this.i18n)||void 0===s?void 0:s.LANG_HEADER_KEY]=null===(u=this.i18n)||void 0===u?void 0:u.lang,b)),this.headers&&(n.headers=r(r({},this.headers),n.headers)),n.headers[v]||(n.headers[v]=g()),n.headers[y]?[3,2]:[4,this.getDeviceId()];case 1:c=i.sent(),n.headers[y]=c,i.label=2;case 2:return(null==n?void 0:n.withBasicAuth)&&this.basicAuth&&(n.headers.Authorization=this.basicAuth),(null==n?void 0:n.withCredentials)?n.getCredentials?[4,n.getCredentials()]:[3,4]:[3,7];case 3:return d=i.sent(),[3,6];case 4:return[4,this.getCredentials()];case 5:d=i.sent(),i.label=6;case 6:return(l=d)&&(this.tokenInURL?(e.indexOf("?")<0&&(e+="?"),e+="access_token=".concat(l.access_token)):n.headers.Authorization="".concat(l.token_type," ").concat(l.access_token)),[3,8];case 7:this.clientId&&e.indexOf("client_id")<0&&(e+=e.indexOf("?")<0?"?":"&",e+="client_id=".concat(this.clientId)),i.label=8;case 8:e.startsWith("/")&&(e="".concat(this.apiOrigin).concat(this.apiPath).concat(e)),h=null,f=o+1,p=0,i.label=9;case 9:if(!(p<f))return[3,21];i.label=10;case 10:return i.trys.push([10,15,,18]),n.useWxCloud||this.useWxCloud?[4,this.wxCloudCallFunction(e,n)]:[3,12];case 11:return h=i.sent(),[3,14];case 12:return[4,this.baseRequest(e,n)];case 13:h=i.sent(),i.label=14;case 14:if(null==h?void 0:h.code)throw{error:h.code,error_description:h.message,error_uri:new URL(e).pathname};return[3,21];case 15:m=i.sent();try{m.requestId=m.requestId||n.headers[v]||""}catch(t){}return n.withCredentials&&m&&m.error===a.ErrorType.UNAUTHENTICATED?[4,this.setCredentials(null)]:[3,17];case 16:return i.sent(),[2,Promise.reject(m)];case 17:return p!==o&&m&&"unreachable"===m.error?[3,18]:[2,Promise.reject(m)];case 18:return[4,this.sleep(t.retryInterval)];case 19:i.sent(),i.label=20;case 20:return p++,[3,9];case 21:return[2,h]}}))}))},t.prototype.wxCloudCallFunction=function(t,e){var n;return o(this,void 0,Promise,(function(){var o,s,u,c,d;return i(this,(function(i){switch(i.label){case 0:o=null,s=null,i.label=1;case 1:i.trys.push([1,7,,8]),u="",i.label=2;case 2:return i.trys.push([2,4,,5]),[4,wx.getRendererUserAgent()];case 3:return u=i.sent(),[3,5];case 4:return i.sent(),[3,5];case 5:return[4,this.wxCloud.callFunction({name:"httpOverCallFunction",data:{url:t,method:e.method,headers:r({origin:"https://servicewechat.com","User-Agent":u},e.headers),body:e.body}})];case 6:return c=i.sent().result,(null===(n=null==c?void 0:c.body)||void 0===n?void 0:n.error_code)?(s=null==c?void 0:c.body).error_uri=(0,l.getPathName)(t):o=null==c?void 0:c.body,[3,8];case 7:return d=i.sent(),s={error:a.ErrorType.UNREACHABLE,error_description:d.message,error_uri:(0,l.getPathName)(t)},[3,8];case 8:if(s)throw s;return[2,o]}}))}))},t.prototype.getCredentials=function(){return o(this,void 0,Promise,(function(){var t=this;return i(this,(function(e){switch(e.label){case 0:return[4,this.initializePromise];case 1:return e.sent(),[2,this._acquireLock(-1,(function(){return o(t,void 0,void 0,(function(){return i(this,(function(t){return[2,this._getCredentials()]}))}))}))]}}))}))},t.prototype.getCredentialsSync=function(){return this.localCredentials.getStorageCredentialsSync()},t.prototype.getCredentialsAsync=function(){return this.getCredentials()},t.prototype.getScope=function(){var t;return o(this,void 0,Promise,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(e=r.sent())?[2,e.scope]:(n="credentials not found",null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:n}),[2,this.unAuthenticatedError(n)])}}))}))},t.prototype.getGroups=function(){var t;return o(this,void 0,Promise,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:return(e=r.sent())?[2,e.groups]:(n="credentials not found",null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:n}),[2,this.unAuthenticatedError(n)])}}))}))},t.prototype.refreshToken=function(t,e){return o(this,void 0,Promise,(function(){var n=this;return i(this,(function(r){switch(r.label){case 0:return[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(-1,(function(){return o(n,void 0,void 0,(function(){return i(this,(function(n){return[2,this._refreshToken(t,e)]}))}))}))]}}))}))},t.prototype._refreshToken=function(t,e){return o(this,void 0,Promise,(function(){var n=this;return i(this,(function(r){return[2,this.singlePromise.run("_refreshToken",(function(){return o(n,void 0,void 0,(function(){var n,r,o,s,c,l,d;return i(this,(function(i){switch(i.label){case 0:if((null==t?void 0:t.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,t];if(!t||!t.refresh_token)return o="no refresh token found in credentials",null===(s=this.onCredentialsError)||void 0===s||s.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];i.label=1;case 1:return i.trys.push([1,4,,7]),[4,this.refreshTokenFunc(t.refresh_token,t)];case 2:return n=i.sent(),[4,this.localCredentials.setCredentials(n)];case 3:return i.sent(),null===(c=this.eventBus)||void 0===c||c.fire(u.EVENTS.AUTH_STATE_CHANGED,{event:u.AUTH_STATE_CHANGED_TYPE.TOKEN_REFRESHED}),[2,n];case 4:if(r=i.sent(),null==e?void 0:e.throwError)throw r;return r.error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return i.sent(),o=r.error_description,null===(l=this.onCredentialsError)||void 0===l||l.call(this,{msg:o}),[2,this.unAuthenticatedError(o)];case 6:return null===(d=this.onCredentialsError)||void 0===d||d.call(this,{msg:r.error_description}),[2,Promise.reject(r)];case 7:return[2]}}))}))}))]}))}))},t.prototype.anonymousLogin=function(t){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(n){return[2,this.singlePromise.run("_anonymousLogin",(function(){return o(e,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return this.anonymousSignInFunc?[4,this.anonymousSignInFunc(t)]:[3,4];case 1:return e=r.sent(),(n=e)?[3,3]:[4,this.localCredentials.getCredentials()];case 2:n=r.sent(),r.label=3;case 3:return t=n,[3,6];case 4:return[4,this.anonymousSignIn(t)];case 5:t=r.sent(),r.label=6;case 6:return[2,t]}}))}))}))]}))}))},t.prototype.checkRetry=function(e){var n=null;if(("number"!=typeof e||e<t.minRetry||e>t.maxRetry)&&(n={error:a.ErrorType.UNREACHABLE,error_description:"wrong options param: retry"}),n)throw n;return e},t.prototype.formatRetry=function(t,e){return void 0===t?e:this.checkRetry(t)},t.prototype.sleep=function(t){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,new Promise((function(e){setTimeout((function(){e()}),t)}))]}))}))},t.prototype.anonymousSignIn=function(t){return o(this,void 0,Promise,(function(){var e=this;return i(this,(function(n){return[2,this.singlePromise.run("_anonymous",(function(){return o(e,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:if(!t||"anonymous"!==t.scope)return[2,this.unAuthenticatedError("no anonymous in credentials")];r.label=1;case 1:return r.trys.push([1,4,,7]),[4,this.request(u.ApiUrls.AUTH_SIGN_IN_ANONYMOUSLY_URL,{method:"POST",withBasicAuth:!0,body:{}})];case 2:return e=r.sent(),[4,this.localCredentials.setCredentials(e)];case 3:return r.sent(),[2,e];case 4:return(n=r.sent()).error!==a.ErrorType.INVALID_GRANT?[3,6]:[4,this.localCredentials.setCredentials(null)];case 5:return r.sent(),[2,this.unAuthenticatedError(n.error_description)];case 6:return[2,Promise.reject(n)];case 7:return[2]}}))}))}))]}))}))},t.prototype.defaultRefreshTokenFunc=function(t,e){var n;return o(this,void 0,Promise,(function(){var o,s,a;return i(this,(function(i){switch(i.label){case 0:return void 0===t||""===t?(o="refresh token not found",null===(n=this.onCredentialsError)||void 0===n||n.call(this,{msg:o}),[2,this.unAuthenticatedError(o)]):(s=u.ApiUrls.AUTH_TOKEN_URL,"v2"===(null==e?void 0:e.version)&&(s=u.ApiUrlsV2.AUTH_TOKEN_URL),[4,this.request(s,{method:"POST",body:{client_id:this.clientId,client_secret:this.clientSecret,grant_type:"refresh_token",refresh_token:t}})]);case 1:return a=i.sent(),[2,r(r({},a),{version:(null==e?void 0:e.version)||"v1"})]}}))}))},t.prototype.getDeviceId=function(){return o(this,void 0,Promise,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return this.deviceID?[2,this.deviceID]:[4,this.storage.getItem(m)];case 1:return"string"==typeof(t=e.sent())&&t.length>=16&&t.length<=48?[3,3]:(t=(0,c.uuidv4)(),[4,this.storage.setItem(m,t)]);case 2:e.sent(),e.label=3;case 3:return this.deviceID=t,[2,t]}}))}))},t.prototype.unAuthenticatedError=function(t){var e={error:a.ErrorType.UNAUTHENTICATED,error_description:t};return Promise.reject(e)},t.prototype._debug=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.logDebugMessages&&console.log.apply(console,s(["[OAuth2Client]"],t,!1))},t.prototype._initialize=function(){return o(this,void 0,Promise,(function(){var t,e,n,r,o,s;return i(this,(function(i){switch(i.label){case 0:if(i.trys.push([0,11,12,13]),!this.getInitialSession)return this._debug("#_initialize()","no getInitialSession callback set, skipping"),[2,{error:null}];this._debug("#_initialize()","calling getInitialSession callback"),i.label=1;case 1:return i.trys.push([1,9,,10]),[4,this.getInitialSession()];case 2:return s=i.sent(),t=s.data,e=s.error,(null==t?void 0:t.session)?(this._debug("#_initialize()","session obtained from getInitialSession",t.session),[4,this.localCredentials.setCredentials(null==t?void 0:t.session)]):[3,4];case 3:i.sent(),i.label=4;case 4:if(!this.onInitialSessionObtained)return[3,8];this._debug("#_initialize()","calling onInitialSessionObtained callback"),i.label=5;case 5:return i.trys.push([5,7,,8]),[4,this.onInitialSessionObtained(t,e)];case 6:return i.sent(),[3,8];case 7:return n=i.sent(),this._debug("#_initialize()","error in onInitialSessionObtained",n),[3,8];case 8:return e?(this._debug("#_initialize()","error from getInitialSession",e),[2,{error:e}]):[2,{error:null}];case 9:return r=i.sent(),this._debug("#_initialize()","exception during getInitialSession",r),[2,{error:r instanceof Error?r:new Error(String(r))}];case 10:return[3,13];case 11:return o=i.sent(),this._debug("#_initialize()","unexpected error",o),[2,{error:o instanceof Error?o:new Error(String(o))}];case 12:return this._debug("#_initialize()","end"),[7];case 13:return[2]}}))}))},t.prototype._acquireLock=function(t,e){return o(this,void 0,Promise,(function(){var n,r,a,u,c=this;return i(this,(function(l){switch(l.label){case 0:this._debug("#_acquireLock","begin",t),l.label=1;case 1:if(l.trys.push([1,,10,11]),this.lockAcquired)return n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),r=o(c,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,n];case 1:return t.sent(),[4,e()];case 2:return[2,t.sent()]}}))})),this.pendingInLock.push(o(c,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,r];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))),[2,r];this._debug("#_acquireLock","acquiring lock for client",this.clientId),l.label=2;case 2:return l.trys.push([2,,8,9]),this.lockAcquired=!0,a=e(),this.pendingInLock.push(o(c,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,a];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}}))}))),[4,a];case 3:l.sent(),l.label=4;case 4:return this.pendingInLock.length?(u=s([],this.pendingInLock,!0),[4,Promise.all(u)]):[3,6];case 5:return l.sent(),this.pendingInLock.splice(0,u.length),[3,4];case 6:return[4,a];case 7:return[2,l.sent()];case 8:return this._debug("#_acquireLock","releasing lock for client",this.clientId),this.lockAcquired=!1,[7];case 9:return[3,11];case 10:return this._debug("#_acquireLock","end"),[7];case 11:return[2]}}))}))},t.prototype._getCredentials=function(){var t,e,n;return o(this,void 0,Promise,(function(){var r,o,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.localCredentials.getCredentials()];case 1:if((null==(r=i.sent())?void 0:r.scope)===u.DEFAULT_NODE_ACCESS_SCOPE)return[2,r];if(!r)return s="credentials not found",null===(t=this.onCredentialsError)||void 0===t||t.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];if(!_(r))return[3,12];if(!r.refresh_token)return[3,9];i.label=2;case 2:return i.trys.push([2,4,,8]),[4,this._refreshToken(r)];case 3:return r=i.sent(),[3,8];case 4:return o=i.sent(),"anonymous"!==r.scope?[3,6]:[4,this.anonymousLogin(r)];case 5:return r=i.sent(),[3,7];case 6:return null===(e=this.onCredentialsError)||void 0===e||e.call(this,{msg:o.error_description}),[2,Promise.reject(o)];case 7:return[3,8];case 8:return[3,12];case 9:return"anonymous"!==r.scope?[3,11]:[4,this.anonymousLogin(r)];case 10:return r=i.sent(),[3,12];case 11:return s="no refresh token found in credentials",null===(n=this.onCredentialsError)||void 0===n||n.call(this,{msg:s}),[2,this.unAuthenticatedError(s)];case 12:return[2,r]}}))}))},t.defaultRetry=2,t.minRetry=0,t.maxRetry=5,t.retryInterval=1e3,t}()},2344:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.weAppJwtDecodeAll=e.weappJwtDecode=e.base64_url_decode=e.weAtob=e.weBtoa=void 0;var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function o(t){var n=t.replace(/-/g,"+").replace(/_/g,"/");switch(n.length%4){case 0:break;case 2:n+="==";break;case 3:n+="=";break;default:throw new Error("Illegal base64url string!")}try{return function(t){return decodeURIComponent((0,e.weAtob)(t).replace(/(.)/g,(function(t){var e=t.charCodeAt(0).toString(16).toUpperCase();return e.length<2&&(e="0".concat(e)),"%".concat(e)})))}(n)}catch(t){return(0,e.weAtob)(n)}}e.weBtoa=function(t){for(var e,r,o,i,s="",a=0,u=(t=String(t)).length%3;a<t.length;){if((r=t.charCodeAt(a++))>255||(o=t.charCodeAt(a++))>255||(i=t.charCodeAt(a++))>255)throw new TypeError("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.");s+=n.charAt((e=r<<16|o<<8|i)>>18&63)+n.charAt(e>>12&63)+n.charAt(e>>6&63)+n.charAt(63&e)}return u?s.slice(0,u-3)+"===".substring(u):s},e.weAtob=function(t){if(t=String(t).replace(/[\t\n\f\r ]+/g,""),!r.test(t))throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var e;t+="==".slice(2-(3&t.length));for(var o,i,s="",a=0;a<t.length;)e=n.indexOf(t.charAt(a++))<<18|n.indexOf(t.charAt(a++))<<12|(o=n.indexOf(t.charAt(a++)))<<6|(i=n.indexOf(t.charAt(a++))),s+=64===o?String.fromCharCode(e>>16&255):64===i?String.fromCharCode(e>>16&255,e>>8&255):String.fromCharCode(e>>16&255,e>>8&255,255&e);return s},e.base64_url_decode=o,e.weappJwtDecode=function(t,e){if("string"!=typeof t)throw new Error("Invalid token specified");var n=!0===(e=e||{}).header?0:1;try{return JSON.parse(o(t.split(".")[n]))}catch(t){throw new Error("Invalid token specified: ".concat(t)?t.message:0)}},e.weAppJwtDecodeAll=function(t){if("string"!=typeof t)throw new Error("Invalid token specified");try{var e=t.split(".").map((function(t,e){return 2===e?t:JSON.parse(o(t))}));return{claims:e[1],header:e[0],signature:e[2]}}catch(t){throw new Error("Invalid token specified: ".concat(t)?t.message:0)}}},5814:function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.getEncryptInfo=void 0;var o=r(n(1012)),i=n(2631);e.getEncryptInfo=function(t){var e=void 0===t?{}:t,n=e.publicKey,r=void 0===n?"":n,s=e.payload,a=void 0===s?{}:s;if(!r)return"";try{var u=(0,i.deepClone)(a),c=new o.default;return c.setPublicKey(r),c.encryptLong("object"==typeof u?JSON.stringify(u):u)}catch(t){console.error("encrypt error:",t)}return""}},8547:function(t,e){"use strict";var n=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.SinglePromise=void 0;var o=new Map,i=function(){function t(t){this.clientId=(null==t?void 0:t.clientId)||"",o=o||new Map}return t.prototype.run=function(t,e){return n(this,void 0,Promise,(function(){var i,s=this;return r(this,(function(a){return t="".concat(this.clientId,"_").concat(t),(i=o.get(t))||(i=new Promise((function(i,a){n(s,void 0,void 0,(function(){var n,s,u;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,4,5]),[4,this.runIdlePromise()];case 1:return r.sent(),n=e(),s=i,[4,n];case 2:return s.apply(void 0,[r.sent()]),[3,5];case 3:return u=r.sent(),a(u),[3,5];case 4:return o.delete(t),[7];case 5:return[2]}}))}))})),o.set(t,i)),[2,i]}))}))},t.prototype.runIdlePromise=function(){return Promise.resolve()},t}();e.SinglePromise=i},2631:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getPathName=e.deepClone=void 0,e.deepClone=function(t){var n=function(n){for(var r in t)t.hasOwnProperty(r)&&(n[r]=(0,e.deepClone)(t[r]));return n},r=null==t?"NullOrUndefined":Object.prototype.toString.call(t).slice(8,-1);if(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(r))return t.slice();switch(r){case"Object":return n(Object.create(Object.getPrototypeOf(t)));case"Array":return n([]);case"Date":return new Date(t.valueOf());case"RegExp":return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""));default:return t}},e.getPathName=function(t){var e=t.match(/^(?:http(s)?:\/\/[^\/]+)?(\/[^\?#]*)/);return e&&e[2]||""}},7425:function(t,e){"use strict";function n(){if("undefined"==typeof globalThis)return!1;var t=globalThis.wx;if(void 0===t)return!1;if(void 0===globalThis.Page)return!1;if(!t.getDeviceInfo)return!1;if(!t.getStorageSync)return!1;if(!t.setStorageSync)return!1;if(!t.connectSocket)return!1;if(!t.request)return!1;try{if(!t.getDeviceInfo())return!1;if("qq"===t.getDeviceInfo().platform)return!1}catch(t){return!1}return!0}Object.defineProperty(e,"__esModule",{value:!0}),e.isInMpWebView=e.isMp=void 0,e.isMp=n;var r=!1;function o(){r=r||void 0!==typeof window&&"miniprogram"===window.__wxjs_environment}try{n()||(r=r||!!navigator.userAgent.match(/miniprogram/i)||"miniprogram"===window.__wxjs_environment,window&&window.WeixinJSBridge&&window.WeixinJSBridge.invoke?o():"undefined"!=typeof document&&document.addEventListener("WeixinJSBridgeReady",o,!1))}catch(t){}e.isInMpWebView=function(){return r}},9639:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){if(this.params={},"string"==typeof t)this.parse(t);else if(t&&"object"==typeof t)for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&this.append(e,t[e])}return t.prototype.parse=function(t){var e=this;t.split("&").forEach((function(t){var n=t.split("=").map(decodeURIComponent),r=n[0],o=n[1];e.append(r,o)}))},t.prototype.append=function(t,e){this.params[t]?this.params[t]=this.params[t].concat([e]):this.params[t]=[e]},t.prototype.get=function(t){return this.params[t]?this.params[t][0]:null},t.prototype.getAll=function(t){return this.params[t]||[]},t.prototype.delete=function(t){delete this.params[t]},t.prototype.has=function(t){return Object.prototype.hasOwnProperty.call(this.params,t)},t.prototype.set=function(t,e){this.params[t]=[e]},t.prototype.toString=function(){var t=[],e=function(e){Object.prototype.hasOwnProperty.call(n.params,e)&&n.params[e].forEach((function(n){t.push("".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(n)))}))},n=this;for(var r in this.params)e(r);return t.join("&")},t}();e.default=n},873:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uuidv4=void 0,e.uuidv4=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}))}},6511:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setRuntime=e.getRuntime=e.setWsClass=e.getWsClass=void 0;var n=null,r="web";e.getWsClass=function(){return n},e.setWsClass=function(t){n=t},e.getRuntime=function(){return r},e.setRuntime=function(t){r=t}},2917:function(t,e){"use strict";var n,r=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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.ERR_CODE=e.CloudSDKError=e.isCancelledError=e.CancelledError=e.isTimeoutError=e.TimeoutError=e.isRealtimeErrorMessageError=e.RealtimeErrorMessageError=void 0;var o=function(t){function e(e){var n=t.call(this,"Watch Error ".concat(JSON.stringify(e.msgData)," (requestid: ").concat(e.requestId,")"))||this;return n.isRealtimeErrorMessageError=!0,n.payload=e,n}return r(e,t),e}(Error);e.RealtimeErrorMessageError=o,e.isRealtimeErrorMessageError=function(t){return null==t?void 0:t.isRealtimeErrorMessageError};var i=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="timeout",e.payload=null,e.generic=!0,e}return r(e,t),e}(Error);e.TimeoutError=i,e.isTimeoutError=function(t){return"timeout"===t.type};var s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="cancelled",e.payload=null,e.generic=!0,e}return r(e,t),e}(Error);e.CancelledError=s,e.isCancelledError=function(t){return"cancelled"===t.type};var a=function(t){function n(n){var r=t.call(this,n.errMsg)||this;return r.errCode="UNKNOWN_ERROR",Object.defineProperties(r,{message:{get:function(){return"errCode: ".concat(this.errCode," ").concat(e.ERR_CODE[this.errCode]||""," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t}}}),r.errCode=n.errCode||"UNKNOWN_ERROR",r.errMsg=n.errMsg,r}return r(n,t),Object.defineProperty(n.prototype,"message",{get:function(){return"errCode: ".concat(this.errCode," | errMsg: ").concat(this.errMsg)},set:function(t){this.errMsg=t},enumerable:!1,configurable:!0}),n}(Error);e.CloudSDKError=a,e.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:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.registerRealtime=void 0;var r=n(2347),o=n(6511),i={target:"database",entity:function(){var t=this.platform,e=t.adapter,n=t.runtime;(0,o.setWsClass)(e.wsClass),(0,o.setRuntime)(n)}},s={name:"realtime",IIFE:!0,entity:function(){this.prototype.wsClientClass=r.RealtimeWebSocketClient}};try{cloudbase.registerComponent(s),cloudbase.registerHook(i)}catch(t){}e.registerRealtime=function(t){try{t.registerComponent(s),t.registerHook(i)}catch(t){console.warn(t)}}},1601:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RealtimeListener=void 0;e.RealtimeListener=function(t){this.close=t.close,this.onChange=t.onChange,this.onError=t.onError,t.debug&&Object.defineProperty(this,"virtualClient",{get:function(){return t.virtualClient}})}},3994:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isInitEventMessage=e.genRequestId=void 0,e.genRequestId=function(t){return void 0===t&&(t=""),"".concat(t?"".concat(t,"_"):"").concat(+new Date,"_").concat(Math.random())},e.isInitEventMessage=function(t){return"INIT_EVENT"===t.msgType}},9770:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Snapshot=void 0;e.Snapshot=function(t){var e,n,r=t.id,o=t.docChanges,i=t.docs,s=t.msgType,a=t.type;Object.defineProperties(this,{id:{get:function(){return r},enumerable:!0},docChanges:{get:function(){return e||(e=JSON.parse(JSON.stringify(o))),e},enumerable:!0},docs:{get:function(){return n||(n=JSON.parse(JSON.stringify(i))),n},enumerable:!0},msgType:{get:function(){return s},enumerable:!0},type:{get:function(){return a},enumerable:!0}})}},7589:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sleep=void 0,e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))}},4151:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},i=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.VirtualWebSocketClient=void 0;var a,u=s(n(6765)),c=s(n(7195)),l=s(n(9850)),d=n(3994),h=n(1601),f=n(9770),p=n(2917),v=n(7589);!function(t){t.LOGGINGIN="LOGGINGIN",t.INITING="INITING",t.REBUILDING="REBUILDING",t.ACTIVE="ACTIVE",t.ERRORED="ERRORED",t.CLOSING="CLOSING",t.CLOSED="CLOSED",t.PAUSED="PAUSED",t.RESUMING="RESUMING"}(a||(a={}));var y=function(){function t(t){var e=this;this.watchStatus=a.INITING,this.wsLogin=function(t,n){return r(e,void 0,Promise,(function(){var e;return o(this,(function(r){switch(r.label){case 0:return this.watchStatus=a.LOGGINGIN,[4,this.login(t,n)];case 1:return e=r.sent(),this.envId||(this.envId=e.envId),[2,e]}}))}))},this.initWatch=function(t){return r(e,void 0,Promise,(function(){var e,n=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(e,i){r(n,void 0,void 0,(function(){var n,r,s,u,c,l,h,p,v,y;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,e()]):[4,this.wsLogin(this.envId,t)];case 1:return n=o.sent().envId,this.watchStatus===a.PAUSED?(console.log("[realtime] initWatch cancelled on pause"),[2,e()]):(this.watchStatus=a.INITING,r={watchId:this.watchId,requestId:(0,d.genRequestId)(),msgType:"INIT_WATCH",msgData:{envId:n,collName:this.collectionName,query:this.query,limit:this.limit,orderBy:this.orderBy}},[4,this.send({msg:r,waitResponse:!0,skipOnMessage:!0,timeout:1e4})]);case 2:if(s=o.sent(),u=s.msgData,c=u.events,l=u.currEvent,this.sessionInfo={queryID:s.msgData.queryID,currentEventId:l-1,currentDocs:[]},c.length>0){for(h=0,p=c;h<p.length;h++)p[h].ID=l;this.handleServerEvents(s)}else this.sessionInfo.currentEventId=l,v=new f.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,e(),[3,4];case 3:return y=o.sent(),this.handleWatchEstablishmentError(y,{operationName:"INIT_WATCH",resolve:e,reject:i}),[3,4];case 4:return[2]}}))}))})),e=!1,i.label=1;case 1:return i.trys.push([1,,3,4]),[4,this.initWatchPromise];case 2:return i.sent(),e=!0,[3,4];case 3:return this.initWatchPromise=void 0,[7];case 4:return console.log("[realtime] initWatch ".concat(e?"success":"fail")),[2]}}))}))},this.rebuildWatch=function(t){return r(e,void 0,Promise,(function(){var e,n=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(e,i){r(n,void 0,void 0,(function(){var n,r,s,u;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,e()]):[4,this.wsLogin(this.envId,t)];case 1:if(n=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,e()]):(this.watchStatus=a.REBUILDING,r={watchId:this.watchId,requestId:(0,d.genRequestId)(),msgType:"REBUILD_WATCH",msgData:{envId:n,collName:this.collectionName,queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:r,waitResponse:!0,skipOnMessage:!1,timeout:1e4})]);case 2:return s=o.sent(),this.handleServerEvents(s),this.watchStatus=a.ACTIVE,this.availableRetries.REBUILD_WATCH=2,e(),[3,4];case 3:return u=o.sent(),this.handleWatchEstablishmentError(u,{operationName:"REBUILD_WATCH",resolve:e,reject:i}),[3,4];case 4:return[2]}}))}))})),e=!1,i.label=1;case 1:return i.trys.push([1,,3,4]),[4,this.rebuildWatchPromise];case 2:return i.sent(),e=!0,[3,4];case 3:return this.rebuildWatchPromise=void 0,[7];case 4:return console.log("[realtime] rebuildWatch ".concat(e?"success":"fail")),[2]}}))}))},this.handleWatchEstablishmentError=function(t,n){return r(e,void 0,void 0,(function(){var e,i,s,u=this;return o(this,(function(c){return e="INIT_WATCH"===n.operationName,i=function(){u.closeWithError(new p.CloudSDKError({errCode:e?p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_INIT_WATCH_FAIL:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_REBUILD_WATCH_FAIL,errMsg:t})),n.reject(t)},s=function(t){u.useRetryTicket(n.operationName)?e?(u.initWatchPromise=void 0,n.resolve(u.initWatch(t))):(u.rebuildWatchPromise=void 0,n.resolve(u.rebuildWatch(t))):i()},this.handleCommonError(t,{onSignError:function(){return s(!0)},onTimeoutError:function(){return s(!1)},onNotRetryableError:i,onCancelledError:n.reject,onUnknownError:function(){r(u,void 0,void 0,(function(){var t,e=this;return o(this,(function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),t=function(){return r(e,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this.pause(),[4,this.onceWSConnected()];case 1:return t.sent(),s(!0),[2]}}))}))},this.isWSConnected()?[3,2]:[4,t()];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]:(n.reject(new p.CancelledError("".concat(n.operationName," cancelled due to pause after unknownError"))),[3,7]);case 4:return this.isWSConnected()?[3,6]:[4,t()];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 r(e,void 0,void 0,(function(){var t,e,n;return o(this,(function(r){switch(r.label){case 0:if(t=this.sessionInfo?this.sessionInfo.queryID:"",this.watchStatus!==a.ACTIVE)return this.watchStatus=a.CLOSED,this.onWatchClose(this,t),[2];r.label=1;case 1:return r.trys.push([1,3,4,5]),this.watchStatus=a.CLOSING,e={watchId:this.watchId,requestId:(0,d.genRequestId)(),msgType:"CLOSE_WATCH",msgData:null},[4,this.send({msg:e})];case 2:return r.sent(),this.sessionInfo=void 0,this.watchStatus=a.CLOSED,[3,5];case 3:return n=r.sent(),this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CLOSE_WATCH_FAIL,errMsg:n})),[3,5];case 4:return this.onWatchClose(this,t),[7];case 5:return[2]}}))}))},this.scheduleSendACK=function(){e.clearACKSchedule(),e.ackTimeoutId=setTimeout((function(){e.waitExpectedTimeoutId?e.scheduleSendACK():e.sendACK()}),1e4)},this.clearACKSchedule=function(){e.ackTimeoutId&&clearTimeout(e.ackTimeoutId)},this.sendACK=function(){return r(e,void 0,Promise,(function(){var t,e,n;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this.watchStatus!==a.ACTIVE?(this.scheduleSendACK(),[2]):this.sessionInfo?(t={watchId:this.watchId,requestId:(0,d.genRequestId)(),msgType:"CHECK_LAST",msgData:{queryID:this.sessionInfo.queryID,eventID:this.sessionInfo.currentEventId}},[4,this.send({msg:t})]):(console.warn("[realtime listener] can not send ack without a successful initWatch (lack of sessionInfo)"),[2]);case 1:return r.sent(),this.scheduleSendACK(),[3,3];case 2:if(e=r.sent(),(0,p.isRealtimeErrorMessageError)(e))switch((n=e.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 p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:n.msgData.code})),[2]}return this.availableRetries.CHECK_LAST&&this.availableRetries.CHECK_LAST>0?(this.availableRetries.CHECK_LAST-=1,this.scheduleSendACK()):this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_CHECK_LAST_FAIL,errMsg:e})),[3,3];case 3:return[2]}}))}))},this.handleCommonError=function(t,e){if((0,p.isRealtimeErrorMessageError)(t))switch(t.payload.msgData.code){case"CHECK_LOGIN_FAILED":case"SIGN_EXPIRED_ERROR":case"SIGN_INVALID_ERROR":case"SIGN_PARAM_INVALID":return void e.onSignError(t);default:return void e.onNotRetryableError(t)}else{if((0,p.isTimeoutError)(t))return void e.onTimeoutError(t);if((0,p.isCancelledError)(t))return void e.onCancelledError(t)}e.onUnknownError(t)},this.watchId="watchid_".concat(+new Date,"_").concat(Math.random()),this.envId=t.envId,this.collectionName=t.collectionName,this.query=t.query,this.limit=t.limit,this.orderBy=t.orderBy,this.send=t.send,this.login=t.login,this.isWSConnected=t.isWSConnected,this.onceWSConnected=t.onceWSConnected,this.getWaitExpectedTimeoutLength=t.getWaitExpectedTimeoutLength,this.onWatchStart=t.onWatchStart,this.onWatchClose=t.onWatchClose,this.debug=t.debug,this.availableRetries={INIT_WATCH:2,REBUILD_WATCH:2,CHECK_LAST:2},this.listener=new h.RealtimeListener({close:function(){e.closeWatch()},onChange:t.onChange,onError:t.onError,debug:this.debug,virtualClient:this}),this.initWatch()}return t.prototype.onMessage=function(t){var e=this;switch(this.watchStatus){case a.PAUSED:if("ERROR"!==t.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(),t.msgType){case"NEXT_EVENT":console.warn("nextevent ".concat(t.msgData.currEvent," ignored"),t),this.handleServerEvents(t);break;case"CHECK_EVENT":this.sessionInfo.currentEventId<t.msgData.currEvent&&(this.sessionInfo.expectEventId=t.msgData.currEvent,this.clearWaitExpectedEvent(),this.waitExpectedTimeoutId=setTimeout((function(){e.rebuildWatch()}),this.getWaitExpectedTimeoutLength()),console.log("[realtime] waitExpectedTimeoutLength ".concat(this.getWaitExpectedTimeoutLength())));break;case"ERROR":this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_SERVER_ERROR_MSG,errMsg:"".concat(t.msgData.code," - ").concat(t.msgData.message)}));break;default:console.warn("[realtime listener] virtual client receive unexpected msg ".concat(t.msgType,": "),t)}else console.warn("[realtime listener] internal non-fatal error: sessionInfo not found while message is received.")},t.prototype.closeWithError=function(t){var e;this.watchStatus=a.ERRORED,this.clearACKSchedule(),this.listener.onError(t),this.onWatchClose(this,(null===(e=this.sessionInfo)||void 0===e?void 0:e.queryID)||""),console.log("[realtime] client closed (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.pause=function(){this.watchStatus=a.PAUSED,console.log("[realtime] client paused (".concat(this.collectionName," ").concat(this.query,") (watchId ").concat(this.watchId,")"))},t.prototype.resume=function(){return r(this,void 0,Promise,(function(){var t;return o(this,(function(e){switch(e.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,")")),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.sessionInfo?this.rebuildWatch():this.initWatch()];case 2:return e.sent(),console.log("[realtime] client successfully resumed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")")),[3,4];case 3:return t=e.sent(),console.error("[realtime] client resume failed (".concat(this.collectionName," ").concat(this.query,") (").concat(this.watchId,")"),t),[3,4];case 4:return[2]}}))}))},t.prototype.useRetryTicket=function(t){return!!(this.availableRetries[t]&&this.availableRetries[t]>0)&&(this.availableRetries[t]-=1,console.log("[realtime] ".concat(t," use a retry ticket, now only ").concat(this.availableRetries[t]," retry left")),!0)},t.prototype.handleServerEvents=function(t){return r(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this.scheduleSendACK(),[4,this.handleServerEventsInternel(t)];case 1:return n.sent(),this.postHandleServerEventsValidityCheck(t),[3,3];case 2:throw e=n.sent(),console.error("[realtime listener] internal non-fatal error: handle server events failed with error: ",e),e;case 3:return[2]}}))}))},t.prototype.handleServerEventsInternel=function(t){return r(this,void 0,void 0,(function(){var e,n,r,s,a,d,h,v,y,g,b,_;return o(this,(function(w){switch(w.label){case 0:if(e=t.requestId,n=t.msgData.events,r=t.msgType,!n.length||!this.sessionInfo)return[2];s=this.sessionInfo;try{a=n.map(m)}catch(t){return this.closeWithError(new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_RECEIVE_INVALID_SERVER_DATA,errMsg:t})),[2]}d=i([],s.currentDocs,!0),h=!1,v=function(n,v){var m,g,b,_,w,E,I,S,O,A,T,P;return o(this,(function(o){switch(o.label){case 0:return m=a[n],s.currentEventId>=m.id?(!a[n-1]||m.id>a[n-1].id?console.warn("[realtime] duplicate event received, cur ".concat(s.currentEventId," but got ").concat(m.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(e,")")),[2,"continue"]):[3,1];case 1:if(s.currentEventId!==m.id-1)return[3,2];switch(m.dataType){case"update":if(!m.doc)switch(m.queueType){case"update":case"dequeue":if(g=d.find((function(t){return t._id===m.docId})),g){if(b=(0,l.default)(g),m.updatedFields&&Object.keys(m.updatedFields).forEach((function(t){(0,u.default)(b,t,m.updatedFields[t])})),m.removedFields)for(_=0,w=m.removedFields;_<w.length;_++)E=w[_],(0,c.default)(b,E);m.doc=b}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 p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="update" and queueType="enqueue" (requestId '.concat(t.requestId,")")}),y.closeWithError(S),S}break;case"replace":if(!m.doc)throw S=new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="replace" (requestId '.concat(t.requestId,")")}),y.closeWithError(S),S;break;case"remove":(I=d.find((function(t){return t._id===m.docId})))?m.doc=I:console.error("[realtime listener] internal non-fatal server error: unexpected remove event where no doc is associated.");break;case"limit":if(!m.doc)switch(m.queueType){case"dequeue":(I=d.find((function(t){return t._id===m.docId})))?m.doc=I:console.error("[realtime listener] internal non-fatal server error: unexpected limit dataType event where no doc is associated.");break;case"enqueue":throw S=new p.CloudSDKError({errCode:p.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_UNEXPECTED_FATAL_ERROR,errMsg:'HandleServerEvents: full doc is not provided with dataType="limit" and queueType="enqueue" (requestId '.concat(t.requestId,")")}),y.closeWithError(S),S}}switch(m.queueType){case"init":h?d.push(m.doc):(h=!0,d=[m.doc]);break;case"enqueue":d.push(m.doc);break;case"dequeue":O=d.findIndex((function(t){return t._id===m.docId})),O>-1?d.splice(O,1):console.error("[realtime listener] internal non-fatal server error: unexpected dequeue event where no doc is associated.");break;case"update":O=d.findIndex((function(t){return t._id===m.docId})),O>-1?d[O]=m.doc:console.error("[realtime listener] internal non-fatal server error: unexpected queueType update event where no doc is associated.")}return(n===v-1||a[n+1]&&a[n+1].id!==m.id)&&(A=i([],d,!0),T=a.slice(0,n+1).filter((function(t){return t.id===m.id})),y.sessionInfo.currentEventId=m.id,y.sessionInfo.currentDocs=d,P=new f.Snapshot({id:m.id,docChanges:T,docs:A,msgType:r}),y.listener.onChange(P)),[3,4];case 2:return console.warn("[realtime listener] event received is out of order, cur ".concat(y.sessionInfo.currentEventId," but got ").concat(m.id)),[4,y.rebuildWatch()];case 3:return o.sent(),[2,{value:void 0}];case 4:return[2]}}))},y=this,g=0,b=a.length,w.label=1;case 1:return g<b?[5,v(g,b)]:[3,4];case 2:if("object"==typeof(_=w.sent()))return[2,_.value];w.label=3;case 3:return g++,[3,1];case 4:return[2]}}))}))},t.prototype.postHandleServerEventsValidityCheck=function(t){this.sessionInfo?(this.sessionInfo.expectEventId&&this.sessionInfo.currentEventId>=this.sessionInfo.expectEventId&&this.clearWaitExpectedEvent(),this.sessionInfo.currentEventId<t.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")},t.prototype.clearWaitExpectedEvent=function(){this.waitExpectedTimeoutId&&(clearTimeout(this.waitExpectedTimeoutId),this.waitExpectedTimeoutId=void 0)},t}();function m(t){var e={id:t.ID,dataType:t.DataType,queueType:t.QueueType,docId:t.DocID,doc:t.Doc&&"{}"!==t.Doc?JSON.parse(t.Doc):void 0};return"update"===t.DataType&&(t.UpdatedFields&&(e.updatedFields=JSON.parse(t.UpdatedFields)),(t.removedFields||t.RemovedFields)&&(e.removedFields=JSON.parse(t.removedFields))),e}e.VirtualWebSocketClient=y},2347:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.RealtimeWebSocketClient=void 0;var s=n(4151),a=n(3994),u=n(636),c=n(2917),l=n(6511),d=n(7589),h=function(){function t(t){var e=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(t){return o(e,void 0,Promise,(function(){var e=this;return i(this,(function(n){return[2,new Promise((function(n,r){o(e,void 0,void 0,(function(){var e,s,a,u,l,h,f,p,v=this;return i(this,(function(y){switch(y.label){case 0:s=!1,a=!1,u=function(t){s=!0,e&&clearTimeout(e),n(t)},l=function(t){a=!0,e&&clearTimeout(e),r(t)},t.timeout&&(e=setTimeout((function(){o(v,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return s&&a?[3,2]:[4,(0,d.sleep)(0)];case 1:t.sent(),s&&a||l(new c.TimeoutError("wsclient.send timedout")),t.label=2;case 2:return[2]}}))}))}),t.timeout)),y.label=1;case 1:return y.trys.push([1,8,,9]),void 0===this.wsInitPromise&&null===this.wsInitPromise?[3,3]:[4,this.wsInitPromise];case 2:y.sent(),y.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];t.waitResponse&&(h={resolve:u,reject:l,skipOnMessage:t.skipOnMessage},this.wsResponseWait.set(t.msg.requestId,h)),y.label=4;case 4:return y.trys.push([4,6,,7]),[4,this.ws.send(JSON.stringify(t.msg))];case 5:return y.sent(),t.waitResponse||u(void 0),[3,7];case 6:return(f=y.sent())&&(l(f),t.waitResponse&&this.wsResponseWait.delete(t.msg.requestId)),[3,7];case 7:return[3,9];case 8:return p=y.sent(),l(p),[3,9];case 9:return[2]}}))}))}))]}))}))},this.closeAllClients=function(t){e.virtualWSClient.forEach((function(e){e.closeWithError(t)}))},this.pauseClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.pause()}))},this.resumeClients=function(t){(t||e.virtualWSClient).forEach((function(t){t.resume()}))},this.initWebSocketConnection=function(t,n){return void 0===n&&(n=e.maxReconnect),o(e,void 0,Promise,(function(){var e=this;return i(this,(function(r){switch(r.label){case 0:if(t&&this.reconnectState)return[2];if(t&&(this.reconnectState=!0),void 0!==this.wsInitPromise&&null!==this.wsInitPromise)return[2,this.wsInitPromise];t&&this.pauseClients(),this.close(u.CloseEventCode.ReconnectWebSocket),this.wsInitPromise=new Promise((function(r,s){o(e,void 0,void 0,(function(){var e,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 e=i.sent(),[4,new Promise((function(t){var n=e.wsUrl||"wss://tcb-ws.tencentcloudapi.com",r=(0,l.getWsClass)();a.ws=r?new r(n):new WebSocket(n),t(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(),r(),t&&(this.resumeClients(),this.reconnectState=!1),[3,11];case 6:return o=i.sent(),console.error("[realtime] initWebSocketConnection connect fail",o),n>0?(this.wsInitPromise=void 0,[4,(0,d.sleep)(this.reconnectInterval)]):[3,9];case 7:i.sent(),t&&(this.reconnectState=!1),i.label=8;case 8:return r(this.initWebSocketConnection(t,n-1)),[3,10];case 9:s(o),t&&this.closeAllClients(new c.CloudSDKError({errCode:c.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_RECONNECT_WATCH_FAIL,errMsg:o})),i.label=10;case 10:return[3,11];case 11:return[2]}}))}))})),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,this.wsInitPromise];case 2:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.resolve)()})),[3,5];case 3:return r.sent(),this.wsReadySubsribers.forEach((function(t){return(0,t.reject)()})),[3,5];case 4:return this.wsInitPromise=void 0,this.wsReadySubsribers=[],[7];case 5:return[2]}}))}))},this.initWebSocketEvent=function(){return new Promise((function(t,n){if(!e.ws)throw new Error("can not initWebSocketEvent, ws not exists");var r=!1;e.ws.onopen=function(e){console.warn("[realtime] ws event: open",e),r=!0,t()},e.ws.onerror=function(t){e.logins=new Map,r?(console.error("[realtime] ws event: error",t),e.clearHeartbeat(),e.virtualWSClient.forEach((function(e){return e.closeWithError(new c.CloudSDKError({errCode:c.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_ERROR,errMsg:t}))}))):(console.error("[realtime] ws open failed with ws event: error",t),n(t))},e.ws.onclose=function(t){switch(console.warn("[realtime] ws event: close",t),e.logins=new Map,e.clearHeartbeat(),t.code){case u.CloseEventCode.ReconnectWebSocket:case u.CloseEventCode.NoRealtimeListeners:break;case u.CloseEventCode.HeartbeatPingError:case u.CloseEventCode.HeartbeatPongTimeoutError:case u.CloseEventCode.NormalClosure:case u.CloseEventCode.AbnormalClosure:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients((0,u.getWSCloseError)(t.code));break;case u.CloseEventCode.NoAuthentication:e.closeAllClients((0,u.getWSCloseError)(t.code,t.reason));break;default:e.maxReconnect>0?e.initWebSocketConnection(!0,e.maxReconnect):e.closeAllClients((0,u.getWSCloseError)(t.code))}},e.ws.onmessage=function(t){var n,r,o=(null===(n=t.data)||void 0===n?void 0:n.data)||t.data;e.heartbeat();try{r="string"==typeof o?JSON.parse(o):o}catch(t){throw new Error("[realtime] onMessage parse res.data error: ".concat(t))}if("ERROR"===r.msgType){var i=null;e.virtualWSClient.forEach((function(t){t.watchId===r.watchId&&(i=t)})),i&&i.listener.onError(r)}var s=e.wsResponseWait.get(r.requestId);if(s){try{"ERROR"===r.msgType?s.reject(new c.RealtimeErrorMessageError(r)):s.resolve(r)}catch(t){console.error("ws onMessage responseWaitSpec.resolve(msg) errored:",t)}finally{e.wsResponseWait.delete(r.requestId)}if(s.skipOnMessage)return}if("PONG"!==r.msgType){var a=r.watchId&&e.watchIdClientMap.get(r.watchId);if(a)a.onMessage(r);else switch(console.error("[realtime] no realtime listener found responsible for watchId ".concat(r.watchId,": "),r),r.msgType){case"INIT_EVENT":case"NEXT_EVENT":case"CHECK_EVENT":(a=e.queryIdClientMap.get(r.msgData.queryID))&&a.onMessage(r);break;default:for(var u=0,l=Array.from(e.watchIdClientMap.entries());u<l.length;u++){l[u][1].onMessage(r);break}}}else if(e.lastPingSendTS){var d=Date.now()-e.lastPingSendTS;if(d>1e4)return void console.warn("[realtime] untrusted rtt observed: ".concat(d));e.rttObserved.length>=3&&e.rttObserved.splice(0,e.rttObserved.length-3+1),e.rttObserved.push(d)}},e.heartbeat()}))},this.isWSConnected=function(){return Boolean(e.ws&&1===e.ws.readyState)},this.onceWSConnected=function(){return o(e,void 0,Promise,(function(){var t=this;return i(this,(function(e){return this.isWSConnected()?[2]:null!==this.wsInitPromise&&void 0!==this.wsInitPromise?[2,this.wsInitPromise]:[2,new Promise((function(e,n){t.wsReadySubsribers.push({resolve:e,reject:n})}))]}))}))},this.webLogin=function(t,n){return o(e,void 0,Promise,(function(){var e,r,s,u,c,d,h,f,p=this;return i(this,(function(v){switch(v.label){case 0:if(!n)if(t){if(e=this.logins.get(t)){if(e.loggedIn&&e.loginResult)return[2,e.loginResult];if(null!==e.loggingInPromise&&void 0!==e.loggingInPromise)return[2,e.loggingInPromise]}}else if(null!==(null==(r=this.logins.get(""))?void 0:r.loggingInPromise)&&void 0!==(null==r?void 0:r.loggingInPromise))return[2,r.loggingInPromise];s=new Promise((function(t,e){o(p,void 0,void 0,(function(){var n,r,o,s,u;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.getWsSign()];case 1:return n=i.sent(),r={envId:n.envId||"",accessToken:"",referrer:"web",sdkVersion:"",dataVersion:""},o={watchId:void 0,requestId:(0,a.genRequestId)(),msgType:"LOGIN",msgData:r,exMsgData:{runtime:(0,l.getRuntime)(),signStr:n.signStr,secretVersion:n.secretVersion}},[4,this.send({msg:o,waitResponse:!0,skipOnMessage:!0,timeout:5e3})];case 2:return(s=i.sent()).msgData.code?e(new Error("".concat(s.msgData.code," ").concat(s.msgData.message))):t({envId:n.envId}),[3,4];case 3:return u=i.sent(),e(u),[3,4];case 4:return[2]}}))}))})),u=t&&this.logins.get(t),c=Date.now(),u?(u.loggedIn=!1,u.loggingInPromise=s,u.loginStartTS=c):(u={loggedIn:!1,loggingInPromise:s,loginStartTS:c},this.logins.set(t||"",u)),v.label=1;case 1:return v.trys.push([1,3,,4]),[4,s];case 2:if(d=v.sent(),(h=t&&this.logins.get(t))&&h===u&&h.loginStartTS===c)return u.loggedIn=!0,u.loggingInPromise=void 0,u.loginStartTS=void 0,u.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 f=v.sent(),u.loggedIn=!1,u.loggingInPromise=void 0,u.loginStartTS=void 0,u.loginResult=void 0,f;case 4:return[2]}}))}))},this.getWsSign=function(){return o(e,void 0,Promise,(function(){var t,e,n,r,o,s,a;return i(this,(function(i){switch(i.label){case 0:return this.wsSign&&this.wsSign.expiredTs>Date.now()?[2,this.wsSign]:(t=Date.now()+6e4,[4,this.context.appConfig.request.send("auth.wsWebSign",{runtime:(0,l.getRuntime)()})]);case 1:if((e=i.sent()).code)throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败: ".concat(e.code));if(e.data)return n=e.data,r=n.signStr,o=n.wsUrl,s=n.secretVersion,a=n.envId,[2,{signStr:r,wsUrl:o,secretVersion:s,envId:a,expiredTs:t}];throw new Error("[tcb-js-sdk] 获取实时数据推送登录票据失败")}}))}))},this.getWaitExpectedTimeoutLength=function(){return e.rttObserved.length?e.rttObserved.reduce((function(t,e){return t+e}))/e.rttObserved.length*1.5:5e3},this.ping=function(){return o(e,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t={watchId:void 0,requestId:(0,a.genRequestId)(),msgType:"PING",msgData:null},[4,this.send({msg:t})];case 1:return e.sent(),[2]}}))}))},this.onWatchStart=function(t,n){e.queryIdClientMap.set(n,t)},this.onWatchClose=function(t,n){n&&e.queryIdClientMap.delete(n),e.watchIdClientMap.delete(t.watchId),e.virtualWSClient.delete(t),e.virtualWSClient.size||e.close(u.CloseEventCode.NoRealtimeListeners)},this.maxReconnect=t.maxReconnect||5,this.reconnectInterval=t.reconnectInterval||1e4,this.context=t.context}return t.prototype.clearHeartbeat=function(){this.pingTimeoutId&&clearTimeout(this.pingTimeoutId),this.pongTimeoutId&&clearTimeout(this.pongTimeoutId)},t.prototype.close=function(t){this.clearHeartbeat(),this.ws&&(this.ws.close(t,u.CLOSE_EVENT_CODE_INFO[t].name),this.ws=void 0)},t.prototype.watch=function(t){this.ws||void 0!==this.wsInitPromise&&null!==this.wsInitPromise||this.initWebSocketConnection(!1);var e=new s.VirtualWebSocketClient(r(r({},t),{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(e),this.watchIdClientMap.set(e.watchId,e),e.listener},t.prototype.heartbeat=function(t){var e=this;this.clearHeartbeat(),this.pingTimeoutId=setTimeout((function(){o(e,void 0,void 0,(function(){var t=this;return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),this.ws&&1===this.ws.readyState?(this.lastPingSendTS=Date.now(),[4,this.ping()]):[2];case 1:return e.sent(),this.pingFailed=0,this.pongTimeoutId=setTimeout((function(){console.error("pong timed out"),t.pongMissed<2?(t.pongMissed+=1,t.heartbeat(!0)):t.initWebSocketConnection(!0)}),this.context.appConfig.realtimePongWaitTimeout),[3,3];case 2:return e.sent(),this.pingFailed<2?(this.pingFailed+=1,this.heartbeat()):this.close(u.CloseEventCode.HeartbeatPingError),[3,3];case 3:return[2]}}))}))}),t?0:this.context.appConfig.realtimePingInterval)},t}();e.RealtimeWebSocketClient=h},636:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getWSCloseError=e.CloseEventCode=e.CLOSE_EVENT_CODE_INFO=void 0;var r,o=n(2917);e.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"}},(r=e.CloseEventCode||(e.CloseEventCode={}))[r.NormalClosure=1e3]="NormalClosure",r[r.GoingAway=1001]="GoingAway",r[r.ProtocolError=1002]="ProtocolError",r[r.UnsupportedData=1003]="UnsupportedData",r[r.NoStatusReceived=1005]="NoStatusReceived",r[r.AbnormalClosure=1006]="AbnormalClosure",r[r.InvalidFramePayloadData=1007]="InvalidFramePayloadData",r[r.PolicyViolation=1008]="PolicyViolation",r[r.MessageTooBig=1009]="MessageTooBig",r[r.MissingExtension=1010]="MissingExtension",r[r.InternalError=1011]="InternalError",r[r.ServiceRestart=1012]="ServiceRestart",r[r.TryAgainLater=1013]="TryAgainLater",r[r.BadGateway=1014]="BadGateway",r[r.TLSHandshake=1015]="TLSHandshake",r[r.ReconnectWebSocket=3e3]="ReconnectWebSocket",r[r.NoRealtimeListeners=3001]="NoRealtimeListeners",r[r.HeartbeatPingError=3002]="HeartbeatPingError",r[r.HeartbeatPongTimeoutError=3003]="HeartbeatPongTimeoutError",r[r.NoAuthentication=3050]="NoAuthentication",e.getWSCloseError=function(t,n){var r=e.CLOSE_EVENT_CODE_INFO[t],i=r?"".concat(r.name,", code ").concat(t,", reason ").concat(n||r.description):"code ".concat(t);return new o.CloudSDKError({errCode:o.ERR_CODE.SDK_DATABASE_REALTIME_LISTENER_WEBSOCKET_CONNECTION_CLOSED,errMsg:i})}},5891:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__decorate||function(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s},i=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseStorage=e.COMPONENT_NAME=e.EUploadMethod=void 0;var u,c=n(2877),l=n(7090),d=n(3388);!function(t){t.put="put",t.post="post"}(u=e.EUploadMethod||(e.EUploadMethod={}));var h=c.constants.getSdkName,f=c.constants.ERRORS,p=c.constants.COMMUNITY_SITE_URL,v=c.utils.isArray,y=c.utils.isString,m=c.utils.isPalinObject,g=c.utils.execCallback,b=c.helpers.catchErrorsDecorator;e.COMPONENT_NAME="storage";var _=function(t,e,n){return s(void 0,void 0,void 0,(function(){var o,i,s;return a(this,(function(a){switch(a.label){case 0:return[4,t.gateWay({path:"storages",name:"get-objects-upload-info",data:[r({objectId:e.path},e.signedHeader?{signedHeader:e.signedHeader}:{})]},n)];case 1:return o=a.sent(),i=(null===(s=o.data)||void 0===s?void 0:s[0])||{},[2,r(r({},o),{data:r(r({},i.code?r({},i):{}),{authorization:i.authorization,token:i.token,url:i.uploadUrl,fileId:i.cloudObjectId,cosFileId:i.cloudObjectMeta,download_url:i.downloadUrl})})]}}))}))},w=function(t,e,n){return s(void 0,void 0,void 0,(function(){var o,i;return a(this,(function(s){switch(s.label){case 0:return[4,t.gateWay({path:"storages",name:"get-objects-download-info",data:e.convertedFileList.map((function(t){return{cloudObjectId:t.fileid}}))},n)];case 1:return o=s.sent(),[2,r(r({},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}}))}})]}}))}))},E=function(t,e,n){return s(void 0,void 0,void 0,(function(){var o,i;return a(this,(function(s){switch(s.label){case 0:return[4,t.gateWay({path:"storages",name:"delete-objects",data:e.fileList.map((function(t){return{cloudObjectId:t}}))},n)];case 1:return o=s.sent(),[2,r(r({},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}}))}})]}}))}))},I=function(t,e,n){return s(void 0,void 0,void 0,(function(){var o,i;return a(this,(function(s){switch(s.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}}))},n)];case 1:return o=s.sent(),[2,r(r({},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}}))}})]}}))}))},S={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 O(t,e){if("undefined"!=typeof Blob&&t instanceof Blob&&t.type)return t.type;var n=/\.([a-zA-Z0-9]+)$/.exec(e||""),r=n?n[1].toLowerCase():"";return S[r]||"application/octet-stream"}function A(t,e){var n=e.toLowerCase();return Object.keys(t).some((function(t){return t.toLowerCase()===n}))}function T(t){return Object.keys(t).reduce((function(e,n){var o;return r(r({},e),((o={})[n]=[t[n]],o))}),{})}e.CloudbaseStorage=function(){function t(t){this.context=t}var n,c,S,P,R,C,N,D,U,x,L,j,k,M,q,W;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,n){return s(this,void 0,Promise,(function(){var o,i,s,c,d,p,v,m,b,_,w,E,I,S,P,R,C,N,D,U,x,L,j,k,M,q,W,B,F,G,H;return a(this,(function(a){switch(a.label){case 0:if(o=t.cloudPath,i=t.filePath,s=t.onUploadProgress,F=t.method,c=void 0===F?"put":F,G=t.headers,d=void 0===G?{}:G,p=t.fileContent,!y(o)||!i&&!p)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".uploadFile] invalid params")}));return v={put:u.put,post:u.post}[c.toLocaleLowerCase()]||u.put,m=this.isGateWay(),b=r({},d),_=Object.keys(d).reduce((function(t,e){return"content-length"!==e.toLowerCase()&&(t[e]=d[e]),t}),{}),v===u.put&&m&&(A(b,"content-length")||(w=function(t,e){var n=null!=t?t:e;if(null!==n){if("undefined"!=typeof Blob&&n instanceof Blob)return n.size;if("undefined"!=typeof ArrayBuffer){if(n instanceof ArrayBuffer)return n.byteLength;if("function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(n))return n.byteLength}if("string"==typeof n){if("undefined"!=typeof Blob)return new Blob([n]).size;var r=(0,l.getStringByteLength)(n);return"number"==typeof r?r:n.length}return"object"==typeof n&&"number"==typeof n.size?n.size:void 0}}(i,p),"number"==typeof w&&(b["content-length"]=String(w))),A(b,"content-type")||(b["content-type"]=O(i,o)),A(_,"content-type")||(_["content-type"]=O(i,o))),[4,this.getUploadMetadata({cloudPath:o,method:v,headers:v!==u.put||m?void 0:_,signedHeader:v===u.put&&m?T(b):void 0,customReqOpts:t.customReqOpts})];case 1:return E=a.sent(),I=E.data,S=E.requestId,(null==(P=I)?void 0:P.code)||!(null==P?void 0:P.url)?(R=(null==P?void 0:P.code)||f.OPERATION_FAIL,C=(null==P?void 0:P.message)||"get upload info failed",[2,g(n,new Error("[".concat(h(),"][").concat(R,"][").concat(e.COMPONENT_NAME,"]:").concat(C)))]):(N=I.url,D=I.authorization,U=I.token,x=I.fileId,L=I.cosFileId,j=I.download_url,M=r(r({},k={url:N,file:i,name:o,onUploadProgress:s,fileContent:p,fileId:x,requestId:S}),{method:u.put,headers:r(r({},_),{authorization:D,"x-cos-meta-fileid":L,"x-cos-security-token":U})}),q=r(r({},k),{method:u.post,data:{key:o,signature:D,"x-cos-meta-fileid":L,success_action_status:"201","x-cos-security-token":U}}),(H={})[u.put]={params:M,isSuccess:function(t){return t>=200&&t<300}},H[u.post]={params:q,isSuccess:function(t){return 201===t}},W=H,[4,this.request.upload(W[v].params)]);case 2:return B=a.sent(),W[v].isSuccess(B.statusCode)?[2,g(n,null,{fileID:x,download_url:j,requestId:S})]:[2,g(n,new Error("[".concat(h(),"][").concat(f.OPERATION_FAIL,"][").concat(e.COMPONENT_NAME,"]:").concat(B.data)))]}}))}))},t.prototype.getUploadMetadata=function(t,n){return s(this,void 0,Promise,(function(){var r,o,i,s,c,l,d,h,p,v;return a(this,(function(a){switch(a.label){case 0:if(r=t.cloudPath,o=t.method,i=t.headers,s=t.signedHeader,!y(r))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getUploadMetadata] invalid cloudPath")}));c=this.request,l="storage.getUploadMetadata",a.label=1;case 1:return a.trys.push([1,6,,7]),d=void 0,h={path:r},p=this.isGateWay(),o&&(h.method=o),o===u.put&&(p&&s?h.signedHeader=s:!p&&i&&(h.headers=i)),p?[4,_(c,h,t.customReqOpts)]:[3,3];case 2:return d=a.sent(),[3,5];case 3:return[4,c.send(l,h,t.customReqOpts)];case 4:d=a.sent(),a.label=5;case 5:return[2,g(n,null,d)];case 6:return v=a.sent(),[2,g(n,v)];case 7:return[2]}}))}))},t.prototype.deleteFile=function(t,n){return s(this,void 0,Promise,(function(){var r,o,i,s,u,c,l,d;return a(this,(function(a){switch(a.label){case 0:if(!(r=t.fileList)||!v(r)||0===r.length)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".deleteFile] fileList must not be empty")}));for(o=0,i=r;o<i.length;o++)if(!(s=i[o])||!y(s))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".deleteFile] fileID must be string")}));return u="storage.batchDeleteFile",c=this.request,l={},this.isGateWay()?[4,E(c,{fileList:r},t.customReqOpts)]:[3,2];case 1:return l=a.sent(),[3,4];case 2:return[4,c.send(u,{fileid_list:r},t.customReqOpts)];case 3:l=a.sent(),a.label=4;case 4:return l.code?[2,g(n,null,l)]:(d={fileList:l.data.delete_list,requestId:l.requestId},[2,g(n,null,d)])}}))}))},t.prototype.getTempFileURL=function(t,n){return s(this,void 0,Promise,(function(){var r,o,i,s,u,c,l,d;return a(this,(function(a){switch(a.label){case 0:if(!(r=t.fileList)||!v(r)||0===r.length)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] fileList must not be empty")}));for(o=[],i=0,s=r;i<s.length;i++)if(u=s[i],m(u)){if(!Object.prototype.hasOwnProperty.call(u,"fileID"))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] file info must include fileID")}));o.push({fileid:u.fileID,max_age:u.maxAge||7200})}else{if(!y(u))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] invalid fileList")}));o.push({fileid:u})}return c="storage.batchGetDownloadUrl",l=this.request,d={},this.isGateWay()?[4,w(l,{convertedFileList:o},t.customReqOpts)]:[3,2];case 1:return d=a.sent(),[3,4];case 2:return[4,l.send(c,{file_list:o},t.customReqOpts)];case 3:d=a.sent(),a.label=4;case 4:return d.code?[2,g(n,null,d)]:[2,g(n,null,{fileList:d.data.download_list,requestId:d.requestId})]}}))}))},t.prototype.downloadFile=function(t,n){return s(this,void 0,Promise,(function(){var r,o,i,s,u,c;return a(this,(function(a){switch(a.label){case 0:if(r=t.fileID,!y(r))throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".getTempFileURL] fileID must be string")}));return[4,this.getTempFileURL.call(this,{fileList:[{fileID:r,maxAge:600}],customReqOpts:t.customReqOpts})];case 1:return o=a.sent(),"SUCCESS"!==(i=o.fileList[0]).code?[2,g(n,i)]:(s=this.request,u=encodeURI(i.download_url),[4,s.download({url:u,tempFilePath:t.tempFilePath})]);case 2:return c=a.sent(),[2,g(n,null,c)]}}))}))},t.prototype.copyFile=function(t,n){return s(this,void 0,Promise,(function(){var r,o,i,s,u,c,l,d,h;return a(this,(function(a){switch(a.label){case 0:if(!(r=t.fileList)||!v(r)||0===r.length)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".copyFile] fileList must not be empty")}));for(o=[],i=0,s=r;i<s.length;i++){if(u=s[i],c=u.srcPath,l=u.dstPath,!c||!l||"string"!=typeof c||"string"!=typeof l)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".copyFile] srcPath and dstPath may not be empty")}));if(c===l)throw new Error(JSON.stringify({code:f.INVALID_PARAMS,msg:"[".concat(e.COMPONENT_NAME,".copyFile] srcPath and dstPath can not be the same")}));o.push({src_path:c,dst_path:l,overwrite:u.overwrite,remove_original:u.removeOriginal})}return d=this.request,h={},this.isGateWay()?[4,I(d,{convertedFileList:o},t.customReqOpts)]:[3,2];case 1:return h=a.sent(),[3,4];case 2:return[4,d.send("storage.batchCopyFile",{file_list:o},t.customReqOpts)];case 3:h=a.sent(),a.label=4;case 4:return h.code?[2,g(n,null,h)]:[2,g(n,null,{fileList:h.data.copy_list,requestId:h.requestId})]}}))}))},t.prototype.getFileInfo=function(t){var e;return s(this,void 0,Promise,(function(){var n,r=this;return a(this,(function(o){switch(o.label){case 0:return[4,this.getTempFileURL(t)];case 1:return(null==(n=o.sent())?void 0:n.fileList)&&(null===(e=null==n?void 0:n.fileList)||void 0===e?void 0:e.length)>0?[4,Promise.all(n.fileList.map((function(t){return s(r,void 0,void 0,(function(){var e,n,r,o,i,s,u;return a(this,(function(a){switch(a.label){case 0:if("SUCCESS"!==t.code)return[2,{code:t.code,fileID:t.fileID,tempFileURL:t.tempFileURL,message:t.message}];a.label=1;case 1:return a.trys.push([1,3,,4]),[4,this.request.fetch({url:t.tempFileURL,method:"HEAD"})];case 2:return e=a.sent(),n=e.header,"undefined"!=typeof Headers&&n instanceof Headers&&(r={},n.forEach((function(t,e){r[e]=t})),n=r),o=parseInt(n["content-length"])||0,i=n["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:n.etag||"",lastModified:n["last-modified"]||"",cacheControl:n["cache-control"]||""}];case 3:return s=a.sent(),u="object"==typeof s&&null!==s&&"message"in s?String(s.message):void 0,[2,{code:"FETCH_FILE_INFO_ERROR",fileID:t.fileID,tempFileURL:t.tempFileURL,message:u}];case 4:return[2]}}))}))})))]:[3,3];case 2:return[2,{fileList:o.sent(),requestId:n.requestId}];case 3:return[2,{fileList:[],requestId:n.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(n="undefined"!=typeof Function&&Function)?n:Object]),i("design:returntype","function"==typeof(c="undefined"!=typeof Promise&&Promise)?c: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(S="undefined"!=typeof Function&&Function)?S:Object]),i("design:returntype","function"==typeof(P="undefined"!=typeof Promise&&Promise)?P: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(R=void 0!==d.ICloudbaseDeleteFileParams&&d.ICloudbaseDeleteFileParams)?R:Object,"function"==typeof(C="undefined"!=typeof Function&&Function)?C:Object]),i("design:returntype","function"==typeof(N="undefined"!=typeof Promise&&Promise)?N: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(D=void 0!==d.ICloudbaseGetTempFileURLParams&&d.ICloudbaseGetTempFileURLParams)?D:Object,"function"==typeof(U="undefined"!=typeof Function&&Function)?U:Object]),i("design:returntype","function"==typeof(x="undefined"!=typeof Promise&&Promise)?x: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(L=void 0!==d.ICloudbaseDownloadFileParams&&d.ICloudbaseDownloadFileParams)?L:Object,"function"==typeof(j="undefined"!=typeof Function&&Function)?j:Object]),i("design:returntype","function"==typeof(k="undefined"!=typeof Promise&&Promise)?k: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(q="undefined"!=typeof Function&&Function)?q:Object]),i("design:returntype","function"==typeof(W="undefined"!=typeof Promise&&Promise)?W:Object)],t.prototype,"copyFile",null),t}()},9656:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.DownloadBuilder=e.StreamDownloadBuilder=void 0;var s=n(7957),a=n(7090);function u(t){return(0,s.isStorageError)(t)?t:new s.StorageError((null==t?void 0:t.message)||String(t))}function c(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 n,o,l,d,h;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=c(this.ctx.options),o=n.headers,l=n.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,a.encodeObjectName)(this.ctx.cleanName)),headers:r(r({},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 s.StorageApiError("Response body is empty",d.status,"STORAGE_PG_EMPTY_BODY");return[2,{data:d.body,error:null}];case 2:if(h=i.sent(),this.ctx.shouldThrowOnError)throw h;return[2,{data:null,error:u(h)}];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 n,o,s,l,d,h;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),n=c(this.ctx.options),o=n.headers,s=n.query,[4,this.ctx.http.download({path:"/object/".concat(this.ctx.bucketId,"/").concat((0,a.encodeObjectName)(this.ctx.cleanName)),headers:r(r({},this.ctx.headers),o),query:s,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,h={},[4,l.blob()];case 2:return[2,(h.data=i.sent(),h.error=null,h)];case 3:if(d=i.sent(),this.ctx.shouldThrowOnError)throw d;return[2,{data:null,error:u(d)}];case 4:return[2]}}))}))},t}();e.DownloadBuilder=d},7090:function(t,e){"use strict";function n(){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=n())||void 0===e?void 0:e.byteLength(t)},e.toBase64=function(t){var e=n();return e?e.from(t).toString("base64"):btoa(t)},e.encodeObjectName=function(t){return t.split("/").map((function(t){return encodeURIComponent(t)})).join("/")}},5098:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Http=e.handleOperation=void 0;var s=n(7957),a="/v1/storages";e.handleOperation=function(t,e){return o(this,void 0,Promise,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t()];case 1:return[2,{data:r.sent(),error:null}];case 2:if(n=r.sent(),e)throw n;return(0,s.isStorageError)(n)?[2,{data:null,error:n}]:[2,{data:null,error:new s.StorageError((null==n?void 0:n.message)||String(n))}];case 3:return[2]}}))}))};var u=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 n="".concat(this.gatewayOrigin()).concat(a).concat(t),r=function(t){if(!t)return"";var e=[];return Object.keys(t).forEach((function(n){var r=t[n];null!=r&&e.push("".concat(encodeURIComponent(n),"=").concat(encodeURIComponent(String(r))))})),e.join("&")}(e);return r&&(n+=(n.includes("?")?"&":"?")+r),n},t.prototype.toFullUrl=function(t){return t?/^https?:\/\//.test(t)||t.startsWith("//")?t:"".concat(this.gatewayOrigin()).concat(a).concat(t.startsWith("/")?"":"/").concat(t):t},t.prototype.send=function(t){return o(this,void 0,Promise,(function(){var e,n,o,s,a,u;return i(this,(function(i){switch(i.label){case 0:return e=this.buildUrl(t.path,t.query),n=t.method.toUpperCase(),o=["GET","HEAD"].includes(n),s=r({},t.headers||{}),o||(void 0!==t.rawBody?a=t.rawBody:void 0!==t.json&&(s["Content-Type"]=s["Content-Type"]||"application/json",a=JSON.stringify(t.json))),[4,this.request.fetch(r(r(r(r({url:e,method:n,headers:s},void 0!==a?{body:a}:{}),{withCredentials:!1!==t.withCredentials,shouldThrowOnError:!1}),t.signal?{signal:t.signal}:{}),t.cache?{cache:t.cache}:{}))];case 1:return u=i.sent(),[2,this.unwrap(u,e)]}}))}))},t.prototype.download=function(t){var e,n;return o(this,void 0,Promise,(function(){var o,a,u,c;return i(this,(function(i){switch(i.label){case 0:return o=this.buildUrl(t.path,t.query),[4,this.request.fetch(r(r({url:o,method:"GET",headers:r({},t.headers||{}),stream:!0,withCredentials:!1!==t.withCredentials,shouldThrowOnError:!1},t.signal?{signal:t.signal}:{}),t.cache?{cache:t.cache}:{}))];case 1:if(a=i.sent(),null===(e=t.signal)||void 0===e?void 0:e.aborted)throw new s.StorageApiError("The download was aborted",0,"STORAGE_PG_ABORTED");if(304===(u=Number(null!==(n=null==a?void 0:a.statusCode)&&void 0!==n?n:200)))throw new s.StorageApiError("Not Modified",u,"STORAGE_PG_NOT_MODIFIED");if(u>=400)throw new s.StorageApiError("Download failed with status ".concat(u),u,"STORAGE_PG_REQUEST_FAIL");if(!(c=null==a?void 0:a.response))throw new s.StorageApiError("Underlying adapter did not expose the raw Response",u,"STORAGE_PG_NO_RESPONSE");return[2,{response:c,status:u,header:null==a?void 0:a.header}]}}))}))},t.prototype.unwrap=function(t,e){var n,r;return o(this,void 0,Promise,(function(){var o,a,u,c;return i(this,(function(i){switch(i.label){case 0:o=Number(null!==(r=null!==(n=null==t?void 0:t.statusCode)&&void 0!==n?n:null==t?void 0:t.status)&&void 0!==r?r:200),a=null==t?void 0:t.data,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,a];case 2:return a=i.sent(),[3,4];case 3:return i.sent(),a=void 0,[3,4];case 4:if(o>=200&&o<300)return[2,a];throw u=(null==a?void 0:a.code)||(null==a?void 0:a.error)||"STORAGE_PG_REQUEST_FAIL",c=(null==a?void 0:a.message)||"Storage request failed with status ".concat(o,": ").concat(e),new s.StorageApiError(c,o,u)}}))}))},t}();e.Http=u},3456:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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.registerStorage=e.StorageClient=e.StorageFileApi=e.ClassicStorageFileApi=e.CloudbaseStorage=e.COMPONENT_NAME=void 0;var i=n(1502),s=n(2014),a=n(5504),u=n(5891),c=n(3077),l=n(5891);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=n(3077);Object.defineProperty(e,"ClassicStorageFileApi",{enumerable:!0,get:function(){return d.ClassicStorageFileApi}});var h=n(1502);Object.defineProperty(e,"StorageFileApi",{enumerable:!0,get:function(){return h.StorageFileApi}});var f=new u.CloudbaseStorage,p={name:u.COMPONENT_NAME,entity:{uploadFile:f.uploadFile,deleteFile:f.deleteFile,getTempFileURL:f.getTempFileURL,downloadFile:f.downloadFile,getUploadMetadata:f.getUploadMetadata,copyFile:f.copyFile,getFileInfo:f.getFileInfo,isGateWay:f.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,a.assertValidBucketId)(t,"from"),new i.StorageFileApi(this.http,t,this.shouldThrowOnError)):new c.ClassicStorageFileApi(this.http.ctx,this.shouldThrowOnError)},e}(s.StorageBucketApi);e.StorageClient=v;var y={name:"".concat(u.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,n=new Proxy({},{get:function(t,n){return"config"===n?e.config:"request"===n?e.request:void 0}}),r=new v(n);return t.set(this,r),r},configurable:!0,enumerable:!0})}};try{cloudbase.registerComponent(p),cloudbase.registerComponent(y)}catch(t){}function m(t){try{t.registerComponent(p),t.registerComponent(y)}catch(t){console.warn(t)}}e.registerStorage=m;try{window.registerStorage=m}catch(t){}},2014:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageBucketApi=void 0;var i=n(5098),s=n(5504),a=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 r(this,void 0,Promise,(function(){var e=this;return o(this,(function(n){return[2,(0,i.handleOperation)((function(){var n={};return void 0!==(null==t?void 0:t.limit)&&(n.limit=t.limit),void 0!==(null==t?void 0:t.offset)&&(n.offset=t.offset),(null==t?void 0:t.sortColumn)&&(n.sortColumn=t.sortColumn),(null==t?void 0:t.sortOrder)&&(n.sortOrder=t.sortOrder),(null==t?void 0:t.search)&&(n.search=t.search),e.http.send({method:"GET",path:"/bucket/",query:n})}),this.shouldThrowOnError)]}))}))},t.prototype.getBucket=function(t){return r(this,void 0,Promise,(function(){var e=this;return o(this,(function(n){return[2,(0,i.handleOperation)((function(){return(0,s.assertValidBucketId)(t,"getBucket"),e.http.send({method:"GET",path:"/bucket/".concat(t)})}),this.shouldThrowOnError)]}))}))},t.prototype.createBucket=function(t,e){return r(this,void 0,Promise,(function(){var n=this;return o(this,(function(r){return[2,(0,i.handleOperation)((function(){var r;return(0,s.assertValidBucketId)(t,"createBucket"),n.http.send({method:"POST",path:"/bucket/",json:{id:t,name:t,public:null!==(r=null==e?void 0:e.public)&&void 0!==r&&r,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 r(this,void 0,Promise,(function(){var n=this;return o(this,(function(r){return[2,(0,i.handleOperation)((function(){return(0,s.assertValidBucketId)(t,"updateBucket"),n.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 r(this,void 0,Promise,(function(){var e=this;return o(this,(function(n){return[2,(0,i.handleOperation)((function(){return(0,s.assertValidBucketId)(t,"deleteBucket"),e.http.send({method:"DELETE",path:"/bucket/".concat(t)})}),this.shouldThrowOnError)]}))}))},t}();e.StorageBucketApi=a},3077:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.ClassicStorageFileApi=void 0;var s=n(2877),a=n(7957),u=n(5891),c=n(7090),l=s.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 u.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,n){return o(this,void 0,Promise,(function(){var o,s,c,d,h,f,p,v,y;return i(this,(function(i){switch(i.label){case 0:o=r({upsert:!0},n),s=o.cacheControl,c=o.contentType,d=o.metadata,i.label=1;case 1:return i.trys.push([1,3,,4]),h=this.getCloudPath(t),f={cloudPath:h,filePath:e},(s||c||d)&&(p={},s&&(p["cache-control"]=s),c&&(p["content-type"]=c),d&&(p["x-cos-metadata-metadata"]=this.toBase64(JSON.stringify(d))),f.headers=p),[4,this.storage.uploadFile(f)];case 2:if(!(v=i.sent()).fileID)throw new Error(JSON.stringify({code:l.OPERATION_FAIL,msg:"[".concat(u.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,a.isStorageError)(y))return[2,{data:null,error:y}];throw y;case 4:return[2]}}))}))},t.prototype.uploadToSignedUrl=function(t,e,n,r){return o(this,void 0,Promise,(function(){return i(this,(function(e){return[2,this.upload(t,n,r)]}))}))},t.prototype.createSignedUploadUrl=function(t){return o(this,void 0,Promise,(function(){var e,n,r;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:(n=o.sent().data).url,token:n.token,path:t,authorization:n.authorization,id:n.fileId,cosFileId:n.cosFileId,downloadUrl:n.download_url},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;return[2,{data:null,error:r instanceof a.StorageError?r:new a.StorageError(r.message)}];case 3:return[2]}}))}))},t.prototype.update=function(t,e,n){return o(this,void 0,Promise,(function(){return i(this,(function(o){return[2,this.upload(t,e,r(r({},n),{upsert:!0}))]}))}))},t.prototype.move=function(t,e){return o(this,void 0,Promise,(function(){var n,r;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((n=o.sent()).fileList[0].code&&"SUCCESS"!==n.fileList[0].code)throw new a.StorageError(n.fileList[0].message||"Move failed");return[2,{data:{message:"File moved from ".concat(t," to ").concat(e)},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.copy=function(t,e){return o(this,void 0,Promise,(function(){var n,r;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((n=o.sent()).fileList[0].code&&"SUCCESS"!==n.fileList[0].code)throw new a.StorageError(n.fileList[0].message||"Copy failed");return[2,{data:{path:this.getCloudPath(e)},error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.createSignedUrl=function(t,e,n){return o(this,void 0,Promise,(function(){var r,o,s,u,c,l,d;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),r=this.normalizeCloudId(t),[4,this.storage.getTempFileURL({fileList:[{fileID:r,maxAge:e}]})];case 1:if("SUCCESS"!==(o=i.sent()).fileList[0].code)throw new a.StorageError("Failed to create signed URL: [".concat(o.fileList[0].code,"] ").concat(o.fileList[0].fileID));return s=o.fileList[0].download_url,u=[],void 0!==(null==n?void 0:n.download)&&("string"==typeof n.download?u.push("download=".concat(encodeURIComponent(n.download))):!0===n.download&&u.push("download=true")),(null==n?void 0:n.transform)&&(c=this.transformOptsToQueryString(n.transform))&&u.push(c),u.length>0&&(l=s.includes("?")?"&":"?",s="".concat(s).concat(l).concat(u.join("&"))),[2,{data:{signedUrl:s},error:null}];case 2:if(d=i.sent(),this.shouldThrowOnError)throw d;if((0,a.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 n,r,o=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=t.map((function(t){return{fileID:o.normalizeCloudId(t),maxAge:e}})),[4,this.storage.getTempFileURL({fileList:n})];case 1:return[2,{data:i.sent().fileList.map((function(e,n){return{path:t[n],signedUrl:e.tempFileURL||"",error:"SUCCESS"===e.code?null:e.message}})),error:null}];case 2:if(r=i.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.download=function(t,e){return o(this,void 0,Promise,(function(){var n,r,s=this;return i(this,(function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),r={},[4,o(s,void 0,void 0,(function(){var n,r,o,s;return i(this,(function(i){switch(i.label){case 0:return[4,this.createSignedUrl(t,600,{transform:e})];case 1:if((n=i.sent()).error)throw n.error;return r=encodeURI(null===(s=n.data)||void 0===s?void 0:s.signedUrl),[4,this.request.reqClass.get({url:r,headers:{},responseType:"blob"})];case 2:if(!(o=i.sent().data))throw new a.StorageError("Download failed: no file content");return[2,new Blob([o])]}}))}))];case 1:return[2,(r.data=u.sent(),r.error=null,r)];case 2:if(n=u.sent(),this.shouldThrowOnError)throw n;if((0,a.isStorageError)(n))return[2,{data:null,error:n}];throw n;case 3:return[2]}}))}))},t.prototype.info=function(t){return o(this,void 0,Promise,(function(){var e,n,r,o,s,u,c,l;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),e=t.startsWith("cloud://"),n=e?this.extractPathFromFileId(t):t,r=e?this.extractBucketFromFileId(t):this.bucketId,[4,this.storage.getFileInfo({fileList:[this.normalizeCloudId(t)]})];case 1:if(o=i.sent(),"SUCCESS"!==(s=o.fileList[0]).code)throw new a.StorageError(s.message);return u=(new Date).toISOString(),c=(s.lastModified?new Date(s.lastModified):new Date).toISOString(),[2,{data:{id:s.fileID,version:"1",name:n,bucketId:r,updatedAt:c,createdAt:c,lastAccessedAt:u,size:s.size,cacheControl:s.cacheControl,contentType:s.contentType,etag:s.etag,lastModified:c,metadata:{}},error:null}];case 2:if(l=i.sent(),this.shouldThrowOnError)throw l;return[2,{data:null,error:l instanceof a.StorageError?l:new a.StorageError(l.message)}];case 3:return[2]}}))}))},t.prototype.exists=function(t){return o(this,void 0,Promise,(function(){var e,n,r;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"===(n=e.fileList[0]).code)return[2,{data:!1,error:null}];if("SUCCESS"!==n.code)throw new a.StorageError(n.message);return[2,{data:!0,error:null}];case 2:if(r=o.sent(),this.shouldThrowOnError)throw r;if((0,a.isStorageError)(r))return[2,{data:null,error:r}];throw r;case 3:return[2]}}))}))},t.prototype.getPublicUrl=function(t,e){return o(this,void 0,Promise,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.createSignedUrl(t,600,e)];case 1:return(n=r.sent()).data?[2,{data:{publicUrl:n.data.signedUrl}}]:[2,{data:null,error:n.error}]}}))}))},t.prototype.remove=function(t){return o(this,void 0,Promise,(function(){var e,n,r,o,s,u,c,l,d,h,f=this;return i(this,(function(i){switch(i.label){case 0:for(i.trys.push([0,3,,4]),e=10,n=[],r=0;r<t.length;r+=e)n.push(t.slice(r,r+e));return[4,Promise.all(n.map((function(t){return Promise.all(t.map((function(t){return f.info(t)})))})))];case 1:return o=i.sent(),s=new Map,o.forEach((function(n,r){n.forEach((function(n,o){n.data&&s.set(t[r*e+o],n.data)}))})),u=t.map((function(t){return f.normalizeCloudId(t)})),[4,this.storage.deleteFile({fileList:u})];case 2:if(c=i.sent(),(l=c.fileList.filter((function(t){return"SUCCESS"!==t.code}))).length>0)throw new a.StorageError("Delete failed for ".concat(l.length," file(s)"));return d=(new Date).toISOString(),[2,{data:t.map((function(t){var e=s.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(h=i.sent(),this.shouldThrowOnError)throw h;if((0,a.isStorageError)(h))return[2,{data:null,error:h}];throw h;case 4:return[2]}}))}))},t.prototype.list=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){throw new a.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 n=this.getCloudPath(t);if(!this.bucketId)throw new a.StorageError("bucketId is not set");var r=(null===(e=this.config)||void 0===e?void 0:e.env)||"";return r?"cloud://".concat(r,".").concat(this.bucketId,"/").concat(n):void 0},t.prototype.toBase64=function(t){return(0,c.toBase64)(t)},t.prototype.transformOptsToQueryString=function(t){var e=["imageMogr2"];if(t.width||t.height){var n=t.width||"",r=t.height||"";"fill"===t.resize?e.push("thumbnail/".concat(n,"x").concat(r,"!")):"contain"===t.resize?e.push("thumbnail/".concat(n,"x").concat(r)):e.push("thumbnail/".concat(n,"x").concat(r,"^"))}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 n=e[0],r=n.indexOf(".");return-1===r?n:n.substring(r+1)},t}();e.ClassicStorageFileApi=d},1502:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.StorageFileApi=void 0;var s=n(7957),a=n(7090),u=n(5098),c=n(9656),l="3600",d=function(){function t(t,e,n){void 0===n&&(n=!1),this.headers={},this.http=t,this.bucketId=e,this.shouldThrowOnError=n}return t.prototype.throwOnError=function(){return this.shouldThrowOnError=!0,this},t.prototype.setHeader=function(t,e){var n;if("string"!=typeof t||""===t.trim())throw new s.StorageError("setHeader requires a non-empty header name");if(/[\r\n]/.test(t)||"string"==typeof e&&/[\r\n]/.test(e))throw new s.StorageError("setHeader does not allow CR/LF characters in header name or value");return this.headers=r(r({},this.headers),((n={})[t]=String(e),n)),this},t.prototype.upload=function(t,e,n){return o(this,void 0,Promise,(function(){return i(this,(function(r){return[2,this.uploadOrUpdate("POST",t,e,n)]}))}))},t.prototype.update=function(t,e,n){return o(this,void 0,Promise,(function(){return i(this,(function(r){return[2,this.uploadOrUpdate("PUT",t,e,n)]}))}))},t.prototype.download=function(t,e,n){return new c.DownloadBuilder({http:this.http,bucketId:this.bucketId,cleanName:this.cleanPath(t),options:e,parameters:n,headers:this.headers,shouldThrowOnError:this.shouldThrowOnError})},t.prototype.list=function(t,e,n){return o(this,void 0,Promise,(function(){var r=this;return i(this,(function(s){return[2,(0,u.handleOperation)((function(){return o(r,void 0,void 0,(function(){var r;return i(this,(function(o){return r={prefix:t||""},void 0!==(null==e?void 0:e.limit)&&(r.limit=e.limit),void 0!==(null==e?void 0:e.cursor)&&(r.cursor=e.cursor),void 0!==(null==e?void 0:e.withDelimiter)&&(r.with_delimiter=e.withDelimiter),void 0!==(null==e?void 0:e.sortBy)&&(r.sortBy=e.sortBy),[2,this.send({method:"POST",path:"/object/list/".concat(this.bucketId),json:r,signal:null==n?void 0:n.signal,cache:null==n?void 0:n.cache})]}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.remove=function(t){return o(this,void 0,Promise,(function(){var e=this;return i(this,(function(n){return[2,(0,u.handleOperation)((function(){return o(e,void 0,void 0,(function(){var e,n,r,o,s,a=this;return i(this,(function(i){switch(i.label){case 0:e=t.map((function(t){return a.cleanPath(t)})),n=[],r=0,i.label=1;case 1:return r<e.length?(o=e.slice(r,r+100),[4,this.send({method:"DELETE",path:"/object/".concat(this.bucketId),json:{prefixes:o}})]):[3,4];case 2:s=i.sent(),Array.isArray(s)&&n.push.apply(n,s),i.label=3;case 3:return r+=100,[3,1];case 4:return[2,n]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.copy=function(t,e,n){return o(this,void 0,Promise,(function(){var r=this;return i(this,(function(s){return[2,(0,u.handleOperation)((function(){return o(r,void 0,void 0,(function(){var r;return i(this,(function(o){switch(o.label){case 0:return r=this.buildCopyMoveHeaders(n),[4,this.send({method:"POST",path:"/object/copy",json:{bucketId:this.bucketId,sourceKey:this.cleanPath(t),destinationKey:this.cleanPath(e),destinationBucket:null==n?void 0:n.destinationBucket,copyMetadata:null==n?void 0:n.copyMetadata,metadata:null==n?void 0:n.metadata},headers:r})];case 1:return[2,{path:o.sent().Key}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.move=function(t,e,n){return o(this,void 0,Promise,(function(){var r=this;return i(this,(function(s){return[2,(0,u.handleOperation)((function(){return o(r,void 0,void 0,(function(){return i(this,(function(r){switch(r.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==n?void 0:n.destinationBucket}})];case 1:return[2,{message:r.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(n){return[2,(0,u.handleOperation)((function(){return o(e,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.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:(n=r.sent()).id,name:n.name,version:n.version,bucketId:n.bucket_id,size:n.size,contentType:n.content_type,cacheControl:n.cache_control,etag:n.etag,metadata:n.metadata,lastModified:n.last_modified,createdAt:n.created_at}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.exists=function(t){return o(this,void 0,Promise,(function(){var e,n,r;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(n=o.sent(),void 0!==(r=null==n?void 0:n.status)&&[400,404].includes(Number(r)))return[2,{data:!1,error:null}];if(this.shouldThrowOnError)throw n;return[2,{data:null,error:n instanceof s.StorageError?n:new s.StorageError((null==n?void 0:n.message)||String(n))}];case 3:return[2]}}))}))},t.prototype.createSignedUrl=function(t,e,n){return o(this,void 0,Promise,(function(){var r=this;return i(this,(function(s){return[2,(0,u.handleOperation)((function(){return o(r,void 0,void 0,(function(){var r,o,s;return i(this,(function(i){switch(i.label){case 0:return r=this.cleanPath(t),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId,"/").concat(this.encodePath(r)),json:{expiresIn:e}})];case 1:return o=i.sent(),s=o.fullSignedURL||this.http.toFullUrl(o.signedURL||""),[2,{fullSignedURL:this.appendUrlOptions(s,n)}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.createSignedUrls=function(t,e,n){return o(this,void 0,Promise,(function(){var r=this;return i(this,(function(s){return[2,(0,u.handleOperation)((function(){return o(r,void 0,void 0,(function(){var r,o,s,a,u=this;return i(this,(function(i){switch(i.label){case 0:r=t.map((function(t){return u.cleanPath(t)})),o=[],s=0,i.label=1;case 1:return s<r.length?(a=r.slice(s,s+500),[4,this.send({method:"POST",path:"/object/sign/".concat(this.bucketId),json:{expiresIn:e,paths:a}})]):[3,4];case 2:i.sent().forEach((function(t){var e,r=t.fullSignedURL||(t.signedURL?u.http.toFullUrl(t.signedURL):null);o.push({path:t.path,fullSignedURL:r?u.appendUrlOptions(r,n):null,error:null!==(e=t.error)&&void 0!==e?e:null})})),i.label=3;case 3:return s+=500,[3,1];case 4:return[2,o]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.createSignedUploadUrl=function(t,e){return o(this,void 0,Promise,(function(){var n=this;return i(this,(function(r){return[2,(0,u.handleOperation)((function(){return o(n,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=this.cleanPath(t),r={},(null==e?void 0:e.upsert)&&(r["x-upsert"]="true"),[4,this.send({method:"POST",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(n)),headers:r})];case 1:return[2,{fullSignedURL:(o=i.sent()).fullURL||this.http.toFullUrl(o.url||""),path:n,token:o.token}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.uploadToSignedUrl=function(t,e,n,r){return o(this,void 0,Promise,(function(){var s=this;return i(this,(function(a){return[2,(0,u.handleOperation)((function(){return o(s,void 0,void 0,(function(){var o,s,a,u,c;return i(this,(function(i){switch(i.label){case 0:return o=this.cleanPath(t),s=this.buildUploadBody(n,r),a=s.body,u=s.headers,[4,this.send({method:"PUT",path:"/object/upload/sign/".concat(this.bucketId,"/").concat(this.encodePath(o)),query:{token:e},rawBody:a,headers:u,withCredentials:!1})];case 1:return c=i.sent(),[2,{path:o,fullPath:c.Key}]}}))}))}),this.shouldThrowOnError)]}))}))},t.prototype.getPublicUrl=function(t,e){var n=this.cleanPath(t),r=this.http.buildUrl("/object/public/".concat(this.bucketId,"/").concat(this.encodePath(n)));return{data:{publicUrl:this.appendUrlOptions(r,e)}}},t.prototype.send=function(t){return this.http.send(r(r({},t),{headers:r(r({},this.headers),t.headers||{})}))},t.prototype.uploadOrUpdate=function(t,e,n,r){return o(this,void 0,Promise,(function(){var s=this;return i(this,(function(a){return[2,(0,u.handleOperation)((function(){return o(s,void 0,void 0,(function(){var o,s,a,u,c;return i(this,(function(i){switch(i.label){case 0:return o=this.cleanPath(e),s=this.buildUploadBody(n,r),a=s.body,u=s.headers,"POST"===t&&(u["x-upsert"]=String(Boolean(null==r?void 0:r.upsert))),[4,this.send({method:t,path:"/object/".concat(this.bucketId,"/").concat(this.encodePath(o)),rawBody:a,headers:u})];case 1:return[2,{id:(c=i.sent()).Id,path:o,fullPath:c.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 s.StorageError('invalid path: ".." segment is not allowed');return e},t.prototype.encodePath=function(t){return(0,a.encodeObjectName)(t)},t.prototype.buildUploadBody=function(t,e){var n,o,i,s,a,u=r({},(null==e?void 0:e.headers)||{}),c=t,d="undefined"!=typeof FormData&&t instanceof FormData;if("undefined"!=typeof Blob&&t instanceof Blob||d){var h=void 0,f={};if(d){var p=this.extractFromFormData(t);h=p.file,f=p.fields}else h=t;var v=null!==(o=null!==(n=null==e?void 0:e.cacheControl)&&void 0!==n?n:f.cacheControl)&&void 0!==o?o:l,y=null!==(i=null==e?void 0:e.contentType)&&void 0!==i?i:f.contentType,m=void 0!==(null==e?void 0:e.metadata)?JSON.stringify(e.metadata):f.metadata,g=new FormData;void 0!==v&&g.append("cacheControl",String(v)),void 0!==y&&g.append("contentType",y),void 0!==m&&g.append("metadata",m),g.append("",h),c=g}else c=t,v=null!==(s=null==e?void 0:e.cacheControl)&&void 0!==s?s:l,y=null!==(a=null==e?void 0:e.contentType)&&void 0!==a?a:"text/plain;charset=UTF-8",u["cache-control"]="max-age=".concat(v),y&&(u["content-type"]=y),(null==e?void 0:e.metadata)&&(u["x-metadata"]=this.toBase64(JSON.stringify(e.metadata)));return{body:c,headers:u}},t.prototype.extractFromFormData=function(t){var e,n={},r=0,o=[];if(t.forEach((function(t,i){if("undefined"!=typeof Blob&&t instanceof Blob)return e=t,void(r+=1);"cacheControl"!==i&&"contentType"!==i&&"metadata"!==i?o.push(i):n[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===r||!e)throw new s.StorageError("FormData must contain a file");if(r>1)throw new s.StorageError("FormData must contain exactly one file");return{file:e,fields:n}},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 n=[];if(void 0!==(null==e?void 0:e.download)){var r=!0===e.download?"":String(e.download);n.push("download=".concat(encodeURIComponent(r)))}if(void 0!==(null==e?void 0:e.cacheNonce)&&n.push("cacheNonce=".concat(encodeURIComponent(String(e.cacheNonce)))),0===n.length)return t;var o=t.includes("?")?"&":"?";return"".concat(t).concat(o).concat(n.join("&"))},t.prototype.toBase64=function(t){return(0,a.toBase64)(t)},t}();e.StorageFileApi=d},7957:function(t,e){"use strict";var n,r=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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.StorageUnknownError=e.StorageApiError=e.isStorageError=e.StorageError=void 0;var o=function(t){function e(e){var n=t.call(this,e)||this;return n.__isStorageError=!0,n.name="StorageError",n}return r(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,n,r){var o=t.call(this,e)||this;return o.name="StorageApiError",o.status=n,o.statusCode=r,o}return r(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 s=function(t){function e(e,n){var r=t.call(this,e)||this;return r.name="StorageUnknownError",r.originalError=n,r}return r(e,t),e}(o);e.StorageUnknownError=s},5504:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.assertValidBucketId=e.isValidBucketId=void 0;var r=n(7957),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 r.StorageError("[storage.".concat(e,"] bucketId is required"));if(t.length>256)throw new r.StorageError("[storage.".concat(e,"] invalid bucketId: length must be 1-").concat(256));var n=o.exec(t);if(n){var i="[storage.".concat(e,'] invalid bucketId "').concat(t,'": ')+"contains forbidden character ".concat(JSON.stringify(n[0]),"; ")+'must not contain whitespace, control chars, "/", "\\", "?", "#" or "%"';throw new r.StorageError(i)}}},2563:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,u=s(n(92)),c=n(962);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var n=0,o=(0,c.isArray)(t)?t:[t];n<o.length;n++){var i=o[n],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:r({isMatch:s},a(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:r({},u.genAdapter()),runtime:a.WEB}}},92:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=n(2764),c=n(962),l=n(8464),d=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}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,n=t.file,r=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",r),c.append("file",n),this.request(i(i({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,Promise,(function(){var e,n,r,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return s(this,void 0,Promise,(function(){var n,r,o,u,c,l,d,h,f,p,v,y,m,g=this;return a(this,(function(b){switch(b.label){case 0:return n=new AbortController,r=t.url,o=t.enableAbort,u=void 0!==o&&o,c=t.stream,l=void 0!==c&&c,d=t.signal,h=t.timeout,f=t.shouldThrowOnError,p=void 0===f||f,v=null!=h?h:this.timeout,d&&(d.aborted&&n.abort(),d.addEventListener("abort",(function(){return n.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(g.timeoutMsg),n.abort(new Error(g.timeoutMsg))}),v)),[4,fetch(r,i(i({},t),{signal:n.signal})).then((function(t){return s(g,void 0,void 0,(function(){var e,n,r;return a(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 r=(n=Promise).reject,[4,t.json()];case 2:e=r.apply(n,[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 m=b.sent(),[2,{data:l?m.body:(null===(e=m.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers,response:m}]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i=t.url,s=t.headers,a=void 0===s?{}:s,u=t.data,d=t.responseType,h=t.withCredentials,f=t.body,p=t.onUploadProgress,v=(0,c.formatUrl)((0,l.getProtocol)(),i,"get"===r?u:{}),y=new XMLHttpRequest;y.open(r,v),d&&(y.responseType=d);var m,g,b=t.signal;b&&(b.aborted?y.abort():b.addEventListener("abort",(function(){return y.abort()}),{once:!0})),Object.keys(a).forEach((function(t){y.setRequestHeader(t,a[t])})),p&&y.upload.addEventListener("progress",p),y.onreadystatechange=function(){var t={};if(4===y.readyState){var e=y.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,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(m),o(t)}},e&&n.timeout&&(m=setTimeout((function(){console.warn(n.timeoutMsg),y.abort()}),n.timeout)),g=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):f||(u?JSON.stringify(u):void 0),h&&(y.withCredentials=!0),y.send(g)}))},e}(u.AbstractSDKRequest);e.WebRequest=d,e.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage:localStorage}}},8464:function(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 n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var r="https:";e.setProtocol=function(t){r=t},e.getProtocol=function(){return r},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},3519:function(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"}},1778:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(8464),e),o(n(3519),e),e.OATUH_LOGINTYPE="constants"},9517:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(962),s=n(1778),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),d=s.findIndex((function(t){return u.test(t)}));if(-1!==d){var h=s.filter((function(t,e){return e>d}));h.unshift(s[d].replace(l,"".concat(n,".").concat(r)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,d=void 0===a?{}:a,h=t.title,f=t.messages,p=void 0===f?[]:f;return function(t,e,a){if(s.IS_DEBUG_MODE){var f=d.className||t.constructor.name,v=d.methodName||e,y=a.value,m=function(){var t="",e=(new Error).stack.split("\n"),n=e.findIndex((function(t){return u.test(t)}));if(-1!==n){var r=c.exec(e[n+1]||"");t=r?r[0]:""}return t}();a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=l({err:new Error,className:f,methodName:v,sourceLink:m});try{return y.apply(this,t)}catch(t){var r=t,o=t.message,s=t.error,a=t.error_description,u={title:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(n?(n.code=c.code,n.msg=c.msg):(t.code=c.code,t.message=c.msg),r=n||t,u.content=p.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,n?(n.code=s,n.msg=a):(t.code=s,t.message=a),r=n||t,u.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(u),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,(function(){var e,n,r,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:e=l({err:new Error,className:f,methodName:v,sourceLink:m}),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 n=o.sent(),r=n,s=n.message,a=n.error,u=n.error_description,c={title:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(d=JSON.parse(s),c.subtitle=d,d.code&&(e?(e.code=d.code,e.message=d.msg):(n.code=d.code,n.message=d.msg),r=e||n,c.content=p.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(n.code=a,n.message=u),r=e||n,c.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(c),r;case 4:return[2]}}))}))}}}}},3260:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(9517),e)},2877:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),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 n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},s=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 a=i(n(1778));e.constants=a;var u=i(n(2563));e.adapters=u;var c=i(n(6865));e.cache=c;var l=i(n(6940));e.events=l;var d=i(n(3991));e.langEvent=d;var h=i(n(962));e.utils=h;var f=i(n(3260));e.helpers=f;var p=s(n(829));e.AbortController=p.default;var v={decode:s(n(3107)).default};e.jwt=v},829:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){var t=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(e,n){"abort"===e&&t.listeners.push(n)}}}return t.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach((function(t){return t()})))},t}();e.default=n},6865:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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)}),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(2764),u=n(962),c=n(1778),l=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}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}(a.AbstractStorage),d=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,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,u.printWarn)(c.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,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var r=this.storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,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(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,u.printWarn)(c.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 s(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}();e.CloudbaseCache=d},6940:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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)}),i=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=n(962),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,u))return console.error(t.error),this;var n=(0,s.isString)(t)?new a(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,c=this.listeners[r]?i([],this.listeners[r],!0):[];o<c.length;o++)c[o].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var l=new c;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)}},3991:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.LANG_CHANGE_EVENT=e.bus=void 0;var r=n(6940);e.bus=new r.CloudbaseEventEmitter,e.LANG_CHANGE_EVENT="lang_change"},962:function(t,e,n){"use strict";var r=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};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=n(1778);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(n){var r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:7&r|8).toString(16)}))},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(n[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(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||decodeURIComponent(window.location.search),r=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);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 n=e.split("?")[0],r=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===t&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},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 n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},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,n=t.title,r=t.subtitle,o=void 0===r?"":r,i=t.content,s=void 0===i?[]:i,a=t.printTrace,u=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var l=0,d=s;l<d.length;l++){var h=d[l],f=h.type,p=h.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(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 n=t.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(e[r]?Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]:e[r]=o)})),e},e.parseCaptcha=function(t){var n={},o=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){t=o[1];var i=o[2];i&&(n=(0,e.parseQueryString)(i))}var s=n.token,a=r(n,["token"]);return/^data:/.test(t)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:s?{state:a.state,token:s,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},543:function(t,e,n){"use strict";n.r(e),n.d(e,{CollectionReference:function(){return Vt},Db:function(){return ye},DocumentReference:function(){return jt},Query:function(){return Wt}});var r,o,i={};n.r(i),n.d(i,{LineString:function(){return H},MultiLineString:function(){return z},MultiPoint:function(){return Y},MultiPolygon:function(){return Q},Point:function(){return ot},Polygon:function(){return K}}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var s,a,u="Object",c="GeoPoint",l="GeoLineString",d="GeoPolygon",h="GeoMultiPoint",f="GeoMultiLineString",p="GeoMultiPolygon",v="Date",y="ServerDate",m=["desc","asc"],g=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(s||(s={})),(r={})[s.eq]="$eq",r[s.lt]="$lt",r[s.lte]="$lte",r[s.gt]="$gt",r[s.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(a||(a={}));var b,_=(b=function(t,e){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},b(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}b(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),w=[],E={},I=function(t){function e(e,n){if(n!==E)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return _(e,t),e.for=function(t){for(var n=0,r=w.length;n<r;n++)if(w[n].target===t)return w[n].instance;var o=new e(t,E);return w.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})})),S=I,O=S.for("UNSET_FIELD_NAME"),A=S.for("UPDATE_COMMAND"),T=S.for("QUERY_COMMAND"),P=S.for("LOGIC_COMMAND"),R=S.for("GEO_POINT"),C=S.for("SYMBOL_GEO_LINE_STRING"),N=S.for("SYMBOL_GEO_POLYGON"),D=S.for("SYMBOL_GEO_MULTI_POINT"),U=S.for("SYMBOL_GEO_MULTI_LINE_STRING"),x=S.for("SYMBOL_GEO_MULTI_POLYGON"),L=S.for("SERVER_DATE"),j=S.for("REGEXP"),k=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},M=function(t){return"object"===k(t)},q=function(t){return"number"===k(t)},W=function(t){return Array.isArray(t)},B=function(t){return"date"===k(t)},F=function(t){return"regexp"===k(t)},G=function(t){return t&&t._internalType instanceof I},H=function(){function t(t){if(!W(t))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t));if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach((function(t){if(!(t instanceof ot))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t,"[]"))})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("LineString"!==t.type||!W(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!q(i[0])||!q(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],n=t.points[t.points.length-1];if(e.latitude===n.latitude&&e.longitude===n.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return C},enumerable:!1,configurable:!0}),t}(),V=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},K=function(){function t(t){if(!W(t))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t,"[]"));if(!H.isClosed(t))throw new Error("LineString ".concat(t.points.map((function(t){return t.toReadableString()}))," is not a closed cycle"))})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("Polygon"!==t.type||!W(t.coordinates))return!1;try{for(var i=V(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;if(!this.isCloseLineString(a))return!1;try{for(var u=(r=void 0,V(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!q(l[0])||!q(l[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return x},enumerable:!1,configurable:!0}),t}(),Y=function(){function t(t){if(!W(t))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t));if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach((function(t){if(!(t instanceof ot))throw new TypeError('"points" must be of type Point[]. Received type '.concat(typeof t,"[]"))})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("MultiPoint"!==t.type||!W(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!q(i[0])||!q(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return D},enumerable:!1,configurable:!0}),t}(),J=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},z=function(){function t(t){if(!W(t))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof H))throw new TypeError('"lines" must be of type LineString[]. Received type '.concat(typeof t,"[]"))})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("MultiLineString"!==t.type||!W(t.coordinates))return!1;try{for(var i=J(t.coordinates),s=i.next();!s.done;s=i.next()){var a=s.value;try{for(var u=(r=void 0,J(a)),c=u.next();!c.done;c=u.next()){var l=c.value;if(!q(l[0])||!q(l[1]))return!1}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return U},enumerable:!1,configurable:!0}),t}(),$=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},Q=function(){function t(t){var e,n;if(!W(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '.concat(typeof t));if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=$(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof K))throw new TypeError('"polygon" must be of type Polygon[]. Received type '.concat(typeof i,"[]"))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.polygons=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))},e},t.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))}},t.validate=function(t){var e,n,r,o,i,s;if("MultiPolygon"!==t.type||!W(t.coordinates))return!1;try{for(var a=$(t.coordinates),u=a.next();!u.done;u=a.next()){var c=u.value;try{for(var l=(r=void 0,$(c)),d=l.next();!d.done;d=l.next()){var h=d.value;try{for(var f=(i=void 0,$(h)),p=f.next();!p.done;p=f.next()){var v=p.value;if(!q(v[0])||!q(v[1]))return!1}}catch(t){i={error:t}}finally{try{p&&!p.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{d&&!d.done&&(o=l.return)&&o.call(l)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return N},enumerable:!1,configurable:!0}),t}(),X=function(){function t(t){var e=(void 0===t?{}:t).offset,n=void 0===e?0:e;this.offset=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!1,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function Z(t){return new X(t)}var tt,et=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},nt=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach((function(n){var o,i=e[n];switch(t.whichType(i)){case c:o=new ot(i.coordinates[0],i.coordinates[1]);break;case l:o=new H(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case d:o=new K(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})));break;case h:o=new Y(i.coordinates.map((function(t){return new ot(t[0],t[1])})));break;case f:o=new z(i.coordinates.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})));break;case p:o=new Q(i.coordinates.map((function(t){return new K(t.map((function(t){return new H(t.map((function(t){var e=et(t,2),n=e[0],r=e[1];return new ot(n,r)})))})))})));break;case v:o=new Date(1e3*i.$timestamp);break;case u:case"Array":o=t.formatField(i);break;case y:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o})),r},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===v)return"BsonDate";if(e===u){if(t instanceof ot)return c;if(t instanceof Date)return v;if(t instanceof X)return y;t.$timestamp?e=v:t.$date?e=y:ot.validate(t)?e=c:H.validate(t)?e=l:K.validate(t)?e=d:Y.validate(t)?e=h:z.validate(t)?e=f:Q.validate(t)&&(e=p)}return e},t.generateDocId=function(){for(var t="",e=0;e<24;e++)t+="ABCDEFabcdef0123456789".charAt(Math.floor(22*Math.random()));return t},t}(),rt=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==nt.whichType(e))throw new Error("Geo Point must be number type");var n=Math.abs(e);if("latitude"===t&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},t.isInteger=function(t,e){if(!Number.isInteger(e))throw new Error(t+o.IntergerError);return!0},t.isFieldOrder=function(t){if(-1===m.indexOf(t))throw new Error(o.DirectionError);return!0},t.isFieldPath=function(t){if(!/^[a-zA-Z0-9-_\.]/.test(t))throw new Error;return!0},t.isOperator=function(t){if(-1===g.indexOf(t))throw new Error(o.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(o.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(o.DocIDError);return!0},t}(),ot=function(){function t(t,e){rt.isGeopoint("longitude",t),rt.isGeopoint("latitude",e),this.longitude=t,this.latitude=e}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Point",coordinates:[this.longitude,this.latitude]},e},t.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},t.prototype.toReadableString=function(){return"[".concat(this.longitude,",").concat(this.latitude,"]")},t.validate=function(t){return"Point"===t.type&&W(t.coordinates)&&rt.isGeopoint("longitude",t.coordinates[0])&&rt.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return R},enumerable:!1,configurable:!0}),t}(),it=function(){var t=function(){};if(!Promise){t.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 n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t};!function(t){t.SET="set",t.REMOVE="remove",t.INC="inc",t.MUL="mul",t.PUSH="push",t.PULL="pull",t.PULL_ALL="pullAll",t.POP="pop",t.SHIFT="shift",t.UNSHIFT="unshift",t.ADD_TO_SET="addToSet",t.BIT="bit",t.RENAME="rename",t.MAX="max",t.MIN="min"}(tt||(tt={}));var st,at=function(){function t(t,e,n){this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||O}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function ut(t){return t&&t instanceof at&&t._internalType===A}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(st||(st={}));var ct=function(){function t(t,e,n){if(this._internalType=P,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||O,this.fieldName!==O)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(lt(i=e[r])||pt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(lt(i=e)||pt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var n=this.operands.map((function(n){return n instanceof t?n._setFieldName(e):n}));return new t(this.operator,n,e)},t.prototype.and=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(st.AND,r,this.fieldName)},t.prototype.or=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(st.OR,r,this.fieldName)},t}();function lt(t){return t&&t instanceof ct&&t._internalType===P}var dt,ht=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t.EQ="eq",t.NEQ="neq",t.GT="gt",t.GTE="gte",t.LT="lt",t.LTE="lte",t.IN="in",t.NIN="nin",t.ALL="all",t.ELEM_MATCH="elemMatch",t.EXISTS="exists",t.SIZE="size",t.MOD="mod",t.GEO_NEAR="geoNear",t.GEO_WITHIN="geoWithin",t.GEO_INTERSECTS="geoIntersects"}(dt||(dt={}));var ft=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=T,o}return ht(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case dt.IN:case dt.NIN:return(t={})["$"+this.operator]=this.operands,t;default:return(e={})["$"+this.operator]=this.operands[0],e}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(dt.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(dt.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(dt.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(dt.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(dt.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(dt.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(dt.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(dt.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof ot))throw new TypeError('"geometry" must be of type Point. Received type '.concat(typeof t.geometry));if(void 0!==t.maxDistance&&!q(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '.concat(typeof t.maxDistance));if(void 0!==t.minDistance&&!q(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '.concat(typeof t.minDistance));var n=new e(dt.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof Q||t.geometry instanceof K))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(dt.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof ot||t.geometry instanceof H||t.geometry instanceof K||t.geometry instanceof Y||t.geometry instanceof z||t.geometry instanceof Q))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '.concat(typeof t.geometry));var n=new e(dt.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(ct);function pt(t){return t&&t instanceof ft&&t._internalType===T}function vt(t){return pt(t)}var yt={};for(var mt in dt)yt[mt]="$"+mt;for(var mt in st)yt[mt]="$"+mt;for(var mt in tt)yt[mt]="$"+mt;function gt(t){return yt[t]||"$"+t}yt[dt.NEQ]="$ne",yt[tt.REMOVE]="$unset",yt[tt.SHIFT]="$pop",yt[tt.UNSHIFT]="$push";var bt=function(){return bt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},bt.apply(this,arguments)},_t=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},wt=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function Et(t){return It(t,[t])}function It(t,e){if(!G(t)){if(B(t))return{$date:+t};if(F(t))return{$regex:t.source,$options:t.flags};if(W(t))return t.map((function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return It(t,wt(wt([],_t(e),!1),[t],!1))}));if(M(t)){var n=bt({},t);for(var r in n){if(e.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=It(n[r],wt(wt([],_t(e),!1),[n[r]],!1))}return n}return t}switch(t._internalType){case R:return t.toJSON();case L:case j:return t.parse();default:return t.toJSON?t.toJSON():t}}var St=function(){return St=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},St.apply(this,arguments)},Ot=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s},At=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function Tt(t,e,n,r){var o=St({},t);for(var i in t)if(!/^\$/.test(i)){var s=t[i];if(s&&M(s)&&!e(s)){if(r.indexOf(s)>-1)throw new Error("Cannot convert circular structure to JSON");var a=Tt(s,e,At(At([],Ot(n),!1),[i],!1),At(At([],Ot(r),!1),[s],!1));o[i]=a;var u=!1;for(var c in a)/^\$/.test(c)?u=!0:(o["".concat(i,".").concat(c)]=a[c],delete o[i][c]);u||delete o[i]}}return o}function Pt(t){return Tt(t,Ct,[],[t])}function Rt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?W(t[r])?t[r].push(e[r]):M(t[r])?M(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is ".concat(k(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(k(t),", can only overwrite"),t,e,n),t[r]=e[r]):t[r]=e[r]}function Ct(t){return G(t)||B(t)||F(t)}function Nt(t){return Et(t)}var Dt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return ut(t)?this.encodeUpdateCommand(t):"object"===k(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case tt.PUSH:case tt.PULL:case tt.PULL_ALL:case tt.POP:case tt.SHIFT:case tt.UNSHIFT:case tt.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=gt(t.operator);return t.operator===tt.REMOVE?((e={})[i]=((n={})[t.fieldName]="",n),e):((r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r)},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,s,a,u,c,l,d=gt(t.operator);switch(t.operator){case tt.PUSH:var h=void 0;return h=W(t.operands)?{$each:t.operands.map(Nt)}:t.operands,(e={})[d]=((n={})[t.fieldName]=h,n),e;case tt.UNSHIFT:return h={$each:t.operands.map(Nt),$position:0},(r={})[d]=((o={})[t.fieldName]=h,o),r;case tt.POP:return(i={})[d]=((s={})[t.fieldName]=1,s),i;case tt.SHIFT:return(a={})[d]=((u={})[t.fieldName]=-1,u),a;default:return(c={})[d]=((l={})[t.fieldName]=Nt(t.operands),l),c}},t.prototype.encodeUpdateObject=function(t){var e=Pt(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(ut(r))e[n]=r._setFieldName(n),Rt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=Nt(r);var o=new at(tt.SET,[r],n);Rt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Ut={};function xt(t){if(!ye.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Ut[e]||(Ut[e]=new ye.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:ye.createRequest(t.config)}}})),Ut[e]}var Lt=function(){return Lt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Lt.apply(this,arguments)},jt=function(){function t(t,e,n,r){void 0===r&&(r={});var o=this;this.watch=function(t){return xt(o._db).watch(Lt(Lt({},t),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=t,this._coll=e,this.id=n,this.request=ye.createRequest(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||it();var n=Array.isArray(t),r={collectionName:this._coll,data:n?t.map((function(t){return Et(t)})):Et(t)};return!n&&this.id&&(r._id=this.id),this.request.send("database.addDocument",r).then((function(t){var r;t.code?e(0,t):e(0,n?{ids:(null===(r=t.data)||void 0===r?void 0:r.insertedIds)||[],requestId:t.requestId}:{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||it(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof at?n=!0:"object"==typeof t[e]&&r(t[e])};if(r(t),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:a.DOC,data:Et(t),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:Dt.encode(t),query:n,queryType:a.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.remove=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(e){e.code?t(0,e):t(0,{deleted:e.data.deleted,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},t.prototype.get=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:a.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n=nt.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var n in e)e[n]?e[n]=1:e[n]=0;return new t(this._db,this._coll,this.id,e)},t}(),kt=function(){function t(){}return t.encode=function(t){return(new Mt).encodeQuery(t)},t}(),Mt=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Ct(t)?lt(t)?this.encodeLogicCommand(t):pt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):M(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,s,a,u=this;switch(t.operator){case st.NOR:case st.AND:case st.OR:var c=gt(t.operator),l=t.operands.map((function(e){return u.encodeQuery(e,t.fieldName)}));return(e={})[c]=l,e;case st.NOT:c=gt(t.operator);var d=t.operands[0];return F(d)?((n={})[t.fieldName]=((r={})[c]=this.encodeRegExp(d),r),n):(l=this.encodeQuery(d)[t.fieldName],(o={})[t.fieldName]=((i={})[c]=l,i),o);default:if(c=gt(t.operator),1===t.operands.length){var h=this.encodeQuery(t.operands[0]);return(s={})[c]=h,s}return l=t.operands.map(this.encodeQuery.bind(this)),(a={})[c]=l,a}},t.prototype.encodeQueryCommand=function(t){return vt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,s,a,u,c;if(t.fieldName===O)throw new Error("Cannot encode a comparison command with unset field name");var l=gt(t.operator);switch(t.operator){case dt.EQ:case dt.NEQ:case dt.LT:case dt.LTE:case dt.GT:case dt.GTE:case dt.ELEM_MATCH:case dt.EXISTS:case dt.SIZE:case dt.MOD:return(e={})[t.fieldName]=((n={})[l]=Nt(t.operands[0]),n),e;case dt.IN:case dt.NIN:case dt.ALL:return(r={})[t.fieldName]=((o={})[l]=Nt(t.operands),o),r;case dt.GEO_NEAR:var d=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:d.geometry.toJSON(),$maxDistance:d.maxDistance,$minDistance:d.minDistance}},i;case dt.GEO_WITHIN:return d=t.operands[0],(s={})[t.fieldName]={$geoWithin:{$geometry:d.geometry.toJSON()}},s;case dt.GEO_INTERSECTS:return d=t.operands[0],(a={})[t.fieldName]={$geoIntersects:{$geometry:d.geometry.toJSON()}},a;default:return(u={})[t.fieldName]=((c={})[l]=Nt(t.operands[0]),c),u}},t.prototype.encodeQueryObject=function(t){var e=Pt(t);for(var n in e){var r=e[n];if(lt(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else vt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Ct(r)&&(e[n]=Nt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?W(t[r])?t[r]=t[r].concat(e[r]):M(t[r])?M(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is ".concat(k(e),", can only overwrite"),e,n),t[r]=e[r]):(console.warn("to-merge query is of type ".concat(k(t),", can only overwrite"),t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),qt=function(){return qt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},qt.apply(this,arguments)},Wt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return xt(i._db).watch(qt(qt({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(t,e){return t[e.field]=e.direction,t}),{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=ye.createRequest(this._db.config)}return t.prototype.get=function(t){t=t||it();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),e.length>0&&(n.order=e),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n={data:nt.formatResDocumentData(e.data.list),requestId:e.requestId};void 0!==e.total&&(n.total=e.total),void 0!==e.limit&&(n.limit=e.limit),void 0!==e.offset&&(n.offset=e.offset),t(0,n)}})).catch((function(e){t(e)})),t.promise},t.prototype.count=function(t){t=t||it();var e={collectionName:this._coll,queryType:a.WHERE};return this._fieldFilters&&(e.query=this._fieldFilters),this._request.send("database.countDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,total:e.data.total})})).catch((function(e){t(e)})),t.promise},t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some((function(t){return void 0!==e[t]}));if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,kt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){rt.isFieldPath(e),rt.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){rt.isInteger("limit",e);var n=qt({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){rt.isInteger("offset",e);var n=qt({},this._queryOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:a.WHERE,multi:!0,merge:!0,upsert:!1,data:Dt.encode(t)};return this._request.send("database.updateDocument",n).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,updated:t.data.updated,upsertId:t.data.upsert_id})})).catch((function(t){e(t)})),e.promise},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=qt({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||it(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var e={collectionName:this._coll,query:kt.encode(this._fieldFilters),queryType:a.WHERE,multi:!0};return this._request.send("database.deleteDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,deleted:e.data.deleted})})).catch((function(e){t(e)})),t.promise},t}(),Bt=n(2701),Ft=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=ye.createRequest(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return t=this,e=void 0,r=function(){var t;return function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}(this,(function(e){switch(e.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:JSON.parse(t.data.list).map(Bt.EJSON.parse)}]:[2,t]}}))},new((n=void 0)||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}));var t,e,n,r},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e}))},t.prototype._pipe=function(t,e){return this._stages.push({stageKey:"$".concat(t),stageValue:JSON.stringify(e)}),this},t.prototype.addFields=function(t){return this._pipe("addFields",t)},t.prototype.bucket=function(t){return this._pipe("bucket",t)},t.prototype.bucketAuto=function(t){return this._pipe("bucketAuto",t)},t.prototype.count=function(t){return this._pipe("count",t)},t.prototype.geoNear=function(t){return t.query&&(t.query=kt.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new ot(t.near.longitude,t.near.latitude).toJSON()),this._pipe("geoNear",t)},t.prototype.group=function(t){return this._pipe("group",t)},t.prototype.limit=function(t){return this._pipe("limit",t)},t.prototype.match=function(t){return this._pipe("match",kt.encode(t))},t.prototype.project=function(t){return this._pipe("project",t)},t.prototype.lookup=function(t){return this._pipe("lookup",t)},t.prototype.replaceRoot=function(t){return this._pipe("replaceRoot",t)},t.prototype.sample=function(t){return this._pipe("sample",t)},t.prototype.skip=function(t){return this._pipe("skip",t)},t.prototype.sort=function(t){return this._pipe("sort",t)},t.prototype.sortByCount=function(t){return this._pipe("sortByCount",t)},t.prototype.unwind=function(t){return this._pipe("unwind",t)},t}(),Gt=Ft,Ht=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Vt=function(t){function e(e,n){return t.call(this,e,n)||this}return Ht(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new jt(this._db,this._coll,t)},e.prototype.add=function(t,e){return new jt(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new Gt(this._db,this._coll)},e}(Wt),Kt={eq:function(t){return new ft(dt.EQ,[t])},neq:function(t){return new ft(dt.NEQ,[t])},lt:function(t){return new ft(dt.LT,[t])},lte:function(t){return new ft(dt.LTE,[t])},gt:function(t){return new ft(dt.GT,[t])},gte:function(t){return new ft(dt.GTE,[t])},in:function(t){return new ft(dt.IN,t)},nin:function(t){return new ft(dt.NIN,t)},all:function(t){return new ft(dt.ALL,t)},elemMatch:function(t){return new ft(dt.ELEM_MATCH,[t])},exists:function(t){return new ft(dt.EXISTS,[t])},size:function(t){return new ft(dt.SIZE,[t])},mod:function(t){return new ft(dt.MOD,[t])},geoNear:function(t){return new ft(dt.GEO_NEAR,[t])},geoWithin:function(t){return new ft(dt.GEO_WITHIN,[t])},geoIntersects:function(t){return new ft(dt.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=W(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=W(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=W(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=W(arguments[0])?arguments[0]:Array.from(arguments);return new ct(st.NOT,n)},set:function(t){return new at(tt.SET,[t])},remove:function(){return new at(tt.REMOVE,[])},inc:function(t){return new at(tt.INC,[t])},mul:function(t){return new at(tt.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(M(e[0])&&e[0].hasOwnProperty("each")){var r=e[0];t={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else t=W(e[0])?e[0]:Array.from(e);return new at(tt.PUSH,t)},pull:function(t){return new at(tt.PULL,t)},pullAll:function(t){return new at(tt.PULL_ALL,t)},pop:function(){return new at(tt.POP,[])},shift:function(){return new at(tt.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=W(arguments[0])?arguments[0]:Array.from(arguments);return new at(tt.UNSHIFT,n)},addToSet:function(t){return new at(tt.ADD_TO_SET,t)},rename:function(t){return new at(tt.RENAME,[t])},bit:function(t){return new at(tt.BIT,[t])},max:function(t){return new at(tt.MAX,[t])},min:function(t){return new at(tt.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===k(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new Gt},abs:function(t){return new Yt("abs",t)},add:function(t){return new Yt("add",t)},ceil:function(t){return new Yt("ceil",t)},divide:function(t){return new Yt("divide",t)},exp:function(t){return new Yt("exp",t)},floor:function(t){return new Yt("floor",t)},ln:function(t){return new Yt("ln",t)},log:function(t){return new Yt("log",t)},log10:function(t){return new Yt("log10",t)},mod:function(t){return new Yt("mod",t)},multiply:function(t){return new Yt("multiply",t)},pow:function(t){return new Yt("pow",t)},sqrt:function(t){return new Yt("sqrt",t)},subtract:function(t){return new Yt("subtract",t)},trunc:function(t){return new Yt("trunc",t)},arrayElemAt:function(t){return new Yt("arrayElemAt",t)},arrayToObject:function(t){return new Yt("arrayToObject",t)},concatArrays:function(t){return new Yt("concatArrays",t)},filter:function(t){return new Yt("filter",t)},in:function(t){return new Yt("in",t)},indexOfArray:function(t){return new Yt("indexOfArray",t)},isArray:function(t){return new Yt("isArray",t)},map:function(t){return new Yt("map",t)},range:function(t){return new Yt("range",t)},reduce:function(t){return new Yt("reduce",t)},reverseArray:function(t){return new Yt("reverseArray",t)},size:function(t){return new Yt("size",t)},slice:function(t){return new Yt("slice",t)},zip:function(t){return new Yt("zip",t)},and:function(t){return new Yt("and",t)},not:function(t){return new Yt("not",t)},or:function(t){return new Yt("or",t)},cmp:function(t){return new Yt("cmp",t)},eq:function(t){return new Yt("eq",t)},gt:function(t){return new Yt("gt",t)},gte:function(t){return new Yt("gte",t)},lt:function(t){return new Yt("lt",t)},lte:function(t){return new Yt("lte",t)},neq:function(t){return new Yt("ne",t)},cond:function(t){return new Yt("cond",t)},ifNull:function(t){return new Yt("ifNull",t)},switch:function(t){return new Yt("switch",t)},dateFromParts:function(t){return new Yt("dateFromParts",t)},dateFromString:function(t){return new Yt("dateFromString",t)},dayOfMonth:function(t){return new Yt("dayOfMonth",t)},dayOfWeek:function(t){return new Yt("dayOfWeek",t)},dayOfYear:function(t){return new Yt("dayOfYear",t)},isoDayOfWeek:function(t){return new Yt("isoDayOfWeek",t)},isoWeek:function(t){return new Yt("isoWeek",t)},isoWeekYear:function(t){return new Yt("isoWeekYear",t)},millisecond:function(t){return new Yt("millisecond",t)},minute:function(t){return new Yt("minute",t)},month:function(t){return new Yt("month",t)},second:function(t){return new Yt("second",t)},hour:function(t){return new Yt("hour",t)},week:function(t){return new Yt("week",t)},year:function(t){return new Yt("year",t)},literal:function(t){return new Yt("literal",t)},mergeObjects:function(t){return new Yt("mergeObjects",t)},objectToArray:function(t){return new Yt("objectToArray",t)},allElementsTrue:function(t){return new Yt("allElementsTrue",t)},anyElementTrue:function(t){return new Yt("anyElementTrue",t)},setDifference:function(t){return new Yt("setDifference",t)},setEquals:function(t){return new Yt("setEquals",t)},setIntersection:function(t){return new Yt("setIntersection",t)},setIsSubset:function(t){return new Yt("setIsSubset",t)},setUnion:function(t){return new Yt("setUnion",t)},concat:function(t){return new Yt("concat",t)},dateToString:function(t){return new Yt("dateToString",t)},indexOfBytes:function(t){return new Yt("indexOfBytes",t)},indexOfCP:function(t){return new Yt("indexOfCP",t)},split:function(t){return new Yt("split",t)},strLenBytes:function(t){return new Yt("strLenBytes",t)},strLenCP:function(t){return new Yt("strLenCP",t)},strcasecmp:function(t){return new Yt("strcasecmp",t)},substr:function(t){return new Yt("substr",t)},substrBytes:function(t){return new Yt("substrBytes",t)},substrCP:function(t){return new Yt("substrCP",t)},toLower:function(t){return new Yt("toLower",t)},toUpper:function(t){return new Yt("toUpper",t)},meta:function(t){return new Yt("meta",t)},addToSet:function(t){return new Yt("addToSet",t)},avg:function(t){return new Yt("avg",t)},first:function(t){return new Yt("first",t)},last:function(t){return new Yt("last",t)},max:function(t){return new Yt("max",t)},min:function(t){return new Yt("min",t)},push:function(t){return new Yt("push",t)},stdDevPop:function(t){return new Yt("stdDevPop",t)},stdDevSamp:function(t){return new Yt("stdDevSamp",t)},sum:function(t){return new Yt("sum",t)},let:function(t){return new Yt("let",t)}},project:{slice:function(t){return new Jt("slice",t)},elemMatch:function(t){return new Jt("elemMatch",t)}}},Yt=function(t,e){this["$"+t]=e},Jt=function(t,e){this["$"+t]=e},zt=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=n}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!1,configurable:!0}),t}();function $t(t){return new zt(t)}var Qt="insert document failed",Xt="DATABASE_TRANSACTION_CONFLICT",Zt=function(){return Zt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Zt.apply(this,arguments)},te=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},ee=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ne="database.updateDocInTransaction",re=function(){function t(t,e,n){this._coll=e,this.id=n,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return te(this,void 0,void 0,(function(){var e,n,r,o;return ee(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:Bt.EJSON.stringify(Et(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=i.sent()).code)throw n;if(r=Bt.EJSON.parse(n.inserted),1==(o=Bt.EJSON.parse(n.ok))&&1==r)return[2,Zt(Zt({},n),{ok:o,inserted:r})];throw new Error(Qt)}}))}))},t.prototype.get=function(){return te(this,void 0,void 0,(function(){var t,e;return ee(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,{data:"null"!==e.data?nt.formatField(Bt.EJSON.parse(e.data)):Bt.EJSON.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return te(this,void 0,void 0,(function(){var e,n;return ee(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Bt.EJSON.stringify(Et(t),{relaxed:!1}),upsert:!0},[4,this._request.send(ne,e)];case 1:if((n=r.sent()).code)throw n;return[2,Zt(Zt({},n),{updated:Bt.EJSON.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return te(this,void 0,void 0,(function(){var e,n;return ee(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:Bt.EJSON.stringify(Dt.encode(t),{relaxed:!1})},[4,this._request.send(ne,e)];case 1:if((n=r.sent()).code)throw n;return[2,Zt(Zt({},n),{updated:Bt.EJSON.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return te(this,void 0,void 0,(function(){var t,e;return ee(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,Zt(Zt({},e),{deleted:Bt.EJSON.parse(e.deleted)})]}}))}))},t}(),oe=function(){return oe=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},oe.apply(this,arguments)},ie=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},se=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},ae="database.getInTransaction",ue=function(){function t(t,e,n,r,o){this._coll=e,this._transaction=t,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some((function(t){return void 0!==e[t]}));if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._transaction,this._coll,kt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){rt.isFieldPath(e),rt.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._transaction,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){rt.isInteger("limit",e);var n=oe({},this._queryOptions);return n.limit=e,new t(this._transaction,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){rt.isInteger("offset",e);var n=oe({},this._queryOptions);return n.offset=e,new t(this._transaction,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=oe({},this._queryOptions);return r.projection=e,new t(this._transaction,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.get=function(){return ie(this,void 0,void 0,(function(){var t,e,n,r,o,i;return se(this,(function(s){switch(s.label){case 0:return t=[],this._fieldOrders&&this._fieldOrders.forEach((function(e){t.push(e)})),e={collectionName:this._coll,transactionId:this._transactionId},this._fieldFilters&&(e.query=this._fieldFilters),t.length>0&&(e.order=t),this._queryOptions.offset&&(e.offset=this._queryOptions.offset),this._queryOptions.limit?e.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:e.limit=100,this._queryOptions.projection&&(e.projection=this._queryOptions.projection),[4,this._request.send(ae,e)];case 1:if((n=s.sent()).code)throw n;return r="null"!==n.data?Bt.EJSON.parse(n.data):null,o=r?Array.isArray(r)?nt.formatResDocumentData(r):[nt.formatField(r)]:[],i={data:o,requestId:n.requestId},void 0!==n.total&&(i.total=n.total),void 0!==n.limit&&(i.limit=n.limit),void 0!==n.offset&&(i.offset=n.offset),[2,i]}}))}))},t.prototype.count=function(){return ie(this,void 0,void 0,(function(){var t,e,n,r;return se(this,(function(o){switch(o.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId},this._fieldFilters&&(t.query=this._fieldFilters),[4,this._request.send(ae,t)];case 1:if((e=o.sent()).code)throw e;return n="null"!==e.data?Bt.EJSON.parse(e.data):null,r=Array.isArray(n)?n.length:n?1:0,[2,{requestId:e.requestId,total:void 0!==e.total?e.total:r}]}}))}))},t.prototype.update=function(t){return ie(this,void 0,void 0,(function(){var e,n;return se(this,(function(r){switch(r.label){case 0:if(!t||"object"!=typeof t)throw new Error("参数必需是非空对象");if(t.hasOwnProperty("_id"))throw new Error("不能更新_id的值");return e={collectionName:this._coll,transactionId:this._transactionId,query:this._fieldFilters,data:Bt.EJSON.stringify(Dt.encode(t),{relaxed:!1})},[4,this._request.send("database.updateDocInTransaction",e)];case 1:if((n=r.sent()).code)throw n;return[2,oe(oe({},n),{updated:Bt.EJSON.parse(n.updated)})]}}))}))},t.prototype.remove=function(){return ie(this,void 0,void 0,(function(){var t,e;return se(this,(function(n){switch(n.label){case 0:return Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation"),t={collectionName:this._coll,transactionId:this._transactionId,query:this._fieldFilters},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,oe(oe({},e),{deleted:Bt.EJSON.parse(e.deleted)})]}}))}))},t}(),ce=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),le=function(t){function e(e,n){return t.call(this,e,n)||this}return ce(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new re(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new re(this._transaction,this._coll,e).create(t)},e}(ue),de=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},he=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},fe=function(){function t(t){this._db=t,this._request=ye.createRequest(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return de(this,void 0,void 0,(function(){var t;return he(this,(function(e){switch(e.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((t=e.sent()).code)throw t;return this.inited=!0,this._id=t.transactionId,[2]}}))}))},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new le(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return de(this,void 0,void 0,(function(){var t,e;return he(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=n.sent()).code)throw e;return this.commited=!0,[2,e]}}))}))},t.prototype.rollback=function(t){return de(this,void 0,void 0,(function(){var e,n;return he(this,(function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=t,[2,n]}}))}))},t}();function pe(){return de(this,void 0,void 0,(function(){var t;return he(this,(function(e){switch(e.label){case 0:return[4,(t=new fe(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function ve(t,e){return void 0===e&&(e=3),de(this,void 0,void 0,(function(){var n,r,o,i,s=this;return he(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,10]),[4,(n=new fe(this)).init()];case 1:return a.sent(),[4,t(n)];case 2:if(r=a.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return a.sent(),[2,r];case 4:if(o=a.sent(),!1===n.inited)throw o;return i=function(t){return de(s,void 0,void 0,(function(){return he(this,(function(e){switch(e.label){case 0:if(n.aborted||n.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===n.aborted)throw n.abortReason;throw t}}))}))},e<=0?[4,i(o)]:[3,6];case 5:a.sent(),a.label=6;case 6:return o&&o.code===Xt?[4,ve.bind(this)(t,--e)]:[3,8];case 7:return[2,a.sent()];case 8:return[4,i(o)];case 9:return a.sent(),[3,10];case 10:return[2]}}))}))}var ye=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=Z,this.command=Kt,this.RegExp=$t,this.startTransaction=pe,this.runTransaction=ve,this.logicCommand=ct,this.updateCommand=at,this.queryCommand=ft}return t.createRequest=function(e){var n=new t.reqClass(e),r=n.send;return n.send=function(t,n){return e.instance&&(n.instance=e.instance),e.database&&(n.database=e.database),r.call(this,t,n)},n},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new Vt(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return t.createRequest(this.config).send("database.addCollection",n)},t}()},3388:function(t){t.exports={}},1012:function(t,e,n){"use strict";var r;if(n.r(e),!globalThis.IS_MP_BUILD){var o="undefined"!=typeof globalThis?globalThis.navigator:window.globalThis,i="0123456789abcdefghijklmnopqrstuvwxyz";function k(t){return i.charAt(t)}function M(t,e){return t&e}function q(t,e){return t|e}function W(t,e){return t^e}function B(t,e){return t&~e}function F(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function G(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function H(t){var e,n,r="";for(e=0;e+3<=t.length;e+=3)n=parseInt(t.substring(e,e+3),16),r+=s.charAt(n>>6)+s.charAt(63&n);for(e+1==t.length?(n=parseInt(t.substring(e,e+1),16),r+=s.charAt(n<<2)):e+2==t.length&&(n=parseInt(t.substring(e,e+2),16),r+=s.charAt(n>>2)+s.charAt((3&n)<<4));(3&r.length)>0;)r+="=";return r}function V(t){var e,n="",r=0,o=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var i=s.indexOf(t.charAt(e));i<0||(0==r?(n+=k(i>>2),o=3&i,r=1):1==r?(n+=k(o<<2|i>>4),o=15&i,r=2):2==r?(n+=k(o),n+=k(i>>2),o=3&i,r=3):(n+=k(o<<2|i>>4),n+=k(15&i),r=0))}return 1==r&&(n+=k(o<<2)),n}var a,u,c={decode:function(t){var e;if(void 0===a){var n="0123456789ABCDEF";for(a={},e=0;e<16;++e)a[n.charAt(e)]=e;for(n=n.toLowerCase(),e=10;e<16;++e)a[n.charAt(e)]=e;for(e=0;e<8;++e)a[" \f\n\r\t \u2028\u2029".charAt(e)]=-1}var r=[],o=0,i=0;for(e=0;e<t.length;++e){var s=t.charAt(e);if("="==s)break;if(-1!=(s=a[s])){if(void 0===s)throw new Error("Illegal character at offset "+e);o|=s,++i>=2?(r[r.length]=o,o=0,i=0):o<<=4}}if(i)throw new Error("Hex encoding incomplete: 4 bits missing");return r}},l={decode:function(t){var e;if(void 0===u){for(u=Object.create(null),e=0;e<64;++e)u["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<9;++e)u["= \f\n\r\t \u2028\u2029".charAt(e)]=-1}var n=[],r=0,o=0;for(e=0;e<t.length;++e){var i=t.charAt(e);if("="==i)break;if(-1!=(i=u[i])){if(void 0===i)throw new Error("Illegal character at offset "+e);r|=i,++o>=4?(n[n.length]=r>>16,n[n.length]=r>>8&255,n[n.length]=255&r,r=0,o=0):r<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:n[n.length]=r>>10;break;case 3:n[n.length]=r>>16,n[n.length]=r>>8&255}return n},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=l.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return l.decode(t)}},d=1e13;class K{constructor(t){this.buf=[+t||0]}mulAdd(t,e){var n,r,o=this.buf,i=o.length;for(n=0;n<i;++n)(r=o[n]*t+e)<d?e=0:r-=(e=0|r/d)*d,o[n]=r;e>0&&(o[n]=e)}sub(t){var e,n,r=this.buf,o=r.length;for(e=0;e<o;++e)(n=r[e]-t)<0?(n+=d,t=1):t=0,r[e]=n;for(;0===r[r.length-1];)r.pop()}toString(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,n=e[e.length-1].toString(),r=e.length-2;r>=0;--r)n+=(d+e[r]).toString().substring(1);return n}valueOf(){for(var t=this.buf,e=0,n=t.length-1;n>=0;--n)e=e*d+t[n];return e}simplify(){var t=this.buf;return 1==t.length?t[0]:this}}var h,f=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,p=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function Y(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}class J{constructor(t,e){this.hexDigits="0123456789ABCDEF",t instanceof J?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}get(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]}hexByte(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)}hexDump(t,e,n){for(var r="",o=t;o<e;++o)if(r+=this.hexByte(this.get(o)),!0!==n)switch(15&o){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r}isASCII(t,e){for(var n=t;n<e;++n){var r=this.get(n);if(r<32||r>176)return!1}return!0}parseStringISO(t,e){for(var n="",r=t;r<e;++r)n+=String.fromCharCode(this.get(r));return n}parseStringUTF(t,e){for(var n="",r=t;r<e;){var o=this.get(r++);n+=o<128?String.fromCharCode(o):o>191&&o<224?String.fromCharCode((31&o)<<6|63&this.get(r++)):String.fromCharCode((15&o)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return n}parseStringBMP(t,e){for(var n,r,o="",i=t;i<e;)n=this.get(i++),r=this.get(i++),o+=String.fromCharCode(n<<8|r);return o}parseTime(t,e,n){var r=this.parseStringISO(t,e),o=(n?f:p).exec(r);return o?(n&&(o[1]=+o[1],o[1]+=+o[1]<70?2e3:1900),r=o[1]+"-"+o[2]+"-"+o[3]+" "+o[4],o[5]&&(r+=":"+o[5],o[6]&&(r+=":"+o[6],o[7]&&(r+="."+o[7]))),o[8]&&(r+=" UTC","Z"!=o[8]&&(r+=o[8],o[9]&&(r+=":"+o[9]))),r):"Unrecognized time: "+r}parseInteger(t,e){for(var n,r=this.get(t),o=r>127,i=o?255:0,s="";r==i&&++t<e;)r=this.get(t);if(0==(n=e-t))return o?-1:0;if(n>4){for(s=r,n<<=3;!(128&(+s^i));)s=+s<<1,--n;s="("+n+" bit)\n"}o&&(r-=256);for(var a=new K(r),u=t+1;u<e;++u)a.mulAdd(256,this.get(u));return s+a.toString()}parseBitString(t,e,n){for(var r=this.get(t),o="("+((e-t-1<<3)-r)+" bit)\n",i="",s=t+1;s<e;++s){for(var a=this.get(s),u=s==e-1?r:0,c=7;c>=u;--c)i+=a>>c&1?"1":"0";if(i.length>n)return o+Y(i,n)}return o+i}parseOctetString(t,e,n){if(this.isASCII(t,e))return Y(this.parseStringISO(t,e),n);var r=e-t,o="("+r+" byte)\n";r>(n/=2)&&(e=t+n);for(var i=t;i<e;++i)o+=this.hexByte(this.get(i));return r>n&&(o+="…"),o}parseOID(t,e,n){for(var r="",o=new K,i=0,s=t;s<e;++s){var a=this.get(s);if(o.mulAdd(128,127&a),i+=7,!(128&a)){if(""===r)if((o=o.simplify())instanceof K)o.sub(80),r="2."+o.toString();else{var u=o<80?o<40?0:1:2;r=u+"."+(o-40*u)}else r+="."+o.toString();if(r.length>n)return Y(r,n);o=new K,i=0}}return i>0&&(r+=".incomplete"),r}}class z{constructor(t,e,n,r,o){if(!(r instanceof $))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=n,this.tag=r,this.sub=o}typeName(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}}content(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),n=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+n);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+n,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);case 6:return this.stream.parseOID(e,e+n,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return Y(this.stream.parseStringUTF(e,e+n),t);case 18:case 19:case 20:case 21:case 22:case 26:return Y(this.stream.parseStringISO(e,e+n),t);case 30:return Y(this.stream.parseStringBMP(e,e+n),t);case 23:case 24:return this.stream.parseTime(e,e+n,23==this.tag.tagNumber)}return null}toString(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"}toPrettyString(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var n=0,r=this.sub.length;n<r;++n)e+=this.sub[n].toPrettyString(t)}return e}posStart(){return this.stream.pos}posContent(){return this.stream.pos+this.header}posEnd(){return this.stream.pos+this.header+Math.abs(this.length)}toHexString(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)}static decodeLength(t){var e=t.get(),n=127&e;if(n==e)return n;if(n>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===n)return null;e=0;for(var r=0;r<n;++r)e=256*e+t.get();return e}getHexStringValue(){var t=this.toHexString(),e=2*this.header,n=2*this.length;return t.substr(e,n)}static decode(t){var e;e=t instanceof J?t:new J(t,0);var n=new J(e),r=new $(e),o=z.decodeLength(e),i=e.pos,s=i-n.pos,a=null,u=function(){var t=[];if(null!==o){for(var n=i+o;e.pos<n;)t[t.length]=z.decode(e);if(e.pos!=n)throw new Error("Content size is not correct for container starting at offset "+i)}else try{for(;;){var r=z.decode(e);if(r.tag.isEOC())break;t[t.length]=r}o=i-e.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(r.tagConstructed)a=u();else if(r.isUniversal()&&(3==r.tagNumber||4==r.tagNumber))try{if(3==r.tagNumber&&0!=e.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+i);e.pos=i+Math.abs(o)}return new z(n,s,o,r,a)}}class ${constructor(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=!!(32&e),this.tagNumber=31&e,31==this.tagNumber){var n=new K;do{e=t.get(),n.mulAdd(128,127&e)}while(128&e);this.tagNumber=n.simplify()}}isUniversal(){return 0===this.tagClass}isEOC(){return 0===this.tagClass&&0===this.tagNumber}}var v=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],y=(1<<26)/v[v.length-1];class Q{constructor(t,e,n){null!=t&&("number"==typeof t?this.fromNumber(t,e,n):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}toString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var n,r=(1<<e)-1,o=!1,i="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(n=this[s]>>a)>0&&(o=!0,i=k(n));s>=0;)a<e?(n=(this[s]&(1<<a)-1)<<e-a,n|=this[--s]>>(a+=this.DB-e)):(n=this[s]>>(a-=e)&r,a<=0&&(a+=this.DB,--s)),n>0&&(o=!0),o&&(i+=k(n));return o?i:"0"}negate(){var t=X();return Q.ZERO.subTo(this,t),t}abs(){return this.s<0?this.negate():this}compareTo(t){var e=this.s-t.s;if(0!=e)return e;var n=this.t;if(0!=(e=n-t.t))return this.s<0?-e:e;for(;--n>=0;)if(0!=(e=this[n]-t[n]))return e;return 0}bitLength(){return this.t<=0?0:this.DB*(this.t-1)+it(this[this.t-1]^this.s&this.DM)}mod(t){var e=X();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(Q.ZERO)>0&&t.subTo(e,e),e}modPowInt(t,e){var n;return n=t<256||e.isEven()?new g(e):new b(e),this.exp(t,n)}clone(){var t=X();return this.copyTo(t),t}intValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]}byteValue(){return 0==this.t?this.s:this[0]<<24>>24}shortValue(){return 0==this.t?this.s:this[0]<<16>>16}signum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}toByteArray(){var t=this.t,e=[];e[0]=this.s;var n,r=this.DB-t*this.DB%8,o=0;if(t-- >0)for(r<this.DB&&(n=this[t]>>r)!=(this.s&this.DM)>>r&&(e[o++]=n|this.s<<this.DB-r);t>=0;)r<8?(n=(this[t]&(1<<r)-1)<<8-r,n|=this[--t]>>(r+=this.DB-8)):(n=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),128&n&&(n|=-256),0==o&&(128&this.s)!=(128&n)&&++o,(o>0||n!=this.s)&&(e[o++]=n);return e}equals(t){return 0==this.compareTo(t)}min(t){return this.compareTo(t)<0?this:t}max(t){return this.compareTo(t)>0?this:t}and(t){var e=X();return this.bitwiseTo(t,M,e),e}or(t){var e=X();return this.bitwiseTo(t,q,e),e}xor(t){var e=X();return this.bitwiseTo(t,W,e),e}andNot(t){var e=X();return this.bitwiseTo(t,B,e),e}not(){for(var t=X(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t}shiftLeft(t){var e=X();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}shiftRight(t){var e=X();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}getLowestSetBit(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+F(this[t]);return this.s<0?this.t*this.DB:-1}bitCount(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=G(this[n]^e);return t}testBit(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)}setBit(t){return this.changeBit(t,q)}clearBit(t){return this.changeBit(t,B)}flipBit(t){return this.changeBit(t,W)}add(t){var e=X();return this.addTo(t,e),e}subtract(t){var e=X();return this.subTo(t,e),e}multiply(t){var e=X();return this.multiplyTo(t,e),e}divide(t){var e=X();return this.divRemTo(t,e,null),e}remainder(t){var e=X();return this.divRemTo(t,null,e),e}divideAndRemainder(t){var e=X(),n=X();return this.divRemTo(t,e,n),[e,n]}modPow(t,e){var n,r,o=t.bitLength(),i=ot(1);if(o<=0)return i;n=o<18?1:o<48?3:o<144?4:o<768?5:6,r=o<8?new g(e):e.isEven()?new _(e):new b(e);var s=[],a=3,u=n-1,c=(1<<n)-1;if(s[1]=r.convert(this),n>1){var l=X();for(r.sqrTo(s[1],l);a<=c;)s[a]=X(),r.mulTo(l,s[a-2],s[a]),a+=2}var d,h,f=t.t-1,p=!0,v=X();for(o=it(t[f])-1;f>=0;){for(o>=u?d=t[f]>>o-u&c:(d=(t[f]&(1<<o+1)-1)<<u-o,f>0&&(d|=t[f-1]>>this.DB+o-u)),a=n;!(1&d);)d>>=1,--a;if((o-=a)<0&&(o+=this.DB,--f),p)s[d].copyTo(i),p=!1;else{for(;a>1;)r.sqrTo(i,v),r.sqrTo(v,i),a-=2;a>0?r.sqrTo(i,v):(h=i,i=v,v=h),r.mulTo(v,s[d],i)}for(;f>=0&&!(t[f]&1<<o);)r.sqrTo(i,v),h=i,i=v,v=h,--o<0&&(o=this.DB-1,--f)}return r.revert(i)}modInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return Q.ZERO;for(var n=t.clone(),r=this.clone(),o=ot(1),i=ot(0),s=ot(0),a=ot(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),e?(o.isEven()&&i.isEven()||(o.addTo(this,o),i.subTo(t,i)),o.rShiftTo(1,o)):i.isEven()||i.subTo(t,i),i.rShiftTo(1,i);for(;r.isEven();)r.rShiftTo(1,r),e?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);n.compareTo(r)>=0?(n.subTo(r,n),e&&o.subTo(s,o),i.subTo(a,i)):(r.subTo(n,r),e&&s.subTo(o,s),a.subTo(i,a))}return 0!=r.compareTo(Q.ONE)?Q.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a}pow(t){return this.exp(t,new m)}gcd(t){var e=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(e.compareTo(n)<0){var r=e;e=n,n=r}var o=e.getLowestSetBit(),i=n.getLowestSetBit();if(i<0)return e;for(o<i&&(i=o),i>0&&(e.rShiftTo(i,e),n.rShiftTo(i,n));e.signum()>0;)(o=e.getLowestSetBit())>0&&e.rShiftTo(o,e),(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n));return i>0&&n.lShiftTo(i,n),n}isProbablePrime(t){var e,n=this.abs();if(1==n.t&&n[0]<=v[v.length-1]){for(e=0;e<v.length;++e)if(n[0]==v[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<v.length;){for(var r=v[e],o=e+1;o<v.length&&r<y;)r*=v[o++];for(r=n.modInt(r);e<o;)if(r%v[e++]==0)return!1}return n.millerRabin(t)}copyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}fromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}fromString(t,e){var n;if(16==e)n=4;else if(8==e)n=3;else if(256==e)n=8;else if(2==e)n=1;else if(32==e)n=5;else{if(4!=e)return void this.fromRadix(t,e);n=2}this.t=0,this.s=0;for(var r=t.length,o=!1,i=0;--r>=0;){var s=8==n?255&+t[r]:rt(t,r);s<0?"-"==t.charAt(r)&&(o=!0):(o=!1,0==i?this[this.t++]=s:i+n>this.DB?(this[this.t-1]|=(s&(1<<this.DB-i)-1)<<i,this[this.t++]=s>>this.DB-i):this[this.t-1]|=s<<i,(i+=n)>=this.DB&&(i-=this.DB))}8==n&&128&+t[0]&&(this.s=-1,i>0&&(this[this.t-1]|=(1<<this.DB-i)-1<<i)),this.clamp(),o&&Q.ZERO.subTo(this,this)}clamp(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t}dlShiftTo(t,e){var n;for(n=this.t-1;n>=0;--n)e[n+t]=this[n];for(n=t-1;n>=0;--n)e[n]=0;e.t=this.t+t,e.s=this.s}drShiftTo(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s}lShiftTo(t,e){for(var n=t%this.DB,r=this.DB-n,o=(1<<r)-1,i=Math.floor(t/this.DB),s=this.s<<n&this.DM,a=this.t-1;a>=0;--a)e[a+i+1]=this[a]>>r|s,s=(this[a]&o)<<n;for(a=i-1;a>=0;--a)e[a]=0;e[i]=s,e.t=this.t+i+1,e.s=this.s,e.clamp()}rShiftTo(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t)e.t=0;else{var r=t%this.DB,o=this.DB-r,i=(1<<r)-1;e[0]=this[n]>>r;for(var s=n+1;s<this.t;++s)e[s-n-1]|=(this[s]&i)<<o,e[s-n]=this[s]>>r;r>0&&(e[this.t-n-1]|=(this.s&i)<<o),e.t=this.t-n,e.clamp()}}subTo(t,e){for(var n=0,r=0,o=Math.min(t.t,this.t);n<o;)r+=this[n]-t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r-=t[n],e[n++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[n++]=this.DV+r:r>0&&(e[n++]=r),e.t=n,e.clamp()}multiplyTo(t,e){var n=this.abs(),r=t.abs(),o=n.t;for(e.t=o+r.t;--o>=0;)e[o]=0;for(o=0;o<r.t;++o)e[o+n.t]=n.am(0,r[o],e,o,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&Q.ZERO.subTo(e,e)}squareTo(t){for(var e=this.abs(),n=t.t=2*e.t;--n>=0;)t[n]=0;for(n=0;n<e.t-1;++n){var r=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,r,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()}divRemTo(t,e,n){var r=t.abs();if(!(r.t<=0)){var o=this.abs();if(o.t<r.t)return null!=e&&e.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=X());var i=X(),s=this.s,a=t.s,u=this.DB-it(r[r.t-1]);u>0?(r.lShiftTo(u,i),o.lShiftTo(u,n)):(r.copyTo(i),o.copyTo(n));var c=i.t,l=i[c-1];if(0!=l){var d=l*(1<<this.F1)+(c>1?i[c-2]>>this.F2:0),h=this.FV/d,f=(1<<this.F1)/d,p=1<<this.F2,v=n.t,y=v-c,m=null==e?X():e;for(i.dlShiftTo(y,m),n.compareTo(m)>=0&&(n[n.t++]=1,n.subTo(m,n)),Q.ONE.dlShiftTo(c,m),m.subTo(i,i);i.t<c;)i[i.t++]=0;for(;--y>=0;){var g=n[--v]==l?this.DM:Math.floor(n[v]*h+(n[v-1]+p)*f);if((n[v]+=i.am(0,g,n,y,0,c))<g)for(i.dlShiftTo(y,m),n.subTo(m,n);n[v]<--g;)n.subTo(m,n)}null!=e&&(n.drShiftTo(c,e),s!=a&&Q.ZERO.subTo(e,e)),n.t=c,n.clamp(),u>0&&n.rShiftTo(u,n),s<0&&Q.ZERO.subTo(n,n)}}}invDigit(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}isEven(){return 0==(this.t>0?1&this[0]:this.s)}exp(t,e){if(t>4294967295||t<1)return Q.ONE;var n=X(),r=X(),o=e.convert(this),i=it(t)-1;for(o.copyTo(n);--i>=0;)if(e.sqrTo(n,r),(t&1<<i)>0)e.mulTo(r,o,n);else{var s=n;n=r,r=s}return e.revert(n)}chunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}toRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),r=ot(n),o=X(),i=X(),s="";for(this.divRemTo(r,o,i);o.signum()>0;)s=(n+i.intValue()).toString(t).substr(1)+s,o.divRemTo(r,o,i);return i.intValue().toString(t)+s}fromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var n=this.chunkSize(e),r=Math.pow(e,n),o=!1,i=0,s=0,a=0;a<t.length;++a){var u=rt(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(o=!0):(s=e*s+u,++i>=n&&(this.dMultiply(r),this.dAddOffset(s,0),i=0,s=0))}i>0&&(this.dMultiply(Math.pow(e,i)),this.dAddOffset(s,0)),o&&Q.ZERO.subTo(this,this)}fromNumber(t,e,n){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(Q.ONE.shiftLeft(t-1),q,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(Q.ONE.shiftLeft(t-1),this);else{var r=[],o=7&t;r.length=1+(t>>3),e.nextBytes(r),o>0?r[0]&=(1<<o)-1:r[0]=0,this.fromString(r,256)}}bitwiseTo(t,e,n){var r,o,i=Math.min(t.t,this.t);for(r=0;r<i;++r)n[r]=e(this[r],t[r]);if(t.t<this.t){for(o=t.s&this.DM,r=i;r<this.t;++r)n[r]=e(this[r],o);n.t=this.t}else{for(o=this.s&this.DM,r=i;r<t.t;++r)n[r]=e(o,t[r]);n.t=t.t}n.s=e(this.s,t.s),n.clamp()}changeBit(t,e){var n=Q.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n}addTo(t,e){for(var n=0,r=0,o=Math.min(t.t,this.t);n<o;)r+=this[n]+t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r+=t[n],e[n++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[n++]=r:r<-1&&(e[n++]=this.DV+r),e.t=n,e.clamp()}dMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}dAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}multiplyLowerTo(t,e,n){var r=Math.min(this.t+t.t,e);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(var o=n.t-this.t;r<o;++r)n[r+this.t]=this.am(0,t[r],n,r,0,this.t);for(o=Math.min(t.t,e);r<o;++r)this.am(0,t[r],n,r,0,e-r);n.clamp()}multiplyUpperTo(t,e,n){--e;var r=n.t=this.t+t.t-e;for(n.s=0;--r>=0;)n[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)n[this.t+r-e]=this.am(e-r,t[r],n,0,0,this.t+r-e);n.clamp(),n.drShiftTo(1,n)}modInt(t){if(t<=0)return 0;var e=this.DV%t,n=this.s<0?t-1:0;if(this.t>0)if(0==e)n=this[0]%t;else for(var r=this.t-1;r>=0;--r)n=(e*n+this[r])%t;return n}millerRabin(t){var e=this.subtract(Q.ONE),n=e.getLowestSetBit();if(n<=0)return!1;var r=e.shiftRight(n);(t=t+1>>1)>v.length&&(t=v.length);for(var o=X(),i=0;i<t;++i){o.fromInt(v[Math.floor(Math.random()*v.length)]);var s=o.modPow(r,this);if(0!=s.compareTo(Q.ONE)&&0!=s.compareTo(e)){for(var a=1;a++<n&&0!=s.compareTo(e);)if(0==(s=s.modPowInt(2,this)).compareTo(Q.ONE))return!1;if(0!=s.compareTo(e))return!1}}return!0}square(){var t=X();return this.squareTo(t),t}gcda(t,e){var n=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(n.compareTo(r)<0){var o=n;n=r,r=o}var i=n.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)e(n);else{i<s&&(s=i),s>0&&(n.rShiftTo(s,n),r.rShiftTo(s,r));var a=()=>{(i=n.getLowestSetBit())>0&&n.rShiftTo(i,n),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),n.compareTo(r)>=0?(n.subTo(r,n),n.rShiftTo(1,n)):(r.subTo(n,r),r.rShiftTo(1,r)),n.signum()>0?setTimeout(a,0):(s>0&&r.lShiftTo(s,r),setTimeout((function(){e(r)}),0))};setTimeout(a,10)}}fromNumberAsync(t,e,n,r){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(Q.ONE.shiftLeft(t-1),q,this),this.isEven()&&this.dAddOffset(1,0);var o=this,i=function(){o.dAddOffset(2,0),o.bitLength()>t&&o.subTo(Q.ONE.shiftLeft(t-1),o),o.isProbablePrime(e)?setTimeout((function(){r()}),0):setTimeout(i,0)};setTimeout(i,0)}else{var s=[],a=7&t;s.length=1+(t>>3),e.nextBytes(s),a>0?s[0]&=(1<<a)-1:s[0]=0,this.fromString(s,256)}}}var m=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),g=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),b=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=X();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(Q.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=X();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var n=32767&t[e],r=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[n=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),_=function(){function t(t){this.m=t,this.r2=X(),this.q3=X(),Q.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=X();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function X(){return new Q(null)}function Z(t,e){return new Q(t,e)}function tt(t,e,n,r,o,i){for(;--i>=0;){var s=e*this[t++]+n[r]+o;o=Math.floor(s/67108864),n[r++]=67108863&s}return o}function et(t,e,n,r,o,i){for(var s=32767&e,a=e>>15;--i>=0;){var u=32767&this[t],c=this[t++]>>15,l=a*u+c*s;o=((u=s*u+((32767&l)<<15)+n[r]+(1073741823&o))>>>30)+(l>>>15)+a*c+(o>>>30),n[r++]=1073741823&u}return o}function nt(t,e,n,r,o,i){for(var s=16383&e,a=e>>14;--i>=0;){var u=16383&this[t],c=this[t++]>>14,l=a*u+c*s;o=((u=s*u+((16383&l)<<14)+n[r]+o)>>28)+(l>>14)+a*c,n[r++]=268435455&u}return o}void 0!==o&&"Microsoft Internet Explorer"==(null==o?void 0:o.appName)?(Q.prototype.am=et,h=30):"Netscape"!=(null==o?void 0:o.appName)?(Q.prototype.am=tt,h=26):(Q.prototype.am=nt,h=28),Q.prototype.DB=h,Q.prototype.DM=(1<<h)-1,Q.prototype.DV=1<<h,Q.prototype.FV=Math.pow(2,52),Q.prototype.F1=52-h,Q.prototype.F2=2*h-52;var w,E,I=[];for(w="0".charCodeAt(0),E=0;E<=9;++E)I[w++]=E;for(w="a".charCodeAt(0),E=10;E<36;++E)I[w++]=E;for(w="A".charCodeAt(0),E=10;E<36;++E)I[w++]=E;function rt(t,e){var n=I[t.charCodeAt(e)];return null==n?-1:n}function ot(t){var e=X();return e.fromInt(t),e}function it(t){var e,n=1;return 0!=(e=t>>>16)&&(t=e,n+=16),0!=(e=t>>8)&&(t=e,n+=8),0!=(e=t>>4)&&(t=e,n+=4),0!=(e=t>>2)&&(t=e,n+=2),0!=(e=t>>1)&&(t=e,n+=1),n}Q.ZERO=ot(0),Q.ONE=ot(1);class st{constructor(){this.i=0,this.j=0,this.S=[]}init(t){var e,n,r;for(e=0;e<256;++e)this.S[e]=e;for(n=0,e=0;e<256;++e)n=n+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[n],this.S[n]=r;this.i=0,this.j=0}next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}}var S,O,A=null;if(null==A){A=[],O=0;var T,P,R=void 0;if("undefined"!=typeof window&&null!==(T=window)&&void 0!==T&&T.crypto&&null!==(P=window)&&void 0!==P&&P.crypto.getRandomValues){var C,N=new Uint32Array(256);for(null===(C=window)||void 0===C||C.crypto.getRandomValues(N),R=0;R<N.length;++R)A[O++]=255&N[R]}var D,U,x,L=function(t){var e,n,r;if(this.count=this.count||0,this.count>=256||O>=256){if("undefined"!=typeof window)if(null!==(e=window)&&void 0!==e&&e.removeEventListener)null===(r=window)||void 0===r||r.removeEventListener("mousemove",L,!1);else if(null!==(n=window)&&void 0!==n&&n.detachEvent){var o;null===(o=window)||void 0===o||o.detachEvent("onmousemove",L)}}else try{var i=t.x+t.y;A[O++]=255&i,this.count+=1}catch(t){}};if("undefined"!=typeof window)if(null!==(D=window)&&void 0!==D&&D.addEventListener)null===(x=window)||void 0===x||x.addEventListener("mousemove",L,!1);else if(null!==(U=window)&&void 0!==U&&U.attachEvent){var j;null===(j=window)||void 0===j||j.attachEvent("onmousemove",L)}}function at(){if(null==S){for(S=new st;O<256;){var t=Math.floor(65536*Math.random());A[O++]=255&t}for(S.init(A),O=0;O<A.length;++O)A[O]=0;O=0}return S.next()}class ut{constructor(){}nextBytes(t){for(var e=0;e<t.length;++e)t[e]=at()}}function ct(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var n=[],r=t.length-1;r>=0&&e>0;){var o=t.charCodeAt(r--);o<128?n[--e]=o:o>127&&o<2048?(n[--e]=63&o|128,n[--e]=o>>6|192):(n[--e]=63&o|128,n[--e]=o>>6&63|128,n[--e]=o>>12|224)}n[--e]=0;for(var i=new ut,s=[];e>2;){for(s[0]=0;0==s[0];)i.nextBytes(s);n[--e]=s[0]}return n[--e]=2,n[--e]=0,new Q(n)}class lt{constructor(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}doPublic(t){return t.modPowInt(this.e,this.n)}doPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),n=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(n)<0;)e=e.add(this.p);return e.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)}setPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=Z(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}encrypt(t){var e=ct(t,this.n.bitLength()+7>>3);if(null==e)return null;var n=this.doPublic(e);if(null==n)return null;var r=n.toString(16);return 1&r.length?"0"+r:r}encryptLong(t){var e=this,n=(this.n.bitLength()+7>>3)-11;try{var r="";return t.length>n?(t.match(/.{1,117}/g).forEach((function(t){var n=e.encrypt(t);r+=n})),H(r)):H(this.encrypt(t))}catch(t){return!1}}decryptLong(t){var e=this,n=this.n.bitLength()+7>>3;t=V(t);try{if(t.length>n){var r="";return t.match(/.{1,256}/g).forEach((function(t){var n=e.decrypt(t);r+=n})),r}return this.decrypt(t)}catch(t){return!1}}setPrivate(t,e,n){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=Z(t,16),this.e=parseInt(e,16),this.d=Z(n,16)):console.error("Invalid RSA private key")}setPrivateEx(t,e,n,r,o,i,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=Z(t,16),this.e=parseInt(e,16),this.d=Z(n,16),this.p=Z(r,16),this.q=Z(o,16),this.dmp1=Z(i,16),this.dmq1=Z(s,16),this.coeff=Z(a,16)):console.error("Invalid RSA private key")}generate(t,e){var n=new ut,r=t>>1;this.e=parseInt(e,16);for(var o=new Q(e,16);;){for(;this.p=new Q(t-r,1,n),0!=this.p.subtract(Q.ONE).gcd(o).compareTo(Q.ONE)||!this.p.isProbablePrime(10););for(;this.q=new Q(r,1,n),0!=this.q.subtract(Q.ONE).gcd(o).compareTo(Q.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q,this.q=i}var s=this.p.subtract(Q.ONE),a=this.q.subtract(Q.ONE),u=s.multiply(a);if(0==u.gcd(o).compareTo(Q.ONE)){this.n=this.p.multiply(this.q),this.d=o.modInverse(u),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}}decrypt(t){var e=Z(t,16),n=this.doPrivate(e);return null==n?null:dt(n,this.n.bitLength()+7>>3)}generateAsync(t,e,n){var r=new ut,o=t>>1;this.e=parseInt(e,16);var i=new Q(e,16),s=this,a=()=>{var e=()=>{if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract(Q.ONE),r=s.q.subtract(Q.ONE),o=e.multiply(r);0==o.gcd(i).compareTo(Q.ONE)?(s.n=s.p.multiply(s.q),s.d=i.modInverse(o),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(r),s.coeff=s.q.modInverse(s.p),setTimeout((function(){n()}),0)):setTimeout(a,0)},u=()=>{s.q=X(),s.q.fromNumberAsync(o,1,r,(function(){s.q.subtract(Q.ONE).gcda(i,(function(t){0==t.compareTo(Q.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(u,0)}))}))},c=()=>{s.p=X(),s.p.fromNumberAsync(t-o,1,r,(function(){s.p.subtract(Q.ONE).gcda(i,(function(t){0==t.compareTo(Q.ONE)&&s.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(c,0)}))}))};setTimeout(c,0)};setTimeout(a,0)}}function dt(t,e){for(var n=t.toByteArray(),r=0;r<n.length&&0==n[r];)++r;if(n.length-r!=e-1||2!=n[r])return null;for(++r;0!=n[r];)if(++r>=n.length)return null;for(var o="";++r<n.length;){var i=255&n[r];i<128?o+=String.fromCharCode(i):i>191&&i<224?(o+=String.fromCharCode((31&i)<<6|63&n[r+1]),++r):(o+=String.fromCharCode((15&i)<<12|(63&n[r+1])<<6|63&n[r+2]),r+=2)}return o}class ht extends lt{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";super(),t&&("string"==typeof t?this.parseKey(t):(this.hasPrivateKeyProperty(t)||this.hasPublicKeyProperty(t))&&this.parsePropertiesFrom(t))}parseKey(t){try{var e=0,n=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?c.decode(t):l.unarmor(t),o=z.decode(r);if(3===o.sub.length&&(o=o.sub[2].sub[0]),9===o.sub.length){e=o.sub[1].getHexStringValue(),this.n=Z(e,16),n=o.sub[2].getHexStringValue(),this.e=parseInt(n,16);var i=o.sub[3].getHexStringValue();this.d=Z(i,16);var s=o.sub[4].getHexStringValue();this.p=Z(s,16);var a=o.sub[5].getHexStringValue();this.q=Z(a,16);var u=o.sub[6].getHexStringValue();this.dmp1=Z(u,16);var d=o.sub[7].getHexStringValue();this.dmq1=Z(d,16);var h=o.sub[8].getHexStringValue();this.coeff=Z(h,16)}else{if(2!==o.sub.length)return!1;var f=o.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=Z(e,16),n=f.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(t){return!1}}hasPublicKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")}hasPrivateKeyProperty(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")}parsePropertiesFrom(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)}}(r=function(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}).prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new ht(t)},r.prototype.setPrivateKey=function(t){this.setKey(t)},r.prototype.setPublicKey=function(t){this.setKey(t)},r.prototype.decrypt=function(t){try{return this.getKey().decrypt(V(t))}catch(t){return!1}},r.prototype.encrypt=function(t){try{return H(this.getKey().encrypt(t))}catch(t){return!1}},r.prototype.encryptLong=function(t){try{for(var e=this.getKey().encryptLong(t)||"",n=this.getKey().decryptLong(e)||"",r=0,o=/null$/g;o.test(n)&&(r++,e=this.getKey().encryptLong(t)||"",n=this.getKey().decryptLong(e)||"",!(r>10)););return e}catch(t){return!1}},r.prototype.getKey=function(t){if(!this.key){if(this.key=new ht,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},r.version="3.1.4"}e.default=r},8182:function(t,e,n){"use strict";var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&o(e,t,n);return i(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.useDefaultAdapter=e.useAdapters=e.RUNTIME=void 0;var a,u=s(n(4274)),c=n(3616);!function(t){t.WEB="web",t.WX_MP="wx_mp"}(a=e.RUNTIME||(e.RUNTIME={})),e.useAdapters=function(t,e){for(var n=0,o=(0,c.isArray)(t)?t:[t];n<o.length;n++){var i=o[n],s=i.isMatch,a=i.genAdapter,u=i.runtime;if(s())return{adapter:r({isMatch:s},a(e)),runtime:u}}},e.useDefaultAdapter=function(){return{adapter:r({},u.genAdapter()),runtime:a.WEB}}},4274:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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)}),i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},a=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.WebRequest=e.genAdapter=void 0;var u=n(2764),c=n(3616),l=n(2946),d=function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}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,n=t.file,r=t.name,o=t.method,s=t.headers,a=void 0===s?{}:s,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",c=new FormData;return"post"===u?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",r),c.append("file",n),this.request(i(i({},t),{data:c,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return s(this,void 0,void 0,(function(){var e,n,r,o;return a(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.get(i(i({},t),{headers:{},responseType:"blob"}))];case 1:return e=s.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return s.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return s(this,void 0,void 0,(function(){var n,r,o,u,c,l,d,h,f,p,v,y,m,g=this;return a(this,(function(b){switch(b.label){case 0:return n=new AbortController,r=t.url,o=t.enableAbort,u=void 0!==o&&o,c=t.stream,l=void 0!==c&&c,d=t.signal,h=t.timeout,f=t.shouldThrowOnError,p=void 0===f||f,v=null!=h?h:this.timeout,d&&(d.aborted&&n.abort(),d.addEventListener("abort",(function(){return n.abort()}))),y=null,u&&v&&(y=setTimeout((function(){console.warn(g.timeoutMsg),n.abort(new Error(g.timeoutMsg))}),v)),[4,fetch(r,i(i({},t),{signal:n.signal})).then((function(t){return s(g,void 0,void 0,(function(){var e,n,r;return a(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 r=(n=Promise).reject,[4,t.json()];case 2:e=r.apply(n,[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 m=b.sent(),[2,{data:l?m.body:(null===(e=m.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers,response:m}]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i=t.url,s=t.headers,a=void 0===s?{}:s,u=t.data,d=t.responseType,h=t.withCredentials,f=t.body,p=t.onUploadProgress,v=(0,c.formatUrl)((0,l.getProtocol)(),i,"get"===r?u:{}),y=new XMLHttpRequest;y.open(r,v),d&&(y.responseType=d);var m,g,b=t.signal;b&&(b.aborted?y.abort():b.addEventListener("abort",(function(){return y.abort()}),{once:!0})),Object.keys(a).forEach((function(t){y.setRequestHeader(t,a[t])})),p&&y.upload.addEventListener("progress",p),y.onreadystatechange=function(){var t={};if(4===y.readyState){var e=y.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,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(m),o(t)}},e&&n.timeout&&(m=setTimeout((function(){console.warn(n.timeoutMsg),y.abort()}),n.timeout)),g=(0,c.isFormData)(u)?u:"application/x-www-form-urlencoded"===a["content-type"]?(0,c.toQueryString)(u):f||(u?JSON.stringify(u):void 0),h&&(y.withCredentials=!0),y.send(g)}))},e}(u.AbstractSDKRequest);e.WebRequest=d,e.genAdapter=function(){return{type:"default",root:window,reqClass:d,wsClass:WebSocket,localStorage:localStorage}}},2946:function(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 n="@cloudbase/js-sdk";e.setSdkName=function(t){n=t},e.getSdkName=function(){return n};var r="https:";e.setProtocol=function(t){r=t},e.getProtocol=function(){return r},e.IS_DEBUG_MODE=!1,e.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},6205:function(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"}},794:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.OATUH_LOGINTYPE=void 0,o(n(2946),e),o(n(6205),e),e.OATUH_LOGINTYPE="constants"},7718:function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.catchErrorsDecorator=void 0;var i=n(3616),s=n(794),a=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(a=-1!==navigator.userAgent.indexOf("Firefox"));var u=a?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,c=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function l(t){var e=t.err,n=t.className,r=t.methodName,o=t.sourceLink;if(!o)return null;var i,s=e.stack.split("\n"),u=a?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),l=a?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),d=s.findIndex((function(t){return u.test(t)}));if(-1!==d){var h=s.filter((function(t,e){return e>d}));h.unshift(s[d].replace(l,"".concat(n,".").concat(r)).replace(c,o)),(i=new Error).stack="".concat(a?"@debugger":"Error","\n").concat(h.join("\n"))}return i}e.catchErrorsDecorator=function(t){var e=t.mode,n=void 0===e?"async":e,a=t.customInfo,d=void 0===a?{}:a,h=t.title,f=t.messages,p=void 0===f?[]:f;return function(t,e,a){if(s.IS_DEBUG_MODE){var f=d.className||t.constructor.name,v=d.methodName||e,y=a.value,m=function(){var t="",e=(new Error).stack.split("\n"),n=e.findIndex((function(t){return u.test(t)}));if(-1!==n){var r=c.exec(e[n+1]||"");t=r?r[0]:""}return t}();a.value="sync"===n?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=l({err:new Error,className:f,methodName:v,sourceLink:m});try{return y.apply(this,t)}catch(t){var r=t,o=t.message,s=t.error,a=t.error_description,u={title:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var c=JSON.parse(o);u.subtitle=o,c.code&&(n?(n.code=c.code,n.msg=c.msg):(t.code=c.code,t.message=c.msg),r=n||t,u.content=p.map((function(t){return{type:"info",body:t}})))}throw s&&a&&(u.subtitle=a,n?(n.code=s,n.msg=a):(t.code=s,t.message=a),r=n||t,u.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(u),r}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return r(this,void 0,void 0,(function(){var e,n,r,s,a,u,c,d;return o(this,(function(o){switch(o.label){case 0:e=l({err:new Error,className:f,methodName:v,sourceLink:m}),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 n=o.sent(),r=n,s=n.message,a=n.error,u=n.error_description,c={title:h||"".concat(f,".").concat(v," failed"),content:[{type:"error",body:n}]},s&&/^\{.*\}$/.test(s)&&(d=JSON.parse(s),c.subtitle=d,d.code&&(e?(e.code=d.code,e.message=d.msg):(n.code=d.code,n.message=d.msg),r=e||n,c.content=p.map((function(t){return{type:"info",body:t}})))),a&&u&&(c.subtitle=u,e?(e.code=a,e.msg=u):(n.code=a,n.message=u),r=e||n,c.content=p.map((function(t){return{type:"info",body:t}}))),(0,i.printGroupLog)(c),r;case 4:return[2]}}))}))}}}}},141:function(t,e,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),o=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||r(e,t,n)};Object.defineProperty(e,"__esModule",{value:!0}),o(n(7718),e)},6197:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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)}),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))},s=this&&this.__generator||function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=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++,r=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=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.CloudbaseCache=void 0;var a=n(2764),u=n(3616),c=n(794),l=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}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}(a.AbstractStorage),d=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,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,u.printWarn)(c.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,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:c.ERRORS.OPERATION_FAIL,msg:"[".concat((0,c.getSdkName)(),"][").concat(c.ERRORS.OPERATION_FAIL,"]setStore failed"),info:t}))}}else(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var r=this.storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}(0,u.printWarn)(c.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return i(this,void 0,void 0,(function(){var r;return s(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,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(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):(0,u.printWarn)(c.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 s(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}();e.CloudbaseCache=d},9689:function(t,e,n){"use strict";var r,o=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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},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)}),i=this&&this.__spreadArray||function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};Object.defineProperty(e,"__esModule",{value:!0}),e.removeEventListener=e.activateEvent=e.addEventListener=e.CloudbaseEventEmitter=e.IErrorEvent=e.CloudbaseEvent=void 0;var s=n(3616),a=function(t,e){this.data=e||null,this.name=t};e.CloudbaseEvent=a;var u=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return o(e,t),e}(a);e.IErrorEvent=u;var c=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if((0,s.isInstanceOf)(t,u))return console.error(t.error),this;var n=(0,s.isString)(t)?new a(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,c=this.listeners[r]?i([],this.listeners[r],!0):[];o<c.length;o++)c[o].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();e.CloudbaseEventEmitter=c;var l=new c;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)}},3616:function(t,e,n){"use strict";var r=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n};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=n(794);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(n){var r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:7&r|8).toString(16)}))},e.formatUrl=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(n[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(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))})),e.join("&")},e.getQuery=function(t,e){if("undefined"==typeof window)return!1;var n=e||decodeURIComponent(window.location.search),r=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);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 n=e.split("?")[0],r=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===t&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},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 n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t},e.execCallback=function(t,e,n){if(void 0===n&&(n=null),t&&"function"==typeof t)return t(e,n);if(e)throw e;return n},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,n=t.title,r=t.subtitle,o=void 0===r?"":r,i=t.content,s=void 0===i?[]:i,a=t.printTrace,u=void 0!==a&&a,c=t.collapsed;void 0!==c&&c?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var l=0,d=s;l<d.length;l++){var h=d[l],f=h.type,p=h.body;switch(f){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}u&&(console.trace||console.log)("stack trace:"),null===(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 n=t.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(e[r]?Array.isArray(e[r])?e[r].push(o):e[r]=[e[r],o]:e[r]=o)})),e},e.parseCaptcha=function(t){var n={},o=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){t=o[1];var i=o[2];i&&(n=(0,e.parseQueryString)(i))}var s=n.token,a=r(n,["token"]);return/^data:/.test(t)&&!s?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:s?{state:a.state,token:s,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}},9515:function(t,e,n){var r=n(8761)(n(7772),"DataView");t.exports=r},9612:function(t,e,n){var r=n(2118),o=n(6909),i=n(8138),s=n(4174),a=n(7942);function u(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}u.prototype.clear=r,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,t.exports=u},235:function(t,e,n){var r=n(3945),o=n(1846),i=n(8028),s=n(6018),a=n(4769);function u(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}u.prototype.clear=r,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,t.exports=u},326:function(t,e,n){var r=n(8761)(n(7772),"Map");t.exports=r},6738:function(t,e,n){var r=n(2411),o=n(6417),i=n(6928),s=n(9493),a=n(4150);function u(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}u.prototype.clear=r,u.prototype.delete=o,u.prototype.get=i,u.prototype.has=s,u.prototype.set=a,t.exports=u},2760:function(t,e,n){var r=n(8761)(n(7772),"Promise");t.exports=r},2143:function(t,e,n){var r=n(8761)(n(7772),"Set");t.exports=r},6571:function(t,e,n){var r=n(235),o=n(5243),i=n(2858),s=n(4417),a=n(8605),u=n(1418);function c(t){var e=this.__data__=new r(t);this.size=e.size}c.prototype.clear=o,c.prototype.delete=i,c.prototype.get=s,c.prototype.has=a,c.prototype.set=u,t.exports=c},857:function(t,e,n){var r=n(7772).Symbol;t.exports=r},9162:function(t,e,n){var r=n(7772).Uint8Array;t.exports=r},3215:function(t,e,n){var r=n(8761)(n(7772),"WeakMap");t.exports=r},2517:function(t){t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}},7552:function(t){t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length,o=0,i=[];++n<r;){var s=t[n];e(s,n,t)&&(i[o++]=s)}return i}},1634:function(t,e,n){var r=n(6473),o=n(9631),i=n(6152),s=n(3226),a=n(9045),u=n(7598),c=Object.prototype.hasOwnProperty;t.exports=function(t,e){var n=i(t),l=!n&&o(t),d=!n&&!l&&s(t),h=!n&&!l&&!d&&u(t),f=n||l||d||h,p=f?r(t.length,String):[],v=p.length;for(var y in t)!e&&!c.call(t,y)||f&&("length"==y||d&&("offset"==y||"parent"==y)||h&&("buffer"==y||"byteLength"==y||"byteOffset"==y)||a(y,v))||p.push(y);return p}},343:function(t){t.exports=function(t,e){for(var n=-1,r=null==t?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}},5067:function(t){t.exports=function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}},91:function(t,e,n){var r=n(3940),o=n(1225),i=Object.prototype.hasOwnProperty;t.exports=function(t,e,n){var s=t[e];i.call(t,e)&&o(s,n)&&(void 0!==n||e in t)||r(t,e,n)}},2218:function(t,e,n){var r=n(1225);t.exports=function(t,e){for(var n=t.length;n--;)if(r(t[n][0],e))return n;return-1}},7993:function(t,e,n){var r=n(752),o=n(249);t.exports=function(t,e){return t&&r(e,o(e),t)}},5906:function(t,e,n){var r=n(752),o=n(8582);t.exports=function(t,e){return t&&r(e,o(e),t)}},3940:function(t,e,n){var r=n(3043);t.exports=function(t,e,n){"__proto__"==e&&r?r(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}},8874:function(t,e,n){var r=n(6571),o=n(2517),i=n(91),s=n(7993),a=n(5906),u=n(2175),c=n(1522),l=n(7680),d=n(9987),h=n(3483),f=n(6939),p=n(940),v=n(9917),y=n(8222),m=n(8725),g=n(6152),b=n(3226),_=n(4714),w=n(9259),E=n(3679),I=n(249),S=n(8582),O="[object Arguments]",A="[object Function]",T="[object Object]",P={};P[O]=P["[object Array]"]=P["[object ArrayBuffer]"]=P["[object DataView]"]=P["[object Boolean]"]=P["[object Date]"]=P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Map]"]=P["[object Number]"]=P[T]=P["[object RegExp]"]=P["[object Set]"]=P["[object String]"]=P["[object Symbol]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P["[object Error]"]=P[A]=P["[object WeakMap]"]=!1,t.exports=function t(e,n,R,C,N,D){var U,x=1&n,L=2&n,j=4&n;if(R&&(U=N?R(e,C,N,D):R(e)),void 0!==U)return U;if(!w(e))return e;var k=g(e);if(k){if(U=v(e),!x)return c(e,U)}else{var M=p(e),q=M==A||"[object GeneratorFunction]"==M;if(b(e))return u(e,x);if(M==T||M==O||q&&!N){if(U=L||q?{}:m(e),!x)return L?d(e,a(U,e)):l(e,s(U,e))}else{if(!P[M])return N?e:{};U=y(e,M,x)}}D||(D=new r);var W=D.get(e);if(W)return W;D.set(e,U),E(e)?e.forEach((function(r){U.add(t(r,n,R,r,e,D))})):_(e)&&e.forEach((function(r,o){U.set(o,t(r,n,R,o,e,D))}));var B=k?void 0:(j?L?f:h:L?S:I)(e);return o(B||e,(function(r,o){B&&(r=e[o=r]),i(U,o,t(r,n,R,o,e,D))})),U}},9413:function(t,e,n){var r=n(9259),o=Object.create,i=function(){function t(){}return function(e){if(!r(e))return{};if(o)return o(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();t.exports=i},3324:function(t,e,n){var r=n(7297),o=n(3812);t.exports=function(t,e){for(var n=0,i=(e=r(e,t)).length;null!=t&&n<i;)t=t[o(e[n++])];return n&&n==i?t:void 0}},1897:function(t,e,n){var r=n(5067),o=n(6152);t.exports=function(t,e,n){var i=e(t);return o(t)?i:r(i,n(t))}},3366:function(t,e,n){var r=n(857),o=n(2107),i=n(7157),s=r?r.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?o(t):i(t)}},5183:function(t,e,n){var r=n(3366),o=n(5125);t.exports=function(t){return o(t)&&"[object Arguments]"==r(t)}},4511:function(t,e,n){var r=n(940),o=n(5125);t.exports=function(t){return o(t)&&"[object Map]"==r(t)}},6840:function(t,e,n){var r=n(1049),o=n(7394),i=n(9259),s=n(7035),a=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,l=u.toString,d=c.hasOwnProperty,h=RegExp("^"+l.call(d).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!i(t)||o(t))&&(r(t)?h:a).test(s(t))}},8436:function(t,e,n){var r=n(940),o=n(5125);t.exports=function(t){return o(t)&&"[object Set]"==r(t)}},5522:function(t,e,n){var r=n(3366),o=n(1158),i=n(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,t.exports=function(t){return i(t)&&o(t.length)&&!!s[r(t)]}},6411:function(t,e,n){var r=n(6001),o=n(4248),i=Object.prototype.hasOwnProperty;t.exports=function(t){if(!r(t))return o(t);var e=[];for(var n in Object(t))i.call(t,n)&&"constructor"!=n&&e.push(n);return e}},8390:function(t,e,n){var r=n(9259),o=n(6001),i=n(2966),s=Object.prototype.hasOwnProperty;t.exports=function(t){if(!r(t))return i(t);var e=o(t),n=[];for(var a in t)("constructor"!=a||!e&&s.call(t,a))&&n.push(a);return n}},2857:function(t,e,n){var r=n(91),o=n(7297),i=n(9045),s=n(9259),a=n(3812);t.exports=function(t,e,n,u){if(!s(t))return t;for(var c=-1,l=(e=o(e,t)).length,d=l-1,h=t;null!=h&&++c<l;){var f=a(e[c]),p=n;if("__proto__"===f||"constructor"===f||"prototype"===f)return t;if(c!=d){var v=h[f];void 0===(p=u?u(v,f,h):void 0)&&(p=s(v)?v:i(e[c+1])?[]:{})}r(h,f,p),h=h[f]}return t}},9872:function(t){t.exports=function(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(n=n>o?o:n)<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(o);++r<o;)i[r]=t[r+e];return i}},6473:function(t){t.exports=function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}},1054:function(t,e,n){var r=n(857),o=n(343),i=n(6152),s=n(4795),a=r?r.prototype:void 0,u=a?a.toString:void 0;t.exports=function t(e){if("string"==typeof e)return e;if(i(e))return o(e,t)+"";if(s(e))return u?u.call(e):"";var n=e+"";return"0"==n&&1/e==-1/0?"-0":n}},7826:function(t){t.exports=function(t){return function(e){return t(e)}}},9078:function(t,e,n){var r=n(7297),o=n(6974),i=n(2721),s=n(3812);t.exports=function(t,e){return e=r(e,t),null==(t=i(t,e))||delete t[s(o(e))]}},7297:function(t,e,n){var r=n(6152),o=n(1401),i=n(4452),s=n(6188);t.exports=function(t,e){return r(t)?t:o(t,e)?[t]:i(s(t))}},9882:function(t,e,n){var r=n(9162);t.exports=function(t){var e=new t.constructor(t.byteLength);return new r(e).set(new r(t)),e}},2175:function(t,e,n){t=n.nmd(t);var r=n(7772),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o?r.Buffer:void 0,a=s?s.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var n=t.length,r=a?a(n):new t.constructor(n);return t.copy(r),r}},4727:function(t,e,n){var r=n(9882);t.exports=function(t,e){var n=e?r(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}},6058:function(t){var e=/\w*$/;t.exports=function(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}},169:function(t,e,n){var r=n(857),o=r?r.prototype:void 0,i=o?o.valueOf:void 0;t.exports=function(t){return i?Object(i.call(t)):{}}},6190:function(t,e,n){var r=n(9882);t.exports=function(t,e){var n=e?r(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}},1522:function(t){t.exports=function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}},752:function(t,e,n){var r=n(91),o=n(3940);t.exports=function(t,e,n,i){var s=!n;n||(n={});for(var a=-1,u=e.length;++a<u;){var c=e[a],l=i?i(n[c],t[c],c,n,t):void 0;void 0===l&&(l=t[c]),s?o(n,c,l):r(n,c,l)}return n}},7680:function(t,e,n){var r=n(752),o=n(633);t.exports=function(t,e){return r(t,o(t),e)}},9987:function(t,e,n){var r=n(752),o=n(2680);t.exports=function(t,e){return r(t,o(t),e)}},4019:function(t,e,n){var r=n(7772)["__core-js_shared__"];t.exports=r},3043:function(t,e,n){var r=n(8761),o=function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=o},1242:function(t,e,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;t.exports=r},3483:function(t,e,n){var r=n(1897),o=n(633),i=n(249);t.exports=function(t){return r(t,i,o)}},6939:function(t,e,n){var r=n(1897),o=n(2680),i=n(8582);t.exports=function(t){return r(t,i,o)}},7937:function(t,e,n){var r=n(8304);t.exports=function(t,e){var n=t.__data__;return r(e)?n["string"==typeof e?"string":"hash"]:n.map}},8761:function(t,e,n){var r=n(6840),o=n(8109);t.exports=function(t,e){var n=o(t,e);return r(n)?n:void 0}},7353:function(t,e,n){var r=n(241)(Object.getPrototypeOf,Object);t.exports=r},2107:function(t,e,n){var r=n(857),o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=r?r.toStringTag:void 0;t.exports=function(t){var e=i.call(t,a),n=t[a];try{t[a]=void 0;var r=!0}catch(t){}var o=s.call(t);return r&&(e?t[a]=n:delete t[a]),o}},633:function(t,e,n){var r=n(7552),o=n(981),i=Object.prototype.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(t){return null==t?[]:(t=Object(t),r(s(t),(function(e){return i.call(t,e)})))}:o;t.exports=a},2680:function(t,e,n){var r=n(5067),o=n(7353),i=n(633),s=n(981),a=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)r(e,i(t)),t=o(t);return e}:s;t.exports=a},940:function(t,e,n){var r=n(9515),o=n(326),i=n(2760),s=n(2143),a=n(3215),u=n(3366),c=n(7035),l="[object Map]",d="[object Promise]",h="[object Set]",f="[object WeakMap]",p="[object DataView]",v=c(r),y=c(o),m=c(i),g=c(s),b=c(a),_=u;(r&&_(new r(new ArrayBuffer(1)))!=p||o&&_(new o)!=l||i&&_(i.resolve())!=d||s&&_(new s)!=h||a&&_(new a)!=f)&&(_=function(t){var e=u(t),n="[object Object]"==e?t.constructor:void 0,r=n?c(n):"";if(r)switch(r){case v:return p;case y:return l;case m:return d;case g:return h;case b:return f}return e}),t.exports=_},8109:function(t){t.exports=function(t,e){return null==t?void 0:t[e]}},2118:function(t,e,n){var r=n(9191);t.exports=function(){this.__data__=r?r(null):{},this.size=0}},6909:function(t){t.exports=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}},8138:function(t,e,n){var r=n(9191),o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;if(r){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return o.call(e,t)?e[t]:void 0}},4174:function(t,e,n){var r=n(9191),o=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;return r?void 0!==e[t]:o.call(e,t)}},7942:function(t,e,n){var r=n(9191);t.exports=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=r&&void 0===e?"__lodash_hash_undefined__":e,this}},9917:function(t){var e=Object.prototype.hasOwnProperty;t.exports=function(t){var n=t.length,r=new t.constructor(n);return n&&"string"==typeof t[0]&&e.call(t,"index")&&(r.index=t.index,r.input=t.input),r}},8222:function(t,e,n){var r=n(9882),o=n(4727),i=n(6058),s=n(169),a=n(6190);t.exports=function(t,e,n){var u=t.constructor;switch(e){case"[object ArrayBuffer]":return r(t);case"[object Boolean]":case"[object Date]":return new u(+t);case"[object DataView]":return o(t,n);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(t,n);case"[object Map]":case"[object Set]":return new u;case"[object Number]":case"[object String]":return new u(t);case"[object RegExp]":return i(t);case"[object Symbol]":return s(t)}}},8725:function(t,e,n){var r=n(9413),o=n(7353),i=n(6001);t.exports=function(t){return"function"!=typeof t.constructor||i(t)?{}:r(o(t))}},9045:function(t){var e=/^(?:0|[1-9]\d*)$/;t.exports=function(t,n){var r=typeof t;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&e.test(t))&&t>-1&&t%1==0&&t<n}},1401:function(t,e,n){var r=n(6152),o=n(4795),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;t.exports=function(t,e){if(r(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!o(t))||s.test(t)||!i.test(t)||null!=e&&t in Object(e)}},8304:function(t){t.exports=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}},7394:function(t,e,n){var r,o=n(4019),i=(r=/[^.]+$/.exec(o&&o.keys&&o.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";t.exports=function(t){return!!i&&i in t}},6001:function(t){var e=Object.prototype;t.exports=function(t){var n=t&&t.constructor;return t===("function"==typeof n&&n.prototype||e)}},3945:function(t){t.exports=function(){this.__data__=[],this.size=0}},1846:function(t,e,n){var r=n(2218),o=Array.prototype.splice;t.exports=function(t){var e=this.__data__,n=r(e,t);return!(n<0||(n==e.length-1?e.pop():o.call(e,n,1),--this.size,0))}},8028:function(t,e,n){var r=n(2218);t.exports=function(t){var e=this.__data__,n=r(e,t);return n<0?void 0:e[n][1]}},6018:function(t,e,n){var r=n(2218);t.exports=function(t){return r(this.__data__,t)>-1}},4769:function(t,e,n){var r=n(2218);t.exports=function(t,e){var n=this.__data__,o=r(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this}},2411:function(t,e,n){var r=n(9612),o=n(235),i=n(326);t.exports=function(){this.size=0,this.__data__={hash:new r,map:new(i||o),string:new r}}},6417:function(t,e,n){var r=n(7937);t.exports=function(t){var e=r(this,t).delete(t);return this.size-=e?1:0,e}},6928:function(t,e,n){var r=n(7937);t.exports=function(t){return r(this,t).get(t)}},9493:function(t,e,n){var r=n(7937);t.exports=function(t){return r(this,t).has(t)}},4150:function(t,e,n){var r=n(7937);t.exports=function(t,e){var n=r(this,t),o=n.size;return n.set(t,e),this.size+=n.size==o?0:1,this}},7777:function(t,e,n){var r=n(733);t.exports=function(t){var e=r(t,(function(t){return 500===n.size&&n.clear(),t})),n=e.cache;return e}},9191:function(t,e,n){var r=n(8761)(Object,"create");t.exports=r},4248:function(t,e,n){var r=n(241)(Object.keys,Object);t.exports=r},2966:function(t){t.exports=function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}},4146:function(t,e,n){t=n.nmd(t);var r=n(1242),o=e&&!e.nodeType&&e,i=o&&t&&!t.nodeType&&t,s=i&&i.exports===o&&r.process,a=function(){try{return i&&i.require&&i.require("util").types||s&&s.binding&&s.binding("util")}catch(t){}}();t.exports=a},7157:function(t){var e=Object.prototype.toString;t.exports=function(t){return e.call(t)}},241:function(t){t.exports=function(t,e){return function(n){return t(e(n))}}},2721:function(t,e,n){var r=n(3324),o=n(9872);t.exports=function(t,e){return e.length<2?t:r(t,o(e,0,-1))}},7772:function(t,e,n){var r=n(1242),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();t.exports=i},5243:function(t,e,n){var r=n(235);t.exports=function(){this.__data__=new r,this.size=0}},2858:function(t){t.exports=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}},4417:function(t){t.exports=function(t){return this.__data__.get(t)}},8605:function(t){t.exports=function(t){return this.__data__.has(t)}},1418:function(t,e,n){var r=n(235),o=n(326),i=n(6738);t.exports=function(t,e){var n=this.__data__;if(n instanceof r){var s=n.__data__;if(!o||s.length<199)return s.push([t,e]),this.size=++n.size,this;n=this.__data__=new i(s)}return n.set(t,e),this.size=n.size,this}},4452:function(t,e,n){var r=n(7777),o=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g,s=r((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(o,(function(t,n,r,o){e.push(r?o.replace(i,"$1"):n||t)})),e}));t.exports=s},3812:function(t,e,n){var r=n(4795);t.exports=function(t){if("string"==typeof t||r(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}},7035:function(t){var e=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return e.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},9850:function(t,e,n){var r=n(8874);t.exports=function(t){return r(t,5)}},1225:function(t){t.exports=function(t,e){return t===e||t!=t&&e!=e}},9631:function(t,e,n){var r=n(5183),o=n(5125),i=Object.prototype,s=i.hasOwnProperty,a=i.propertyIsEnumerable,u=r(function(){return arguments}())?r:function(t){return o(t)&&s.call(t,"callee")&&!a.call(t,"callee")};t.exports=u},6152:function(t){var e=Array.isArray;t.exports=e},7878:function(t,e,n){var r=n(1049),o=n(1158);t.exports=function(t){return null!=t&&o(t.length)&&!r(t)}},3226:function(t,e,n){t=n.nmd(t);var r=n(7772),o=n(6330),i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,a=s&&s.exports===i?r.Buffer:void 0,u=(a?a.isBuffer:void 0)||o;t.exports=u},1049:function(t,e,n){var r=n(3366),o=n(9259);t.exports=function(t){if(!o(t))return!1;var e=r(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}},1158:function(t){t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},4714:function(t,e,n){var r=n(4511),o=n(7826),i=n(4146),s=i&&i.isMap,a=s?o(s):r;t.exports=a},9259:function(t){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},5125:function(t){t.exports=function(t){return null!=t&&"object"==typeof t}},3679:function(t,e,n){var r=n(8436),o=n(7826),i=n(4146),s=i&&i.isSet,a=s?o(s):r;t.exports=a},4795:function(t,e,n){var r=n(3366),o=n(5125);t.exports=function(t){return"symbol"==typeof t||o(t)&&"[object Symbol]"==r(t)}},7598:function(t,e,n){var r=n(5522),o=n(7826),i=n(4146),s=i&&i.isTypedArray,a=s?o(s):r;t.exports=a},249:function(t,e,n){var r=n(1634),o=n(6411),i=n(7878);t.exports=function(t){return i(t)?r(t):o(t)}},8582:function(t,e,n){var r=n(1634),o=n(8390),i=n(7878);t.exports=function(t){return i(t)?r(t,!0):o(t)}},6974:function(t){t.exports=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}},733:function(t,e,n){var r=n(6738);function o(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var s=t.apply(this,r);return n.cache=i.set(o,s)||i,s};return n.cache=new(o.Cache||r),n}o.Cache=r,t.exports=o},6765:function(t,e,n){var r=n(2857);t.exports=function(t,e,n){return null==t?t:r(t,e,n)}},981:function(t){t.exports=function(){return[]}},6330:function(t){t.exports=function(){return!1}},6188:function(t,e,n){var r=n(1054);t.exports=function(t){return null==t?"":r(t)}},7195:function(t,e,n){var r=n(9078);t.exports=function(t,e){return null==t||r(t,e)}},2764:function(t){"use strict";t.exports=require("@cloudbase/adapter-interface")},7917:function(t){"use strict";t.exports=require("@cloudbase/adapter-wx_mp")},8630:function(t){"use strict";t.exports=require("@cloudbase/wx-cloud-client-sdk")},766:function(t){"use strict";t.exports=require("@mattiasbuelens/web-streams-adapter")},2701:function(t){"use strict";t.exports=require("bson")},3107:function(t){"use strict";t.exports=require("jwt-decode")},6282:function(t){"use strict";t.exports=require("text-encoding-shim")},8775:function(t){"use strict";t.exports=require("web-streams-polyfill")}},r={};function o(t){var e=r[t];if(void 0!==e)return e.exports;var i=r[t]={id:t,loaded:!1,exports:{}};return n[t].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}e=Object.getPrototypeOf?function(t){return Object.getPrototypeOf(t)}:function(t){return t.__proto__},o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var s={};t=t||[null,e({}),e([]),e(e)];for(var a=2&r&&n;"object"==typeof a&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach((function(t){s[t]=function(){return n[t]}}));return s.default=function(){return n},o.d(i,s),i},o.d=function(t,e){for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.nmd=function(t){return t.paths=[],t.children||(t.children=[]),t};var i=o(8795);module.exports=i}();
3
3
  //# sourceMappingURL=index.cjs.js.map