@cloudbase/js-sdk 3.6.2 → 3.6.3

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 (74) hide show
  1. package/CHANGELOG.md +6 -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/app/dist/index.node.esm.js +1 -1
  11. package/app/dist/index.node.esm.js.map +1 -1
  12. package/app/dist/index.node.js +1 -1
  13. package/app/dist/index.node.js.map +1 -1
  14. package/auth/dist/index.esm.js +1 -1
  15. package/auth/dist/index.esm.js.map +1 -1
  16. package/auth/dist/index.js +1 -1
  17. package/auth/dist/index.js.map +1 -1
  18. package/core.d.ts +4331 -0
  19. package/core.node.d.ts +294 -0
  20. package/dist/index.cjs.js +1 -1
  21. package/dist/index.cjs.js.map +1 -1
  22. package/dist/index.esm.js +1 -1
  23. package/dist/index.esm.js.map +1 -1
  24. package/dist/index.node.cjs.js +1 -1
  25. package/dist/index.node.cjs.js.map +1 -1
  26. package/dist/index.node.esm.js +1 -1
  27. package/dist/index.node.esm.js.map +1 -1
  28. package/index.d.ts +5 -4268
  29. package/index.node.d.ts +13 -0
  30. package/miniprogram_dist/ai/index.d.ts +42 -0
  31. package/miniprogram_dist/ai/index.js +2 -0
  32. package/miniprogram_dist/apis/index.d.ts +5 -0
  33. package/miniprogram_dist/{apis.js → apis/index.js} +1 -1
  34. package/miniprogram_dist/app/index.d.ts +67 -0
  35. package/miniprogram_dist/app/index.js +2 -0
  36. package/miniprogram_dist/auth/index.d.ts +284 -0
  37. package/miniprogram_dist/auth/index.js +2 -0
  38. package/miniprogram_dist/cloudrun/index.d.ts +4 -0
  39. package/miniprogram_dist/cloudrun/index.js +1 -0
  40. package/miniprogram_dist/container/index.d.ts +13 -0
  41. package/miniprogram_dist/container/index.js +1 -0
  42. package/miniprogram_dist/database/index.d.ts +3 -0
  43. package/miniprogram_dist/functions/index.d.ts +2 -0
  44. package/miniprogram_dist/functions/index.js +1 -0
  45. package/miniprogram_dist/index.js +1 -1
  46. package/miniprogram_dist/model/index.d.ts +5 -0
  47. package/miniprogram_dist/model/index.js +1 -0
  48. package/miniprogram_dist/mysql/index.d.ts +3 -0
  49. package/miniprogram_dist/mysql/index.js +1 -0
  50. package/miniprogram_dist/oauth/index.d.ts +22 -0
  51. package/miniprogram_dist/oauth/index.js +2 -0
  52. package/miniprogram_dist/realtime/index.d.ts +2 -0
  53. package/miniprogram_dist/realtime/index.js +1 -0
  54. package/miniprogram_dist/storage/index.d.ts +13 -0
  55. package/miniprogram_dist/{storage.js → storage/index.js} +1 -1
  56. package/oauth/dist/index.esm.js +1 -1
  57. package/oauth/dist/index.esm.js.map +1 -1
  58. package/oauth/dist/index.js +1 -1
  59. package/oauth/dist/index.js.map +1 -1
  60. package/package.json +6 -2
  61. package/types/package.json +1 -1
  62. package/utilities/package.json +2 -2
  63. package/dist/index.d.ts +0 -9
  64. package/miniprogram_dist/ai.js +0 -2
  65. package/miniprogram_dist/app.js +0 -2
  66. package/miniprogram_dist/auth.js +0 -2
  67. package/miniprogram_dist/cloudrun.js +0 -1
  68. package/miniprogram_dist/container.js +0 -1
  69. package/miniprogram_dist/functions.js +0 -1
  70. package/miniprogram_dist/model.js +0 -1
  71. package/miniprogram_dist/mysql.js +0 -1
  72. package/miniprogram_dist/oauth.js +0 -2
  73. package/miniprogram_dist/realtime.js +0 -1
  74. /package/miniprogram_dist/{database.js → database/index.js} +0 -0
@@ -0,0 +1,13 @@
1
+ /// <reference path="./core.d.ts" />
2
+ /// <reference path="./core.node.d.ts" />
3
+
4
+ /**
5
+ * Node.js 环境类型入口。
6
+ *
7
+ * 在共享类型定义(core.d.ts)之上,叠加 Node.js 专属定义(core.node.d.ts),
8
+ * 因此 `version`、`parseContext`、`getCloudbaseContext`、`app.callWxOpenApi`、
9
+ * `auth.getEndUserInfo` 等仅在 Node.js 运行时可用的能力,只有通过本入口才可见。
10
+ */
11
+
12
+ export = cloudbase
13
+ export as namespace cloudbase
@@ -0,0 +1,42 @@
1
+ import type { SDKRequestInterface } from '@cloudbase/adapter-interface';
2
+ import type { ICloudbase, ICloudbaseConfig } from '@cloudbase/types';
3
+ import { AI } from './AI';
4
+ import { Bot } from './bot';
5
+ import * as models from './models';
6
+ import * as utils from './utils';
7
+ declare const restModels: {
8
+ ZhiPuSimpleModel: typeof models.ZhiPuSimpleModel;
9
+ HunYuanBetaSimpleModel: typeof models.HunYuanBetaSimpleModel;
10
+ HunYuanSimpleModel: typeof models.HunYuanSimpleModel;
11
+ ArkSimpleModel: typeof models.ArkSimpleModel;
12
+ DSSimpleModel: typeof models.DSSimpleModel;
13
+ YiSimpleModel: typeof models.YiSimpleModel;
14
+ MoonshotSimpleModel: typeof models.MoonshotSimpleModel;
15
+ HunYuanExpSimpleModel: typeof models.HunYuanExpSimpleModel;
16
+ HunYuanOpenSimpleModel: typeof models.HunYuanOpenSimpleModel;
17
+ DefaultSimpleModel: typeof models.DefaultSimpleModel;
18
+ DefaultImageModel: typeof models.DefaultImageModel;
19
+ ReactModel: typeof models.ReactModel;
20
+ toolMap: Map<string, CallableFunction>;
21
+ };
22
+ interface IHandleRequestInstance {
23
+ req: SDKRequestInterface;
24
+ }
25
+ type HandleRequestInstanceFunc = (options: IHandleRequestInstance) => SDKRequestInterface;
26
+ interface ICreateAI {
27
+ req: SDKRequestInterface;
28
+ baseUrl?: string;
29
+ getBaseUrl?: () => string;
30
+ env?: string;
31
+ getAccessToken?: () => Promise<{
32
+ accessToken: string;
33
+ }>;
34
+ handleReqInstance?: HandleRequestInstanceFunc;
35
+ i18n?: ICloudbaseConfig['i18n'];
36
+ }
37
+ declare function createAI({ env, baseUrl, getBaseUrl: getBaseUrlFunc, req, getAccessToken, handleReqInstance, i18n }: ICreateAI): AI;
38
+ declare const createAi: typeof createAI;
39
+ declare function registerAi(app: ICloudbase): void;
40
+ export { AI, Bot, createAi, createAI, restModels as models, registerAi, utils };
41
+ export * from './type';
42
+ export * from './errors';
@@ -0,0 +1,2 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_ai",[],t):"object"==typeof exports?exports.cloudbase_ai=t():e.cloudbase_ai=t()}("undefined"!=typeof window?window:this,()=>(()=>{var e={829:(e,t,r)=>{"use strict";var n;r.r(t),r.d(t,{AbstractSDKRequest:()=>o,AbstractStorage:()=>i,StorageType:()=>n,formatUrl:()=>a}),function(e){e.local="local",e.none="none",e.session="session"}(n||(n={}));var o=function(){},i=function(){};function a(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";for(var i in r)""===o?!n&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(r[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}},756: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}),a=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},s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},l=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AI=void 0;var u=r(737),c=a(r(305)),f=r(689),d=r(877),h=c.MODELS,p=function(){function e(e,t,r,o){var i=this;this.req=e,this.baseUrl=t,this.modelRequest=function(e){var t=e.url,r=e.data,o=e.headers,a=e.stream,u=e.timeout;return s(i,void 0,void 0,function(){var e,i,s,c,f,d,h;return l(this,function(l){switch(l.label){case 0:return e={"Content-Type":"application/json"},a&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:n(n((f={},f[null===(d=this.i18n)||void 0===d?void 0:d.LANG_HEADER_KEY]=null===(h=this.i18n)||void 0===h?void 0:h.lang,f),e),o),body:JSON.stringify(r),url:this.resolveUrl(t),stream:a,timeout:u})];case 1:return i=l.sent(),s=i.data,c=i.header,[2,this.handleResponseData(s,c)]}})})},this.botRequest=function(e){var t=e.method,r=e.url,o=e.data,a=void 0===o?{}:o,u=e.headers,c=e.stream,f=e.timeout;return s(i,void 0,void 0,function(){var e,o,i,s,d,h,p,b,m;return l(this,function(l){switch(l.label){case 0:return e=this.resolveUrl(r),"get"!==t?[3,2]:(o=this.handleResponseData,[4,this.req.fetch({url:"".concat(e,"?").concat((y=a,Object.entries(y).map(function(e){var t=e[0],r=e[1];return"".concat(t,"=").concat(r)}).join("&"))),method:t,headers:u,stream:c,timeout:f})]);case 1:return[2,o.apply(this,[l.sent().data])];case 2:return i={"Content-Type":"application/json"},c&&Object.assign(i,{Accept:"text/event-stream"}),[4,this.req.fetch({url:e,body:JSON.stringify(a),headers:n(n((p={},p[null===(b=this.i18n)||void 0===b?void 0:b.LANG_HEADER_KEY]=null===(m=this.i18n)||void 0===m?void 0:m.lang,p),i),u),stream:c,method:t,timeout:f})];case 3:return s=l.sent(),d=s.data,h=s.header,[2,this.handleResponseData(d,h)]}var y})})},this._getBaseUrl=o,this.bot=new u.Bot(this.botRequest,this.aiBotBaseUrl),this.i18n=r,d.langEvent.bus.on(d.langEvent.LANG_CHANGE_EVENT,function(e){var t;i.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||i.i18n})}return Object.defineProperty(e.prototype,"aiBaseUrl",{get:function(){return"".concat(this._getBaseUrl?this._getBaseUrl():this.baseUrl,"/ai")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aiBotBaseUrl",{get:function(){return"".concat(this._getBaseUrl?this._getBaseUrl():this.baseUrl,"/aibot")},enumerable:!1,configurable:!0}),e.prototype.handleResponseData=function(e,t){var r,n;return s(this,void 0,void 0,function(){var o,i,a,s,u=this;return l(this,function(l){switch(l.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),i=function(e){if("object"==typeof e&&e&&"code"in e&&"NORMAL"!==e.code)throw new Error("".concat(u.i18n.t("AI+ 请求出错,错误码"),":").concat(e.code,",").concat(u.i18n.t("错误信息"),":").concat(e.message,"\n").concat(o,"\n").concat(JSON.stringify(e,null,2)))},"object"==typeof e&&e&&"function"!=typeof e.getReader?"then"in e?[4,e]:[3,2]:[3,4];case 1:return a=l.sent(),[3,3];case 2:a=e,l.label=3;case 3:return i(s=a),[2,e];case 4:if("function"!=typeof(null==e?void 0:e.getReader)){if("object"==typeof(s=e)&&s&&"code"in s&&"NORMAL"!==s.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(s.code,",").concat(this.i18n.t("错误信息"),":").concat(s.message,"\n").concat(o,"\n").concat(JSON.stringify(s,null,2)));return[2,e]}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,f.readableStream2JsonObject)(e)]:[3,6];case 5:s=l.sent(),i(s),l.label=6;case 6:return[2,e]}})})},e.prototype.createModel=function(e,t){var r,n=h[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 c.DefaultSimpleModel(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new c.ReactModel(r)},e.prototype.registerModel=function(e,t){null==h[e]?h[e]=t:console.warn("AI model ".concat(e," already exists!"))},e.prototype.createImageModel=function(e){return new c.DefaultImageModel(this.modelRequest,this.aiBaseUrl,e)},e.prototype.registerFunctionTool=function(e){c.toolMap.has(e.name)&&console.warn("AI function tool ".concat(e.name," already exists and will be overwritten!")),c.toolMap.set(e.name,e.fn)},e.prototype.resolveUrl=function(e){if(!this._getBaseUrl)return e;var t=this._getBaseUrl();return t!==this.baseUrl&&e.startsWith(this.baseUrl)?e.replace(this.baseUrl,t):e},e}();t.AI=p},737: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},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.Bot=void 0;var s=r(689),l=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,s=a(t,["headers"]);return e(n(n({},s),{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=a(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,s=void 0===r?10:r,l=e.pageNumber,u=void 0===l?1:l,c=e.botId,f=a(e,["pageSize","pageNumber","botId"]);return o(this,void 0,void 0,function(){var e,r;return i(this,function(o){if(u<1)throw new Error("pageNumber must be greater than 0");return e=s*(u-1),r=s,[2,this.req({method:"get",url:this.join("bots/".concat(c,"/conversation")),data:n(n({},f),{offset:e,limit:r}),timeout:null==t?void 0:t.timeout})]})})},e.prototype.deleteConversation=function(e,t){var r=e.botId,n=e.conversationId,s=a(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:s,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 u(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 u(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 u(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 u(r)]}})})},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}();t.Bot=l;var u=function(){function e(e){var t=(0,s.toPolyfillReadable)(e);this._eventSourceStream=t.pipeThrough(new s.TextDecoderStream).pipeThrough((0,s.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,s.createAsyncIterable)(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataStream",{get:function(){return(0,s.createAsyncIterable)(this.eventSourceStream.pipeThrough(new s.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,s.createAsyncIterable)(this.dataStream.pipeThrough(new s.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}()},713: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.InvalidParamsError=void 0;var o=function(e){function t(t,r){var n=e.call(this,t)||this;return n.name="InvalidParamsError",n.code="INVALID_PARAMS",n.field=r,n}return n(t,e),t.prototype.toJSON=function(){return{code:this.code,message:this.message,field:this.field}},t}(Error);t.InvalidParamsError=o},964:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0;var n=r(298);Object.defineProperty(t,"createParser",{enumerable:!0,get:function(){return n.createParser}})},298:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0,t.createParser=function(e){var t,n,o,i,a,s,l;return u(),{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 a=n.length,s=0,l=!1;s<a;){l&&("\n"===n[s]&&(s+=1),l=!1);for(var u=-1,f=i,d=void 0,h=o;u<0&&h<a;h++)":"===(d=n[h])&&f<0?f=h-s:"\r"===d?(l=!0,u=h-s):"\n"===d&&(u=h-s);if(u<0){o=a-s,i=f;break}o=0,i=-1,c(n,s,f,u),s+=u+1}s===a?n="":s>0&&(n=n.slice(s))},reset:u};function u(){t=!0,n="",o=0,i=-1,a=void 0,s=void 0,l=""}function c(t,r,n,o){if(0===o)return l.length>0&&(e({type:"event",id:a,event:s||void 0,data:l.slice(0,-1)}),l="",a=void 0),void(s=void 0);var i,u=n<0,c=t.slice(r,r+(u?o:n)),f=r+(i=u?o:" "===t[r+n+1]?n+2:n+1),d=o-i,h=t.slice(f,f+d).toString();if("data"===c)l+=h?"".concat(h,"\n"):"\n";else if("event"===c)s=h;else if("id"!==c||h.includes("\0")){if("retry"===c){var p=parseInt(h,10);Number.isNaN(p)||e({type:"reconnect-interval",value:p})}}else a=h}};var r=[239,187,191]},337: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}),a=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},s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)},l=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},u=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},c=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 f=r(756);Object.defineProperty(t,"AI",{enumerable:!0,get:function(){return f.AI}});var d=r(737);Object.defineProperty(t,"Bot",{enumerable:!0,get:function(){return d.Bot}});var h=a(r(305)),p=a(r(689));t.utils=p,h.MODELS;var b=c(h,["MODELS"]);function m(e){var t=e.env,r=e.baseUrl,o=e.getBaseUrl,i=e.req,a=e.getAccessToken,s=e.handleReqInstance,d=e.i18n;return new f.AI(function(){if(null==s){if(null==a)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 l(void 0,void 0,void 0,function(){var o,i,a,s,l;return u(this,function(u){switch(u.label){case 0:if("function"!=typeof r.fetch)throw new Error("req.fetch is not a function");return o=e.token,i=e.headers,a=void 0===i?{}:i,s=c(e,["token","headers"]),null==o?[3,1]:(l=o,[3,3]);case 1:return[4,t()];case 2:l=u.sent().accessToken,u.label=3;case 3:return[2,r.fetch(n({headers:n({Authorization:"Bearer ".concat(l)},a)},s))]}})})}}}({req:i,getAccessToken:a})}return s({req:i})}(),function(){if(null!=o)return o();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")}(),d,o)}t.models=b,t.createAI=m;var y=m;t.createAi=y;var v={name:"ai",entity:{ai:function(e){var t=this,r=this.request;if(null==r.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");var n=function(){var e=t.getEndPointWithKey("GATEWAY"),r=e.BASE_URL,n=e.PROTOCOL;return"".concat(n).concat(r)};return(null==e?void 0:e.baseUrl)?m({req:r,baseUrl:e.baseUrl,handleReqInstance:function(e){return e.req},i18n:this.config.i18n}):m({req:r,baseUrl:n(),getBaseUrl:n,handleReqInstance:function(e){return e.req},i18n:this.config.i18n})}}};function _(e){try{e.registerComponent(v)}catch(e){console.warn(e)}}t.registerAi=_,s(r(669),t),s(r(713),t);try{window.registerAi=_}catch(e){}},476: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ArkSimpleModel=void 0;var a=r(689);function s(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,a=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:a,temperature:o})}var l=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({},s(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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.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,a.createAsyncIterable)(c)]}})})},e}();t.ArkSimpleModel=l},265: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DSSimpleModel=void 0;var a=r(689);function s(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,a=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:a,temperature:o})}var l=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({},s(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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.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,a.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,a.createAsyncIterable)(c)]}})})},e}();t.DSSimpleModel=l},102: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepSeekSimpleModel=void 0;var a=r(689),s=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,s,l,u;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(),s=(0,a.toPolyfillReadable)(o),l=(0,a.intoStandardStream)(s),u=l.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.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,a.createAsyncIterable)(u)]}})})},e}();t.DeepSeekSimpleModel=s},17: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSimpleModel=void 0;var a=r(689),s=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,s,l;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,a.toPolyfillReadable)(r),s=(0,a.intoStandardStream)(o),l=s.pipeThrough(new a.TransformStream({transform:function(e,r){var o=e.choices.map(function(e){var r=e.delta;return null==t&&(t=(0,a.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,a.createAsyncIterable)(l)]}})})},e}();t.DefaultSimpleModel=s},239: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanSimpleModel=void 0;var a=r(689),s=r(586),l=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,s.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return r=i.sent(),o=(0,s.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,l,u,c;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(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=(0,s.titleCaseToSnakeCase)(e),i=o.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.isToolCallAssistantMessage)(t)),r?n(n({},e),{finish_reason:"tool_calls",delta:t}):e}),l=n(n({},o),{choices:i});t.enqueue(n(n({},l),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(c)]}})})},e}();t.HunYuanSimpleModel=l},586: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,a=e.tools,s=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(a)return a.forEach(function(e){"function"!==e.type&&console.warn("`type` in tool is not 'function'",e)}),a}(),top_p:s,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},{})}},301: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanBetaSimpleModel=void 0;var a=r(689),s=r(586),l=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,s.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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},(0,s.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.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,a.createAsyncIterable)(c)]}})})},e}();t.HunYuanBetaSimpleModel=l},720: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanExpSimpleModel=void 0;var a=r(689),s=r(586),l=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,s.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,l,u;return i(this,function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:n(n({},(0,s.processInput)(e)),{stream:!0}),stream:!0})];case 1:return r=i.sent(),o=(0,a.toPolyfillReadable)(r),l=(0,a.intoStandardStream)(o),u=l.pipeThrough(new a.TransformStream({transform:function(e,r){var o=e.choices.map(function(e){var r=e.delta;return null==t&&(t=(0,a.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,a.createAsyncIterable)(u)]}})})},e}();t.HunYuanExpSimpleModel=l},418: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanOpenSimpleModel=void 0;var a=r(689),s=r(586),l=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,s.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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},(0,s.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.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,a.createAsyncIterable)(c)]}})})},e}();t.HunYuanOpenSimpleModel=l},925: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.MoonshotSimpleModel=void 0;var a=r(689);function s(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,a=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:a,temperature:o})}var l=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({},s(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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map(function(e){var t=e.delta;return null==r&&(r=(0,a.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,a.createAsyncIterable)(c)]}})})},e}();t.MoonshotSimpleModel=l},532: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.YiSimpleModel=void 0;var a=r(689);function s(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tools,a=e.top_p;return n(n({},e),{messages:t,model:r,tools:i,top_p:a,temperature:o})}var l=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({},s(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,l,u,c;return i(this,function(i){switch(i.label){case 0:return r=null,[4,this.req({url:this.url,data:n(n({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),l=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(l),c=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o,i,s,l,u,c;if((null===(s=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===s?void 0:s.content)||(null===(c=null===(u=null===(l=null==e?void 0:e.choices)||void 0===l?void 0:l[0])||void 0===u?void 0:u.delta)||void 0===c?void 0:c.tool_calls)){var f=e.choices.map(function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==r&&(r=(0,a.isToolCallAssistantMessage)(t)),n(n({},e),r?{finish_reason:"tool_calls",delta:t}:{delta:t})}),d=n(n({},e),{choices:f});t.enqueue(n(n({},d),{rawResponse:e}))}}})),[2,(0,a.createAsyncIterable)(c)]}})})},e}();t.YiSimpleModel=l},173: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ZhiPuSimpleModel=void 0;var a=r(689);function s(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tool_choice,a=e.tools,s=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:a,top_p:s})}var l=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=s(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,l,u,c,f;return i(this,function(i){switch(i.label){case 0:return r=s(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 l=i.sent(),u=(0,a.toPolyfillReadable)(l),c=(0,a.intoStandardStream)(u),f=c.pipeThrough(new a.TransformStream({transform:function(e,t){var r=e.choices.map(function(e){var t=e.delta;return null==o&&(o=(0,a.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,a.createAsyncIterable)(f)]}})})},e}();t.ZhiPuSimpleModel=l},328: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultImageModel=void 0;var i=r(713),a=function(){function e(e,t,r){this.req=e,this.baseUrl=t,this.provider=r,this.defaultGenerateImageSubUrl="images/ar/generations",this.generateImageSubUrlConfig={"hunyuan-image":[[/^hunyuan-image(-v[12](\..*)?)?$/,"images/generations"]]},this.generateImage=this.generateImageImpl.bind(this)}return e.prototype.generateImageImpl=function(e){return n(this,void 0,Promise,function(){var t,r,n,a,s;return o(this,function(o){switch(o.label){case 0:if("object"==typeof e&&e&&"model"in e&&"HY-Image-v3.0-I2I-ToB-v1.0.1"===e.model&&(""===this.provider||"hunyuan-image"===this.provider)){if(r=(t=e).image_urls,n=t.images,r&&r.length>1)throw new i.InvalidParamsError("当模型为 HY-Image-v3.0-I2I-ToB-v1.0.1 时,image_urls 最多只能有 1 个元素","image_urls");if(n&&n.length>1)throw new i.InvalidParamsError("当模型为 HY-Image-v3.0-I2I-ToB-v1.0.1 时,images 最多只能有 1 个元素","images")}return a=this.defaultGenerateImageSubUrl,"object"==typeof e&&e&&"model"in e&&"string"==typeof e.model&&(s=this.getGenerateImageSubUrl(this.provider,e.model))&&(a=s),[4,this.req({url:this.getGenerateUrl(a),data:e,stream:!1})];case 1:return[2,o.sent()]}})})},e.prototype.getGenerateUrl=function(e){return"".concat(this.baseUrl,"/").concat(this.provider,"/").concat(e)},e.prototype.getGenerateImageSubUrl=function(e,t){var r=this.generateImageSubUrlConfig[e];if(r)for(var n=0,o=r;n<o.length;n++){var i=o[n],a=i[0],s=i[1];if(a.test(t))return s}},e}();t.DefaultImageModel=a},305:(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(173);Object.defineProperty(t,"ZhiPuSimpleModel",{enumerable:!0,get:function(){return n.ZhiPuSimpleModel}});var o=r(301);Object.defineProperty(t,"HunYuanBetaSimpleModel",{enumerable:!0,get:function(){return o.HunYuanBetaSimpleModel}});var i=r(239);Object.defineProperty(t,"HunYuanSimpleModel",{enumerable:!0,get:function(){return i.HunYuanSimpleModel}});var a=r(476);Object.defineProperty(t,"ArkSimpleModel",{enumerable:!0,get:function(){return a.ArkSimpleModel}});var s=r(265);Object.defineProperty(t,"DSSimpleModel",{enumerable:!0,get:function(){return s.DSSimpleModel}});var l=r(532);Object.defineProperty(t,"YiSimpleModel",{enumerable:!0,get:function(){return l.YiSimpleModel}});var u=r(925);Object.defineProperty(t,"MoonshotSimpleModel",{enumerable:!0,get:function(){return u.MoonshotSimpleModel}});var c=r(720);Object.defineProperty(t,"HunYuanExpSimpleModel",{enumerable:!0,get:function(){return c.HunYuanExpSimpleModel}});var f=r(418);Object.defineProperty(t,"HunYuanOpenSimpleModel",{enumerable:!0,get:function(){return f.HunYuanOpenSimpleModel}});var d=r(102),h=r(17);Object.defineProperty(t,"DefaultSimpleModel",{enumerable:!0,get:function(){return h.DefaultSimpleModel}});var p=r(328);Object.defineProperty(t,"DefaultImageModel",{enumerable:!0,get:function(){return p.DefaultImageModel}}),t.MODELS={hunyuan:i.HunYuanSimpleModel,"hunyuan-beta":o.HunYuanBetaSimpleModel,ark:a.ArkSimpleModel,dashscope:s.DSSimpleModel,"01-ai":l.YiSimpleModel,moonshot:u.MoonshotSimpleModel,zhipu:n.ZhiPuSimpleModel,"hunyuan-exp":c.HunYuanExpSimpleModel,"hunyuan-open":f.HunYuanOpenSimpleModel,deepseek:d.DeepSeekSimpleModel};var b=r(443);Object.defineProperty(t,"ReactModel",{enumerable:!0,get:function(){return b.ReactModel}}),Object.defineProperty(t,"toolMap",{enumerable:!0,get:function(){return b.toolMap}})},443: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},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},s=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)})}}},l=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 u=r(689);function c(e){var t,r=e.onStepFinish,o=e.abortSignal,i=e.maxSteps,s=e.topP,l=e.toolChoice,c=a(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({},c),{tools:null===(t=c.tools)||void 0===t?void 0:t.map(function(e){return"fn"in e?(0,u.functionToolToModelTool)(e):e}),top_p:null!=s?s:c.top_p,tool_choice:null!=l?l:c.tool_choice})]}var f=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,a,s,u,f,y,v,_,g,w,S,P,O,R,T,j,E,k,C,q,I,A=this;return i(this,function(i){switch(i.label){case 0:return o=[],a={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=c(e),u=s[0],f=u.onStepFinish,y=u.maxSteps,v=void 0===y?10:y,_=s[1],[4,(g=function(){return A.model.doGenerate(_,t)})()];case 1:w=i.sent(),S=1,w.rawResponse&&o.push(w.rawResponse),P=null,i.label=2;case 2:if(!(S<v&&null!=(P=d(w))))return[3,9];O=b(w.usage),m(a,O),i.label=3;case 3:return i.trys.push([3,7,,8]),[4,p(P)];case 4:return R=i.sent(),T=w.choices[0],[4,null==f?void 0:f({finishReason:T.finish_reason,messages:_.messages.slice(),text:T.message.content,toolCall:P,toolResult:R,stepUsage:O,totalUsage:Object.assign({},a)})];case 5:return i.sent(),h(_.messages,T.message,R),[4,g()];case 6:return(w=i.sent()).rawResponse&&o.push(w.rawResponse),S+=1,[3,8];case 7:return j=i.sent(),[2,{text:"",messages:_.messages,usage:a,error:j,rawResponses:o}];case 8:return[3,2];case 9:return E=null===(r=null==w?void 0:w.choices)||void 0===r?void 0:r[0],k=null==E?void 0:E.message,C=null!==(n=null==k?void 0:k.content)&&void 0!==n?n:"",q=k?l(l([],_.messages,!0),[k],!1):_.messages,I=b(w.usage),m(a,I),[4,null==f?void 0:f({finishReason:E.finish_reason,messages:q.slice(),text:C,toolCall:d(w),toolResult:null,stepUsage:I,totalUsage:Object.assign({},a)})];case 10:return i.sent(),[2,{text:C,messages:q,usage:a,rawResponses:o}]}})})},e.prototype.streamText=function(e,t){var r;return o(this,void 0,Promise,function(){var n,a,f,d,b,y,v,_,g,w,S,P,O,R,T,j,E,k,C,q,I,A,x,M,W,U,B,D,L,N,F,z,$,Y,G,H,V=this;return i(this,function(Q){switch(Q.label){case 0:return n={completion_tokens:0,prompt_tokens:0,total_tokens:0},a=c(e),f=a[0],d=f.onStepFinish,b=f.maxSteps,y=void 0===b?10:b,v=a[1],[4,(_=function(){return V.model.doStream(v,t)})()];case 1:g=Q.sent(),w=1,S=null,P=function(){var e=g.tee(),t=e[0],r=e[1];return g=(0,u.createAsyncIterable)(t),function(e){var t,r,n,a,l,c,f,d,h,p;return o(this,void 0,Promise,function(){var o,b,m,y,v,_,g,w,S,P,O,R,T;return i(this,function(i){switch(i.label){case 0:o={completion_tokens:0,prompt_tokens:0,total_tokens:0},b=(0,u.createAsyncIterable)(e),y={role:"assistant",content:"",tool_calls:[m={id:"",function:{name:"",arguments:""},type:""}]},i.label=1;case 1:i.trys.push([1,6,7,12]),v=!0,_=s(b),i.label=2;case 2:return[4,_.next()];case 3:if(g=i.sent(),t=g.done)return[3,5];a=g.value,v=!1;try{if(!(S=null==(w=a)?void 0:w.choices[0]))return[2,null];if(P=S.finish_reason,O=S.delta,"tool_calls"!==P)return[2,null];if(!O)return[3,4];if(O.content&&(y.content+=O.content),!("tool_calls"in O))return[3,4];(null==(R=null===(l=null==O?void 0:O.tool_calls)||void 0===l?void 0:l[0])?void 0:R.id)&&(m.id=R.id),(null==R?void 0:R.type)&&(m.type=R.type),(null===(c=null==R?void 0:R.function)||void 0===c?void 0:c.name)&&(m.function.name=R.function.name),(null===(f=null==R?void 0:R.function)||void 0===f?void 0:f.arguments)&&(m.function.arguments+=R.function.arguments),(null===(d=null==w?void 0:w.usage)||void 0===d?void 0:d.completion_tokens)&&(o.completion_tokens=w.usage.completion_tokens),(null===(h=null==w?void 0:w.usage)||void 0===h?void 0:h.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{v=!0}i.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return T=i.sent(),r={error:T},[3,12];case 7:return i.trys.push([7,,10,11]),v||t||!(n=_.return)?[3,9]:[4,n.call(_)];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:y,usage:o}]}})})}(r)},Q.label=2;case 2:return(O=w<y)?[4,P()]:[3,4];case 3:O=null!=(S=Q.sent()),Q.label=4;case 4:if(!O)return[3,11];R=S.message,T=S.usage,m(n,T),j=null===(r=R.tool_calls)||void 0===r?void 0:r[0],Q.label=5;case 5:return Q.trys.push([5,9,,10]),[4,p(j)];case 6:return E=Q.sent(),[4,null==d?void 0:d({finishReason:"tool_calls",messages:v.messages.slice(),text:R.content,toolCall:j,toolResult:E,stepUsage:T,totalUsage:Object.assign({},n)})];case 7:return Q.sent(),h(v.messages,R,E),[4,_()];case 8:return g=Q.sent(),[3,10];case 9:return k=Q.sent(),C=g.tee(),q=C[0],I=C[1],[2,{messages:Promise.resolve(v.messages),dataStream:(0,u.createAsyncIterable)(q),textStream:(0,u.createAsyncIterable)(I.pipeThrough(new u.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:k}];case 10:return[3,2];case 11:return[4,P()];case 12:return(S=Q.sent())?(A=S.message,x=S.usage,m(n,x),M=l(l([],v.messages,!0),[A],!1),d({messages:M.slice(),finishReason:"tool_call",stepUsage:x,text:A.content,toolCall:A.tool_calls[0],totalUsage:Object.assign({},n)}),W=g.tee(),U=W[0],B=W[1],[2,{messages:Promise.resolve(l(l([],v.messages,!0),[A],!1)),dataStream:(0,u.createAsyncIterable)(U),textStream:(0,u.createAsyncIterable)(B.pipeThrough(new u.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)}]):(D=(0,u.createPromise)(),L=(0,u.createPromise)(),N={role:"assistant",content:""},F="",z={completion_tokens:0,prompt_tokens:0,total_tokens:0},$=g.pipeThrough(new u.TransformStream({transform:function(e,t){var r,n,o,i,a,s,l,u,c=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 c&&(N.content+=c);var f=null===(a=null===(i=null==e?void 0:e.choices)||void 0===i?void 0:i[0])||void 0===a?void 0:a.finish_reason;f&&(F=f),(null===(s=null==e?void 0:e.usage)||void 0===s?void 0:s.completion_tokens)&&(z.completion_tokens=e.usage.completion_tokens),(null===(l=null==e?void 0:e.usage)||void 0===l?void 0:l.prompt_tokens)&&(z.prompt_tokens=e.usage.prompt_tokens),(null===(u=null==e?void 0:e.usage)||void 0===u?void 0:u.total_tokens)&&(z.total_tokens=e.usage.total_tokens),t.enqueue(e)},flush:function(){D.res(l(l([],v.messages,!0),[N],!1)),m(n,z),L.res(Object.assign({},n)),null==d||d({messages:l(l([],v.messages,!0),[N],!1),finishReason:F,text:N.content,stepUsage:z,totalUsage:Object.assign({},n)})}})),Y=$.tee(),G=Y[0],H=Y[1],[2,{messages:D.promise,dataStream:(0,u.createAsyncIterable)(G),textStream:(0,u.createAsyncIterable)(H.pipeThrough(new u.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:L.promise}])}})})},e}();function d(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,u.isToolCallAssistantMessage)(o)?o.tool_calls[0]:null}function h(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 b(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 m(e,t){e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens}t.ReactModel=f,t.toolMap=new Map},669:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleChatModel=void 0;t.SimpleChatModel=function(){}},689: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},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 a=r(993),s=r(308),l=r(964),u=r(410),c="function"==typeof globalThis.ReadableStream&&"function"==typeof globalThis.TransformStream&&"function"==typeof globalThis.ReadableStream.prototype.pipeThrough;t.ReadableStream=c?globalThis.ReadableStream:a.ReadableStream,t.TransformStream=c?globalThis.TransformStream:a.TransformStream,t.createEventSourceParserTransformStream=function(){var e;return new t.TransformStream({start:function(t){e=(0,l.createParser)(function(e){"event"===e.type&&t.enqueue(e)})},transform:function(t){e.feed(t)}})},t.toPolyfillReadable=c?function(e){return e}:(0,s.createReadableStreamWrapper)(t.ReadableStream);var f=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 u.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 f))}t.TextDecoderStream=f,t.createAsyncIterable=d,t.intoStandardStream=function(e){return d(e.pipeThrough(new f).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,a,s;return n(this,void 0,void 0,function(){var n,l,u,c,f,d;return o(this,function(o){switch(o.label){case 0:n=h(e),l="",o.label=1;case 1:o.trys.push([1,6,7,12]),u=!0,c=i(n),o.label=2;case 2:return[4,c.next()];case 3:if(f=o.sent(),t=f.done)return[3,5];s=f.value,u=!1;try{l+=s}finally{u=!0}o.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return d=o.sent(),r={error:d},[3,12];case 7:return o.trys.push([7,,10,11]),u||t||!(a=c.return)?[3,9]:[4,a.call(c)];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(l)]}})})},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}}}},563: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}),a=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 s,l=a(r(92)),u=r(962);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(s=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var r=0,o=(0,u.isArray)(e)?e:[e];r<o.length;r++){var i=o[r],a=i.isMatch,s=i.genAdapter,l=i.runtime;if(a())return{adapter:n({isMatch:a},s(t)),runtime:l}}},t.useDefaultAdapter=function(){return{adapter:n({},l.genAdapter()),runtime:s.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)},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var l=r(829),u=r(962),c=r(464),f=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,a=e.headers,s=void 0===a?{}:a,l={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",u=new FormData;return"post"===l?(Object.keys(t).forEach(function(e){u.append(e,t[e])}),u.append("key",n),u.append("file",r),this.request(i(i({},e),{data:u,method:l}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:s,body:r}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return a(this,void 0,Promise,function(){var t,r,n,o;return s(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=a.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 a.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 a(this,void 0,Promise,function(){var r,n,o,l,u,c,f,d,h,p,b,m,y,v=this;return s(this,function(_){switch(_.label){case 0:return r=new AbortController,n=e.url,o=e.enableAbort,l=void 0!==o&&o,u=e.stream,c=void 0!==u&&u,f=e.signal,d=e.timeout,h=e.shouldThrowOnError,p=void 0===h||h,b=null!=d?d:this.timeout,f&&(f.aborted&&r.abort(),f.addEventListener("abort",function(){return r.abort()})),m=null,l&&b&&(m=setTimeout(function(){console.warn(v.timeoutMsg),r.abort(new Error(v.timeoutMsg))},b)),[4,fetch(n,i(i({},e),{signal:r.signal})).then(function(e){return a(v,void 0,void 0,function(){var t,r,n;return s(this,function(o){switch(o.label){case 0:return clearTimeout(m),p?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return n=(r=Promise).reject,[4,e.json()];case 2:t=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}})})}).catch(function(e){return clearTimeout(m),Promise.reject(e)})];case 1:return y=_.sent(),[2,{data:c?y.body:(null===(t=y.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?y.json():y.text(),statusCode:y.status,header:y.headers,response:y}]}})})},t.prototype.request=function(e,t){var r=this;void 0===t&&(t=!1);var n=String(e.method).toLowerCase()||"get";return new Promise(function(o){var i=e.url,a=e.headers,s=void 0===a?{}:a,l=e.data,f=e.responseType,d=e.withCredentials,h=e.body,p=e.onUploadProgress,b=(0,u.formatUrl)((0,c.getProtocol)(),i,"get"===n?l:{}),m=new XMLHttpRequest;m.open(n,b),f&&(m.responseType=f);var y,v,_=e.signal;_&&(_.aborted?m.abort():_.addEventListener("abort",function(){return m.abort()},{once:!0})),Object.keys(s).forEach(function(e){m.setRequestHeader(e,s[e])}),p&&m.upload.addEventListener("progress",p),m.onreadystatechange=function(){var e={};if(4===m.readyState){var t=m.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=m.status;try{e.data="blob"===f?m.response:JSON.parse(m.responseText)}catch(t){e.data="blob"===f?m.response:m.responseText}clearTimeout(y),o(e)}},t&&r.timeout&&(y=setTimeout(function(){console.warn(r.timeoutMsg),m.abort()},r.timeout)),v=(0,u.isFormData)(l)?l:"application/x-www-form-urlencoded"===s["content-type"]?(0,u.toQueryString)(l):h||(l?JSON.stringify(l):void 0),d&&(m.withCredentials=!0),m.send(v)})},t}(l.AbstractSDKRequest);t.WebRequest=f,t.genAdapter=function(){return{type:"default",root:window,reqClass:f,wsClass:WebSocket,localStorage}}},464:(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"},519:(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"}},778: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(464),t),o(r(519),t),t.OATUH_LOGINTYPE="constants"},517: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=r(962),a=r(778),s=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(s=-1!==navigator.userAgent.indexOf("Firefox"));var l=s?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,u=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function c(e){var t=e.err,r=e.className,n=e.methodName,o=e.sourceLink;if(!o)return null;var i,a=t.stack.split("\n"),l=s?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),c=s?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),f=a.findIndex(function(e){return l.test(e)});if(-1!==f){var d=a.filter(function(e,t){return t>f});d.unshift(a[f].replace(c,"".concat(r,".").concat(n)).replace(u,o)),(i=new Error).stack="".concat(s?"@debugger":"Error","\n").concat(d.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,r=void 0===t?"async":t,s=e.customInfo,f=void 0===s?{}:s,d=e.title,h=e.messages,p=void 0===h?[]:h;return function(e,t,s){if(a.IS_DEBUG_MODE){var h=f.className||e.constructor.name,b=f.methodName||t,m=s.value,y=function(){var e="",t=(new Error).stack.split("\n"),r=t.findIndex(function(e){return l.test(e)});if(-1!==r){var n=u.exec(t[r+1]||"");e=n?n[0]:""}return e}();s.value="sync"===r?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=c({err:new Error,className:h,methodName:b,sourceLink:y});try{return m.apply(this,e)}catch(e){var n=e,o=e.message,a=e.error,s=e.error_description,l={title:d||"".concat(h,".").concat(b," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var u=JSON.parse(o);l.subtitle=o,u.code&&(r?(r.code=u.code,r.msg=u.msg):(e.code=u.code,e.message=u.msg),n=r||e,l.content=p.map(function(e){return{type:"info",body:e}}))}throw a&&s&&(l.subtitle=s,r?(r.code=a,r.msg=s):(e.code=a,e.message=s),n=r||e,l.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(l),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,a,s,l,u,f;return o(this,function(o){switch(o.label){case 0:t=c({err:new Error,className:h,methodName:b,sourceLink:y}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,m.apply(this,e)];case 2:return[2,o.sent()];case 3:throw r=o.sent(),n=r,a=r.message,s=r.error,l=r.error_description,u={title:d||"".concat(h,".").concat(b," failed"),content:[{type:"error",body:r}]},a&&/^\{.*\}$/.test(a)&&(f=JSON.parse(a),u.subtitle=f,f.code&&(t?(t.code=f.code,t.message=f.msg):(r.code=f.code,r.message=f.msg),n=t||r,u.content=p.map(function(e){return{type:"info",body:e}}))),s&&l&&(u.subtitle=l,t?(t.code=s,t.msg=l):(r.code=s,r.message=l),n=t||r,u.content=p.map(function(e){return{type:"info",body:e}})),(0,i.printGroupLog)(u),n;case 4:return[2]}})})}}}}},260: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(517),t)},877: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},a=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 s=i(r(778));t.constants=s;var l=i(r(563));t.adapters=l;var u=i(r(865));t.cache=u;var c=i(r(940));t.events=c;var f=i(r(991));t.langEvent=f;var d=i(r(962));t.utils=d;var h=i(r(260));t.helpers=h;var p=a(r(644));t.AbortController=p.default;var b={decode:a(r(949)).default};t.jwt=b},644:(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},865: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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(a,s)}l((n=n.apply(e,t||[])).next())})},a=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var s=r(829),l=r(962),u=r(778),c=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}(s.AbstractStorage),f=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,l.printWarn)(u.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new c(t.root));case"none":return new c(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:u.ERRORS.OPERATION_FAIL,msg:"[".concat((0,u.getSdkName)(),"][").concat(u.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,l.printWarn)(u.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 a(this,function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}})})},e.prototype.getStore=function(e,t){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var n=this.storage.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""}(0,l.printWarn)(u.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 a(this,function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r={IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0})||void 0===r?void 0:r.tcb_token))return[2,{IS_MP_BUILD:!0,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(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,l.printWarn)(u.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 a(this,function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}})})},e}();t.CloudbaseCache=f},940: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 a=r(962),s=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=s;var l=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}(s);t.IErrorEvent=l;var u=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,a.isInstanceOf)(e,l))return console.error(e.error),this;var r=(0,a.isString)(e)?new s(e,t||{}):e,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,u=this.listeners[n]?i([],this.listeners[n],!0):[];o<u.length;o++)u[o].call(this,r)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=u;var c=new u;t.addEventListener=function(e,t){c.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),c.fire(e,t)},t.removeEventListener=function(e,t){c.off(e,t)}},991:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LANG_CHANGE_EVENT=t.bus=void 0;var n=r(940);t.bus=new n.CloudbaseEventEmitter,t.LANG_CHANGE_EVENT="lang_change"},962:function(e,t,r){"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(778);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var n=16*Math.random();return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),("x"===r?n:7&n|8).toString(16)})},t.formatUrl=function(e,t,r){void 0===r&&(r={});var n=/\?/.test(t),o="";return Object.keys(r).forEach(function(e){""===o?!n&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(r[e]))}),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach(function(r){t.push("".concat(r,"=").concat(encodeURIComponent(e[r])))}),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var r=t||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var r=t.split("?")[0],n=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===e&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var r=new Promise(function(t,r){e=function(e,n){return e?r(e):t(n)}});return e.promise=r,e},t.execCallback=function(e,t,r){if(void 0===r&&(r=null),e&&"function"==typeof e)return e(t,r);if(t)throw t;return r},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,r=e.title,n=e.subtitle,o=void 0===n?"":n,i=e.content,a=void 0===i?[]:i,s=e.printTrace,l=void 0!==s&&s,u=e.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var c=0,f=a;c<f.length;c++){var d=f[c],h=d.type,p=d.body;switch(h){case"info":console.log(p);break;case"warn":console.warn(p);break;case"error":console.error(p)}}l&&(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 a=r.token,s=n(r,["token"]);return/^data:/.test(e)&&!a?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:a?{state:s.state,token:a,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},949:(e,t,r)=>{"use strict";function n(e){this.message=e}r.r(t),r.d(t,{InvalidTokenError:()=>a,default:()=>s}),n.prototype=new Error,n.prototype.name="InvalidCharacterError";var o="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new n("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,o,i=0,a=0,s="";o=t.charAt(a++);~o&&(r=i%4?64*r+o:o,i++%4)?s+=String.fromCharCode(255&r>>(-2*i&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return s};function i(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(e){return decodeURIComponent(o(e).replace(/(.)/g,function(e,t){var r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r}))}(t)}catch(e){return o(t)}}function a(e){this.message=e}a.prototype=new Error,a.prototype.name="InvalidTokenError";const s=function(e,t){if("string"!=typeof e)throw new a("Invalid token specified");var r=!0===(t=t||{}).header?0:1;try{return JSON.parse(i(e.split(".")[r]))}catch(e){throw new a("Invalid token specified: "+e.message)}}},410:function(e,t,r){var n,o;void 0===(o="function"==typeof(n=function(){"use strict";var e=void 0!==r.g?r.g:self;if(void 0!==e.TextEncoder&&void 0!==e.TextDecoder)return{TextEncoder:e.TextEncoder,TextDecoder:e.TextDecoder};var t=["utf8","utf-8","unicode-1-1-utf-8"];return{TextEncoder:function(e){if(t.indexOf(e)<0&&null!=e)throw new RangeError("Invalid encoding type. Only utf-8 is supported");this.encoding="utf-8",this.encode=function(e){if("string"!=typeof e)throw new TypeError("passed argument must be of type string");var t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);return t.split("").forEach(function(e,t){r[t]=e.charCodeAt(0)}),r}},TextDecoder:function(e,r){if(t.indexOf(e)<0&&null!=e)throw new RangeError("Invalid encoding type. Only utf-8 is supported");if(this.encoding="utf-8",this.ignoreBOM=!1,this.fatal=void 0!==r&&"fatal"in r&&r.fatal,"boolean"!=typeof this.fatal)throw new TypeError("fatal flag must be boolean");this.decode=function(e,t){if(void 0===e)return"";if("boolean"!=typeof(void 0!==t&&"stream"in t&&t.stream))throw new TypeError("stream option must be boolean");if(ArrayBuffer.isView(e)){var r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=new Array(r.length);return r.forEach(function(e,t){n[t]=String.fromCharCode(e)}),decodeURIComponent(escape(n.join("")))}throw new TypeError("passed argument must be an array buffer view")}}}})?n.apply(t,[]):n)||(e.exports=o)},308:(e,t,r)=>{"use strict";r.r(t),r.d(t,{createReadableStreamWrapper:()=>h,createTransformStreamWrapper:()=>P,createWrappingReadableSource:()=>p,createWrappingTransformer:()=>O,createWrappingWritableSink:()=>w,createWritableStreamWrapper:()=>g});var 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 o(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)}function i(e){if(!e)throw new TypeError("Assertion failed")}function a(){}function s(e){return"object"==typeof e&&null!==e||"function"==typeof e}function l(e){if("function"!=typeof e)return!1;var t=!1;try{new e({start:function(){t=!0}})}catch(e){}return t}function u(e){return!!s(e)&&"function"==typeof e.getReader}function c(e){return!!s(e)&&"function"==typeof e.getWriter}function f(e){return!!s(e)&&!!u(e.readable)&&!!c(e.writable)}function d(e){try{return e.getReader({mode:"byob"}).releaseLock(),!0}catch(e){return!1}}function h(e){i(function(e){return!!l(e)&&!!u(new e)}(e));var t=function(e){try{return new e({type:"bytes"}),!0}catch(e){return!1}}(e);return function(r,n){var o=(void 0===n?{}:n).type;if("bytes"!==(o=b(o))||t||(o=void 0),r.constructor===e&&("bytes"!==o||d(r)))return r;if("bytes"===o){var i=p(r,{type:o});return new e(i)}return i=p(r),new e(i)}}function p(e,t){var r=(void 0===t?{}:t).type;return i(u(e)),i(!1===e.locked),"bytes"===(r=b(r))?new _(e):new y(e)}function b(e){var t=String(e);if("bytes"===t)return t;if(void 0===e)return e;throw new RangeError("Invalid type is specified")}var m=function(){function e(e){this._underlyingReader=void 0,this._readerMode=void 0,this._readableStreamController=void 0,this._pendingRead=void 0,this._underlyingStream=e,this._attachDefaultReader()}return e.prototype.start=function(e){this._readableStreamController=e},e.prototype.cancel=function(e){return i(void 0!==this._underlyingReader),this._underlyingReader.cancel(e)},e.prototype._attachDefaultReader=function(){if("default"!==this._readerMode){this._detachReader();var e=this._underlyingStream.getReader();this._readerMode="default",this._attachReader(e)}},e.prototype._attachReader=function(e){var t=this;i(void 0===this._underlyingReader),this._underlyingReader=e;var r=this._underlyingReader.closed;r&&r.then(function(){return t._finishPendingRead()}).then(function(){e===t._underlyingReader&&t._readableStreamController.close()},function(r){e===t._underlyingReader&&t._readableStreamController.error(r)}).catch(a)},e.prototype._detachReader=function(){void 0!==this._underlyingReader&&(this._underlyingReader.releaseLock(),this._underlyingReader=void 0,this._readerMode=void 0)},e.prototype._pullWithDefaultReader=function(){var e=this;this._attachDefaultReader();var t=this._underlyingReader.read().then(function(t){var r=e._readableStreamController;t.done?e._tryClose():r.enqueue(t.value)});return this._setPendingRead(t),t},e.prototype._tryClose=function(){try{this._readableStreamController.close()}catch(e){}},e.prototype._setPendingRead=function(e){var t,r=this,n=function(){r._pendingRead===t&&(r._pendingRead=void 0)};this._pendingRead=t=e.then(n,n)},e.prototype._finishPendingRead=function(){var e=this;if(this._pendingRead){var t=function(){return e._finishPendingRead()};return this._pendingRead.then(t,t)}},e}(),y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.pull=function(){return this._pullWithDefaultReader()},t}(m);function v(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var _=function(e){function t(t){var r=this,n=d(t);return(r=e.call(this,t)||this)._supportsByob=n,r}return o(t,e),Object.defineProperty(t.prototype,"type",{get:function(){return"bytes"},enumerable:!1,configurable:!0}),t.prototype._attachByobReader=function(){if("byob"!==this._readerMode){i(this._supportsByob),this._detachReader();var e=this._underlyingStream.getReader({mode:"byob"});this._readerMode="byob",this._attachReader(e)}},t.prototype.pull=function(){if(this._supportsByob){var e=this._readableStreamController.byobRequest;if(e)return this._pullWithByobRequest(e)}return this._pullWithDefaultReader()},t.prototype._pullWithByobRequest=function(e){var t=this;this._attachByobReader();var r=new Uint8Array(e.view.byteLength),n=this._underlyingReader.read(r).then(function(r){var n,o,i;t._readableStreamController,r.done?(t._tryClose(),e.respond(0)):(n=r.value,o=e.view,i=v(n),v(o).set(i,0),e.respond(r.value.byteLength))});return this._setPendingRead(n),n},t}(m);function g(e){return i(function(e){return!!l(e)&&!!c(new e)}(e)),function(t){if(t.constructor===e)return t;var r=w(t);return new e(r)}}function w(e){i(c(e)),i(!1===e.locked);var t=e.getWriter();return new S(t)}var S=function(){function e(e){var t=this;this._writableStreamController=void 0,this._pendingWrite=void 0,this._state="writable",this._storedError=void 0,this._underlyingWriter=e,this._errorPromise=new Promise(function(e,r){t._errorPromiseReject=r}),this._errorPromise.catch(a)}return e.prototype.start=function(e){var t=this;this._writableStreamController=e,this._underlyingWriter.closed.then(function(){t._state="closed"}).catch(function(e){return t._finishErroring(e)})},e.prototype.write=function(e){var t=this,r=this._underlyingWriter;if(null===r.desiredSize)return r.ready;var n=r.write(e);n.catch(function(e){return t._finishErroring(e)}),r.ready.catch(function(e){return t._startErroring(e)});var o=Promise.race([n,this._errorPromise]);return this._setPendingWrite(o),o},e.prototype.close=function(){var e=this;return void 0===this._pendingWrite?this._underlyingWriter.close():this._finishPendingWrite().then(function(){return e.close()})},e.prototype.abort=function(e){if("errored"!==this._state)return this._underlyingWriter.abort(e)},e.prototype._setPendingWrite=function(e){var t,r=this,n=function(){r._pendingWrite===t&&(r._pendingWrite=void 0)};this._pendingWrite=t=e.then(n,n)},e.prototype._finishPendingWrite=function(){var e=this;if(void 0===this._pendingWrite)return Promise.resolve();var t=function(){return e._finishPendingWrite()};return this._pendingWrite.then(t,t)},e.prototype._startErroring=function(e){var t=this;if("writable"===this._state){this._state="erroring",this._storedError=e;var r=function(){return t._finishErroring(e)};void 0===this._pendingWrite?r():this._finishPendingWrite().then(r,r),this._writableStreamController.error(e)}},e.prototype._finishErroring=function(e){"writable"===this._state&&this._startErroring(e),"erroring"===this._state&&(this._state="errored",this._errorPromiseReject(this._storedError))},e}();function P(e){return i(function(e){return!!l(e)&&!!f(new e)}(e)),function(t){if(t.constructor===e)return t;var r=O(t);return new e(r)}}function O(e){i(f(e));var t=e.readable,r=e.writable;i(!1===t.locked),i(!1===r.locked);var n,o=t.getReader();try{n=r.getWriter()}catch(e){throw o.releaseLock(),e}return new R(o,n)}var R=function(){function e(e,t){var r=this;this._transformStreamController=void 0,this._onRead=function(e){if(!e.done)return r._transformStreamController.enqueue(e.value),r._reader.read().then(r._onRead)},this._onError=function(e){r._flushReject(e),r._transformStreamController.error(e),r._reader.cancel(e).catch(a),r._writer.abort(e).catch(a)},this._onTerminate=function(){r._flushResolve(),r._transformStreamController.terminate();var e=new TypeError("TransformStream terminated");r._writer.abort(e).catch(a)},this._reader=e,this._writer=t,this._flushPromise=new Promise(function(e,t){r._flushResolve=e,r._flushReject=t})}return e.prototype.start=function(e){this._transformStreamController=e,this._reader.read().then(this._onRead).then(this._onTerminate,this._onError);var t=this._reader.closed;t&&t.then(this._onTerminate,this._onError)},e.prototype.transform=function(e){return this._writer.write(e)},e.prototype.flush=function(){var e=this;return this._writer.close().then(function(){return e._flushPromise})},e}()},993:(e,t,r)=>{"use strict";function n(){}function o(e){return"object"==typeof e&&null!==e||"function"==typeof e}r.r(t),r.d(t,{ByteLengthQueuingStrategy:()=>nn,CountQueuingStrategy:()=>ln,ReadableByteStreamController:()=>Me,ReadableStream:()=>Yr,ReadableStreamBYOBReader:()=>mt,ReadableStreamBYOBRequest:()=>xe,ReadableStreamDefaultController:()=>jr,ReadableStreamDefaultReader:()=>te,TransformStream:()=>bn,TransformStreamDefaultController:()=>wn,WritableStream:()=>It,WritableStreamDefaultController:()=>Xt,WritableStreamDefaultWriter:()=>Yt});const i=n;function a(e,t){try{Object.defineProperty(e,"name",{value:t,configurable:!0})}catch(e){}}const s=Promise,l=Promise.resolve.bind(s),u=Promise.prototype.then,c=Promise.reject.bind(s),f=l;function d(e){return new s(e)}function h(e){return d(t=>t(e))}function p(e){return c(e)}function b(e,t,r){return u.call(e,t,r)}function m(e,t,r){b(b(e,t,r),void 0,i)}function y(e,t){m(e,t)}function v(e,t){m(e,void 0,t)}function _(e,t,r){return b(e,t,r)}function g(e){b(e,void 0,i)}let w=e=>{if("function"==typeof queueMicrotask)w=queueMicrotask;else{const e=h(void 0);w=t=>b(e,t)}return w(e)};function S(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function P(e,t,r){try{return h(S(e,t,r))}catch(e){return p(e)}}class O{constructor(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}get length(){return this._size}push(e){const t=this._back;let r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size}shift(){const e=this._front;let t=e;const r=this._cursor;let n=r+1;const o=e._elements,i=o[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),o[r]=void 0,i}forEach(e){let t=this._cursor,r=this._front,n=r._elements;for(;!(t===n.length&&void 0===r._next||t===n.length&&(r=r._next,n=r._elements,t=0,0===n.length));)e(n[t]),++t}peek(){const e=this._front,t=this._cursor;return e._elements[t]}}const R=Symbol("[[AbortSteps]]"),T=Symbol("[[ErrorSteps]]"),j=Symbol("[[CancelSteps]]"),E=Symbol("[[PullSteps]]"),k=Symbol("[[CanPullSyncSteps]]"),C=Symbol("[[ReleaseSteps]]");function q(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?M(e):"closed"===t._state?function(e){M(e),B(e)}(e):W(e,t._storedError)}function I(e,t){return Kr(e._ownerReadableStream,t)}function A(e){const t=e._ownerReadableStream;"readable"===t._state?U(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e){W(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness"))}(e),t._readableStreamController[C](),t._reader=void 0,e._ownerReadableStream=void 0}function x(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function M(e){e._closedPromise=d((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function W(e,t){M(e),U(e,t)}function U(e,t){void 0!==e._closedPromise_reject&&(g(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function B(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}const D=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},L=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function N(e,t){if(void 0!==e&&"object"!=typeof(r=e)&&"function"!=typeof r)throw new TypeError(`${t} is not an object.`);var r}function F(e,t){if("function"!=typeof e)throw new TypeError(`${t} is not a function.`)}function z(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(`${t} is not an object.`)}function $(e,t,r){if(void 0===e)throw new TypeError(`Parameter ${t} is required in '${r}'.`)}function Y(e,t,r){if(void 0===e)throw new TypeError(`${t} is required in '${r}'.`)}function G(e){return Number(e)}function H(e){return 0===e?0:e}function V(e,t){const r=Number.MAX_SAFE_INTEGER;let n=Number(e);if(n=H(n),!D(n))throw new TypeError(`${t} is not a finite number`);if(n=function(e){return H(L(e))}(n),n<0||n>r)throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);return D(n)&&0!==n?n:0}function Q(e,t){if(!Qr(e))throw new TypeError(`${t} is not a ReadableStream.`)}function J(e){return new te(e)}function K(e,t){e._reader._readRequests.push(t)}function X(e,t,r){const n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function Z(e){return e._reader._readRequests.length}function ee(e){const t=e._reader;return void 0!==t&&!!oe(t)}class te{constructor(e){if($(e,1,"ReadableStreamDefaultReader"),Q(e,"First parameter"),Jr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");q(this,e),this._readRequests=new O}get closed(){return oe(this)?this._closedPromise:p(le("closed"))}cancel(e=void 0){return oe(this)?void 0===this._ownerReadableStream?p(x("cancel")):I(this,e):p(le("cancel"))}read(){if(!oe(this))return p(le("read"));if(void 0===this._ownerReadableStream)return p(x("read from"));const e=ae(this)?new ne:new re;return ie(this,e),e._promise}releaseLock(){if(!oe(this))throw le("releaseLock");void 0!==this._ownerReadableStream&&function(e){A(e),se(e,new TypeError("Reader was released"))}(this)}}Object.defineProperties(te.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),a(te.prototype.cancel,"cancel"),a(te.prototype.read,"read"),a(te.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(te.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});class re{constructor(){this._promise=d((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._resolvePromise({value:e,done:!1})}_closeSteps(){this._resolvePromise({value:void 0,done:!0})}_errorSteps(e){this._rejectPromise(e)}}class ne{constructor(){this._promise=void 0}_chunkSteps(e){this._promise=f({value:e,done:!1})}_closeSteps(){this._promise=f({value:void 0,done:!0})}_errorSteps(e){this._promise=p(e)}}function oe(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof te}function ie(e,t){const r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[E](t)}function ae(e){const t=e._ownerReadableStream;return"closed"===t._state||"errored"===t._state||t._readableStreamController[k]()}function se(e,t){const r=e._readRequests;e._readRequests=new O,r.forEach(e=>{e._errorSteps(t)})}function le(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}var ue,ce,fe;function de(e){return e.slice()}function he(e,t,r,n,o){new Uint8Array(e).set(new Uint8Array(r,n,o),t)}let pe=e=>(pe="function"==typeof e.transfer?e=>e.transfer():"function"==typeof structuredClone?e=>structuredClone(e,{transfer:[e]}):e=>e,pe(e)),be=e=>(be="boolean"==typeof e.detached?e=>e.detached:e=>0===e.byteLength,be(e));function me(e,t,r){if(e.slice)return e.slice(t,r);const n=r-t,o=new ArrayBuffer(n);return he(o,0,e,t,n),o}function ye(e,t){const r=e[t];if(null!=r){if("function"!=typeof r)throw new TypeError(`${String(t)} is not a function`);return r}}function ve(e){try{const t=e.done,r=e.value;return b(f(r),e=>({done:t,value:e}))}catch(e){return p(e)}}const _e=null!==(fe=null!==(ue=Symbol.asyncIterator)&&void 0!==ue?ue:null===(ce=Symbol.for)||void 0===ce?void 0:ce.call(Symbol,"Symbol.asyncIterator"))&&void 0!==fe?fe:"@@asyncIterator";function ge(e,t="sync",r){if(void 0===r)if("async"===t){if(void 0===(r=ye(e,_e)))return function(e){const t={next(){let t;try{t=we(e)}catch(e){return p(e)}return ve(t)},return(t){let r;try{const n=ye(e.iterator,"return");if(void 0===n)return h({done:!0,value:t});r=S(n,e.iterator,[t])}catch(e){return p(e)}return o(r)?ve(r):p(new TypeError("The iterator.return() method must return an object"))}};return{iterator:t,nextMethod:t.next,done:!1}}(ge(e,"sync",ye(e,Symbol.iterator)))}else r=ye(e,Symbol.iterator);if(void 0===r)throw new TypeError("The object is not iterable");const n=S(r,e,[]);if(!o(n))throw new TypeError("The iterator method must return an object");return{iterator:n,nextMethod:n.next,done:!1}}function we(e){const t=S(e.nextMethod,e.iterator,[]);if(!o(t))throw new TypeError("The iterator.next() method must return an object");return t}class Se{constructor(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}next(){const e=()=>this._nextSteps();return this._ongoingPromise=this._ongoingPromise?_(this._ongoingPromise,e,e):e(),this._ongoingPromise}return(e){const t=()=>this._returnSteps(e);return this._ongoingPromise=this._ongoingPromise?_(this._ongoingPromise,t,t):t(),this._ongoingPromise}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const e=this._reader,t=new Pe(this);return ie(e,t),t._promise}_returnSteps(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;const t=this._reader;if(!this._preventCancel){const r=I(t,e);return A(t),_(r,()=>({value:e,done:!0}))}return A(t),h({value:e,done:!0})}}class Pe{constructor(e){this._iterator=e,this._promise=d((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._iterator._ongoingPromise=void 0,w(()=>this._resolvePromise({value:e,done:!1}))}_closeSteps(){const e=this._iterator;e._ongoingPromise=void 0,e._isFinished=!0,A(e._reader),this._resolvePromise({value:void 0,done:!0})}_errorSteps(e){const t=this._iterator;t._ongoingPromise=void 0,t._isFinished=!0,A(t._reader),this._rejectPromise(e)}}const Oe={next(){return Re(this)?this._asyncIteratorImpl.next():p(Te("next"))},return(e){return Re(this)?this._asyncIteratorImpl.return(e):p(Te("return"))},[_e](){return this}};function Re(e){if(!o(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof Se}catch(e){return!1}}function Te(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}Object.defineProperty(Oe,_e,{enumerable:!1});const je=Number.isNaN||function(e){return e!=e};function Ee(e){const t=me(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function ke(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Ce(e,t,r){if("number"!=typeof(n=r)||je(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function qe(e){e._queue=new O,e._queueTotalSize=0}function Ie(e){return e===DataView}function Ae(e){return Ie(e)?1:e.BYTES_PER_ELEMENT}class xe{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!Ue(this))throw ut("view");return this._view}respond(e){if(!Ue(this))throw ut("respond");if($(e,1,"respond"),e=V(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(be(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");at(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!Ue(this))throw ut("respondWithNewView");if($(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(be(e.buffer))throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");st(this._associatedReadableByteStreamController,e)}}Object.defineProperties(xe.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),a(xe.prototype.respond,"respond"),a(xe.prototype.respondWithNewView,"respondWithNewView"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(xe.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});class Me{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!We(this))throw ct("byobRequest");return ot(this)}get desiredSize(){if(!We(this))throw ct("desiredSize");return it(this)}close(){if(!We(this))throw ct("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);et(this)}enqueue(e){if(!We(this))throw ct("enqueue");if($(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);tt(this,e)}error(e=void 0){if(!We(this))throw ct("error");rt(this,e)}[j](e){De(this),qe(this);const t=this._cancelAlgorithm(e);return Ze(this),t}[E](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0)return void nt(this,e);const r=this._autoAllocateChunkSize;if(void 0!==r){let n;try{n=new ArrayBuffer(r)}catch(t){return void e._errorSteps(t)}const o={buffer:n,bufferByteLength:r,byteOffset:0,byteLength:r,bytesFilled:0,minimumFill:1,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}K(t,e),Be(this)}[k](){return this._queueTotalSize>0}[C](){if(this._pendingPullIntos.length>0){const e=this._pendingPullIntos.peek();e.readerType="none",this._pendingPullIntos=new O,this._pendingPullIntos.push(e)}}}function We(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof Me}function Ue(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof xe}function Be(e){const t=function(e){const t=e._controlledReadableByteStream;return"readable"===t._state&&(!e._closeRequested&&(!!e._started&&(!!(ee(t)&&Z(t)>0)||(!!(bt(t)&&pt(t)>0)||it(e)>0))))}(e);t&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,m(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,Be(e)),null),t=>(rt(e,t),null))))}function De(e){Qe(e),e._pendingPullIntos=new O}function Le(e,t){let r=!1;"closed"===e._state&&(r=!0);const n=Fe(t);"default"===t.readerType?X(e,n,r):function(e,t,r){const n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function Ne(e,t){for(let r=0;r<t.length;++r)Le(e,t[r])}function Fe(e){const t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function ze(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function $e(e,t,r,n){let o;try{o=me(t,r,r+n)}catch(t){throw rt(e,t),t}ze(e,o,0,n)}function Ye(e,t){t.bytesFilled>0&&$e(e,t.buffer,t.byteOffset,t.bytesFilled),Xe(e)}function Ge(e,t){const r=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),n=t.bytesFilled+r;let o=r,i=!1;const a=n-n%t.elementSize;a>=t.minimumFill&&(o=a-t.bytesFilled,i=!0);const s=e._queue;for(;o>0;){const r=s.peek(),n=Math.min(o,r.byteLength),i=t.byteOffset+t.bytesFilled;he(t.buffer,i,r.buffer,r.byteOffset,n),r.byteLength===n?s.shift():(r.byteOffset+=n,r.byteLength-=n),e._queueTotalSize-=n,He(0,n,t),o-=n}return i}function He(e,t,r){r.bytesFilled+=t}function Ve(e){0===e._queueTotalSize&&e._closeRequested?(Ze(e),Xr(e._controlledReadableByteStream)):Be(e)}function Qe(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function Je(e){const t=[];for(;e._pendingPullIntos.length>0&&0!==e._queueTotalSize;){const r=e._pendingPullIntos.peek();Ge(e,r)&&(Xe(e),t.push(r))}return t}function Ke(e,t){const r=e._pendingPullIntos.peek();Qe(e),"closed"===e._controlledReadableByteStream._state?function(e,t){"none"===t.readerType&&Xe(e);const r=e._controlledReadableByteStream;if(bt(r)){const t=[];for(;t.length<pt(r);)t.push(Xe(e));Ne(r,t)}}(e,r):function(e,t,r){if(He(0,t,r),"none"===r.readerType){Ye(e,r);const t=Je(e);return void Ne(e._controlledReadableByteStream,t)}if(r.bytesFilled<r.minimumFill)return;Xe(e);const n=r.bytesFilled%r.elementSize;if(n>0){const t=r.byteOffset+r.bytesFilled;$e(e,r.buffer,t-n,n)}r.bytesFilled-=n;const o=Je(e);Le(e._controlledReadableByteStream,r),Ne(e._controlledReadableByteStream,o)}(e,t,r),Be(e)}function Xe(e){return e._pendingPullIntos.shift()}function Ze(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function et(e){const t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(t.bytesFilled%t.elementSize!==0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw rt(e,t),t}}Ze(e),Xr(t)}}function tt(e,t){const r=e._controlledReadableByteStream;if(e._closeRequested||"readable"!==r._state)return;const{buffer:n,byteOffset:o,byteLength:i}=t;if(be(n))throw new TypeError("chunk's buffer is detached and so cannot be enqueued");const a=pe(n);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek();if(be(t.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");Qe(e),t.buffer=pe(t.buffer),"none"===t.readerType&&Ye(e,t)}ee(r)?(function(e){const t=e._controlledReadableByteStream._reader;for(;t._readRequests.length>0;){if(0===e._queueTotalSize)return;nt(e,t._readRequests.shift())}}(e),0===Z(r)?ze(e,a,o,i):(e._pendingPullIntos.length>0&&Xe(e),X(r,new Uint8Array(a,o,i),!1))):bt(r)?(ze(e,a,o,i),Ne(r,Je(e))):ze(e,a,o,i),Be(e)}function rt(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(De(e),qe(e),Ze(e),Zr(r,t))}function nt(e,t){const r=e._queue.shift();e._queueTotalSize-=r.byteLength,Ve(e);const n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);t._chunkSteps(n)}function ot(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){const t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),n=Object.create(xe.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function it(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function at(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=pe(r.buffer),Ke(e,t)}function st(e,t){const r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");const n=t.byteLength;r.buffer=pe(t.buffer),Ke(e,n)}function lt(e,t,r,n,o,i,a){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,qe(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,t._autoAllocateChunkSize=a,t._pendingPullIntos=new O,e._readableStreamController=t,m(h(r()),()=>(t._started=!0,Be(t),null),e=>(rt(t,e),null))}function ut(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function ct(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}function ft(e,t){if("byob"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);return e}function dt(e){return new mt(e)}function ht(e,t){e._reader._readIntoRequests.push(t)}function pt(e){return e._reader._readIntoRequests.length}function bt(e){const t=e._reader;return void 0!==t&&!!_t(t)}Object.defineProperties(Me.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),a(Me.prototype.close,"close"),a(Me.prototype.enqueue,"enqueue"),a(Me.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Me.prototype,Symbol.toStringTag,{value:"ReadableByteStreamController",configurable:!0});class mt{constructor(e){if($(e,1,"ReadableStreamBYOBReader"),Q(e,"First parameter"),Jr(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!We(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");q(this,e),this._readIntoRequests=new O}get closed(){return _t(this)?this._closedPromise:p(St("closed"))}cancel(e=void 0){return _t(this)?void 0===this._ownerReadableStream?p(x("cancel")):I(this,e):p(St("cancel"))}read(e,t={}){if(!_t(this))return p(St("read"));if(!ArrayBuffer.isView(e))return p(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return p(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return p(new TypeError("view's buffer must have non-zero byteLength"));if(be(e.buffer))return p(new TypeError("view's buffer has been detached"));let r;try{r=function(e,t){var r;return N(e,t),{min:V(null!==(r=null==e?void 0:e.min)&&void 0!==r?r:1,`${t} has member 'min' that`)}}(t,"options")}catch(e){return p(e)}const n=r.min;if(0===n)return p(new TypeError("options.min must be greater than 0"));if(function(e){return Ie(e.constructor)}(e)){if(n>e.byteLength)return p(new RangeError("options.min must be less than or equal to view's byteLength"))}else if(n>e.length)return p(new RangeError("options.min must be less than or equal to view's length"));if(void 0===this._ownerReadableStream)return p(x("read from"));const o=function(e,t,r){const n=e._ownerReadableStream;return"errored"===n._state||function(e,t,r){const n=e._controlledReadableByteStream,o=Ae(t.constructor),{byteLength:i}=t,a=r*o;return!(e._pendingPullIntos.length>0)&&("closed"===n._state||e._queueTotalSize>=a)}(n._readableStreamController,t,r)}(this,e,n)?new vt:new yt;return gt(this,e,n,o),o._promise}releaseLock(){if(!_t(this))throw St("releaseLock");void 0!==this._ownerReadableStream&&function(e){A(e),wt(e,new TypeError("Reader was released"))}(this)}}Object.defineProperties(mt.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),a(mt.prototype.cancel,"cancel"),a(mt.prototype.read,"read"),a(mt.prototype.releaseLock,"releaseLock"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(mt.prototype,Symbol.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});class yt{constructor(){this._promise=d((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._resolvePromise({value:e,done:!1})}_closeSteps(e){this._resolvePromise({value:e,done:!0})}_errorSteps(e){this._rejectPromise(e)}}class vt{constructor(){this._promise=void 0}_chunkSteps(e){this._promise=f({value:e,done:!1})}_closeSteps(e){this._promise=f({value:e,done:!0})}_errorSteps(e){this._promise=p(e)}}function _t(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof mt}function gt(e,t,r,n){const o=e._ownerReadableStream;o._disturbed=!0,"errored"===o._state?n._errorSteps(o._storedError):function(e,t,r,n){const o=e._controlledReadableByteStream,i=t.constructor,a=Ae(i),{byteOffset:s,byteLength:l}=t,u=r*a;let c;try{c=pe(t.buffer)}catch(e){return void n._errorSteps(e)}const f={buffer:c,bufferByteLength:c.byteLength,byteOffset:s,byteLength:l,bytesFilled:0,minimumFill:u,elementSize:a,viewConstructor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(f),void ht(o,n);if("closed"===o._state){const e=new i(f.buffer,f.byteOffset,0);return void n._closeSteps(e)}if(e._queueTotalSize>0){if(Ge(e,f)){const t=Fe(f);return Ve(e),void n._chunkSteps(t)}if(e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return rt(e,t),void n._errorSteps(t)}}e._pendingPullIntos.push(f),ht(o,n),Be(e)}(o._readableStreamController,t,r,n)}function wt(e,t){const r=e._readIntoRequests;e._readIntoRequests=new O,r.forEach(e=>{e._errorSteps(t)})}function St(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function Pt(e,t){const{highWaterMark:r}=e;if(void 0===r)return t;if(je(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function Ot(e){const{size:t}=e;return t||(()=>1)}function Rt(e,t){N(e,t);const r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:G(r),size:void 0===n?void 0:Tt(n,`${t} has member 'size' that`)}}function Tt(e,t){return F(e,t),t=>G(e(t))}function jt(e,t,r){return F(e,r),r=>P(e,t,[r])}function Et(e,t,r){return F(e,r),()=>P(e,t,[])}function kt(e,t,r){return F(e,r),r=>S(e,t,[r])}function Ct(e,t,r){return F(e,r),(r,n)=>P(e,t,[r,n])}function qt(e,t){if(!Mt(e))throw new TypeError(`${t} is not a WritableStream.`)}class It{constructor(e={},t={}){void 0===e?e=null:z(e,"First parameter");const r=Rt(t,"Second parameter"),n=function(e,t){N(e,t);const r=null==e?void 0:e.abort,n=null==e?void 0:e.close,o=null==e?void 0:e.start,i=null==e?void 0:e.type,a=null==e?void 0:e.write;return{abort:void 0===r?void 0:jt(r,e,`${t} has member 'abort' that`),close:void 0===n?void 0:Et(n,e,`${t} has member 'close' that`),start:void 0===o?void 0:kt(o,e,`${t} has member 'start' that`),write:void 0===a?void 0:Ct(a,e,`${t} has member 'write' that`),type:i}}(e,"First parameter");if(xt(this),void 0!==n.type)throw new RangeError("Invalid type is specified");const o=Ot(r);!function(e,t,r,n){const o=Object.create(Xt.prototype);let i,a,s,l;i=void 0!==t.start?()=>t.start(o):()=>{},a=void 0!==t.write?e=>t.write(e,o):()=>h(void 0),s=void 0!==t.close?()=>t.close():()=>h(void 0),l=void 0!==t.abort?e=>t.abort(e):()=>h(void 0),er(e,o,i,a,s,l,r,n)}(this,n,Pt(r,1),o)}get locked(){if(!Mt(this))throw sr("locked");return Wt(this)}abort(e=void 0){return Mt(this)?Wt(this)?p(new TypeError("Cannot abort a stream that already has a writer")):Ut(this,e):p(sr("abort"))}close(){return Mt(this)?Wt(this)?p(new TypeError("Cannot close a stream that already has a writer")):Ft(this)?p(new TypeError("Cannot close an already-closing stream")):Bt(this):p(sr("close"))}getWriter(){if(!Mt(this))throw sr("getWriter");return At(this)}}function At(e){return new Yt(e)}function xt(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new O,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function Mt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof It}function Wt(e){return void 0!==e._writer}function Ut(e,t){var r;if("closed"===e._state||"errored"===e._state)return h(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort(t);const n=e._state;if("closed"===n||"errored"===n)return h(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===n&&(o=!0,t=void 0);const i=d((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=i,o||Lt(e,t),i}function Bt(e){const t=e._state;if("closed"===t||"errored"===t)return p(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const r=d((t,r)=>{const n={_resolve:t,_reject:r};e._closeRequest=n}),n=e._writer;var o;return void 0!==n&&e._backpressure&&"writable"===t&&_r(n),Ce(o=e._writableStreamController,Kt,0),nr(o),r}function Dt(e,t){"writable"!==e._state?Nt(e):Lt(e,t)}function Lt(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const n=e._writer;void 0!==n&&Vt(n,t),!function(e){return void 0!==e._inFlightWriteRequest||void 0!==e._inFlightCloseRequest}(e)&&r._started&&Nt(e)}function Nt(e){e._state="errored",e._writableStreamController[T]();const t=e._storedError;if(e._writeRequests.forEach(e=>{e._reject(t)}),e._writeRequests=new O,void 0===e._pendingAbortRequest)return void zt(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void zt(e);m(e._writableStreamController[R](r._reason),()=>(r._resolve(),zt(e),null),t=>(r._reject(t),zt(e),null))}function Ft(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function zt(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&hr(t,e._storedError)}function $t(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){br(e)}(r):_r(r)),e._backpressure=t}Object.defineProperties(It.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),a(It.prototype.abort,"abort"),a(It.prototype.close,"close"),a(It.prototype.getWriter,"getWriter"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(It.prototype,Symbol.toStringTag,{value:"WritableStream",configurable:!0});class Yt{constructor(e){if($(e,1,"WritableStreamDefaultWriter"),qt(e,"First parameter"),Wt(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!Ft(e)&&e._backpressure?br(this):yr(this),fr(this);else if("erroring"===t)mr(this,e._storedError),fr(this);else if("closed"===t)yr(this),fr(this),pr(this);else{const t=e._storedError;mr(this,t),dr(this,t)}}get closed(){return Gt(this)?this._closedPromise:p(ur("closed"))}get desiredSize(){if(!Gt(this))throw ur("desiredSize");if(void 0===this._ownerWritableStream)throw cr("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;return"errored"===r||"erroring"===r?null:"closed"===r?0:rr(t._writableStreamController)}(this)}get ready(){return Gt(this)?this._readyPromise:p(ur("ready"))}abort(e=void 0){return Gt(this)?void 0===this._ownerWritableStream?p(cr("abort")):function(e,t){return Ut(e._ownerWritableStream,t)}(this,e):p(ur("abort"))}close(){if(!Gt(this))return p(ur("close"));const e=this._ownerWritableStream;return void 0===e?p(cr("close")):Ft(e)?p(new TypeError("Cannot close an already-closing stream")):Ht(this)}releaseLock(){if(!Gt(this))throw ur("releaseLock");void 0!==this._ownerWritableStream&&Qt(this)}write(e=void 0){return Gt(this)?void 0===this._ownerWritableStream?p(cr("write to")):Jt(this,e):p(ur("write"))}}function Gt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof Yt}function Ht(e){return Bt(e._ownerWritableStream)}function Vt(e,t){"pending"===e._readyPromiseState?vr(e,t):function(e,t){mr(e,t)}(e,t)}function Qt(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Vt(e,r),function(e,t){"pending"===e._closedPromiseState?hr(e,t):function(e,t){dr(e,t)}(e,t)}(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Jt(e,t){const r=e._ownerWritableStream,n=r._writableStreamController,o=function(e,t){if(void 0===e._strategySizeAlgorithm)return 1;try{return e._strategySizeAlgorithm(t)}catch(t){return or(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return p(cr("write to"));const i=r._state;if("errored"===i)return p(r._storedError);if(Ft(r)||"closed"===i)return p(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return p(r._storedError);const a=function(e){return d((t,r)=>{const n={_resolve:t,_reject:r};e._writeRequests.push(n)})}(r);return function(e,t,r){try{Ce(e,t,r)}catch(t){return void or(e,t)}const n=e._controlledWritableStream;Ft(n)||"writable"!==n._state||$t(n,ir(e)),nr(e)}(n,t,o),a}Object.defineProperties(Yt.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),a(Yt.prototype.abort,"abort"),a(Yt.prototype.close,"close"),a(Yt.prototype.releaseLock,"releaseLock"),a(Yt.prototype.write,"write"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Yt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});const Kt={};class Xt{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!Zt(this))throw lr("abortReason");return this._abortReason}get signal(){if(!Zt(this))throw lr("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(e=void 0){if(!Zt(this))throw lr("error");"writable"===this._controlledWritableStream._state&&ar(this,e)}[R](e){const t=this._abortAlgorithm(e);return tr(this),t}[T](){qe(this)}}function Zt(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof Xt}function er(e,t,r,n,o,i,a,s){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,qe(t),t._abortReason=void 0,t._abortController=function(){if("function"==typeof AbortController)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=s,t._strategyHWM=a,t._writeAlgorithm=n,t._closeAlgorithm=o,t._abortAlgorithm=i;const l=ir(t);$t(e,l),m(h(r()),()=>(t._started=!0,nr(t),null),r=>(t._started=!0,Dt(e,r),null))}function tr(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function rr(e){return e._strategyHWM-e._queueTotalSize}function nr(e){const t=e._controlledWritableStream;if(!e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void Nt(t);if(0===e._queue.length)return;const r=e._queue.peek().value;r===Kt?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),ke(e);const r=e._closeAlgorithm();tr(e),m(r,()=>(function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&pr(t)}(t),null),e=>(function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),Dt(e,t)}(t,e),null))}(e):function(e,t){const r=e._controlledWritableStream;!function(e){e._inFlightWriteRequest=e._writeRequests.shift()}(r),m(e._writeAlgorithm(t),()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(ke(e),!Ft(r)&&"writable"===t){const t=ir(e);$t(r,t)}return nr(e),null},t=>("writable"===r._state&&tr(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,Dt(e,t)}(r,t),null))}(e,r)}function or(e,t){"writable"===e._controlledWritableStream._state&&ar(e,t)}function ir(e){return rr(e)<=0}function ar(e,t){const r=e._controlledWritableStream;tr(e),Lt(r,t)}function sr(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function lr(e){return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`)}function ur(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function cr(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function fr(e){e._closedPromise=d((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function dr(e,t){fr(e),hr(e,t)}function hr(e,t){void 0!==e._closedPromise_reject&&(g(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function pr(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function br(e){e._readyPromise=d((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function mr(e,t){br(e),vr(e,t)}function yr(e){br(e),_r(e)}function vr(e,t){void 0!==e._readyPromise_reject&&(g(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function _r(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(Xt.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Xt.prototype,Symbol.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});const gr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0,wr=function(){const e=null==gr?void 0:gr.DOMException;return function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;if("DOMException"!==e.name)return!1;try{return new e,!0}catch(e){return!1}}(e)?e:void 0}()||function(){const e=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)};return a(e,"DOMException"),e.prototype=Object.create(Error.prototype),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,configurable:!0}),e}();function Sr(e,t,r,n,o,i){const a=J(e),s=At(t);e._disturbed=!0;const l=new Pr(s),u=new Rr(l);return d((c,f)=>{let v;if(void 0!==i){if(v=()=>{const r=void 0!==i.reason?i.reason:new wr("Aborted","AbortError"),a=[];n||a.push(()=>"writable"===t._state?Ut(t,r):h(void 0)),o||a.push(()=>"readable"===e._state?Kr(e,r):h(void 0)),O(()=>Promise.all(a.map(e=>e())),!0,r)},i.aborted)return void v();i.addEventListener("abort",v)}function _(){for(;!l._shuttingDown&&!t._backpressure&&"writable"===t._state&&!Ft(t)&&"readable"===e._state&&ae(a);)ie(a,u);if(l._shuttingDown)return h(!0);if(t._backpressure)return b(s._readyPromise,_);const r=new Or(l);return ie(a,r),r._promise}var w,S,P;if(Tr(e,a._closedPromise,e=>(n?R(!0,e):O(()=>Ut(t,e),!0,e),null)),Tr(t,s._closedPromise,t=>(o?R(!0,t):O(()=>Kr(e,t),!0,t),null)),w=e,S=a._closedPromise,P=()=>(r?R():O(()=>function(e){const t=e._ownerWritableStream,r=t._state;return Ft(t)||"closed"===r?h(void 0):"errored"===r?p(t._storedError):Ht(e)}(s)),null),"closed"===w._state?P():y(S,P),Ft(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");o?R(!0,t):O(()=>Kr(e,t),!0,t)}function O(e,r,n){function o(){return m(e(),()=>T(r,n),e=>T(!0,e)),null}l._shuttingDown||(l._shuttingDown=!0,"writable"!==t._state||Ft(t)?o():y(l._waitForWritesToFinish(),o))}function R(e,r){l._shuttingDown||(l._shuttingDown=!0,"writable"!==t._state||Ft(t)?T(e,r):y(l._waitForWritesToFinish(),()=>T(e,r)))}function T(e,t){return Qt(s),A(a),void 0!==i&&i.removeEventListener("abort",v),e?f(t):c(void 0),null}g(d((e,t)=>{!function r(n){n?e():b(_(),r,t)}(!1)}))})}class Pr{constructor(e){this._writer=e,this._shuttingDown=!1,this._currentWrite=h(void 0)}_waitForWritesToFinish(){const e=this._currentWrite;return b(this._currentWrite,()=>e!==this._currentWrite?this._waitForWritesToFinish():void 0)}}class Or{constructor(e){this._state=e,this._promise=d((e,t)=>{this._resolvePromise=e,this._rejectPromise=t})}_chunkSteps(e){this._state._currentWrite=b(Jt(this._state._writer,e),void 0,n),this._resolvePromise(!1)}_closeSteps(){this._resolvePromise(!0)}_errorSteps(e){this._rejectPromise(e)}}class Rr{constructor(e){this._state=e}_chunkSteps(e){this._state._currentWrite=b(Jt(this._state._writer,e),void 0,n)}_closeSteps(){}_errorSteps(e){}}function Tr(e,t,r){"errored"===e._state?r(e._storedError):v(t,r)}class jr{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Er(this))throw Br("desiredSize");return Mr(this)}close(){if(!Er(this))throw Br("close");if(!Wr(this))throw new TypeError("The stream is not in a state that permits close");Ir(this)}enqueue(e=void 0){if(!Er(this))throw Br("enqueue");if(!Wr(this))throw new TypeError("The stream is not in a state that permits enqueue");return Ar(this,e)}error(e=void 0){if(!Er(this))throw Br("error");xr(this,e)}[j](e){qe(this);const t=this._cancelAlgorithm(e);return qr(this),t}[E](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=ke(this);this._closeRequested&&0===this._queue.length?(qr(this),Xr(t)):kr(this),e._chunkSteps(r)}else K(t,e),kr(this)}[k](){return this._queue.length>0}[C](){}}function Er(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof jr}function kr(e){Cr(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,m(e._pullAlgorithm(),()=>(e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,kr(e)),null),t=>(xr(e,t),null))))}function Cr(e){const t=e._controlledReadableStream;return!!Wr(e)&&!!e._started&&(!!(Jr(t)&&Z(t)>0)||Mr(e)>0)}function qr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Ir(e){if(!Wr(e))return;const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(qr(e),Xr(t))}function Ar(e,t){if(!Wr(e))return;const r=e._controlledReadableStream;if(Jr(r)&&Z(r)>0)X(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw xr(e,t),t}try{Ce(e,t,r)}catch(t){throw xr(e,t),t}}kr(e)}function xr(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(qe(e),qr(e),Zr(r,t))}function Mr(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Wr(e){const t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function Ur(e,t,r,n,o,i,a){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,qe(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=a,t._strategyHWM=i,t._pullAlgorithm=n,t._cancelAlgorithm=o,e._readableStreamController=t,m(h(r()),()=>(t._started=!0,kr(t),null),e=>(xr(t,e),null))}function Br(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Dr(e){return o(t=e)&&void 0!==t.getReader?function(e){let t;return t=Gr(n,function(){let r;try{r=e.read()}catch(r){return p(r)}return _(r,e=>{if(!o(e))throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");if(e.done)Ir(t._readableStreamController);else{const r=e.value;Ar(t._readableStreamController,r)}})},function(t){try{return h(e.cancel(t))}catch(t){return p(t)}},0),t}(e.getReader()):function(e){let t;const r=ge(e,"async");return t=Gr(n,function(){let e;try{e=we(r)}catch(e){return p(e)}return _(h(e),e=>{if(!o(e))throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");if(e.done)Ir(t._readableStreamController);else{const r=e.value;Ar(t._readableStreamController,r)}})},function(e){const t=r.iterator;let n;try{n=ye(t,"return")}catch(e){return p(e)}return void 0===n?h(void 0):_(P(n,t,[e]),e=>{if(!o(e))throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object")})},0),t}(e);var t}function Lr(e,t,r){return F(e,r),r=>P(e,t,[r])}function Nr(e,t,r){return F(e,r),r=>P(e,t,[r])}function Fr(e,t,r){return F(e,r),r=>S(e,t,[r])}function zr(e,t){if("bytes"!=(e=`${e}`))throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);return e}function $r(e,t){N(e,t);const r=null==e?void 0:e.preventAbort,n=null==e?void 0:e.preventCancel,o=null==e?void 0:e.preventClose,i=null==e?void 0:e.signal;return void 0!==i&&function(e,t){if(!function(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}(e))throw new TypeError(`${t} is not an AbortSignal.`)}(i,`${t} has member 'signal' that`),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(o),signal:i}}Object.defineProperties(jr.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),a(jr.prototype.close,"close"),a(jr.prototype.enqueue,"enqueue"),a(jr.prototype.error,"error"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(jr.prototype,Symbol.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});class Yr{constructor(e={},t={}){void 0===e?e=null:z(e,"First parameter");const r=Rt(t,"Second parameter"),n=function(e,t){N(e,t);const r=e,n=null==r?void 0:r.autoAllocateChunkSize,o=null==r?void 0:r.cancel,i=null==r?void 0:r.pull,a=null==r?void 0:r.start,s=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===n?void 0:V(n,`${t} has member 'autoAllocateChunkSize' that`),cancel:void 0===o?void 0:Lr(o,r,`${t} has member 'cancel' that`),pull:void 0===i?void 0:Nr(i,r,`${t} has member 'pull' that`),start:void 0===a?void 0:Fr(a,r,`${t} has member 'start' that`),type:void 0===s?void 0:zr(s,`${t} has member 'type' that`)}}(e,"First parameter");if(Vr(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(e,t,r){const n=Object.create(Me.prototype);let o,i,a;o=void 0!==t.start?()=>t.start(n):()=>{},i=void 0!==t.pull?()=>t.pull(n):()=>h(void 0),a=void 0!==t.cancel?e=>t.cancel(e):()=>h(void 0);const s=t.autoAllocateChunkSize;if(0===s)throw new TypeError("autoAllocateChunkSize must be greater than 0");lt(e,n,o,i,a,r,s)}(this,n,Pt(r,0))}else{const e=Ot(r);!function(e,t,r,n){const o=Object.create(jr.prototype);let i,a,s;i=void 0!==t.start?()=>t.start(o):()=>{},a=void 0!==t.pull?()=>t.pull(o):()=>h(void 0),s=void 0!==t.cancel?e=>t.cancel(e):()=>h(void 0),Ur(e,o,i,a,s,r,n)}(this,n,Pt(r,1),e)}}get locked(){if(!Qr(this))throw en("locked");return Jr(this)}cancel(e=void 0){return Qr(this)?Jr(this)?p(new TypeError("Cannot cancel a stream that already has a reader")):Kr(this,e):p(en("cancel"))}getReader(e=void 0){if(!Qr(this))throw en("getReader");return void 0===function(e,t){N(e,t);const r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:ft(r,`${t} has member 'mode' that`)}}(e,"First parameter").mode?J(this):dt(this)}pipeThrough(e,t={}){if(!Qr(this))throw en("pipeThrough");$(e,1,"pipeThrough");const r=function(e,t){N(e,t);const r=null==e?void 0:e.readable;Y(r,"readable","ReadableWritablePair"),Q(r,`${t} has member 'readable' that`);const n=null==e?void 0:e.writable;return Y(n,"writable","ReadableWritablePair"),qt(n,`${t} has member 'writable' that`),{readable:r,writable:n}}(e,"First parameter"),n=$r(t,"Second parameter");if(Jr(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Wt(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return g(Sr(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable}pipeTo(e,t={}){if(!Qr(this))return p(en("pipeTo"));if(void 0===e)return p("Parameter 1 is required in 'pipeTo'.");if(!Mt(e))return p(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));let r;try{r=$r(t,"Second parameter")}catch(e){return p(e)}return Jr(this)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Wt(e)?p(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Sr(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)}tee(){if(!Qr(this))throw en("tee");return de(function(e){return We(e._readableStreamController)?function(e){let t,r,n,o,i,a=J(e),s=!1,l=!1,u=!1,c=!1,f=!1;const p=d(e=>{i=e});function b(e){v(e._closedPromise,t=>(e!==a||(rt(n._readableStreamController,t),rt(o._readableStreamController,t),c&&f||i(void 0)),null))}function m(){_t(a)&&(A(a),a=J(e),b(a)),ie(a,{_chunkSteps:t=>{w(()=>{l=!1,u=!1;const r=t;let a=t;if(!c&&!f)try{a=Ee(t)}catch(t){return rt(n._readableStreamController,t),rt(o._readableStreamController,t),void i(Kr(e,t))}c||tt(n._readableStreamController,r),f||tt(o._readableStreamController,a),s=!1,l?_():u&&g()})},_closeSteps:()=>{s=!1,c||et(n._readableStreamController),f||et(o._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&at(n._readableStreamController,0),o._readableStreamController._pendingPullIntos.length>0&&at(o._readableStreamController,0),c&&f||i(void 0)},_errorSteps:()=>{s=!1}})}function y(t,r){oe(a)&&(A(a),a=dt(e),b(a));const d=r?o:n,h=r?n:o;gt(a,t,1,{_chunkSteps:t=>{w(()=>{l=!1,u=!1;const n=r?f:c;if(r?c:f)n||st(d._readableStreamController,t);else{let r;try{r=Ee(t)}catch(t){return rt(d._readableStreamController,t),rt(h._readableStreamController,t),void i(Kr(e,t))}n||st(d._readableStreamController,t),tt(h._readableStreamController,r)}s=!1,l?_():u&&g()})},_closeSteps:e=>{s=!1;const t=r?f:c,n=r?c:f;t||et(d._readableStreamController),n||et(h._readableStreamController),void 0!==e&&(t||st(d._readableStreamController,e),!n&&h._readableStreamController._pendingPullIntos.length>0&&at(h._readableStreamController,0)),t&&n||i(void 0)},_errorSteps:()=>{s=!1}})}function _(){if(s)return l=!0,h(void 0);s=!0;const e=ot(n._readableStreamController);return null===e?m():y(e._view,!1),h(void 0)}function g(){if(s)return u=!0,h(void 0);s=!0;const e=ot(o._readableStreamController);return null===e?m():y(e._view,!0),h(void 0)}function S(){}return n=Hr(S,_,function(n){if(c=!0,t=n,f){const n=de([t,r]),o=Kr(e,n);i(o)}return p}),o=Hr(S,g,function(n){if(f=!0,r=n,c){const n=de([t,r]),o=Kr(e,n);i(o)}return p}),b(a),[n,o]}(e):function(e){const t=J(e);let r,n,o,i,a,s=!1,l=!1,u=!1,c=!1;const f=d(e=>{a=e});function p(){return s?(l=!0,h(void 0)):(s=!0,ie(t,{_chunkSteps:e=>{w(()=>{l=!1;const t=e,r=e;u||Ar(o._readableStreamController,t),c||Ar(i._readableStreamController,r),s=!1,l&&p()})},_closeSteps:()=>{s=!1,u||Ir(o._readableStreamController),c||Ir(i._readableStreamController),u&&c||a(void 0)},_errorSteps:()=>{s=!1}}),h(void 0))}function b(){}return o=Gr(b,p,function(t){if(u=!0,r=t,c){const t=de([r,n]),o=Kr(e,t);a(o)}return f}),i=Gr(b,p,function(t){if(c=!0,n=t,u){const t=de([r,n]),o=Kr(e,t);a(o)}return f}),v(t._closedPromise,e=>(xr(o._readableStreamController,e),xr(i._readableStreamController,e),u&&c||a(void 0),null)),[o,i]}(e)}(this))}values(e=void 0){if(!Qr(this))throw en("values");return function(e,t){const r=J(e),n=new Se(r,t),o=Object.create(Oe);return o._asyncIteratorImpl=n,o}(this,function(e){N(e,"First parameter");const t=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(t)}}(e).preventCancel)}[_e](e){return this.values(e)}static from(e){return Dr(e)}}function Gr(e,t,r,n=1,o=()=>1){const i=Object.create(Yr.prototype);return Vr(i),Ur(i,Object.create(jr.prototype),e,t,r,n,o),i}function Hr(e,t,r){const n=Object.create(Yr.prototype);return Vr(n),lt(n,Object.create(Me.prototype),e,t,r,0,void 0),n}function Vr(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Qr(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof Yr}function Jr(e){return void 0!==e._reader}function Kr(e,t){if(e._disturbed=!0,"closed"===e._state)return h(void 0);if("errored"===e._state)return p(e._storedError);Xr(e);const r=e._reader;if(void 0!==r&&_t(r)){const e=r._readIntoRequests;r._readIntoRequests=new O,e.forEach(e=>{e._closeSteps(void 0)})}return _(e._readableStreamController[j](t),n)}function Xr(e){e._state="closed";const t=e._reader;if(void 0!==t&&(B(t),oe(t))){const e=t._readRequests;t._readRequests=new O,e.forEach(e=>{e._closeSteps()})}}function Zr(e,t){e._state="errored",e._storedError=t;const r=e._reader;void 0!==r&&(U(r,t),oe(r)?se(r,t):wt(r,t))}function en(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function tn(e,t){N(e,t);const r=null==e?void 0:e.highWaterMark;return Y(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:G(r)}}Object.defineProperties(Yr,{from:{enumerable:!0}}),Object.defineProperties(Yr.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),a(Yr.from,"from"),a(Yr.prototype.cancel,"cancel"),a(Yr.prototype.getReader,"getReader"),a(Yr.prototype.pipeThrough,"pipeThrough"),a(Yr.prototype.pipeTo,"pipeTo"),a(Yr.prototype.tee,"tee"),a(Yr.prototype.values,"values"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(Yr.prototype,Symbol.toStringTag,{value:"ReadableStream",configurable:!0}),Object.defineProperty(Yr.prototype,_e,{value:Yr.prototype.values,writable:!0,configurable:!0});const rn=e=>e.byteLength;a(rn,"size");class nn{constructor(e){$(e,1,"ByteLengthQueuingStrategy"),e=tn(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!an(this))throw on("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark}get size(){if(!an(this))throw on("size");return rn}}function on(e){return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`)}function an(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof nn}Object.defineProperties(nn.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(nn.prototype,Symbol.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});const sn=()=>1;a(sn,"size");class ln{constructor(e){$(e,1,"CountQueuingStrategy"),e=tn(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}get highWaterMark(){if(!cn(this))throw un("highWaterMark");return this._countQueuingStrategyHighWaterMark}get size(){if(!cn(this))throw un("size");return sn}}function un(e){return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`)}function cn(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof ln}function fn(e,t,r){return F(e,r),r=>P(e,t,[r])}function dn(e,t,r){return F(e,r),r=>S(e,t,[r])}function hn(e,t,r){return F(e,r),(r,n)=>P(e,t,[r,n])}function pn(e,t,r){return F(e,r),r=>P(e,t,[r])}Object.defineProperties(ln.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(ln.prototype,Symbol.toStringTag,{value:"CountQueuingStrategy",configurable:!0});class bn{constructor(e={},t={},r={}){void 0===e&&(e=null);const n=Rt(t,"Second parameter"),o=Rt(r,"Third parameter"),i=function(e,t){N(e,t);const r=null==e?void 0:e.cancel,n=null==e?void 0:e.flush,o=null==e?void 0:e.readableType,i=null==e?void 0:e.start,a=null==e?void 0:e.transform,s=null==e?void 0:e.writableType;return{cancel:void 0===r?void 0:pn(r,e,`${t} has member 'cancel' that`),flush:void 0===n?void 0:fn(n,e,`${t} has member 'flush' that`),readableType:o,start:void 0===i?void 0:dn(i,e,`${t} has member 'start' that`),transform:void 0===a?void 0:hn(a,e,`${t} has member 'transform' that`),writableType:s}}(e,"First parameter");if(void 0!==i.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==i.writableType)throw new RangeError("Invalid writableType specified");const a=Pt(o,0),s=Ot(o),l=Pt(n,1),u=Ot(n);let c;!function(e,t,r,n,o,i){function a(){return t}e._writable=function(e,t,r,n,o=1,i=()=>1){const a=Object.create(It.prototype);return xt(a),er(a,Object.create(Xt.prototype),e,t,r,n,o,i),a}(a,function(t){return function(e,t){const r=e._transformStreamController;return e._backpressure?_(e._backpressureChangePromise,()=>{const n=e._writable;if("erroring"===n._state)throw n._storedError;return Rn(r,t)}):Rn(r,t)}(e,t)},function(){return function(e){const t=e._transformStreamController;if(void 0!==t._finishPromise)return t._finishPromise;const r=e._readable;t._finishPromise=d((e,r)=>{t._finishPromise_resolve=e,t._finishPromise_reject=r});const n=t._flushAlgorithm();return Pn(t),m(n,()=>("errored"===r._state?En(t,r._storedError):(Ir(r._readableStreamController),jn(t)),null),e=>(xr(r._readableStreamController,e),En(t,e),null)),t._finishPromise}(e)},function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._readable;r._finishPromise=d((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const o=r._cancelAlgorithm(t);return Pn(r),m(o,()=>("errored"===n._state?En(r,n._storedError):(xr(n._readableStreamController,t),jn(r)),null),e=>(xr(n._readableStreamController,e),En(r,e),null)),r._finishPromise}(e,t)},r,n),e._readable=Gr(a,function(){return function(e){return gn(e,!1),e._backpressureChangePromise}(e)},function(t){return function(e,t){const r=e._transformStreamController;if(void 0!==r._finishPromise)return r._finishPromise;const n=e._writable;r._finishPromise=d((e,t)=>{r._finishPromise_resolve=e,r._finishPromise_reject=t});const o=r._cancelAlgorithm(t);return Pn(r),m(o,()=>("errored"===n._state?En(r,n._storedError):(or(n._writableStreamController,t),_n(e),jn(r)),null),t=>(or(n._writableStreamController,t),_n(e),En(r,t),null)),r._finishPromise}(e,t)},o,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,gn(e,!0),e._transformStreamController=void 0}(this,d(e=>{c=e}),l,u,a,s),function(e,t){const r=Object.create(wn.prototype);let n,o,i;n=void 0!==t.transform?e=>t.transform(e,r):e=>{try{return On(r,e),h(void 0)}catch(e){return p(e)}},o=void 0!==t.flush?()=>t.flush(r):()=>h(void 0),i=void 0!==t.cancel?e=>t.cancel(e):()=>h(void 0),function(e,t,r,n,o){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n,t._cancelAlgorithm=o,t._finishPromise=void 0,t._finishPromise_resolve=void 0,t._finishPromise_reject=void 0}(e,r,n,o,i)}(this,i),void 0!==i.start?c(i.start(this._transformStreamController)):c(void 0)}get readable(){if(!mn(this))throw kn("readable");return this._readable}get writable(){if(!mn(this))throw kn("writable");return this._writable}}function mn(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof bn}function yn(e,t){xr(e._readable._readableStreamController,t),vn(e,t)}function vn(e,t){Pn(e._transformStreamController),or(e._writable._writableStreamController,t),_n(e)}function _n(e){e._backpressure&&gn(e,!1)}function gn(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=d(t=>{e._backpressureChangePromise_resolve=t}),e._backpressure=t}Object.defineProperties(bn.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(bn.prototype,Symbol.toStringTag,{value:"TransformStream",configurable:!0});class wn{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!Sn(this))throw Tn("desiredSize");return Mr(this._controlledTransformStream._readable._readableStreamController)}enqueue(e=void 0){if(!Sn(this))throw Tn("enqueue");On(this,e)}error(e=void 0){if(!Sn(this))throw Tn("error");var t;t=e,yn(this._controlledTransformStream,t)}terminate(){if(!Sn(this))throw Tn("terminate");!function(e){const t=e._controlledTransformStream;Ir(t._readable._readableStreamController),vn(t,new TypeError("TransformStream terminated"))}(this)}}function Sn(e){return!!o(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof wn}function Pn(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0,e._cancelAlgorithm=void 0}function On(e,t){const r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!Wr(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{Ar(n,t)}catch(e){throw vn(r,e),r._readable._storedError}const o=function(e){return!Cr(e)}(n);o!==r._backpressure&&gn(r,!0)}function Rn(e,t){return _(e._transformAlgorithm(t),void 0,t=>{throw yn(e._controlledTransformStream,t),t})}function Tn(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function jn(e){void 0!==e._finishPromise_resolve&&(e._finishPromise_resolve(),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function En(e,t){void 0!==e._finishPromise_reject&&(g(e._finishPromise),e._finishPromise_reject(t),e._finishPromise_resolve=void 0,e._finishPromise_reject=void 0)}function kn(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}Object.defineProperties(wn.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),a(wn.prototype.enqueue,"enqueue"),a(wn.prototype.error,"error"),a(wn.prototype.terminate,"terminate"),"symbol"==typeof Symbol.toStringTag&&Object.defineProperty(wn.prototype,Symbol.toStringTag,{value:"TransformStreamDefaultController",configurable:!0})}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}return r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(337)})());
@@ -0,0 +1,5 @@
1
+ import type { ICloudbase } from '@cloudbase/types';
2
+ import { generateApis } from './callApis';
3
+ declare function registerApis(app: ICloudbase): void;
4
+ export { generateApis, registerApis };
5
+ export * from './type';
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_apis",[],t):"object"==typeof exports?exports.cloudbase_apis=t():e.cloudbase_apis=t()}("undefined"!=typeof window?window:this,()=>(()=>{"use strict";var e={378:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function c(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateApis=t.generateCallApis=t.callApi=void 0;var a=n(794);function c(e,t){var n,c,s,u;return o(this,void 0,Promise,function(){var o,l,f,p,d,h,v,O,b,y,_,g,P,A,E,w,R,m,T,S,j,I,N;return i(this,function(i){switch(i.label){case 0:l=(o=e||{}).name,f=o.body,p=o.path,d=void 0===p?"":p,h=o.method,v=void 0===h?"POST":h,O=o.headers,b=void 0===O?{}:O,y=(e||{}).token,_={};try{_=JSON.parse(f)}catch(e){_=f||{}}if(!l)throw new Error(JSON.stringify({code:a.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return g="",A=(P=this).gatewayOrigin,E=P.getAccessToken,w=P.env,A?g="".concat(A,"/v1"):this.getEndPointWithKey?(R=this.getEndPointWithKey("GATEWAY"),m=R.BASE_URL,T=R.PROTOCOL,g="".concat(T).concat(m)):g="https://".concat(w,".api.tcloudbasegateway.com/v1"),S="".concat(g,"/apis/").concat(l),j=d.startsWith("/")?d:"/".concat(d),E?[4,E()]:[3,2];case 1:I=i.sent().accessToken,b.Authorization="Bearer ".concat(I),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{j="".concat(j).concat(j.includes("?")?"&":"?").concat(Object.keys(_).map(function(e){return"".concat(e,"=").concat(_[e])}).join("&"))}catch(e){}return[4,this.request.fetch(r(r(r({url:"".concat(S).concat(j),method:v||"POST",headers:r({"Content-Type":"application/json; charset=utf-8"},b)},N?{}:{body:JSON.stringify(_)}),{token:(null===(c=null==y?void 0:y.trim)||void 0===c?void 0:c.call(y))||(null===(u=null===(s=b.Authorization)||void 0===s?void 0:s.replace)||void 0===u?void 0:u.call(s,/^Bearer /,""))||null}),t))];case 3:return[4,i.sent().data];case 4:return[2,i.sent()]}})})}t.callApi=c;var s=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function u(e){var t=this;return new Proxy({},{get:function(n,a){if("string"!=typeof a)throw new Error("[apis] method must be string");var u=a.toLocaleUpperCase();if(!s.includes(u))throw new Error("[apis] invalid method: ".concat(a));return function(n,a){return o(t,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,c.call(this,r({name:e,method:("REQUEST"===u?n.method:u)||"POST"},n),a)];case 1:return[2,t.sent()]}})})}}})}t.generateCallApis=u,t.generateApis=function(e){var t=this;return Object.keys(e||{}).forEach(function(n){void 0!==e[n]&&(t[n]=e[n])}),new Proxy({},{get:function(e,n){if("string"==typeof n)return u.call(t,n)}})}},944:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.registerApis=t.generateApis=void 0;var i=n(378);Object.defineProperty(t,"generateApis",{enumerable:!0,get:function(){return i.generateApis}});var a="apis",c={name:a,IIFE:!0,entity:function(){Object.defineProperty(this.prototype,a,{get:function(){return i.generateApis.call(this)},configurable:!0,enumerable:!0})}};function s(e){try{e.registerComponent(c)}catch(e){console.warn(e)}}t.registerApis=s;try{cloudbase.registerComponent(c)}catch(e){}o(n(26),t);try{window.registerApis=s}catch(e){}},26:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},749:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(944),t)},946:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var n="@cloudbase/js-sdk";t.setSdkName=function(e){n=e},t.getSdkName=function(){return n};var r="https:";t.setProtocol=function(e){r=e},t.getProtocol=function(){return r},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},205:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},794:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(n(946),t),o(n(205),t),t.OATUH_LOGINTYPE="constants"}},t={};return function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(749)})());
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cloudbase_apis",[],t):"object"==typeof exports?exports.cloudbase_apis=t():e.cloudbase_apis=t()}("undefined"!=typeof window?window:this,()=>(()=>{"use strict";var e={378:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function c(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,c)}s((r=r.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.generateApis=t.generateCallApis=t.callApi=void 0;var a=n(794);function c(e,t){var n,c,s,u;return o(this,void 0,Promise,function(){var o,l,p,f,d,h,v,O,y,b,_,g,A,E,P,w,R,T,m,I,N,S,j;return i(this,function(i){switch(i.label){case 0:l=(o=e||{}).name,p=o.body,f=o.path,d=void 0===f?"":f,h=o.method,v=void 0===h?"POST":h,O=o.headers,y=void 0===O?{}:O,b=(e||{}).token,_={};try{_=JSON.parse(p)}catch(e){_=p||{}}if(!l)throw new Error(JSON.stringify({code:a.ERRORS.INVALID_PARAMS,msg:"[apis] invalid api name"}));return g="",E=(A=this).gatewayOrigin,P=A.getAccessToken,w=A.env,E?g="".concat(E,"/v1"):this.getEndPointWithKey?(R=this.getEndPointWithKey("GATEWAY"),T=R.BASE_URL,m=R.PROTOCOL,g="".concat(m).concat(T)):g="https://".concat(w,".api.tcloudbasegateway.com/v1"),I="".concat(g,"/apis/").concat(l),N=d.startsWith("/")?d:"/".concat(d),P?[4,P()]:[3,2];case 1:S=i.sent().accessToken,y.Authorization="Bearer ".concat(S),i.label=2;case 2:if(j=["GET","HEAD"].includes(null===(n=null==v?void 0:v.toUpperCase)||void 0===n?void 0:n.call(v)))try{N="".concat(N).concat(N.includes("?")?"&":"?").concat(Object.keys(_).map(function(e){return"".concat(e,"=").concat(_[e])}).join("&"))}catch(e){}return[4,this.request.fetch(r(r(r({url:"".concat(I).concat(N),method:v||"POST",headers:r({"Content-Type":"application/json; charset=utf-8"},y)},j?{}:{body:JSON.stringify(_)}),{token:(null===(c=null==b?void 0:b.trim)||void 0===c?void 0:c.call(b))||(null===(u=null===(s=y.Authorization)||void 0===s?void 0:s.replace)||void 0===u?void 0:u.call(s,/^Bearer /,""))||null}),t))];case 3:return[4,i.sent().data];case 4:return[2,i.sent()]}})})}t.callApi=c;var s=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH","REQUEST"];function u(e){var t=this;return new Proxy({},{get:function(n,a){if("string"!=typeof a)throw new Error("[apis] method must be string");var u=a.toLocaleUpperCase();if(!s.includes(u))throw new Error("[apis] invalid method: ".concat(a));return function(n,a){return o(t,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,c.call(this,r({name:e,method:("REQUEST"===u?n.method:u)||"POST"},n),a)];case 1:return[2,t.sent()]}})})}}})}t.generateCallApis=u,t.generateApis=function(e){var t=this;return Object.keys(e||{}).forEach(function(n){void 0!==e[n]&&(t[n]=e[n])}),new Proxy({},{get:function(e,n){if("string"==typeof n)return u.call(t,n)}})}},944:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.registerApis=t.generateApis=void 0;var i=n(378);Object.defineProperty(t,"generateApis",{enumerable:!0,get:function(){return i.generateApis}});var a="apis",c={name:a,IIFE:!0,entity:function(){Object.defineProperty(this.prototype,a,{get:function(){return i.generateApis.call(this)},configurable:!0,enumerable:!0})}};function s(e){try{e.registerComponent(c)}catch(e){console.warn(e)}}t.registerApis=s;try{cloudbase.registerComponent(c)}catch(e){}o(n(26),t);try{window.registerApis=s}catch(e){}},26:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},946:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var n="@cloudbase/js-sdk";t.setSdkName=function(e){n=e},t.getSdkName=function(){return n};var r="https:";t.setProtocol=function(e){r=e},t.getProtocol=function(){return r},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},205:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},794:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(n(946),t),o(n(205),t),t.OATUH_LOGINTYPE="constants"}},t={};return function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(944)})());