@coze/cli 0.1.0-alpha.09fbab → 0.1.0-alpha.2030b2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +203 -195
- package/bin/main +3 -1
- package/lib/cli.js +1 -41641
- package/lib/index-DJO171OF.js +1 -0
- package/lib/send-message.worker.js +1 -52
- package/package.json +7 -4
- package/lib/index-SwtgDxQR.js +0 -25171
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("lodash"),t=require("mitt"),s=require("crypto"),r=require("form-data"),n=require("url"),o=require("http"),i=require("https"),a=require("http2"),c=require("util"),l=require("stream"),u=require("assert"),h=require("tty"),p=require("os"),d=require("zlib"),_=require("events"),f=require("path"),g=require("fs"),m=require("fs/promises"),E=require("undici");var T;!function(e){e.SendMessage="sendMessage";e.ResumeMessage="resumeMessage";e.GetMessage="getMessage";e.ClearHistory="clearHistory";e.ClearMessageContext="clearMessageContext";e.DeleteMessage="deleteMessage";e.BreakMessage="breakMessage";e.ReportMessage="reportMessage";e.ChatASR="chatASR";e.ChatReconnect="chatReconnect";e.ChatRetrieve="chatRetrieve"}(T||(T={}));let A,R,L=(e=21)=>{var t;t=e-=0,!A||A.length<t?(A=Buffer.allocUnsafe(128*t),s.randomFillSync(A),R=0):R+t>A.length&&(s.randomFillSync(A),R=0),R+=t;let r="";for(let t=R-e;t<R;t++)r+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&A[t]];return r};var S="object"==typeof global&&global&&global.Object===Object&&global,y="object"==typeof self&&self&&self.Object===Object&&self,b=S||y||Function("return this")(),C=b.Symbol,v=Object.prototype,I=v.hasOwnProperty,O=v.toString,N=C?C.toStringTag:void 0;var M=Object.prototype.toString;var w=C?C.toStringTag:void 0;function U(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":w&&w in Object(e)?function(e){var t=I.call(e,N),s=e[N];try{e[N]=void 0;var r=!0}catch(e){}var n=O.call(e);return r&&(t?e[N]=s:delete e[N]),n}(e):function(e){return M.call(e)}(e)}function k(e){return null!=e&&"object"==typeof e}function P(e){return"symbol"==typeof e||k(e)&&"[object Symbol]"==U(e)}function B(e,t){for(var s=-1,r=null==e?0:e.length,n=Array(r);++s<r;)n[s]=t(e[s],s,e);return n}var j=Array.isArray,D=C?C.prototype:void 0,x=D?D.toString:void 0;function F(e){if("string"==typeof e)return e;if(j(e))return B(e,F)+"";if(P(e))return x?x.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function q(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function G(e){return e}function H(e){if(!q(e))return!1;var t=U(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var z,W=b["__core-js_shared__"],$=(z=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"";var V=Function.prototype.toString;function K(e){if(null!=e){try{return V.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var J=/^\[object .+?Constructor\]$/,Q=Function.prototype,Y=Object.prototype,Z=Q.toString,X=Y.hasOwnProperty,ee=RegExp("^"+Z.call(X).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function te(e){return!(!q(e)||(t=e,$&&$ in t))&&(H(e)?ee:J).test(K(e));var t}function se(e,t){var s=function(e,t){return null==e?void 0:e[t]}(e,t);return te(s)?s:void 0}var re=se(b,"WeakMap"),ne=Object.create,oe=function(){function e(){}return function(t){if(!q(t))return{};if(ne)return ne(t);e.prototype=t;var s=new e;return e.prototype=void 0,s}}();function ie(){}var ae=Date.now;var ce,le,ue,he=function(){try{var e=se(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),pe=he?function(e,t){return he(e,"toString",{configurable:!0,enumerable:!1,value:(s=t,function(){return s}),writable:!0});var s}:G,de=(ce=pe,le=0,ue=0,function(){var e=ae(),t=16-(e-ue);if(ue=e,t>0){if(++le>=800)return arguments[0]}else le=0;return ce.apply(void 0,arguments)});var _e=/^(?:0|[1-9]\d*)$/;function fe(e,t){var s=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==s||"symbol"!=s&&_e.test(e))&&e>-1&&e%1==0&&e<t}function ge(e,t,s){"__proto__"==t&&he?he(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s}function me(e,t){return e===t||e!=e&&t!=t}var Ee=Object.prototype.hasOwnProperty;function Te(e,t,s){var r=e[t];Ee.call(e,t)&&me(r,s)&&(void 0!==s||t in e)||ge(e,t,s)}var Ae=Math.max;function Re(e,t){return de(function(e,t,s){return t=Ae(void 0===t?e.length-1:t,0),function(){for(var r=arguments,n=-1,o=Ae(r.length-t,0),i=Array(o);++n<o;)i[n]=r[t+n];n=-1;for(var a=Array(t+1);++n<t;)a[n]=r[n];return a[t]=s(i),function(e,t,s){switch(s.length){case 0:return e.call(t);case 1:return e.call(t,s[0]);case 2:return e.call(t,s[0],s[1]);case 3:return e.call(t,s[0],s[1],s[2])}return e.apply(t,s)}(e,this,a)}}(e,t,G),e+"")}function Le(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function Se(e){return null!=e&&Le(e.length)&&!H(e)}function ye(e){return Re(function(t,s){var r=-1,n=s.length,o=n>1?s[n-1]:void 0,i=n>2?s[2]:void 0;for(o=e.length>3&&"function"==typeof o?(n--,o):void 0,i&&function(e,t,s){if(!q(s))return!1;var r=typeof t;return!!("number"==r?Se(s)&&fe(t,s.length):"string"==r&&t in s)&&me(s[t],e)}(s[0],s[1],i)&&(o=n<3?void 0:o,n=1),t=Object(t);++r<n;){var a=s[r];a&&e(t,a,r,o)}return t})}var be=Object.prototype;function Ce(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||be)}function ve(e){return k(e)&&"[object Arguments]"==U(e)}var Ie=Object.prototype,Oe=Ie.hasOwnProperty,Ne=Ie.propertyIsEnumerable,Me=ve(function(){return arguments}())?ve:function(e){return k(e)&&Oe.call(e,"callee")&&!Ne.call(e,"callee")};var we="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ue=we&&"object"==typeof module&&module&&!module.nodeType&&module,ke=Ue&&Ue.exports===we?b.Buffer:void 0,Pe=(ke?ke.isBuffer:void 0)||function(){return!1},Be={};function je(e){return function(t){return e(t)}}Be["[object Float32Array]"]=Be["[object Float64Array]"]=Be["[object Int8Array]"]=Be["[object Int16Array]"]=Be["[object Int32Array]"]=Be["[object Uint8Array]"]=Be["[object Uint8ClampedArray]"]=Be["[object Uint16Array]"]=Be["[object Uint32Array]"]=!0,Be["[object Arguments]"]=Be["[object Array]"]=Be["[object ArrayBuffer]"]=Be["[object Boolean]"]=Be["[object DataView]"]=Be["[object Date]"]=Be["[object Error]"]=Be["[object Function]"]=Be["[object Map]"]=Be["[object Number]"]=Be["[object Object]"]=Be["[object RegExp]"]=Be["[object Set]"]=Be["[object String]"]=Be["[object WeakMap]"]=!1;var De="object"==typeof exports&&exports&&!exports.nodeType&&exports,xe=De&&"object"==typeof module&&module&&!module.nodeType&&module,Fe=xe&&xe.exports===De&&S.process,qe=function(){try{var e=xe&&xe.require&&xe.require("util").types;return e||Fe&&Fe.binding&&Fe.binding("util")}catch(e){}}(),Ge=qe&&qe.isTypedArray,He=Ge?je(Ge):function(e){return k(e)&&Le(e.length)&&!!Be[U(e)]},ze=Object.prototype.hasOwnProperty;function We(e,t){var s=j(e),r=!s&&Me(e),n=!s&&!r&&Pe(e),o=!s&&!r&&!n&&He(e),i=s||r||n||o,a=i?function(e,t){for(var s=-1,r=Array(e);++s<e;)r[s]=t(s);return r}(e.length,String):[],c=a.length;for(var l in e)!t&&!ze.call(e,l)||i&&("length"==l||n&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||fe(l,c))||a.push(l);return a}function $e(e,t){return function(s){return e(t(s))}}var Ve=$e(Object.keys,Object),Ke=Object.prototype.hasOwnProperty;function Je(e){return Se(e)?We(e):function(e){if(!Ce(e))return Ve(e);var t=[];for(var s in Object(e))Ke.call(e,s)&&"constructor"!=s&&t.push(s);return t}(e)}var Qe=Object.prototype.hasOwnProperty;function Ye(e){if(!q(e))return function(e){var t=[];if(null!=e)for(var s in Object(e))t.push(s);return t}(e);var t=Ce(e),s=[];for(var r in e)("constructor"!=r||!t&&Qe.call(e,r))&&s.push(r);return s}function Ze(e){return Se(e)?We(e,!0):Ye(e)}var Xe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,et=/^\w*$/;function tt(e,t){if(j(e))return!1;var s=typeof e;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=e&&!P(e))||(et.test(e)||!Xe.test(e)||null!=t&&e in Object(t))}var st=se(Object,"create");var rt=Object.prototype.hasOwnProperty;var nt=Object.prototype.hasOwnProperty;function ot(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var r=e[t];this.set(r[0],r[1])}}function it(e,t){for(var s=e.length;s--;)if(me(e[s][0],t))return s;return-1}ot.prototype.clear=function(){this.__data__=st?st(null):{},this.size=0},ot.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},ot.prototype.get=function(e){var t=this.__data__;if(st){var s=t[e];return"__lodash_hash_undefined__"===s?void 0:s}return rt.call(t,e)?t[e]:void 0},ot.prototype.has=function(e){var t=this.__data__;return st?void 0!==t[e]:nt.call(t,e)},ot.prototype.set=function(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=st&&void 0===t?"__lodash_hash_undefined__":t,this};var at=Array.prototype.splice;function ct(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var r=e[t];this.set(r[0],r[1])}}ct.prototype.clear=function(){this.__data__=[],this.size=0},ct.prototype.delete=function(e){var t=this.__data__,s=it(t,e);return!(s<0)&&(s==t.length-1?t.pop():at.call(t,s,1),--this.size,!0)},ct.prototype.get=function(e){var t=this.__data__,s=it(t,e);return s<0?void 0:t[s][1]},ct.prototype.has=function(e){return it(this.__data__,e)>-1},ct.prototype.set=function(e,t){var s=this.__data__,r=it(s,e);return r<0?(++this.size,s.push([e,t])):s[r][1]=t,this};var lt=se(b,"Map");function ut(e,t){var s,r,n=e.__data__;return("string"==(r=typeof(s=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==s:null===s)?n["string"==typeof t?"string":"hash"]:n.map}function ht(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var r=e[t];this.set(r[0],r[1])}}ht.prototype.clear=function(){this.size=0,this.__data__={hash:new ot,map:new(lt||ct),string:new ot}},ht.prototype.delete=function(e){var t=ut(this,e).delete(e);return this.size-=t?1:0,t},ht.prototype.get=function(e){return ut(this,e).get(e)},ht.prototype.has=function(e){return ut(this,e).has(e)},ht.prototype.set=function(e,t){var s=ut(this,e),r=s.size;return s.set(e,t),this.size+=s.size==r?0:1,this};function pt(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var s=function(){var r=arguments,n=t?t.apply(this,r):r[0],o=s.cache;if(o.has(n))return o.get(n);var i=e.apply(this,r);return s.cache=o.set(n,i)||o,i};return s.cache=new(pt.Cache||ht),s}pt.Cache=ht;var dt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,_t=/\\(\\)?/g,ft=function(e){var t=pt(e,function(e){return 500===s.size&&s.clear(),e}),s=t.cache;return t}(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(dt,function(e,s,r,n){t.push(r?n.replace(_t,"$1"):s||e)}),t});function gt(e,t){return j(e)?e:tt(e,t)?[e]:ft(function(e){return null==e?"":F(e)}(e))}function mt(e){if("string"==typeof e||P(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function Et(e,t){for(var s=0,r=(t=gt(t,e)).length;null!=e&&s<r;)e=e[mt(t[s++])];return s&&s==r?e:void 0}function Tt(e,t,s){var r=null==e?void 0:Et(e,t);return void 0===r?s:r}function At(e,t){for(var s=-1,r=t.length,n=e.length;++s<r;)e[n+s]=t[s];return e}var Rt=$e(Object.getPrototypeOf,Object),Lt=Function.prototype,St=Object.prototype,yt=Lt.toString,bt=St.hasOwnProperty,Ct=yt.call(Object);function vt(e){var t=this.__data__=new ct(e);this.size=t.size}vt.prototype.clear=function(){this.__data__=new ct,this.size=0},vt.prototype.delete=function(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s},vt.prototype.get=function(e){return this.__data__.get(e)},vt.prototype.has=function(e){return this.__data__.has(e)},vt.prototype.set=function(e,t){var s=this.__data__;if(s instanceof ct){var r=s.__data__;if(!lt||r.length<199)return r.push([e,t]),this.size=++s.size,this;s=this.__data__=new ht(r)}return s.set(e,t),this.size=s.size,this};var It="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ot=It&&"object"==typeof module&&module&&!module.nodeType&&module,Nt=Ot&&Ot.exports===It?b.Buffer:void 0,Mt=Nt?Nt.allocUnsafe:void 0;function wt(e,t){if(t)return e.slice();var s=e.length,r=Mt?Mt(s):new e.constructor(s);return e.copy(r),r}function Ut(){return[]}var kt=Object.prototype.propertyIsEnumerable,Pt=Object.getOwnPropertySymbols,Bt=Pt?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var s=-1,r=null==e?0:e.length,n=0,o=[];++s<r;){var i=e[s];t(i,s,e)&&(o[n++]=i)}return o}(Pt(e),function(t){return kt.call(e,t)}))}:Ut,jt=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)At(t,Bt(e)),e=Rt(e);return t}:Ut;function Dt(e,t,s){var r=t(e);return j(e)?r:At(r,s(e))}function xt(e){return Dt(e,Je,Bt)}var Ft=se(b,"DataView"),qt=se(b,"Promise"),Gt=se(b,"Set"),Ht="[object Map]",zt="[object Promise]",Wt="[object Set]",$t="[object WeakMap]",Vt="[object DataView]",Kt=K(Ft),Jt=K(lt),Qt=K(qt),Yt=K(Gt),Zt=K(re),Xt=U;(Ft&&Xt(new Ft(new ArrayBuffer(1)))!=Vt||lt&&Xt(new lt)!=Ht||qt&&Xt(qt.resolve())!=zt||Gt&&Xt(new Gt)!=Wt||re&&Xt(new re)!=$t)&&(Xt=function(e){var t=U(e),s="[object Object]"==t?e.constructor:void 0,r=s?K(s):"";if(r)switch(r){case Kt:return Vt;case Jt:return Ht;case Qt:return zt;case Yt:return Wt;case Zt:return $t}return t});var es=Object.prototype.hasOwnProperty;var ts=b.Uint8Array;function ss(e){var t=new e.constructor(e.byteLength);return new ts(t).set(new ts(e)),t}var rs=/\w*$/;var ns=C?C.prototype:void 0,os=ns?ns.valueOf:void 0;function is(e,t){var s=t?ss(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function as(e,t,s){var r,n,o,i,a,c=e.constructor;switch(t){case"[object ArrayBuffer]":return ss(e);case"[object Boolean]":case"[object Date]":return new c(+e);case"[object DataView]":return a=ss((i=e).buffer),new i.constructor(a,i.byteOffset,i.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return is(e,s);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(e);case"[object RegExp]":return(o=new(n=e).constructor(n.source,rs.exec(n))).lastIndex=n.lastIndex,o;case"[object Symbol]":return r=e,os?Object(os.call(r)):{}}}function cs(e){return"function"!=typeof e.constructor||Ce(e)?{}:oe(Rt(e))}var ls=qe&&qe.isMap,us=ls?je(ls):function(e){return k(e)&&"[object Map]"==Xt(e)};var hs=qe&&qe.isSet,ps=hs?je(hs):function(e){return k(e)&&"[object Set]"==Xt(e)},ds="[object Arguments]",_s="[object Function]",fs="[object Object]",gs={};function ms(e,t,s,r,n,o){var i,a=1&t;if(void 0!==i)return i;if(!q(e))return e;var c=j(e);if(c)i=function(e){var t=e.length,s=new e.constructor(t);return t&&"string"==typeof e[0]&&es.call(e,"index")&&(s.index=e.index,s.input=e.input),s}(e);else{var l=Xt(e),u=l==_s||"[object GeneratorFunction]"==l;if(Pe(e))return wt(e,a);if(l==fs||l==ds||u&&!n)i=u?{}:cs(e);else{if(!gs[l])return n?e:{};i=as(e,l,a)}}o||(o=new vt);var h=o.get(e);if(h)return h;o.set(e,i),ps(e)?e.forEach(function(r){i.add(ms(r,t,s,r,e,o))}):us(e)&&e.forEach(function(r,n){i.set(n,ms(r,t,s,n,e,o))});var p=c?void 0:xt(e);return function(e,t){for(var s=-1,r=null==e?0:e.length;++s<r&&!1!==t(e[s],s,e););}(p||e,function(r,n){p&&(r=e[n=r]),Te(i,n,ms(r,t,s,n,e,o))}),i}gs[ds]=gs["[object Array]"]=gs["[object ArrayBuffer]"]=gs["[object DataView]"]=gs["[object Boolean]"]=gs["[object Date]"]=gs["[object Float32Array]"]=gs["[object Float64Array]"]=gs["[object Int8Array]"]=gs["[object Int16Array]"]=gs["[object Int32Array]"]=gs["[object Map]"]=gs["[object Number]"]=gs[fs]=gs["[object RegExp]"]=gs["[object Set]"]=gs["[object String]"]=gs["[object Symbol]"]=gs["[object Uint8Array]"]=gs["[object Uint8ClampedArray]"]=gs["[object Uint16Array]"]=gs["[object Uint32Array]"]=!0,gs["[object Error]"]=gs[_s]=gs["[object WeakMap]"]=!1;function Es(e){return ms(e,5)}function Ts(e){var t=-1,s=null==e?0:e.length;for(this.__data__=new ht;++t<s;)this.add(e[t])}function As(e,t){for(var s=-1,r=null==e?0:e.length;++s<r;)if(t(e[s],s,e))return!0;return!1}Ts.prototype.add=Ts.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Ts.prototype.has=function(e){return this.__data__.has(e)};function Rs(e,t,s,r,n,o){var i=1&s,a=e.length,c=t.length;if(a!=c&&!(i&&c>a))return!1;var l=o.get(e),u=o.get(t);if(l&&u)return l==t&&u==e;var h=-1,p=!0,d=2&s?new Ts:void 0;for(o.set(e,t),o.set(t,e);++h<a;){var _=e[h],f=t[h];if(r)var g=i?r(f,_,h,t,e,o):r(_,f,h,e,t,o);if(void 0!==g){if(g)continue;p=!1;break}if(d){if(!As(t,function(e,t){if(i=t,!d.has(i)&&(_===e||n(_,e,s,r,o)))return d.push(t);var i})){p=!1;break}}else if(_!==f&&!n(_,f,s,r,o)){p=!1;break}}return o.delete(e),o.delete(t),p}function Ls(e){var t=-1,s=Array(e.size);return e.forEach(function(e,r){s[++t]=[r,e]}),s}function Ss(e){var t=-1,s=Array(e.size);return e.forEach(function(e){s[++t]=e}),s}var ys=C?C.prototype:void 0,bs=ys?ys.valueOf:void 0;var Cs=Object.prototype.hasOwnProperty;var vs="[object Arguments]",Is="[object Array]",Os="[object Object]",Ns=Object.prototype.hasOwnProperty;function Ms(e,t,s,r,n,o){var i=j(e),a=j(t),c=i?Is:Xt(e),l=a?Is:Xt(t),u=(c=c==vs?Os:c)==Os,h=(l=l==vs?Os:l)==Os,p=c==l;if(p&&Pe(e)){if(!Pe(t))return!1;i=!0,u=!1}if(p&&!u)return o||(o=new vt),i||He(e)?Rs(e,t,s,r,n,o):function(e,t,s,r,n,o,i){switch(s){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!o(new ts(e),new ts(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return me(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=Ls;case"[object Set]":var c=1&r;if(a||(a=Ss),e.size!=t.size&&!c)return!1;var l=i.get(e);if(l)return l==t;r|=2,i.set(e,t);var u=Rs(a(e),a(t),r,n,o,i);return i.delete(e),u;case"[object Symbol]":if(bs)return bs.call(e)==bs.call(t)}return!1}(e,t,c,s,r,n,o);if(!(1&s)){var d=u&&Ns.call(e,"__wrapped__"),_=h&&Ns.call(t,"__wrapped__");if(d||_){var f=d?e.value():e,g=_?t.value():t;return o||(o=new vt),n(f,g,s,r,o)}}return!!p&&(o||(o=new vt),function(e,t,s,r,n,o){var i=1&s,a=xt(e),c=a.length;if(c!=xt(t).length&&!i)return!1;for(var l=c;l--;){var u=a[l];if(!(i?u in t:Cs.call(t,u)))return!1}var h=o.get(e),p=o.get(t);if(h&&p)return h==t&&p==e;var d=!0;o.set(e,t),o.set(t,e);for(var _=i;++l<c;){var f=e[u=a[l]],g=t[u];if(r)var m=i?r(g,f,u,t,e,o):r(f,g,u,e,t,o);if(!(void 0===m?f===g||n(f,g,s,r,o):m)){d=!1;break}_||(_="constructor"==u)}if(d&&!_){var E=e.constructor,T=t.constructor;E==T||!("constructor"in e)||!("constructor"in t)||"function"==typeof E&&E instanceof E&&"function"==typeof T&&T instanceof T||(d=!1)}return o.delete(e),o.delete(t),d}(e,t,s,r,n,o))}function ws(e,t,s,r,n){return e===t||(null==e||null==t||!k(e)&&!k(t)?e!=e&&t!=t:Ms(e,t,s,r,ws,n))}function Us(e){return e==e&&!q(e)}function ks(e,t){return function(s){return null!=s&&(s[e]===t&&(void 0!==t||e in Object(s)))}}function Ps(e){var t=function(e){for(var t=Je(e),s=t.length;s--;){var r=t[s],n=e[r];t[s]=[r,n,Us(n)]}return t}(e);return 1==t.length&&t[0][2]?ks(t[0][0],t[0][1]):function(s){return s===e||function(e,t,s,r){var n=s.length,o=n;if(null==e)return!o;for(e=Object(e);n--;){var i=s[n];if(i[2]?i[1]!==e[i[0]]:!(i[0]in e))return!1}for(;++n<o;){var a=(i=s[n])[0],c=e[a],l=i[1];if(i[2]){if(void 0===c&&!(a in e))return!1}else if(!ws(l,c,3,r,new vt))return!1}return!0}(s,0,t)}}function Bs(e,t){return null!=e&&t in Object(e)}function js(e,t){return null!=e&&function(e,t,s){for(var r=-1,n=(t=gt(t,e)).length,o=!1;++r<n;){var i=mt(t[r]);if(!(o=null!=e&&s(e,i)))break;e=e[i]}return o||++r!=n?o:!!(n=null==e?0:e.length)&&Le(n)&&fe(i,n)&&(j(e)||Me(e))}(e,t,Bs)}function Ds(e){return tt(e)?(t=mt(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return Et(t,e)}}(e);var t}function xs(e){return"function"==typeof e?e:null==e?G:"object"==typeof e?j(e)?function(e,t){return tt(e)&&Us(t)?ks(mt(e),t):function(s){var r=Tt(s,e);return void 0===r&&r===t?js(s,e):ws(t,r,3)}}(e[0],e[1]):Ps(e):Ds(e)}var Fs=function(e,t,s){for(var r=-1,n=Object(e),o=s(e),i=o.length;i--;){var a=o[++r];if(!1===t(n[a],a,n))break}return e};function qs(e,t,s){(void 0!==s&&!me(e[t],s)||void 0===s&&!(t in e))&&ge(e,t,s)}function Gs(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function Hs(e){return function(e,t,s){var r=!s;s||(s={});for(var n=-1,o=t.length;++n<o;){var i=t[n],a=void 0;void 0===a&&(a=e[i]),r?ge(s,i,a):Te(s,i,a)}return s}(e,Ze(e))}function zs(e,t,s,r,n,o,i){var a=Gs(e,s),c=Gs(t,s),l=i.get(c);if(l)qs(e,s,l);else{var u,h=o?o(a,c,s+"",e,t,i):void 0,p=void 0===h;if(p){var d=j(c),_=!d&&Pe(c),f=!d&&!_&&He(c);h=c,d||_||f?j(a)?h=a:k(u=a)&&Se(u)?h=function(e,t){var s=-1,r=e.length;for(t||(t=Array(r));++s<r;)t[s]=e[s];return t}(a):_?(p=!1,h=wt(c,!0)):f?(p=!1,h=is(c,!0)):h=[]:function(e){if(!k(e)||"[object Object]"!=U(e))return!1;var t=Rt(e);if(null===t)return!0;var s=bt.call(t,"constructor")&&t.constructor;return"function"==typeof s&&s instanceof s&&yt.call(s)==Ct}(c)||Me(c)?(h=a,Me(a)?h=Hs(a):q(a)&&!H(a)||(h=cs(c))):p=!1}p&&(i.set(c,h),n(h,c,r,o,i),i.delete(c)),qs(e,s,h)}}function Ws(e,t,s,r,n){e!==t&&Fs(t,function(o,i){if(n||(n=new vt),q(o))zs(e,t,i,s,Ws,r,n);else{var a=r?r(Gs(e,i),o,i+"",e,t,n):void 0;void 0===a&&(a=o),qs(e,i,a)}},Ze)}var $s=ye(function(e,t,s,r){Ws(e,t,s,r)});function Vs(e){return void 0===e}var Ks=ye(function(e,t,s){Ws(e,t,s)});function Js(e,t,s,r){if(!q(e))return e;for(var n=-1,o=(t=gt(t,e)).length,i=o-1,a=e;null!=a&&++n<o;){var c=mt(t[n]),l=s;if("__proto__"===c||"constructor"===c||"prototype"===c)return e;if(n!=i){var u=a[c];void 0===(l=void 0)&&(l=q(u)?u:fe(t[n+1])?[]:{})}Te(a,c,l),a=a[c]}return e}function Qs(e,t){if(null==e)return{};var s=B(function(e){return Dt(e,Ze,jt)}(e),function(e){return[e]});return t=xs(t),function(e,t,s){for(var r=-1,n=t.length,o={};++r<n;){var i=t[r],a=Et(e,i);s(a,i)&&Js(o,gt(i,e),a)}return o}(e,s,function(e,s){return t(e,s[0])})}function Ys(e,t,s){return null==e?e:Js(e,t,s)}function Zs(e,t,s){return null==e?e:function(e,t,s){return Js(e,t,s(Et(e,t)))}(e,t,"function"==typeof(r=s)?r:G);var r}class Xs{createQueryMessage(e,t){return{content:e,session_id:t.session_id,type:"query",project_id:t.project_id,context:t.context,local_msg_id:L()}}createRetryMessage(e,t){return{content:e,session_id:t.session_id,type:"retry",project_id:t.project_id,context:t.context,local_msg_id:L()}}createEditMessage(e,t){const s=L();return{content:Ks(e,{edit:{local_msg_id:s}}),session_id:t.session_id,type:"edit",project_id:t.project_id,context:t.context,local_msg_id:s}}createInputMessage(e,t){return{content:e,session_id:t.session_id,type:"input",project_id:t.project_id,context:t.context,local_msg_id:L()}}createCancelMessage(e,t){return{content:e,session_id:t.session_id,type:"cancel",project_id:t.project_id,context:t.context,local_msg_id:L()}}}const er=(...e)=>$s(...e,(e,t)=>{if(j(e))return e.concat(t)});function tr(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}class sr extends Error{constructor(e,t={}){super(e),this.name="HttpError",this.status=t.status,this.code=t.code,this.config=t.config,this.response=t.response,this.data=t.data,Error.captureStackTrace&&Error.captureStackTrace(this,sr)}toString(){const e=[];let t=this.name;if(this.status||this.code){const e=[];this.status&&e.push(String(this.status)),this.code&&e.push(String(this.code)),t+=` [${e.join(" ")}]`}if(t+=`: ${this.message}`,e.push(t),this.config){const t=tr([this,"access",e=>e.config,"access",e=>e.method,"optionalAccess",e=>e.toUpperCase,"call",e=>e()])||"GET",s=this.config.url||"unknown",r=(this.config.baseURL?`${this.config.baseURL}`:"")+s;e.push(` URL: ${t} ${r}`)}if(this.data)try{const t=JSON.stringify(this.data);t.length<200?e.push(` Data: ${t}`):e.push(` Data: [${t.length} bytes]`)}catch(t){const s=t instanceof Error?t.constructor.name:"unknown";e.push(` Data: [non-serializable: ${s}]`)}return e.join("\n")}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code,data:this.data,url:tr([this,"access",e=>e.config,"optionalAccess",e=>e.url]),method:tr([this,"access",e=>e.config,"optionalAccess",e=>e.method]),baseURL:tr([this,"access",e=>e.config,"optionalAccess",e=>e.baseURL])}}}function rr(e,t){return function(){return e.apply(t,arguments)}}const{toString:nr}=Object.prototype,{getPrototypeOf:or}=Object,{iterator:ir,toStringTag:ar}=Symbol,cr=(lr=Object.create(null),e=>{const t=nr.call(e);return lr[t]||(lr[t]=t.slice(8,-1).toLowerCase())});var lr;const ur=e=>(e=e.toLowerCase(),t=>cr(t)===e),hr=e=>t=>typeof t===e,{isArray:pr}=Array,dr=hr("undefined");function _r(e){return null!==e&&!dr(e)&&null!==e.constructor&&!dr(e.constructor)&&mr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const fr=ur("ArrayBuffer");const gr=hr("string"),mr=hr("function"),Er=hr("number"),Tr=e=>null!==e&&"object"==typeof e,Ar=e=>{if("object"!==cr(e))return!1;const t=or(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||ar in e||ir in e)},Rr=ur("Date"),Lr=ur("File"),Sr=ur("Blob"),yr=ur("FileList");const br="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},Cr=void 0!==br.FormData?br.FormData:void 0,vr=ur("URLSearchParams"),[Ir,Or,Nr,Mr]=["ReadableStream","Request","Response","Headers"].map(ur);function wr(e,t,{allOwnKeys:s=!1}={}){if(null==e)return;let r,n;if("object"!=typeof e&&(e=[e]),pr(e))for(r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else{if(_r(e))return;const n=s?Object.getOwnPropertyNames(e):Object.keys(e),o=n.length;let i;for(r=0;r<o;r++)i=n[r],t.call(null,e[i],i,e)}}function Ur(e,t){if(_r(e))return null;t=t.toLowerCase();const s=Object.keys(e);let r,n=s.length;for(;n-- >0;)if(r=s[n],t===r.toLowerCase())return r;return null}const kr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Pr=e=>!dr(e)&&e!==kr;const Br=(jr="undefined"!=typeof Uint8Array&&or(Uint8Array),e=>jr&&e instanceof jr);var jr;const Dr=ur("HTMLFormElement"),xr=(({hasOwnProperty:e})=>(t,s)=>e.call(t,s))(Object.prototype),Fr=ur("RegExp"),qr=(e,t)=>{const s=Object.getOwnPropertyDescriptors(e),r={};wr(s,(s,n)=>{let o;!1!==(o=t(s,n,e))&&(r[n]=o||s)}),Object.defineProperties(e,r)};const Gr=ur("AsyncFunction"),Hr=(zr="function"==typeof setImmediate,Wr=mr(kr.postMessage),zr?setImmediate:Wr?($r=`axios@${Math.random()}`,Vr=[],kr.addEventListener("message",({source:e,data:t})=>{e===kr&&t===$r&&Vr.length&&Vr.shift()()},!1),e=>{Vr.push(e),kr.postMessage($r,"*")}):e=>setTimeout(e));var zr,Wr,$r,Vr;const Kr="undefined"!=typeof queueMicrotask?queueMicrotask.bind(kr):"undefined"!=typeof process&&process.nextTick||Hr,Jr={isArray:pr,isArrayBuffer:fr,isBuffer:_r,isFormData:e=>{let t;return e&&(Cr&&e instanceof Cr||mr(e.append)&&("formdata"===(t=cr(e))||"object"===t&&mr(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&fr(e.buffer),t},isString:gr,isNumber:Er,isBoolean:e=>!0===e||!1===e,isObject:Tr,isPlainObject:Ar,isEmptyObject:e=>{if(!Tr(e)||_r(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:Ir,isRequest:Or,isResponse:Nr,isHeaders:Mr,isUndefined:dr,isDate:Rr,isFile:Lr,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:Sr,isRegExp:Fr,isFunction:mr,isStream:e=>Tr(e)&&mr(e.pipe),isURLSearchParams:vr,isTypedArray:Br,isFileList:yr,forEach:wr,merge:function e(){const{caseless:t,skipUndefined:s}=Pr(this)&&this||{},r={},n=(n,o)=>{if("__proto__"===o||"constructor"===o||"prototype"===o)return;const i=t&&Ur(r,o)||o;Ar(r[i])&&Ar(n)?r[i]=e(r[i],n):Ar(n)?r[i]=e({},n):pr(n)?r[i]=n.slice():s&&dr(n)||(r[i]=n)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&wr(arguments[e],n);return r},extend:(e,t,s,{allOwnKeys:r}={})=>(wr(t,(t,r)=>{s&&mr(t)?Object.defineProperty(e,r,{value:rr(t,s),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,s,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{value:t.prototype}),s&&Object.assign(e.prototype,s)},toFlatObject:(e,t,s,r)=>{let n,o,i;const a={};if(t=t||{},null==e)return t;do{for(n=Object.getOwnPropertyNames(e),o=n.length;o-- >0;)i=n[o],r&&!r(i,e,t)||a[i]||(t[i]=e[i],a[i]=!0);e=!1!==s&&or(e)}while(e&&(!s||s(e,t))&&e!==Object.prototype);return t},kindOf:cr,kindOfTest:ur,endsWith:(e,t,s)=>{e=String(e),(void 0===s||s>e.length)&&(s=e.length),s-=t.length;const r=e.indexOf(t,s);return-1!==r&&r===s},toArray:e=>{if(!e)return null;if(pr(e))return e;let t=e.length;if(!Er(t))return null;const s=new Array(t);for(;t-- >0;)s[t]=e[t];return s},forEachEntry:(e,t)=>{const s=(e&&e[ir]).call(e);let r;for(;(r=s.next())&&!r.done;){const s=r.value;t.call(e,s[0],s[1])}},matchAll:(e,t)=>{let s;const r=[];for(;null!==(s=e.exec(t));)r.push(s);return r},isHTMLForm:Dr,hasOwnProperty:xr,hasOwnProp:xr,reduceDescriptors:qr,freezeMethods:e=>{qr(e,(t,s)=>{if(mr(e)&&-1!==["arguments","caller","callee"].indexOf(s))return!1;const r=e[s];mr(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+s+"'")}))})},toObjectSet:(e,t)=>{const s={},r=e=>{e.forEach(e=>{s[e]=!0})};return pr(e)?r(e):r(String(e).split(t)),s},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,s){return t.toUpperCase()+s}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Ur,global:kr,isContextDefined:Pr,isSpecCompliantForm:function(e){return!!(e&&mr(e.append)&&"FormData"===e[ar]&&e[ir])},toJSONObject:e=>{const t=new Array(10),s=(e,r)=>{if(Tr(e)){if(t.indexOf(e)>=0)return;if(_r(e))return e;if(!("toJSON"in e)){t[r]=e;const n=pr(e)?[]:{};return wr(e,(e,t)=>{const o=s(e,r+1);!dr(o)&&(n[t]=o)}),t[r]=void 0,n}}return e};return s(e,0)},isAsyncFn:Gr,isThenable:e=>e&&(Tr(e)||mr(e))&&mr(e.then)&&mr(e.catch),setImmediate:Hr,asap:Kr,isIterable:e=>null!=e&&mr(e[ir])};let Qr=class e extends Error{static from(t,s,r,n,o,i){const a=new e(t.message,s||t.code,r,n,o);return a.cause=t,a.name=t.name,null!=t.status&&null==a.status&&(a.status=t.status),i&&Object.assign(a,i),a}constructor(e,t,s,r,n){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,t&&(this.code=t),s&&(this.config=s),r&&(this.request=r),n&&(this.response=n,this.status=n.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Jr.toJSONObject(this.config),code:this.code,status:this.status}}};function Yr(e){return Jr.isPlainObject(e)||Jr.isArray(e)}function Zr(e){return Jr.endsWith(e,"[]")?e.slice(0,-2):e}function Xr(e,t,s){return e?e.concat(t).map(function(e,t){return e=Zr(e),!s&&t?"["+e+"]":e}).join(s?".":""):t}Qr.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Qr.ERR_BAD_OPTION="ERR_BAD_OPTION",Qr.ECONNABORTED="ECONNABORTED",Qr.ETIMEDOUT="ETIMEDOUT",Qr.ERR_NETWORK="ERR_NETWORK",Qr.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Qr.ERR_DEPRECATED="ERR_DEPRECATED",Qr.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Qr.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Qr.ERR_CANCELED="ERR_CANCELED",Qr.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Qr.ERR_INVALID_URL="ERR_INVALID_URL";const en=Jr.toFlatObject(Jr,{},null,function(e){return/^is[A-Z]/.test(e)});function tn(e,t,s){if(!Jr.isObject(e))throw new TypeError("target must be an object");t=t||new(r||FormData);const n=(s=Jr.toFlatObject(s,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Jr.isUndefined(t[e])})).metaTokens,o=s.visitor||u,i=s.dots,a=s.indexes,c=(s.Blob||"undefined"!=typeof Blob&&Blob)&&Jr.isSpecCompliantForm(t);if(!Jr.isFunction(o))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Jr.isDate(e))return e.toISOString();if(Jr.isBoolean(e))return e.toString();if(!c&&Jr.isBlob(e))throw new Qr("Blob is not supported. Use a Buffer instead.");return Jr.isArrayBuffer(e)||Jr.isTypedArray(e)?c&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,s,r){let o=e;if(Jr.isReactNative(t)&&Jr.isReactNativeBlob(e))return t.append(Xr(r,s,i),l(e)),!1;if(e&&!r&&"object"==typeof e)if(Jr.endsWith(s,"{}"))s=n?s:s.slice(0,-2),e=JSON.stringify(e);else if(Jr.isArray(e)&&function(e){return Jr.isArray(e)&&!e.some(Yr)}(e)||(Jr.isFileList(e)||Jr.endsWith(s,"[]"))&&(o=Jr.toArray(e)))return s=Zr(s),o.forEach(function(e,r){!Jr.isUndefined(e)&&null!==e&&t.append(!0===a?Xr([s],r,i):null===a?s:s+"[]",l(e))}),!1;return!!Yr(e)||(t.append(Xr(r,s,i),l(e)),!1)}const h=[],p=Object.assign(en,{defaultVisitor:u,convertValue:l,isVisitable:Yr});if(!Jr.isObject(e))throw new TypeError("data must be an object");return function e(s,r){if(!Jr.isUndefined(s)){if(-1!==h.indexOf(s))throw Error("Circular reference detected in "+r.join("."));h.push(s),Jr.forEach(s,function(s,n){!0===(!(Jr.isUndefined(s)||null===s)&&o.call(t,s,Jr.isString(n)?n.trim():n,r,p))&&e(s,r?r.concat(n):[n])}),h.pop()}}(e),t}function sn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function rn(e,t){this._pairs=[],e&&tn(e,this,t)}const nn=rn.prototype;function on(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function an(e,t,s){if(!t)return e;const r=s&&s.encode||on,n=Jr.isFunction(s)?{serialize:s}:s,o=n&&n.serialize;let i;if(i=o?o(t,n):Jr.isURLSearchParams(t)?t.toString():new rn(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}nn.append=function(e,t){this._pairs.push([e,t])},nn.toString=function(e){const t=e?function(t){return e.call(this,t,sn)}:sn;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class cn{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!s&&s.synchronous,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Jr.forEach(this.handlers,function(t){null!==t&&e(t)})}}const ln={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},un=n.URLSearchParams,hn="abcdefghijklmnopqrstuvwxyz",pn="0123456789",dn={DIGIT:pn,ALPHA:hn,ALPHA_DIGIT:hn+hn.toUpperCase()+pn},_n={isNode:!0,classes:{URLSearchParams:un,FormData:r,Blob:"undefined"!=typeof Blob&&Blob||null},ALPHABET:dn,generateString:(e=16,t=dn.ALPHA_DIGIT)=>{let r="";const{length:n}=t,o=new Uint32Array(e);s.randomFillSync(o);for(let s=0;s<e;s++)r+=t[o[s]%n];return r},protocols:["http","https","file","data"]},fn="undefined"!=typeof window&&"undefined"!=typeof document,gn="object"==typeof navigator&&navigator||void 0,mn=fn&&(!gn||["ReactNative","NativeScript","NS"].indexOf(gn.product)<0),En="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Tn=fn&&window.location.href||"http://localhost",An={...Object.freeze({__proto__:null,hasBrowserEnv:fn,hasStandardBrowserEnv:mn,hasStandardBrowserWebWorkerEnv:En,navigator:gn,origin:Tn}),..._n};function Rn(e){function t(e,s,r,n){let o=e[n++];if("__proto__"===o)return!0;const i=Number.isFinite(+o),a=n>=e.length;if(o=!o&&Jr.isArray(r)?r.length:o,a)return Jr.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!i;r[o]&&Jr.isObject(r[o])||(r[o]=[]);return t(e,s,r[o],n)&&Jr.isArray(r[o])&&(r[o]=function(e){const t={},s=Object.keys(e);let r;const n=s.length;let o;for(r=0;r<n;r++)o=s[r],t[o]=e[o];return t}(r[o])),!i}if(Jr.isFormData(e)&&Jr.isFunction(e.entries)){const s={};return Jr.forEachEntry(e,(e,r)=>{t(function(e){return Jr.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,s,0)}),s}return null}const Ln={transitional:ln,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,n=Jr.isObject(e);n&&Jr.isHTMLForm(e)&&(e=new FormData(e));if(Jr.isFormData(e))return r?JSON.stringify(Rn(e)):e;if(Jr.isArrayBuffer(e)||Jr.isBuffer(e)||Jr.isStream(e)||Jr.isFile(e)||Jr.isBlob(e)||Jr.isReadableStream(e))return e;if(Jr.isArrayBufferView(e))return e.buffer;if(Jr.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(n){if(s.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return tn(e,new An.classes.URLSearchParams,{visitor:function(e,t,s,r){return An.isNode&&Jr.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=Jr.isFileList(e))||s.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return tn(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return n||r?(t.setContentType("application/json",!1),function(e,t,s){if(Jr.isString(e))try{return(t||JSON.parse)(e),Jr.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(s||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Ln.transitional,s=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Jr.isResponse(e)||Jr.isReadableStream(e))return e;if(e&&Jr.isString(e)&&(s&&!this.responseType||r)){const s=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(s){if("SyntaxError"===e.name)throw Qr.from(e,Qr.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:An.classes.FormData,Blob:An.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Jr.forEach(["delete","get","head","post","put","patch"],e=>{Ln.headers[e]={}});const Sn=Jr.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),yn=Symbol("internals");function bn(e){return e&&String(e).trim().toLowerCase()}function Cn(e){return!1===e||null==e?e:Jr.isArray(e)?e.map(Cn):String(e)}function vn(e,t,s,r,n){return Jr.isFunction(r)?r.call(this,t,s):(n&&(t=s),Jr.isString(t)?Jr.isString(r)?-1!==t.indexOf(r):Jr.isRegExp(r)?r.test(t):void 0:void 0)}let In=class{constructor(e){e&&this.set(e)}set(e,t,s){const r=this;function n(e,t,s){const n=bn(t);if(!n)throw new Error("header name must be a non-empty string");const o=Jr.findKey(r,n);(!o||void 0===r[o]||!0===s||void 0===s&&!1!==r[o])&&(r[o||t]=Cn(e))}const o=(e,t)=>Jr.forEach(e,(e,s)=>n(e,s,t));if(Jr.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Jr.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let s,r,n;return e&&e.split("\n").forEach(function(e){n=e.indexOf(":"),s=e.substring(0,n).trim().toLowerCase(),r=e.substring(n+1).trim(),!s||t[s]&&Sn[s]||("set-cookie"===s?t[s]?t[s].push(r):t[s]=[r]:t[s]=t[s]?t[s]+", "+r:r)}),t})(e),t);else if(Jr.isObject(e)&&Jr.isIterable(e)){let s,r,n={};for(const t of e){if(!Jr.isArray(t))throw TypeError("Object iterator must return a key-value pair");n[r=t[0]]=(s=n[r])?Jr.isArray(s)?[...s,t[1]]:[s,t[1]]:t[1]}o(n,t)}else null!=e&&n(t,e,s);return this}get(e,t){if(e=bn(e)){const s=Jr.findKey(this,e);if(s){const e=this[s];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),s=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=s.exec(e);)t[r[1]]=r[2];return t}(e);if(Jr.isFunction(t))return t.call(this,e,s);if(Jr.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=bn(e)){const s=Jr.findKey(this,e);return!(!s||void 0===this[s]||t&&!vn(0,this[s],s,t))}return!1}delete(e,t){const s=this;let r=!1;function n(e){if(e=bn(e)){const n=Jr.findKey(s,e);!n||t&&!vn(0,s[n],n,t)||(delete s[n],r=!0)}}return Jr.isArray(e)?e.forEach(n):n(e),r}clear(e){const t=Object.keys(this);let s=t.length,r=!1;for(;s--;){const n=t[s];e&&!vn(0,this[n],n,e,!0)||(delete this[n],r=!0)}return r}normalize(e){const t=this,s={};return Jr.forEach(this,(r,n)=>{const o=Jr.findKey(s,n);if(o)return t[o]=Cn(r),void delete t[n];const i=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}(n):String(n).trim();i!==n&&delete t[n],t[i]=Cn(r),s[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Jr.forEach(this,(s,r)=>{null!=s&&!1!==s&&(t[r]=e&&Jr.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const s=new this(e);return t.forEach(e=>s.set(e)),s}static accessor(e){const t=(this[yn]=this[yn]={accessors:{}}).accessors,s=this.prototype;function r(e){const r=bn(e);t[r]||(!function(e,t){const s=Jr.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+s,{value:function(e,s,n){return this[r].call(this,t,e,s,n)},configurable:!0})})}(s,e),t[r]=!0)}return Jr.isArray(e)?e.forEach(r):r(e),this}};function On(e,t){const s=this||Ln,r=t||s,n=In.from(r.headers);let o=r.data;return Jr.forEach(e,function(e){o=e.call(s,o,n.normalize(),t?t.status:void 0)}),n.normalize(),o}function Nn(e){return!(!e||!e.__CANCEL__)}In.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Jr.reduceDescriptors(In.prototype,({value:e},t)=>{let s=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[s]=e}}}),Jr.freezeMethods(In);let Mn=class extends Qr{constructor(e,t,s){super(null==e?"canceled":e,Qr.ERR_CANCELED,t,s),this.name="CanceledError",this.__CANCEL__=!0}};function wn(e,t,s){const r=s.config.validateStatus;s.status&&r&&!r(s.status)?t(new Qr("Request failed with status code "+s.status,[Qr.ERR_BAD_REQUEST,Qr.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):e(s)}function Un(e,t,s){let r=!("string"==typeof(n=t)&&/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n));var n;return e&&(r||0==s)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}function kn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pn,Bn={};const jn=kn(function(){if(Pn)return Bn;Pn=1;var e=n.parse,t={ftp:21,gopher:70,http:80,https:443,ws:80,wss:443},s=String.prototype.endsWith||function(e){return e.length<=this.length&&-1!==this.indexOf(e,this.length-e.length)};function r(e){return process.env[e.toLowerCase()]||process.env[e.toUpperCase()]||""}return Bn.getProxyForUrl=function(n){var o="string"==typeof n?e(n):n||{},i=o.protocol,a=o.host,c=o.port;if("string"!=typeof a||!a||"string"!=typeof i)return"";if(i=i.split(":",1)[0],!function(e,t){var n=(r("npm_config_no_proxy")||r("no_proxy")).toLowerCase();if(!n)return!0;if("*"===n)return!1;return n.split(/[,\s]/).every(function(r){if(!r)return!0;var n=r.match(/^(.+):(\d+)$/),o=n?n[1]:r,i=n?parseInt(n[2]):0;return!(!i||i===t)||(/^[.*]/.test(o)?("*"===o.charAt(0)&&(o=o.slice(1)),!s.call(e,o)):e!==o)})}(a=a.replace(/:\d*$/,""),c=parseInt(c)||t[i]||0))return"";var l=r("npm_config_"+i+"_proxy")||r(i+"_proxy")||r("npm_config_proxy")||r("all_proxy");return l&&-1===l.indexOf("://")&&(l=i+"://"+l),l},Bn}());var Dn,xn,Fn,qn,Gn,Hn={exports:{}},zn={exports:{}},Wn={exports:{}};function $n(){if(xn)return Dn;xn=1;var e=1e3,t=60*e,s=60*t,r=24*s,n=7*r,o=365.25*r;function i(e,t,s,r){var n=t>=1.5*s;return Math.round(e/s)+" "+r+(n?"s":"")}return Dn=function(a,c){c=c||{};var l=typeof a;if("string"===l&&a.length>0)return function(i){if((i=String(i)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*n;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*s;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(a);if("number"===l&&isFinite(a))return c.long?function(n){var o=Math.abs(n);if(o>=r)return i(n,o,r,"day");if(o>=s)return i(n,o,s,"hour");if(o>=t)return i(n,o,t,"minute");if(o>=e)return i(n,o,e,"second");return n+" ms"}(a):function(n){var o=Math.abs(n);if(o>=r)return Math.round(n/r)+"d";if(o>=s)return Math.round(n/s)+"h";if(o>=t)return Math.round(n/t)+"m";if(o>=e)return Math.round(n/e)+"s";return n+"ms"}(a);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(a))}}function Vn(){if(qn)return Fn;return qn=1,Fn=function(e){function t(e){let r,n,o,i=null;function a(...e){if(!a.enabled)return;const s=a,n=Number(new Date),o=n-(r||n);s.diff=o,s.prev=r,s.curr=n,r=n,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,n)=>{if("%%"===r)return"%";i++;const o=t.formatters[n];if("function"==typeof o){const t=e[i];r=o.call(s,t),e.splice(i,1),i--}return r}),t.formatArgs.call(s,e);(s.log||t.log).apply(s,e)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=s,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==i?i:(n!==t.namespaces&&(n=t.namespaces,o=t.enabled(e)),o),set:e=>{i=e}}),"function"==typeof t.init&&t.init(a),a}function s(e,s){const r=t(this.namespace+(void 0===s?":":s)+e);return r.log=this.log,r}function r(e,t){let s=0,r=0,n=-1,o=0;for(;s<e.length;)if(r<t.length&&(t[r]===e[s]||"*"===t[r]))"*"===t[r]?(n=r,o=s,r++):(s++,r++);else{if(-1===n)return!1;r=n+1,o++,s=o}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const s=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of s)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const s of t.skips)if(r(e,s))return!1;for(const s of t.names)if(r(e,s))return!0;return!1},t.humanize=$n(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(s=>{t[s]=e[s]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let s=0;for(let t=0;t<e.length;t++)s=(s<<5)-s+e.charCodeAt(t),s|=0;return t.colors[Math.abs(s)%t.colors.length]},t.enable(t.load()),t},Fn}var Kn,Jn,Qn,Yn,Zn,Xn,eo,to,so,ro={exports:{}};function no(){return Jn?Kn:(Jn=1,Kn=(e,t)=>{t=t||process.argv;const s=e.startsWith("-")?"":1===e.length?"-":"--",r=t.indexOf(s+e),n=t.indexOf("--");return-1!==r&&(-1===n||r<n)})}function oo(){if(Yn)return Qn;Yn=1;const e=p,t=no(),{env:s}=process;let r;function n(n){const o=function(n){if(0===r)return 0;if(t("color=16m")||t("color=full")||t("color=truecolor"))return 3;if(t("color=256"))return 2;if(n&&!n.isTTY&&void 0===r)return 0;const o=r||0;if("dumb"===s.TERM)return o;if("win32"===process.platform){const t=e.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("true"in s)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(e=>e in s)||"codeship"===s.CI_NAME?1:o;if("TEAMCITY_VERSION"in s)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(s.TEAMCITY_VERSION)?1:0;if("truecolor"===s.COLORTERM)return 3;if("TERM_PROGRAM"in s){const e=parseInt((s.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(s.TERM_PROGRAM){case"iTerm.app":return e>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(s.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(s.TERM)||"COLORTERM"in s?1:o}(n);return function(e){return 0!==e&&{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}(o)}return t("no-color")||t("no-colors")||t("color=false")||t("color=never")?r=0:(t("color")||t("colors")||t("color=true")||t("color=always"))&&(r=1),"FORCE_COLOR"in s&&(r=!0===s.FORCE_COLOR||"true"===s.FORCE_COLOR?1:!1===s.FORCE_COLOR||"false"===s.FORCE_COLOR?0:0===s.FORCE_COLOR.length?1:Math.min(parseInt(s.FORCE_COLOR,10),3)),Qn={supportsColor:n,stdout:n(process.stdout),stderr:n(process.stderr)}}function io(){return Zn||(Zn=1,function(e,t){const s=h,r=c;t.init=function(e){e.inspectOpts={};const s=Object.keys(t.inspectOpts);for(let r=0;r<s.length;r++)e.inspectOpts[s[r]]=t.inspectOpts[s[r]]},t.log=function(...e){return process.stderr.write(r.formatWithOptions(t.inspectOpts,...e)+"\n")},t.formatArgs=function(s){const{namespace:r,useColors:n}=this;if(n){const t=this.color,n="[3"+(t<8?t:"8;5;"+t),o=` ${n};1m${r} [0m`;s[0]=o+s[0].split("\n").join("\n"+o),s.push(n+"m+"+e.exports.humanize(this.diff)+"[0m")}else s[0]=function(){if(t.inspectOpts.hideDate)return"";return(new Date).toISOString()+" "}()+r+" "+s[0]},t.save=function(e){e?process.env.DEBUG=e:delete process.env.DEBUG},t.load=function(){return process.env.DEBUG},t.useColors=function(){return"colors"in t.inspectOpts?Boolean(t.inspectOpts.colors):s.isatty(process.stderr.fd)},t.destroy=r.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),t.colors=[6,2,3,4,5,1];try{const e=oo();e&&(e.stderr||e).level>=2&&(t.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}t.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{const s=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase());let r=process.env[t];return r=!!/^(yes|on|true|enabled)$/i.test(r)||!/^(no|off|false|disabled)$/i.test(r)&&("null"===r?null:Number(r)),e[s]=r,e},{}),e.exports=Vn()(t);const{formatters:n}=e.exports;n.o=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts).split("\n").map(e=>e.trim()).join(" ")},n.O=function(e){return this.inspectOpts.colors=this.useColors,r.inspect(e,this.inspectOpts)}}(ro,ro.exports)),ro.exports}function ao(){return Xn||(Xn=1,"undefined"==typeof process||"renderer"===process.type||!0===process.browser||process.__nwjs?zn.exports=(Gn||(Gn=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const s="color: "+this.color;t.splice(1,0,s,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(n=r))}),t.splice(n,0,s)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=Vn()(t);const{formatters:s}=e.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(Wn,Wn.exports)),Wn.exports):zn.exports=io()),zn.exports}var co=function(){if(so)return Hn.exports;so=1;var e,t,s,r=n,a=r.URL,c=o,h=i,p=l.Writable,d=u,_=function(){return to||(to=1,eo=function(){if(!e){try{e=ao()("follow-redirects")}catch(e){}"function"!=typeof e&&(e=function(){})}e.apply(null,arguments)}),eo;var e}();e="undefined"!=typeof process,t="undefined"!=typeof window&&"undefined"!=typeof document,s=P(Error.captureStackTrace),e||!t&&s||console.warn("The follow-redirects package should be excluded from browser builds.");var f=!1;try{d(new a(""))}catch(e){f="ERR_INVALID_URL"===e.code}var g=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],m=["abort","aborted","connect","error","socket","timeout"],E=Object.create(null);m.forEach(function(e){E[e]=function(t,s,r){this._redirectable.emit(e,t,s,r)}});var T=w("ERR_INVALID_URL","Invalid URL",TypeError),A=w("ERR_FR_REDIRECTION_FAILURE","Redirected request failed"),R=w("ERR_FR_TOO_MANY_REDIRECTS","Maximum number of redirects exceeded",A),L=w("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),S=w("ERR_STREAM_WRITE_AFTER_END","write after end"),y=p.prototype.destroy||v;function b(e,t){p.call(this),this._sanitizeOptions(e),this._options=e,this._ended=!1,this._ending=!1,this._redirectCount=0,this._redirects=[],this._requestBodyLength=0,this._requestBodyBuffers=[],t&&this.on("response",t);var s=this;this._onNativeResponse=function(e){try{s._processResponse(e)}catch(e){s.emit("error",e instanceof A?e:new A({cause:e}))}},this._performRequest()}function C(e){var t={maxRedirects:21,maxBodyLength:10485760},s={};return Object.keys(e).forEach(function(r){var n=r+":",o=s[n]=e[r],i=t[r]=Object.create(o);Object.defineProperties(i,{request:{value:function(e,r,o){var i;return i=e,a&&i instanceof a?e=N(e):k(e)?e=N(I(e)):(o=r,r=O(e),e={protocol:n}),P(r)&&(o=r,r=null),(r=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,r)).nativeProtocols=s,k(r.host)||k(r.hostname)||(r.hostname="::1"),d.equal(r.protocol,n,"protocol mismatch"),_("options",r),new b(r,o)},configurable:!0,enumerable:!0,writable:!0},get:{value:function(e,t,s){var r=i.request(e,t,s);return r.end(),r},configurable:!0,enumerable:!0,writable:!0}})}),t}function v(){}function I(e){var t;if(f)t=new a(e);else if(!k((t=O(r.parse(e))).protocol))throw new T({input:e});return t}function O(e){if(/^\[/.test(e.hostname)&&!/^\[[:0-9a-f]+\]$/i.test(e.hostname))throw new T({input:e.href||e});if(/^\[/.test(e.host)&&!/^\[[:0-9a-f]+\](:\d+)?$/i.test(e.host))throw new T({input:e.href||e});return e}function N(e,t){var s=t||{};for(var r of g)s[r]=e[r];return s.hostname.startsWith("[")&&(s.hostname=s.hostname.slice(1,-1)),""!==s.port&&(s.port=Number(s.port)),s.path=s.search?s.pathname+s.search:s.pathname,s}function M(e,t){var s;for(var r in t)e.test(r)&&(s=t[r],delete t[r]);return null==s?void 0:String(s).trim()}function w(e,t,s){function r(s){P(Error.captureStackTrace)&&Error.captureStackTrace(this,this.constructor),Object.assign(this,s||{}),this.code=e,this.message=this.cause?t+": "+this.cause.message:t}return r.prototype=new(s||Error),Object.defineProperties(r.prototype,{constructor:{value:r,enumerable:!1},name:{value:"Error ["+e+"]",enumerable:!1}}),r}function U(e,t){for(var s of m)e.removeListener(s,E[s]);e.on("error",v),e.destroy(t)}function k(e){return"string"==typeof e||e instanceof String}function P(e){return"function"==typeof e}return b.prototype=Object.create(p.prototype),b.prototype.abort=function(){U(this._currentRequest),this._currentRequest.abort(),this.emit("abort")},b.prototype.destroy=function(e){return U(this._currentRequest,e),y.call(this,e),this},b.prototype.write=function(e,t,s){if(this._ending)throw new S;if(!k(e)&&("object"!=typeof(r=e)||!("length"in r)))throw new TypeError("data should be a string, Buffer or Uint8Array");var r;P(t)&&(s=t,t=null),0!==e.length?this._requestBodyLength+e.length<=this._options.maxBodyLength?(this._requestBodyLength+=e.length,this._requestBodyBuffers.push({data:e,encoding:t}),this._currentRequest.write(e,t,s)):(this.emit("error",new L),this.abort()):s&&s()},b.prototype.end=function(e,t,s){if(P(e)?(s=e,e=t=null):P(t)&&(s=t,t=null),e){var r=this,n=this._currentRequest;this.write(e,t,function(){r._ended=!0,n.end(null,null,s)}),this._ending=!0}else this._ended=this._ending=!0,this._currentRequest.end(null,null,s)},b.prototype.setHeader=function(e,t){this._options.headers[e]=t,this._currentRequest.setHeader(e,t)},b.prototype.removeHeader=function(e){delete this._options.headers[e],this._currentRequest.removeHeader(e)},b.prototype.setTimeout=function(e,t){var s=this;function r(t){t.setTimeout(e),t.removeListener("timeout",t.destroy),t.addListener("timeout",t.destroy)}function n(t){s._timeout&&clearTimeout(s._timeout),s._timeout=setTimeout(function(){s.emit("timeout"),o()},e),r(t)}function o(){s._timeout&&(clearTimeout(s._timeout),s._timeout=null),s.removeListener("abort",o),s.removeListener("error",o),s.removeListener("response",o),s.removeListener("close",o),t&&s.removeListener("timeout",t),s.socket||s._currentRequest.removeListener("socket",n)}return t&&this.on("timeout",t),this.socket?n(this.socket):this._currentRequest.once("socket",n),this.on("socket",r),this.on("abort",o),this.on("error",o),this.on("response",o),this.on("close",o),this},["flushHeaders","getHeader","setNoDelay","setSocketKeepAlive"].forEach(function(e){b.prototype[e]=function(t,s){return this._currentRequest[e](t,s)}}),["aborted","connection","socket"].forEach(function(e){Object.defineProperty(b.prototype,e,{get:function(){return this._currentRequest[e]}})}),b.prototype._sanitizeOptions=function(e){if(e.headers||(e.headers={}),e.host&&(e.hostname||(e.hostname=e.host),delete e.host),!e.pathname&&e.path){var t=e.path.indexOf("?");t<0?e.pathname=e.path:(e.pathname=e.path.substring(0,t),e.search=e.path.substring(t))}},b.prototype._performRequest=function(){var e=this._options.protocol,t=this._options.nativeProtocols[e];if(!t)throw new TypeError("Unsupported protocol "+e);if(this._options.agents){var s=e.slice(0,-1);this._options.agent=this._options.agents[s]}var n=this._currentRequest=t.request(this._options,this._onNativeResponse);for(var o of(n._redirectable=this,m))n.on(o,E[o]);if(this._currentUrl=/^\//.test(this._options.path)?r.format(this._options):this._options.path,this._isRedirect){var i=0,a=this,c=this._requestBodyBuffers;!function e(t){if(n===a._currentRequest)if(t)a.emit("error",t);else if(i<c.length){var s=c[i++];n.finished||n.write(s.data,s.encoding,e)}else a._ended&&n.end()}()}},b.prototype._processResponse=function(e){var t=e.statusCode;this._options.trackRedirects&&this._redirects.push({url:this._currentUrl,headers:e.headers,statusCode:t});var s,n=e.headers.location;if(!n||!1===this._options.followRedirects||t<300||t>=400)return e.responseUrl=this._currentUrl,e.redirects=this._redirects,this.emit("response",e),void(this._requestBodyBuffers=[]);if(U(this._currentRequest),e.destroy(),++this._redirectCount>this._options.maxRedirects)throw new R;var o=this._options.beforeRedirect;o&&(s=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var i=this._options.method;((301===t||302===t)&&"POST"===this._options.method||303===t&&!/^(?:GET|HEAD)$/.test(this._options.method))&&(this._options.method="GET",this._requestBodyBuffers=[],M(/^content-/i,this._options.headers));var c,l,u=M(/^host$/i,this._options.headers),h=I(this._currentUrl),p=u||h.host,g=/^\w+:/.test(n)?this._currentUrl:r.format(Object.assign(h,{host:p})),m=(c=n,l=g,f?new a(c,l):I(r.resolve(l,c)));if(_("redirecting to",m.href),this._isRedirect=!0,N(m,this._options),(m.protocol!==h.protocol&&"https:"!==m.protocol||m.host!==p&&!function(e,t){d(k(e)&&k(t));var s=e.length-t.length-1;return s>0&&"."===e[s]&&e.endsWith(t)}(m.host,p))&&M(/^(?:(?:proxy-)?authorization|cookie)$/i,this._options.headers),P(o)){var E={headers:e.headers,statusCode:t},T={url:g,method:i,headers:s};o(this._options,E,T),this._sanitizeOptions(this._options)}this._performRequest()},Hn.exports=C({http:c,https:h}),Hn.exports.wrap=C,Hn.exports}();const lo=kn(co),uo="1.13.6";function ho(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}const po=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;const _o=Symbol("internals");class fo extends l.Transform{constructor(e){super({readableHighWaterMark:(e=Jr.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(e,t)=>!Jr.isUndefined(t[e]))).chunkSize});const t=this[_o]={timeWindow:e.timeWindow,chunkSize:e.chunkSize,maxRate:e.maxRate,minChunkSize:e.minChunkSize,bytesSeen:0,isCaptured:!1,notifiedBytesLoaded:0,ts:Date.now(),bytes:0,onReadCallback:null};this.on("newListener",e=>{"progress"===e&&(t.isCaptured||(t.isCaptured=!0))})}_read(e){const t=this[_o];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,s){const r=this[_o],n=r.maxRate,o=this.readableHighWaterMark,i=r.timeWindow,a=n/(1e3/i),c=!1!==r.minChunkSize?Math.max(r.minChunkSize,.01*a):0,l=(e,t)=>{const s=Buffer.byteLength(e);r.bytesSeen+=s,r.bytes+=s,r.isCaptured&&this.emit("progress",r.bytesSeen),this.push(e)?process.nextTick(t):r.onReadCallback=()=>{r.onReadCallback=null,process.nextTick(t)}},u=(e,t)=>{const s=Buffer.byteLength(e);let u,h=null,p=o,d=0;if(n){const e=Date.now();(!r.ts||(d=e-r.ts)>=i)&&(r.ts=e,u=a-r.bytes,r.bytes=u<0?-u:0,d=0),u=a-r.bytes}if(n){if(u<=0)return setTimeout(()=>{t(null,e)},i-d);u<p&&(p=u)}p&&s>p&&s-p>c&&(h=e.subarray(p),e=e.subarray(0,p)),l(e,h?()=>{process.nextTick(t,null,h)}:t)};u(e,function e(t,r){if(t)return s(t);r?u(r,e):s(null)})}}const{asyncIterator:go}=Symbol,mo=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[go]?yield*e[go]():yield e},Eo=An.ALPHABET.ALPHA_DIGIT+"-_",To="function"==typeof TextEncoder?new TextEncoder:new c.TextEncoder,Ao="\r\n",Ro=To.encode(Ao);class Lo{constructor(e,t){const{escapeName:s}=this.constructor,r=Jr.isString(t);let n=`Content-Disposition: form-data; name="${s(e)}"${!r&&t.name?`; filename="${s(t.name)}"`:""}${Ao}`;r?t=To.encode(String(t).replace(/\r?\n|\r\n?/g,Ao)):n+=`Content-Type: ${t.type||"application/octet-stream"}${Ao}`,this.headers=To.encode(n+Ao),this.contentLength=r?t.byteLength:t.size,this.size=this.headers.byteLength+this.contentLength+2,this.name=e,this.value=t}async*encode(){yield this.headers;const{value:e}=this;Jr.isTypedArray(e)?yield e:yield*mo(e),yield Ro}static escapeName(e){return String(e).replace(/[\r\n"]/g,e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e]))}}class So extends l.Transform{__transform(e,t,s){this.push(e),s()}_transform(e,t,s){if(0!==e.length&&(this._transform=this.__transform,120!==e[0])){const e=Buffer.alloc(2);e[0]=120,e[1]=156,this.push(e,t)}this.__transform(e,t,s)}}const yo=(e,t)=>Jr.isAsyncFn(e)?function(...s){const r=s.pop();e.apply(this,s).then(e=>{try{t?r(null,...t(e)):r(null,e)}catch(e){r(e)}},r)}:e;const bo=(e,t,s=3)=>{let r=0;const n=function(e,t){e=e||10;const s=new Array(e),r=new Array(e);let n,o=0,i=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=r[i];n||(n=c),s[o]=a,r[o]=c;let u=i,h=0;for(;u!==o;)h+=s[u++],u%=e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-n<t)return;const p=l&&c-l;return p?Math.round(1e3*h/p):void 0}}(50,250);return function(e,t){let s,r,n=0,o=1e3/t;const i=(t,o=Date.now())=>{n=o,s=null,r&&(clearTimeout(r),r=null),e(...t)};return[(...e)=>{const t=Date.now(),a=t-n;a>=o?i(e,t):(s=e,r||(r=setTimeout(()=>{r=null,i(s)},o-a)))},()=>s&&i(s)]}(s=>{const o=s.loaded,i=s.lengthComputable?s.total:void 0,a=o-r,c=n(a);r=o;e({loaded:o,total:i,progress:i?o/i:void 0,bytes:a,rate:c||void 0,estimated:c&&i&&o<=i?(i-o)/c:void 0,event:s,lengthComputable:null!=i,[t?"download":"upload"]:!0})},s)},Co=(e,t)=>{const s=null!=e;return[r=>t[0]({lengthComputable:s,total:e,loaded:r}),t[1]]},vo=e=>(...t)=>Jr.asap(()=>e(...t));const Io={flush:d.constants.Z_SYNC_FLUSH,finishFlush:d.constants.Z_SYNC_FLUSH},Oo={flush:d.constants.BROTLI_OPERATION_FLUSH,finishFlush:d.constants.BROTLI_OPERATION_FLUSH},No=Jr.isFunction(d.createBrotliDecompress),{http:Mo,https:wo}=lo,Uo=/https:?/,ko=An.protocols.map(e=>e+":"),Po=(e,[t,s])=>(e.on("end",s).on("error",s),t);const Bo=new class{constructor(){this.sessions=Object.create(null)}getSession(e,t){t=Object.assign({sessionTimeout:1e3},t);let s=this.sessions[e];if(s){let e=s.length;for(let r=0;r<e;r++){const[e,n]=s[r];if(!e.destroyed&&!e.closed&&c.isDeepStrictEqual(n,t))return e}}const r=a.connect(e,t);let n;const o=()=>{if(n)return;n=!0;let t=s,o=t.length,i=o;for(;i--;)if(t[i][0]===r)return void(1===o?delete this.sessions[e]:t.splice(i,1))},i=r.request,{sessionTimeout:l}=t;if(null!=l){let e,t=0;r.request=function(){const s=i.apply(this,arguments);return t++,e&&(clearTimeout(e),e=null),s.once("close",()=>{--t||(e=setTimeout(()=>{e=null,o()},l))}),s}}r.once("close",o);let u=[r,t];return s?s.push(u):s=this.sessions[e]=[u],r}};function jo(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function Do(e,t,s){let r=t;if(!r&&!1!==r){const e=jn.getProxyForUrl(s);e&&(r=new URL(e))}if(r){if(r.username&&(r.auth=(r.username||"")+":"+(r.password||"")),r.auth){if(Boolean(r.auth.username||r.auth.password))r.auth=(r.auth.username||"")+":"+(r.auth.password||"");else if("object"==typeof r.auth)throw new Qr("Invalid proxy authorization",Qr.ERR_BAD_OPTION,{proxy:r});const t=Buffer.from(r.auth,"utf8").toString("base64");e.headers["Proxy-Authorization"]="Basic "+t}e.headers.host=e.hostname+(e.port?":"+e.port:"");const t=r.hostname||r.host;e.hostname=t,e.host=t,e.port=r.port,e.path=s,r.protocol&&(e.protocol=r.protocol.includes(":")?r.protocol:`${r.protocol}:`)}e.beforeRedirects.proxy=function(e){Do(e,t,e.href)}}const xo="undefined"!=typeof process&&"process"===Jr.kindOf(process),Fo=(e,t)=>(({address:e,family:t})=>{if(!Jr.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}})(Jr.isObject(e)?e:{address:e,family:t}),qo={request(e,t){const s=e.protocol+"//"+e.hostname+":"+(e.port||("https:"===e.protocol?443:80)),{http2Options:r,headers:n}=e,o=Bo.getSession(s,r),{HTTP2_HEADER_SCHEME:i,HTTP2_HEADER_METHOD:c,HTTP2_HEADER_PATH:l,HTTP2_HEADER_STATUS:u}=a.constants,h={[i]:e.protocol.replace(":",""),[c]:e.method,[l]:e.path};Jr.forEach(n,(e,t)=>{":"!==t.charAt(0)&&(h[t]=e)});const p=o.request(h);return p.once("response",e=>{const s=p,r=(e=Object.assign({},e))[u];delete e[u],s.headers=e,s.statusCode=+r,t(s)}),p}},Go=xo&&function(e){return t=async function(t,s,r){let{data:n,lookup:a,family:u,httpVersion:h=1,http2Options:p}=e;const{responseType:f,responseEncoding:g}=e,m=e.method.toUpperCase();let E,T,A=!1;if(h=+h,Number.isNaN(h))throw TypeError(`Invalid protocol version: '${e.httpVersion}' is not a number`);if(1!==h&&2!==h)throw TypeError(`Unsupported protocol version '${h}'`);const R=2===h;if(a){const e=yo(a,e=>Jr.isArray(e)?e:[e]);a=(t,s,r)=>{e(t,s,(e,t,n)=>{if(e)return r(e);const o=Jr.isArray(t)?t.map(e=>Fo(e)):[Fo(t,n)];s.all?r(e,o):r(e,o[0].address,o[0].family)})}}const L=new _.EventEmitter;function S(t){try{L.emit("abort",!t||t.type?new Mn(null,e,T):t)}catch(e){console.warn("emit error",e)}}L.once("abort",s);const y=()=>{e.cancelToken&&e.cancelToken.unsubscribe(S),e.signal&&e.signal.removeEventListener("abort",S),L.removeAllListeners()};(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(S),e.signal&&(e.signal.aborted?S():e.signal.addEventListener("abort",S))),r((e,t)=>{if(E=!0,t)return A=!0,void y();const{data:s}=e;if(s instanceof l.Readable||s instanceof l.Duplex){const e=l.finished(s,()=>{e(),y()})}else y()});const b=Un(e.baseURL,e.url,e.allowAbsoluteUrls),C=new URL(b,An.hasBrowserEnv?An.origin:void 0),v=C.protocol||ko[0];if("data:"===v){if(e.maxContentLength>-1&&function(e){if(!e||"string"!=typeof e)return 0;if(!e.startsWith("data:"))return 0;const t=e.indexOf(",");if(t<0)return 0;const s=e.slice(5,t),r=e.slice(t+1);if(/;base64/i.test(s)){let e=r.length;const t=r.length;for(let s=0;s<t;s++)if(37===r.charCodeAt(s)&&s+2<t){const t=r.charCodeAt(s+1),n=r.charCodeAt(s+2);(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102)&&(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102)&&(e-=2,s+=2)}let s=0,n=t-1;const o=e=>e>=2&&37===r.charCodeAt(e-2)&&51===r.charCodeAt(e-1)&&(68===r.charCodeAt(e)||100===r.charCodeAt(e));n>=0&&(61===r.charCodeAt(n)?(s++,n--):o(n)&&(s++,n-=3)),1===s&&n>=0&&(61===r.charCodeAt(n)||o(n))&&s++;const i=3*Math.floor(e/4)-(s||0);return i>0?i:0}return Buffer.byteLength(r,"utf8")}(String(e.url||b||""))>e.maxContentLength)return s(new Qr("maxContentLength size of "+e.maxContentLength+" exceeded",Qr.ERR_BAD_RESPONSE,e));let r;if("GET"!==m)return wn(t,s,{status:405,statusText:"method not allowed",headers:{},config:e});try{r=function(e,t,s){const r=s&&s.Blob||An.classes.Blob,n=ho(e);if(void 0===t&&r&&(t=!0),"data"===n){e=n.length?e.slice(n.length+1):e;const s=po.exec(e);if(!s)throw new Qr("Invalid URL",Qr.ERR_INVALID_URL);const o=s[1],i=s[2],a=s[3],c=Buffer.from(decodeURIComponent(a),i?"base64":"utf8");if(t){if(!r)throw new Qr("Blob is not supported",Qr.ERR_NOT_SUPPORT);return new r([c],{type:o})}return c}throw new Qr("Unsupported protocol "+n,Qr.ERR_NOT_SUPPORT)}(e.url,"blob"===f,{Blob:e.env&&e.env.Blob})}catch(t){throw Qr.from(t,Qr.ERR_BAD_REQUEST,e)}return"text"===f?(r=r.toString(g),g&&"utf8"!==g||(r=Jr.stripBOM(r))):"stream"===f&&(r=l.Readable.from(r)),wn(t,s,{data:r,status:200,statusText:"OK",headers:new In,config:e})}if(-1===ko.indexOf(v))return s(new Qr("Unsupported protocol "+v,Qr.ERR_BAD_REQUEST,e));const I=In.from(e.headers).normalize();I.set("User-Agent","axios/"+uo,!1);const{onUploadProgress:O,onDownloadProgress:N}=e,M=e.maxRate;let w,U;if(Jr.isSpecCompliantForm(n)){const e=I.getContentType(/boundary=([-_\w\d]{10,70})/i);n=((e,t,s)=>{const{tag:r="form-data-boundary",size:n=25,boundary:o=r+"-"+An.generateString(n,Eo)}=s||{};if(!Jr.isFormData(e))throw TypeError("FormData instance required");if(o.length<1||o.length>70)throw Error("boundary must be 10-70 characters long");const i=To.encode("--"+o+Ao),a=To.encode("--"+o+"--"+Ao);let c=a.byteLength;const u=Array.from(e.entries()).map(([e,t])=>{const s=new Lo(e,t);return c+=s.size,s});c+=i.byteLength*u.length,c=Jr.toFiniteNumber(c);const h={"Content-Type":`multipart/form-data; boundary=${o}`};return Number.isFinite(c)&&(h["Content-Length"]=c),t&&t(h),l.Readable.from(async function*(){for(const e of u)yield i,yield*e.encode();yield a}())})(n,e=>{I.set(e)},{tag:`axios-${uo}-boundary`,boundary:e&&e[1]||void 0})}else if(Jr.isFormData(n)&&Jr.isFunction(n.getHeaders)){if(I.set(n.getHeaders()),!I.hasContentLength())try{const e=await c.promisify(n.getLength).call(n);Number.isFinite(e)&&e>=0&&I.setContentLength(e)}catch(e){}}else if(Jr.isBlob(n)||Jr.isFile(n))n.size&&I.setContentType(n.type||"application/octet-stream"),I.setContentLength(n.size||0),n=l.Readable.from(mo(n));else if(n&&!Jr.isStream(n)){if(Buffer.isBuffer(n));else if(Jr.isArrayBuffer(n))n=Buffer.from(new Uint8Array(n));else{if(!Jr.isString(n))return s(new Qr("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Qr.ERR_BAD_REQUEST,e));n=Buffer.from(n,"utf-8")}if(I.setContentLength(n.length,!1),e.maxBodyLength>-1&&n.length>e.maxBodyLength)return s(new Qr("Request body larger than maxBodyLength limit",Qr.ERR_BAD_REQUEST,e))}const k=Jr.toFiniteNumber(I.getContentLength());let P,B;Jr.isArray(M)?(w=M[0],U=M[1]):w=U=M,n&&(O||w)&&(Jr.isStream(n)||(n=l.Readable.from(n,{objectMode:!1})),n=l.pipeline([n,new fo({maxRate:Jr.toFiniteNumber(w)})],Jr.noop),O&&n.on("progress",Po(n,Co(k,bo(vo(O),!1,3))))),e.auth&&(P=(e.auth.username||"")+":"+(e.auth.password||"")),!P&&C.username&&(P=C.username+":"+C.password),P&&I.delete("authorization");try{B=an(C.pathname+C.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(t){const r=new Error(t.message);return r.config=e,r.url=e.url,r.exists=!0,s(r)}I.set("Accept-Encoding","gzip, compress, deflate"+(No?", br":""),!1);const j={path:B,method:m,headers:I.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:P,protocol:v,family:u,beforeRedirect:jo,beforeRedirects:{},http2Options:p};let D;!Jr.isUndefined(a)&&(j.lookup=a),e.socketPath?j.socketPath=e.socketPath:(j.hostname=C.hostname.startsWith("[")?C.hostname.slice(1,-1):C.hostname,j.port=C.port,Do(j,e.proxy,v+"//"+C.hostname+(C.port?":"+C.port:"")+j.path));const x=Uo.test(j.protocol);if(j.agent=x?e.httpsAgent:e.httpAgent,R?D=qo:e.transport?D=e.transport:0===e.maxRedirects?D=x?i:o:(e.maxRedirects&&(j.maxRedirects=e.maxRedirects),e.beforeRedirect&&(j.beforeRedirects.config=e.beforeRedirect),D=x?wo:Mo),e.maxBodyLength>-1?j.maxBodyLength=e.maxBodyLength:j.maxBodyLength=1/0,e.insecureHTTPParser&&(j.insecureHTTPParser=e.insecureHTTPParser),T=D.request(j,function(r){if(T.destroyed)return;const n=[r],o=Jr.toFiniteNumber(r.headers["content-length"]);if(N||U){const e=new fo({maxRate:Jr.toFiniteNumber(U)});N&&e.on("progress",Po(e,Co(o,bo(vo(N),!0,3)))),n.push(e)}let i=r;const a=r.req||T;if(!1!==e.decompress&&r.headers["content-encoding"])switch("HEAD"!==m&&204!==r.statusCode||delete r.headers["content-encoding"],(r.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":n.push(d.createUnzip(Io)),delete r.headers["content-encoding"];break;case"deflate":n.push(new So),n.push(d.createUnzip(Io)),delete r.headers["content-encoding"];break;case"br":No&&(n.push(d.createBrotliDecompress(Oo)),delete r.headers["content-encoding"])}i=n.length>1?l.pipeline(n,Jr.noop):n[0];const c={status:r.statusCode,statusText:r.statusMessage,headers:new In(r.headers),config:e,request:a};if("stream"===f)c.data=i,wn(t,s,c);else{const r=[];let n=0;i.on("data",function(t){r.push(t),n+=t.length,e.maxContentLength>-1&&n>e.maxContentLength&&(A=!0,i.destroy(),S(new Qr("maxContentLength size of "+e.maxContentLength+" exceeded",Qr.ERR_BAD_RESPONSE,e,a)))}),i.on("aborted",function(){if(A)return;const t=new Qr("stream has been aborted",Qr.ERR_BAD_RESPONSE,e,a);i.destroy(t),s(t)}),i.on("error",function(t){T.destroyed||s(Qr.from(t,null,e,a))}),i.on("end",function(){try{let e=1===r.length?r[0]:Buffer.concat(r);"arraybuffer"!==f&&(e=e.toString(g),g&&"utf8"!==g||(e=Jr.stripBOM(e))),c.data=e}catch(t){return s(Qr.from(t,null,e,c.request,c))}wn(t,s,c)})}L.once("abort",e=>{i.destroyed||(i.emit("error",e),i.destroy())})}),L.once("abort",e=>{T.close?T.close():T.destroy(e)}),T.on("error",function(t){s(Qr.from(t,null,e,T))}),T.on("socket",function(e){e.setKeepAlive(!0,6e4)}),e.timeout){const t=parseInt(e.timeout,10);if(Number.isNaN(t))return void S(new Qr("error trying to parse `config.timeout` to int",Qr.ERR_BAD_OPTION_VALUE,e,T));T.setTimeout(t,function(){if(E)return;let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const s=e.transitional||ln;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),S(new Qr(t,s.clarifyTimeoutError?Qr.ETIMEDOUT:Qr.ECONNABORTED,e,T))})}else T.setTimeout(0);if(Jr.isStream(n)){let t=!1,s=!1;n.on("end",()=>{t=!0}),n.once("error",e=>{s=!0,T.destroy(e)}),n.on("close",()=>{t||s||S(new Mn("Request stream has been aborted",e,T))}),n.pipe(T)}else n&&T.write(n),T.end()},new Promise((e,s)=>{let r,n;const o=(e,t)=>{n||(n=!0,r&&r(e,t))},i=e=>{o(e,!0),s(e)};t(t=>{o(t),e(t)},i,e=>r=e).catch(i)});var t},Ho=An.hasStandardBrowserEnv?((e,t)=>s=>(s=new URL(s,An.origin),e.protocol===s.protocol&&e.host===s.host&&(t||e.port===s.port)))(new URL(An.origin),An.navigator&&/(msie|trident)/i.test(An.navigator.userAgent)):()=>!0,zo=An.hasStandardBrowserEnv?{write(e,t,s,r,n,o,i){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Jr.isNumber(s)&&a.push(`expires=${new Date(s).toUTCString()}`),Jr.isString(r)&&a.push(`path=${r}`),Jr.isString(n)&&a.push(`domain=${n}`),!0===o&&a.push("secure"),Jr.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(e){if("undefined"==typeof document)return null;const t=document.cookie.match(new RegExp("(?:^|; )"+e+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,"",Date.now()-864e5,"/")}}:{write(){},read:()=>null,remove(){}},Wo=e=>e instanceof In?{...e}:e;function $o(e,t){t=t||{};const s={};function r(e,t,s,r){return Jr.isPlainObject(e)&&Jr.isPlainObject(t)?Jr.merge.call({caseless:r},e,t):Jr.isPlainObject(t)?Jr.merge({},t):Jr.isArray(t)?t.slice():t}function n(e,t,s,n){return Jr.isUndefined(t)?Jr.isUndefined(e)?void 0:r(void 0,e,0,n):r(e,t,0,n)}function o(e,t){if(!Jr.isUndefined(t))return r(void 0,t)}function i(e,t){return Jr.isUndefined(t)?Jr.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function a(s,n,o){return o in t?r(s,n):o in e?r(void 0,s):void 0}const c={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(e,t,s)=>n(Wo(e),Wo(t),0,!0)};return Jr.forEach(Object.keys({...e,...t}),function(r){if("__proto__"===r||"constructor"===r||"prototype"===r)return;const o=Jr.hasOwnProp(c,r)?c[r]:n,i=o(e[r],t[r],r);Jr.isUndefined(i)&&o!==a||(s[r]=i)}),s}const Vo=e=>{const t=$o({},e);let{data:s,withXSRFToken:r,xsrfHeaderName:n,xsrfCookieName:o,headers:i,auth:a}=t;if(t.headers=i=In.from(i),t.url=an(Un(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Jr.isFormData(s))if(An.hasStandardBrowserEnv||An.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Jr.isFunction(s.getHeaders)){const e=s.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,s])=>{t.includes(e.toLowerCase())&&i.set(e,s)})}if(An.hasStandardBrowserEnv&&(r&&Jr.isFunction(r)&&(r=r(t)),r||!1!==r&&Ho(t.url))){const e=n&&o&&zo.read(o);e&&i.set(n,e)}return t},Ko="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,s){const r=Vo(e);let n=r.data;const o=In.from(r.headers).normalize();let i,a,c,l,u,{responseType:h,onUploadProgress:p,onDownloadProgress:d}=r;function _(){l&&l(),u&&u(),r.cancelToken&&r.cancelToken.unsubscribe(i),r.signal&&r.signal.removeEventListener("abort",i)}let f=new XMLHttpRequest;function g(){if(!f)return;const r=In.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());wn(function(e){t(e),_()},function(e){s(e),_()},{data:h&&"text"!==h&&"json"!==h?f.response:f.responseText,status:f.status,statusText:f.statusText,headers:r,config:e,request:f}),f=null}f.open(r.method.toUpperCase(),r.url,!0),f.timeout=r.timeout,"onloadend"in f?f.onloadend=g:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(g)},f.onabort=function(){f&&(s(new Qr("Request aborted",Qr.ECONNABORTED,e,f)),f=null)},f.onerror=function(t){const r=t&&t.message?t.message:"Network Error",n=new Qr(r,Qr.ERR_NETWORK,e,f);n.event=t||null,s(n),f=null},f.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const n=r.transitional||ln;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),s(new Qr(t,n.clarifyTimeoutError?Qr.ETIMEDOUT:Qr.ECONNABORTED,e,f)),f=null},void 0===n&&o.setContentType(null),"setRequestHeader"in f&&Jr.forEach(o.toJSON(),function(e,t){f.setRequestHeader(t,e)}),Jr.isUndefined(r.withCredentials)||(f.withCredentials=!!r.withCredentials),h&&"json"!==h&&(f.responseType=r.responseType),d&&([c,u]=bo(d,!0),f.addEventListener("progress",c)),p&&f.upload&&([a,l]=bo(p),f.upload.addEventListener("progress",a),f.upload.addEventListener("loadend",l)),(r.cancelToken||r.signal)&&(i=t=>{f&&(s(!t||t.type?new Mn(null,e,f):t),f.abort(),f=null)},r.cancelToken&&r.cancelToken.subscribe(i),r.signal&&(r.signal.aborted?i():r.signal.addEventListener("abort",i)));const m=ho(r.url);m&&-1===An.protocols.indexOf(m)?s(new Qr("Unsupported protocol "+m+":",Qr.ERR_BAD_REQUEST,e)):f.send(n||null)})},Jo=(e,t)=>{const{length:s}=e=e?e.filter(Boolean):[];if(t||s){let s,r=new AbortController;const n=function(e){if(!s){s=!0,i();const t=e instanceof Error?e:this.reason;r.abort(t instanceof Qr?t:new Mn(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,n(new Qr(`timeout of ${t}ms exceeded`,Qr.ETIMEDOUT))},t);const i=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(n):e.removeEventListener("abort",n)}),e=null)};e.forEach(e=>e.addEventListener("abort",n));const{signal:a}=r;return a.unsubscribe=()=>Jr.asap(i),a}},Qo=function*(e,t){let s=e.byteLength;if(s<t)return void(yield e);let r,n=0;for(;n<s;)r=n+t,yield e.slice(n,r),n=r},Yo=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:s}=await t.read();if(e)break;yield s}}finally{await t.cancel()}},Zo=(e,t,s,r)=>{const n=async function*(e,t){for await(const s of Yo(e))yield*Qo(s,t)}(e,t);let o,i=0,a=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await n.next();if(t)return a(),void e.close();let o=r.byteLength;if(s){let e=i+=o;s(e)}e.enqueue(new Uint8Array(r))}catch(e){throw a(e),e}},cancel:e=>(a(e),n.return())},{highWaterMark:2})},{isFunction:Xo}=Jr,ei=(({Request:e,Response:t})=>({Request:e,Response:t}))(Jr.global),{ReadableStream:ti,TextEncoder:si}=Jr.global,ri=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},ni=e=>{e=Jr.merge.call({skipUndefined:!0},ei,e);const{fetch:t,Request:s,Response:r}=e,n=t?Xo(t):"function"==typeof fetch,o=Xo(s),i=Xo(r);if(!n)return!1;const a=n&&Xo(ti),c=n&&("function"==typeof si?(l=new si,e=>l.encode(e)):async e=>new Uint8Array(await new s(e).arrayBuffer()));var l;const u=o&&a&&ri(()=>{let e=!1;const t=new s(An.origin,{body:new ti,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),h=i&&a&&ri(()=>Jr.isReadableStream(new r("").body)),p={stream:h&&(e=>e.body)};n&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!p[e]&&(p[e]=(t,s)=>{let r=t&&t[e];if(r)return r.call(t);throw new Qr(`Response type '${e}' is not supported`,Qr.ERR_NOT_SUPPORT,s)})});const d=async(e,t)=>{const r=Jr.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Jr.isBlob(e))return e.size;if(Jr.isSpecCompliantForm(e)){const t=new s(An.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Jr.isArrayBufferView(e)||Jr.isArrayBuffer(e)?e.byteLength:(Jr.isURLSearchParams(e)&&(e+=""),Jr.isString(e)?(await c(e)).byteLength:void 0)})(t):r};return async e=>{let{url:n,method:i,data:a,signal:c,cancelToken:l,timeout:_,onDownloadProgress:f,onUploadProgress:g,responseType:m,headers:E,withCredentials:T="same-origin",fetchOptions:A}=Vo(e),R=t||fetch;m=m?(m+"").toLowerCase():"text";let L=Jo([c,l&&l.toAbortSignal()],_),S=null;const y=L&&L.unsubscribe&&(()=>{L.unsubscribe()});let b;try{if(g&&u&&"get"!==i&&"head"!==i&&0!==(b=await d(E,a))){let e,t=new s(n,{method:"POST",body:a,duplex:"half"});if(Jr.isFormData(a)&&(e=t.headers.get("content-type"))&&E.setContentType(e),t.body){const[e,s]=Co(b,bo(vo(g)));a=Zo(t.body,65536,e,s)}}Jr.isString(T)||(T=T?"include":"omit");const t=o&&"credentials"in s.prototype,c={...A,signal:L,method:i.toUpperCase(),headers:E.normalize().toJSON(),body:a,duplex:"half",credentials:t?T:void 0};S=o&&new s(n,c);let l=await(o?R(S,A):R(n,c));const _=h&&("stream"===m||"response"===m);if(h&&(f||_&&y)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=l[t]});const t=Jr.toFiniteNumber(l.headers.get("content-length")),[s,n]=f&&Co(t,bo(vo(f),!0))||[];l=new r(Zo(l.body,65536,s,()=>{n&&n(),y&&y()}),e)}m=m||"text";let C=await p[Jr.findKey(p,m)||"text"](l,e);return!_&&y&&y(),await new Promise((t,s)=>{wn(t,s,{data:C,headers:In.from(l.headers),status:l.status,statusText:l.statusText,config:e,request:S})})}catch(t){if(y&&y(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Qr("Network Error",Qr.ERR_NETWORK,e,S,t&&t.response),{cause:t.cause||t});throw Qr.from(t,t&&t.code,e,S,t&&t.response)}}},oi=new Map,ii=e=>{let t=e&&e.env||{};const{fetch:s,Request:r,Response:n}=t,o=[r,n,s];let i,a,c=o.length,l=oi;for(;c--;)i=o[c],a=l.get(i),void 0===a&&l.set(i,a=c?new Map:ni(t)),l=a;return a};ii();const ai={http:Go,xhr:Ko,fetch:{get:ii}};Jr.forEach(ai,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const ci=e=>`- ${e}`,li=e=>Jr.isFunction(e)||null===e||!1===e;const ui={getAdapter:function(e,t){e=Jr.isArray(e)?e:[e];const{length:s}=e;let r,n;const o={};for(let i=0;i<s;i++){let s;if(r=e[i],n=r,!li(r)&&(n=ai[(s=String(r)).toLowerCase()],void 0===n))throw new Qr(`Unknown adapter '${s}'`);if(n&&(Jr.isFunction(n)||(n=n.get(t))))break;o[s||"#"+i]=n}if(!n){const e=Object.entries(o).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));let t=s?e.length>1?"since :\n"+e.map(ci).join("\n"):" "+ci(e[0]):"as no adapter specified";throw new Qr("There is no suitable adapter to dispatch the request "+t,"ERR_NOT_SUPPORT")}return n},adapters:ai};function hi(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Mn(null,e)}function pi(e){hi(e),e.headers=In.from(e.headers),e.data=On.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ui.getAdapter(e.adapter||Ln.adapter,e)(e).then(function(t){return hi(e),t.data=On.call(e,e.transformResponse,t),t.headers=In.from(t.headers),t},function(t){return Nn(t)||(hi(e),t&&t.response&&(t.response.data=On.call(e,e.transformResponse,t.response),t.response.headers=In.from(t.response.headers))),Promise.reject(t)})}const di={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{di[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const _i={};di.transitional=function(e,t,s){function r(e,t){return"[Axios v"+uo+"] Transitional option '"+e+"'"+t+(s?". "+s:"")}return(s,n,o)=>{if(!1===e)throw new Qr(r(n," has been removed"+(t?" in "+t:"")),Qr.ERR_DEPRECATED);return t&&!_i[n]&&(_i[n]=!0,console.warn(r(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(s,n,o)}},di.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};const fi={assertOptions:function(e,t,s){if("object"!=typeof e)throw new Qr("options must be an object",Qr.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let n=r.length;for(;n-- >0;){const o=r[n],i=t[o];if(i){const t=e[o],s=void 0===t||i(t,o,e);if(!0!==s)throw new Qr("option "+o+" must be "+s,Qr.ERR_BAD_OPTION_VALUE);continue}if(!0!==s)throw new Qr("Unknown option "+o,Qr.ERR_BAD_OPTION)}},validators:di},gi=fi.validators;let mi=class{constructor(e){this.defaults=e||{},this.interceptors={request:new cn,response:new cn}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const s=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?s&&!String(e.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+s):e.stack=s}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=$o(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:n}=t;void 0!==s&&fi.assertOptions(s,{silentJSONParsing:gi.transitional(gi.boolean),forcedJSONParsing:gi.transitional(gi.boolean),clarifyTimeoutError:gi.transitional(gi.boolean),legacyInterceptorReqResOrdering:gi.transitional(gi.boolean)},!1),null!=r&&(Jr.isFunction(r)?t.paramsSerializer={serialize:r}:fi.assertOptions(r,{encode:gi.function,serialize:gi.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),fi.assertOptions(t,{baseUrl:gi.spelling("baseURL"),withXsrfToken:gi.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=n&&Jr.merge(n.common,n[t.method]);n&&Jr.forEach(["delete","get","head","post","put","patch","common"],e=>{delete n[e]}),t.headers=In.concat(o,n);const i=[];let a=!0;this.interceptors.request.forEach(function(e){if("function"==typeof e.runWhen&&!1===e.runWhen(t))return;a=a&&e.synchronous;const s=t.transitional||ln;s&&s.legacyInterceptorReqResOrdering?i.unshift(e.fulfilled,e.rejected):i.push(e.fulfilled,e.rejected)});const c=[];let l;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let u,h=0;if(!a){const e=[pi.bind(this),void 0];for(e.unshift(...i),e.push(...c),u=e.length,l=Promise.resolve(t);h<u;)l=l.then(e[h++],e[h++]);return l}u=i.length;let p=t;for(;h<u;){const e=i[h++],t=i[h++];try{p=e(p)}catch(e){t.call(this,e);break}}try{l=pi.call(this,p)}catch(e){return Promise.reject(e)}for(h=0,u=c.length;h<u;)l=l.then(c[h++],c[h++]);return l}getUri(e){return an(Un((e=$o(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Jr.forEach(["delete","get","head","options"],function(e){mi.prototype[e]=function(t,s){return this.request($o(s||{},{method:e,url:t,data:(s||{}).data}))}}),Jr.forEach(["post","put","patch"],function(e){function t(t){return function(s,r,n){return this.request($o(n||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:s,data:r}))}}mi.prototype[e]=t(),mi.prototype[e+"Form"]=t(!0)});const Ei={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ei).forEach(([e,t])=>{Ei[t]=e});const Ti=function e(t){const s=new mi(t),r=rr(mi.prototype.request,s);return Jr.extend(r,mi.prototype,s,{allOwnKeys:!0}),Jr.extend(r,s,null,{allOwnKeys:!0}),r.create=function(s){return e($o(t,s))},r}(Ln);Ti.Axios=mi,Ti.CanceledError=Mn,Ti.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const s=this;this.promise.then(e=>{if(!s._listeners)return;let t=s._listeners.length;for(;t-- >0;)s._listeners[t](e);s._listeners=null}),this.promise.then=e=>{let t;const r=new Promise(e=>{s.subscribe(e),t=e}).then(e);return r.cancel=function(){s.unsubscribe(t)},r},e(function(e,r,n){s.reason||(s.reason=new Mn(e,r,n),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},Ti.isCancel=Nn,Ti.VERSION=uo,Ti.toFormData=tn,Ti.AxiosError=Qr,Ti.Cancel=Ti.CanceledError,Ti.all=function(e){return Promise.all(e)},Ti.spread=function(e){return function(t){return e.apply(null,t)}},Ti.isAxiosError=function(e){return Jr.isObject(e)&&!0===e.isAxiosError},Ti.mergeConfig=$o,Ti.AxiosHeaders=In,Ti.formToJSON=e=>Rn(Jr.isHTMLForm(e)?new FormData(e):e),Ti.getAdapter=ui.getAdapter,Ti.HttpStatusCode=Ei,Ti.default=Ti;const{Axios:Ai,AxiosError:Ri,CanceledError:Li,isCancel:Si,CancelToken:yi,VERSION:bi,all:Ci,Cancel:vi,isAxiosError:Ii,spread:Oi,toFormData:Ni,AxiosHeaders:Mi,HttpStatusCode:wi,formToJSON:Ui,getAdapter:ki,mergeConfig:Pi}=Ti;function Bi(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}function ji(){return function(e={}){const{isSuccess:t=e=>0===e,getCode:s=e=>Bi([e,"access",e=>e.data,"optionalAccess",e=>e.code]),getMessage:r=e=>Bi([e,"access",e=>e.data,"optionalAccess",e=>e.message])||Bi([e,"access",e=>e.data,"optionalAccess",e=>e.msg]),getData:n=e=>Bi([e,"access",e=>e.data,"optionalAccess",e=>e.data]),throwOnError:o=!0,onError:i}=e;return{name:"response-validator",onResponse:e=>{const a=s(e);if(void 0===a)return e;if(t(a))return n(e);const c=r(e)||"Request failed";if(i&&!1===i(a,c,e))return e;if(o)throw new sr(c,{status:e.status,code:a,config:e.config,response:e,data:e.data});return e}}}({isSuccess:e=>0===e,getCode:e=>Bi([e,"access",e=>e.data,"optionalAccess",e=>e.code]),getMessage:e=>Bi([e,"access",e=>e.data,"optionalAccess",e=>e.message])||Bi([e,"access",e=>e.data,"optionalAccess",e=>e.msg]),getData:e=>e.data})}function Di(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}const xi={"/api/marketplace/trade/benefit/user/extra/create":{fields:["extra_benefit.item_info.start_at","extra_benefit.item_info.end_at"]},"/api/memory/volcano_database/list_instance":{fields:["page_num","page_size"]},"/api/memory/volcano_database/list_database":{fields:["page_num","page_size"]},"/api/memory/volcano_database/list_table":{fields:["page_num","page_size"]}};function Fi(e){const{config:t}=e;return{name:"i64-transform",onRequest:e=>{const s=function(e,t){return s=t[e],r=()=>null,null!=s?s:r();var s,r}(e.url||"",t);return s?(e.data&&(e.data=function(e,t){if(null==e)return e;const s=Es(e);for(const e of t){const t=Tt(s,e);if("string"==typeof t){const r=Number(t);Number.isInteger(r)&&Ys(s,e,r)}else Array.isArray(t)&&Ys(s,e,t.map(e=>{if("string"==typeof e){const t=Number(e);if(Number.isInteger(t))return t}return e}))}return s}(e.data,s.fields)),e):e}}}function qi(e={}){const t=Ti.create({baseURL:e.baseURL,timeout:e.timeout,headers:e.headers,...e.axiosConfig}),s=[];return!1!==e.useDefaultPlugins&&s.push(function(e={}){const{xRequestedWith:t="XMLHttpRequest",autoContentTypeMethods:s=["post","get"],contentType:r="application/json",setEmptyDataForContentType:n=!0}=e;return{name:"request-headers",onRequest:e=>{const o=(t,s)=>{"function"==typeof Di([e,"access",e=>e.headers,"optionalAccess",e=>e.set])?e.headers.set(t,s):e.headers&&(e.headers[t]=s)};!1!==t&&o("x-requested-with",t);const i=Di([e,"access",e=>e.method,"optionalAccess",e=>e.toLowerCase,"call",e=>e()])||"get";var a;return s.includes(i)&&(a="content-type",!("function"==typeof Di([e,"access",e=>e.headers,"optionalAccess",e=>e.get])?e.headers.get(a):Di([e,"access",e=>e.headers,"optionalAccess",e=>e[a]])))&&(o("content-type",r),n&&!e.data&&(e.data={})),e}}}(),Fi({config:xi}),ji(),function(e={}){const t=new Set(e.interceptors||[]);return{plugin:{name:"interceptor-chain",onResponse:e=>{let s=e;for(const e of t)s=e(s);return s}},add:e=>(t.add(e),()=>{t.delete(e)}),remove:e=>{t.delete(e)},clear:()=>{t.clear()},size:()=>t.size}}().plugin),e.plugins&&e.plugins.length>0&&s.push(...e.plugins),s.forEach(e=>{e.onRequest&&t.interceptors.request.use(e.onRequest,e.onError),(e.onResponse||e.onError)&&t.interceptors.response.use(e.onResponse,e.onError)}),t}const Gi=qi({baseURL:"/",headers:{"Agw-Js-Conv":"str"}}),Hi=Gi,zi=(e,t)=>Hi({...e,...t});var Wi,$i,Vi,Ki,Ji,Qi,Yi,Zi,Xi,ea,ta,sa,ra,na,oa,ia,aa;function ca(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}!function(e){e[e.OpenClawChannelTypeLark=1]="OpenClawChannelTypeLark";e[e.OpenClawChannelTypeWeixin=2]="OpenClawChannelTypeWeixin"}(Wi||(Wi={})),function(e){e[e.OpenClawLarkAuthStatusAuthorized=1]="OpenClawLarkAuthStatusAuthorized";e[e.OpenClawLarkAuthStatusUnauthorized=2]="OpenClawLarkAuthStatusUnauthorized"}($i||($i={})),function(e){e[e.OpenClawLarkConfigStatusNotCreated=1]="OpenClawLarkConfigStatusNotCreated";e[e.OpenClawLarkConfigStatusCreated=2]="OpenClawLarkConfigStatusCreated";e[e.OpenClawLarkConfigStatusConfigured=3]="OpenClawLarkConfigStatusConfigured"}(Vi||(Vi={})),function(e){e[e.OpenClawUpdateStatusNoUpdate=1]="OpenClawUpdateStatusNoUpdate";e[e.OpenClawUpdateStatusPending=2]="OpenClawUpdateStatusPending";e[e.OpenClawUpdateStatusUpdating=3]="OpenClawUpdateStatusUpdating"}(Ki||(Ki={})),function(e){e[e.OpenClawVersionTypeFull=1]="OpenClawVersionTypeFull";e[e.OpenClawVersionTypeLite=2]="OpenClawVersionTypeLite"}(Ji||(Ji={})),function(e){e[e.RequirementsNotMet=1]="RequirementsNotMet";e[e.FunctionDefect=2]="FunctionDefect";e[e.PoorDesign=3]="PoorDesign";e[e.InteractionIssue=4]="InteractionIssue";e[e.LongTimeWait=5]="LongTimeWait";e[e.RequirementsMisunderstood=6]="RequirementsMisunderstood";e[e.BadPlanning=7]="BadPlanning";e[e.ExecutionFailed=8]="ExecutionFailed";e[e.UnstableExecution=9]="UnstableExecution"}(Qi||(Qi={})),function(e){e[e.Unknown=0]="Unknown";e[e.Like=1]="Like";e[e.Dislike=2]="Dislike"}(Yi||(Yi={})),function(e){e[e.Wait=0]="Wait";e[e.Done=1]="Done"}(Zi||(Zi={})),function(e){e[e.RoleTypeUnknown=0]="RoleTypeUnknown";e[e.RoleTypeUser=1]="RoleTypeUser";e[e.RoleTypeAssistant=2]="RoleTypeAssistant"}(Xi||(Xi={})),function(e){e[e.AddAttributes=1]="AddAttributes";e[e.RemoveAttributes=2]="RemoveAttributes"}(ea||(ea={})),function(e){e[e.CloseConnection=1]="CloseConnection"}(ta||(ta={})),function(e){e[e.ON_LINE=0]="ON_LINE";e[e.OFF_LINE=1]="OFF_LINE";e[e.TOUCH=2]="TOUCH"}(sa||(sa={})),function(e){e[e.AddGroups=1]="AddGroups";e[e.RemoveGroups=2]="RemoveGroups";e[e.ReplaceWithGroups=3]="ReplaceWithGroups"}(ra||(ra={})),function(e){e[e.App=0]="App";e[e.Service=1]="Service";e[e.Method=2]="Method"}(na||(na={})),function(e){e[e.ApiKey=1]="ApiKey";e[e.WechatOfficialAccount=2]="WechatOfficialAccount";e[e.OAuth=3]="OAuth"}(oa||(oa={})),function(e){e[e.PROJECT_COPY=1]="PROJECT_COPY";e[e.SKILL_STORE=2]="SKILL_STORE"}(ia||(ia={})),function(e){e[e.PENDING=1]="PENDING";e[e.SUCCESS=2]="SUCCESS";e[e.FAILED=3]="FAILED"}(aa||(aa={}));class la{__init(){this.request=zi}__init2(){this.baseURL=""}constructor(e){la.prototype.__init.call(this),la.prototype.__init2.call(this),this.request=ca([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=ca([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}GetHistory(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/history`),n={before:s.before,limit:s.limit,after:s.after};return this.request({url:r,method:"GET",params:n},t)}ReplyFeedback(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/feedback`),n={reply_id:s.reply_id,type:s.type,session_id:s.session_id,feedback_detail:s.feedback_detail};return this.request({url:r,method:"POST",data:n},t)}TestChat(e,t){const s=e,r=this.genBaseURL("/v1/api/project/:project_id/chat/mock"),n={msg:s.msg};return this.request({url:r,method:"POST",data:n},t)}GetCanvasInfo(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/agent/canvas`),n={space_id:s.space_id,commit_id:s.commit_id};return this.request({url:r,method:"POST",data:n},t)}ExplainNode(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/agent/explain_node`),n={node_ids:s.node_ids,schema:s.schema};return this.request({url:r,method:"POST",data:n},t)}GetInOutSchema(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/agent/inout_schema`),n={space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}GetSkillMeta(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/skill/meta`);return this.request({url:r,method:"POST"},t)}ListSpans(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/list_spans`),n={workspace_id:s.workspace_id,start_time:s.start_time,end_time:s.end_time,filters:s.filters,page_size:s.page_size,order_bys:s.order_bys,page_token:s.page_token,platform_type:s.platform_type,span_list_type:s.span_list_type};return this.request({url:r,method:"POST",data:n},t)}GetModelList(e,t){const s=e||{},r=this.genBaseURL("/v1/api/project/model_list"),n={project_id:s.project_id,project_type:s.project_type,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}GetCommercialInfo(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/commercial_info`),n={reply_id_list:s.reply_id_list};return this.request({url:r,method:"POST",data:n},t)}PackSkill(e,t){const s=e,r=this.genBaseURL("/v1/api/project/:project_id/skill/pack"),n={project_id:s.project_id};return this.request({url:r,method:"POST",data:n},t)}GetSkillOAuthUrl(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/skill/oauth_url`),n={checkpoint_id:s.checkpoint_id,credential_name:s.credential_name,platform_oauth_info:s.platform_oauth_info,custom_oauth_info:s.custom_oauth_info,credential_tips:s.credential_tips};return this.request({url:r,method:"POST",data:n},t)}GetTools(e,t){const s=this.genBaseURL("/v1/api/project/tools");return this.request({url:s,method:"GET"},t)}CanvasSubmit(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/agent/canvas_submit`),n={after_canvas:s.after_canvas};return this.request({url:r,method:"POST",data:n},t)}UpdateOpenClawSettings(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/update_setting`),n={selected_model_id:s.selected_model_id,version:s.version,channels:s.channels};return this.request({url:r,method:"POST",data:n},t)}CreateOpenClawLarkApp(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/create_lark_app`),n={app_name:s.app_name,recreate:s.recreate};return this.request({url:r,method:"POST",data:n},t)}GetOpenClawSettings(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/settings`);return this.request({url:r,method:"GET"},t)}CancelChatCLIMessage(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/message/cancel`);return this.request({url:r,method:"POST"},t)}GetChatCLIMessageStatus(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/message/status`);return this.request({url:r,method:"GET"},t)}ChatCLISendMessage(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/message/send`),n={message:s.message,device_id:s.device_id};return this.request({url:r,method:"POST",data:n},t)}GetChatCLIMessageResultContent(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/chat/message/result`);return this.request({url:r,method:"GET"},t)}CreateOpenClawWeixinQRCode(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/create_weixin_qrcode`);return this.request({url:r,method:"POST"},t)}GetOpenClawUpdateStatus(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/update_status`);return this.request({url:r,method:"GET"},t)}TriggerOpenClawUpdate(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/trigger_update`);return this.request({url:r,method:"POST"},t)}}const ua=new la({});class ha{constructor({options:e,reportLog:t}){this.mergedBaseOptions=er({scenes:{[T.GetMessage]:async(...e)=>await ua.GetHistory(...e)}},e),this.reportLog=t,this.reportLogWithScope=this.reportLog.createLoggerWith({scope:"RequestManager"}),this.reportLogWithScope.info({message:"RequestManager is initialized",meta:{...this.mergedBaseOptions}})}appendRequestOptions(e){this.mergedBaseOptions=er(this.mergedBaseOptions,e)}getSceneConfig(e){const{scenes:t}=this.mergedBaseOptions;return t[e]}}class pa{constructor(){pa.prototype.__init.call(this)}__init(){this.preSendLocalMessageEvents=t()}on(e,t){this.preSendLocalMessageEvents.on(e,t)}off(e,t){this.preSendLocalMessageEvents.off(e,t)}once(e,t){const s=r=>{t(r),this.preSendLocalMessageEvents.off(e,s)};this.preSendLocalMessageEvents.on(e,s)}emit(e,t){this.preSendLocalMessageEvents.emit(e,t)}destroy(){this.preSendLocalMessageEvents.all.clear()}}class da{getSendChatMessageStructure(e,t){const s=Ks(e,function(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}([t,"optionalAccess",e=>e.extendFields]));return Qs(s,e=>null!=e&&""!==e)}}function _a(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}const fa=["console","file","text"],ga="generate_image";function ma(e,t){return null!=e?e:t()}function Ea(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}const Ta=(e,t)=>{const s=t.at(0);if(!s)return e;if("message_start"===s.type||"message_end"===s.type)return Es(s);const r=Es(e||s),n=e?t:t.slice(1);if(0===n.length)return r;const o=n.filter(e=>e.type===r.type);if("answer"===r.type){const e=o.map(e=>ma(e.content.answer,()=>""));r.content.answer=ma(r.content.answer,()=>"")+e.join("")}else if("thinking"===r.type){const e=o.map(e=>ma(e.content.thinking,()=>""));r.content.thinking=ma(r.content.thinking,()=>"")+e.join("")}else if("tool_request"===r.type&&r.content.tool_request){const e=o.map(e=>ma(Ea([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters]),()=>""));r.content.tool_request.stream_parameters=ma(r.content.tool_request.stream_parameters,()=>"")+e.join("")}else if("tool_process"===r.type){const e=o.map(e=>Ea([e,"access",e=>e.content,"access",e=>e.tool_process,"optionalAccess",e=>e.data,"access",e=>e.content])),t=function(e,t){const s={};let r=!1;const n=t.map(e=>_a([e,"optionalAccess",e=>e[ga],"optionalAccess",e=>e.images])||[]).flat();return(n.length>0||!Vs(_a([e,"optionalAccess",e=>e[ga]])))&&(s[ga]={images:(_a([e,"optionalAccess",e=>e[ga],"optionalAccess",e=>e.images])||[]).concat(n)},r=!0),fa.forEach(n=>{const o=t.filter(e=>!Vs(_a([e,"optionalAccess",e=>e[n]]))).map(e=>_a([e,"optionalAccess",e=>e[n]])||"");(o.length>0||!Vs(_a([e,"optionalAccess",e=>e[n]])))&&(s[n]=(_a([e,"optionalAccess",e=>e[n]])||"")+o.join(""),r=!0)}),r?s:e||{}}(Ea([r,"access",e=>e.content,"access",e=>e.tool_process,"optionalAccess",e=>e.data,"access",e=>e.content]),e);r.content.tool_process&&(r.content.tool_process.data.content=t)}const i=t.at(-1);return i&&(r.sequence_id=i.sequence_id,r.finish=i.finish),r};function Aa(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}class Ra{__init(){this.streamBufferSnapshot=null}constructor(e){Ra.prototype.__init.call(this),Ra.prototype.__init2.call(this),Ra.prototype.__init3.call(this),this.key=e.key}__init2(){this.getBufferMeta=e=>{return{query_msg_id:(t=Aa([e,"access",e=>e.at,"call",e=>e(0),"optionalAccess",e=>e.query_msg_id]),s=()=>"",null!=t?t:s()),timestamp:Date.now(),key:this.key};var t,s}}__init3(){this.recordStreamBuffer=e=>{const{streamMessageBuffer:t,streamChunkBuffer:s}=e;this.streamBufferSnapshot={streamMessageBuffer:[...t],streamChunkBuffer:[...s],...this.getBufferMeta(t)}}}getStreamBufferSnapshot(){return this.streamBufferSnapshot}clear(){this.streamBufferSnapshot=null}}class La{__init(){this.timeoutMs=3e4}__init2(){this.debugLogTimer=null}__init3(){this.debugTimeoutTimer=null}__init4(){this.currentQueryMsgId=""}__init5(){this.logInterval=3e3}get isDebugging(){return null!==this.debugLogTimer||null!==this.debugTimeoutTimer}constructor(e){La.prototype.__init.call(this),La.prototype.__init2.call(this),La.prototype.__init3.call(this),La.prototype.__init4.call(this),La.prototype.__init5.call(this),this.reportLogWithScope=e.reportLogWithScope,this.getEnableDebug=e.getEnableDebug,this.getLogPayload=e.getLogPayload,this.mark=e.mark}startDebugLog(e){this.getEnableDebug()&&this.currentQueryMsgId!==e&&(this.clearAllTimers(),this.currentQueryMsgId=e,this.debugLogTimer=setInterval(()=>{this.clearTimeoutTimer(),this.reportLogWithScope.info({message:`${this.mark} Debug - Pulling`,meta:{query_msg_id:this.currentQueryMsgId,payload:this.getLogPayload()}}),this.startTimeout(e)},this.logInterval))}stopDebugLog(){this.getEnableDebug()&&(this.debugLogTimer||this.debugTimeoutTimer)&&(this.clearAllTimers(),this.reportLogWithScope.info({message:`${this.mark} Debug - Final`,meta:{query_msg_id:this.currentQueryMsgId,payload:this.getLogPayload()}}))}destroy(){this.clearAllTimers(),this.currentQueryMsgId=""}clearAllTimers(){this.debugLogTimer&&(clearInterval(this.debugLogTimer),this.debugLogTimer=null),this.clearTimeoutTimer()}startTimeout(e){this.debugTimeoutTimer=setTimeout(()=>{this.reportLogWithScope.info({message:`${this.mark} Debug - Timeout兜底触发`,meta:{query_msg_id:e,payload:this.getLogPayload(),timeoutMs:this.timeoutMs}}),this.clearAllTimers(),this.currentQueryMsgId=""},this.timeoutMs)}clearTimeoutTimer(){this.debugTimeoutTimer&&(clearTimeout(this.debugTimeoutTimer),this.debugTimeoutTimer=null)}}var Sa;!function(e){e[e.BACKSPACE=8]="BACKSPACE",e[e.FORM_FEED=12]="FORM_FEED",e[e.NEWLINE=10]="NEWLINE",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.TAB=9]="TAB",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.NUMBER_SIGN=35]="NUMBER_SIGN",e[e.DOLLAR_SIGN=36]="DOLLAR_SIGN",e[e.PERCENT_SIGN=37]="PERCENT_SIGN",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.LEFT_PARENTHESIS=40]="LEFT_PARENTHESIS",e[e.RIGHT_PARENTHESIS=41]="RIGHT_PARENTHESIS",e[e.ASTERISK=42]="ASTERISK",e[e.PLUS_SIGN=43]="PLUS_SIGN",e[e.COMMA=44]="COMMA",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.FULL_STOP=46]="FULL_STOP",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_ZERO=48]="DIGIT_ZERO",e[e.DIGIT_ONE=49]="DIGIT_ONE",e[e.DIGIT_TWO=50]="DIGIT_TWO",e[e.DIGIT_THREE=51]="DIGIT_THREE",e[e.DIGIT_FOUR=52]="DIGIT_FOUR",e[e.DIGIT_FIVE=53]="DIGIT_FIVE",e[e.DIGIT_SIX=54]="DIGIT_SIX",e[e.DIGIT_SEVEN=55]="DIGIT_SEVEN",e[e.DIGIT_EIGHT=56]="DIGIT_EIGHT",e[e.DIGIT_NINE=57]="DIGIT_NINE",e[e.COLON=58]="COLON",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.COMMERCIAL_AT=64]="COMMERCIAL_AT",e[e.LATIN_CAPITAL_LETTER_A=65]="LATIN_CAPITAL_LETTER_A",e[e.LATIN_CAPITAL_LETTER_B=66]="LATIN_CAPITAL_LETTER_B",e[e.LATIN_CAPITAL_LETTER_C=67]="LATIN_CAPITAL_LETTER_C",e[e.LATIN_CAPITAL_LETTER_D=68]="LATIN_CAPITAL_LETTER_D",e[e.LATIN_CAPITAL_LETTER_E=69]="LATIN_CAPITAL_LETTER_E",e[e.LATIN_CAPITAL_LETTER_F=70]="LATIN_CAPITAL_LETTER_F",e[e.LATIN_CAPITAL_LETTER_G=71]="LATIN_CAPITAL_LETTER_G",e[e.LATIN_CAPITAL_LETTER_H=72]="LATIN_CAPITAL_LETTER_H",e[e.LATIN_CAPITAL_LETTER_I=73]="LATIN_CAPITAL_LETTER_I",e[e.LATIN_CAPITAL_LETTER_J=74]="LATIN_CAPITAL_LETTER_J",e[e.LATIN_CAPITAL_LETTER_K=75]="LATIN_CAPITAL_LETTER_K",e[e.LATIN_CAPITAL_LETTER_L=76]="LATIN_CAPITAL_LETTER_L",e[e.LATIN_CAPITAL_LETTER_M=77]="LATIN_CAPITAL_LETTER_M",e[e.LATIN_CAPITAL_LETTER_N=78]="LATIN_CAPITAL_LETTER_N",e[e.LATIN_CAPITAL_LETTER_O=79]="LATIN_CAPITAL_LETTER_O",e[e.LATIN_CAPITAL_LETTER_P=80]="LATIN_CAPITAL_LETTER_P",e[e.LATIN_CAPITAL_LETTER_Q=81]="LATIN_CAPITAL_LETTER_Q",e[e.LATIN_CAPITAL_LETTER_R=82]="LATIN_CAPITAL_LETTER_R",e[e.LATIN_CAPITAL_LETTER_S=83]="LATIN_CAPITAL_LETTER_S",e[e.LATIN_CAPITAL_LETTER_T=84]="LATIN_CAPITAL_LETTER_T",e[e.LATIN_CAPITAL_LETTER_U=85]="LATIN_CAPITAL_LETTER_U",e[e.LATIN_CAPITAL_LETTER_V=86]="LATIN_CAPITAL_LETTER_V",e[e.LATIN_CAPITAL_LETTER_W=87]="LATIN_CAPITAL_LETTER_W",e[e.LATIN_CAPITAL_LETTER_X=88]="LATIN_CAPITAL_LETTER_X",e[e.LATIN_CAPITAL_LETTER_Y=89]="LATIN_CAPITAL_LETTER_Y",e[e.LATIN_CAPITAL_LETTER_Z=90]="LATIN_CAPITAL_LETTER_Z",e[e.LEFT_SQUARE_BRACKET=91]="LEFT_SQUARE_BRACKET",e[e.REVERSE_SOLIDUS=92]="REVERSE_SOLIDUS",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.CIRCUMFLEX_ACCENT=94]="CIRCUMFLEX_ACCENT",e[e.LOW_LINE=95]="LOW_LINE",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_LETTER_A=97]="LATIN_SMALL_LETTER_A",e[e.LATIN_SMALL_LETTER_B=98]="LATIN_SMALL_LETTER_B",e[e.LATIN_SMALL_LETTER_C=99]="LATIN_SMALL_LETTER_C",e[e.LATIN_SMALL_LETTER_D=100]="LATIN_SMALL_LETTER_D",e[e.LATIN_SMALL_LETTER_E=101]="LATIN_SMALL_LETTER_E",e[e.LATIN_SMALL_LETTER_F=102]="LATIN_SMALL_LETTER_F",e[e.LATIN_SMALL_LETTER_G=103]="LATIN_SMALL_LETTER_G",e[e.LATIN_SMALL_LETTER_H=104]="LATIN_SMALL_LETTER_H",e[e.LATIN_SMALL_LETTER_I=105]="LATIN_SMALL_LETTER_I",e[e.LATIN_SMALL_LETTER_J=106]="LATIN_SMALL_LETTER_J",e[e.LATIN_SMALL_LETTER_K=107]="LATIN_SMALL_LETTER_K",e[e.LATIN_SMALL_LETTER_L=108]="LATIN_SMALL_LETTER_L",e[e.LATIN_SMALL_LETTER_M=109]="LATIN_SMALL_LETTER_M",e[e.LATIN_SMALL_LETTER_N=110]="LATIN_SMALL_LETTER_N",e[e.LATIN_SMALL_LETTER_O=111]="LATIN_SMALL_LETTER_O",e[e.LATIN_SMALL_LETTER_P=112]="LATIN_SMALL_LETTER_P",e[e.LATIN_SMALL_LETTER_Q=113]="LATIN_SMALL_LETTER_Q",e[e.LATIN_SMALL_LETTER_R=114]="LATIN_SMALL_LETTER_R",e[e.LATIN_SMALL_LETTER_S=115]="LATIN_SMALL_LETTER_S",e[e.LATIN_SMALL_LETTER_T=116]="LATIN_SMALL_LETTER_T",e[e.LATIN_SMALL_LETTER_U=117]="LATIN_SMALL_LETTER_U",e[e.LATIN_SMALL_LETTER_V=118]="LATIN_SMALL_LETTER_V",e[e.LATIN_SMALL_LETTER_W=119]="LATIN_SMALL_LETTER_W",e[e.LATIN_SMALL_LETTER_X=120]="LATIN_SMALL_LETTER_X",e[e.LATIN_SMALL_LETTER_Y=121]="LATIN_SMALL_LETTER_Y",e[e.LATIN_SMALL_LETTER_Z=122]="LATIN_SMALL_LETTER_Z",e[e.LEFT_CURLY_BRACKET=123]="LEFT_CURLY_BRACKET",e[e.VERTICAL_LINE=124]="VERTICAL_LINE",e[e.RIGHT_CURLY_BRACKET=125]="RIGHT_CURLY_BRACKET",e[e.TILDE=126]="TILDE"}(Sa||(Sa={}));const ya={[Sa.QUOTATION_MARK]:Sa.QUOTATION_MARK,[Sa.REVERSE_SOLIDUS]:Sa.REVERSE_SOLIDUS,[Sa.SOLIDUS]:Sa.SOLIDUS,[Sa.LATIN_SMALL_LETTER_B]:Sa.BACKSPACE,[Sa.LATIN_SMALL_LETTER_F]:Sa.FORM_FEED,[Sa.LATIN_SMALL_LETTER_N]:Sa.NEWLINE,[Sa.LATIN_SMALL_LETTER_R]:Sa.CARRIAGE_RETURN,[Sa.LATIN_SMALL_LETTER_T]:Sa.TAB};class ba{constructor(){this.decoder=new TextDecoder("utf-8"),this.strings=[],this.byteLength=0}appendChar(e){this.strings.push(String.fromCharCode(e)),this.byteLength+=1}appendBuf(e,t=0,s=e.length){this.strings.push(this.decoder.decode(e.subarray(t,s))),this.byteLength+=s-t}reset(){this.strings=[],this.byteLength=0}toString(){return this.strings.join("")}}class Ca{constructor(e){this.decoder=new TextDecoder("utf-8"),this.bufferOffset=0,this.string="",this.byteLength=0,this.buffer=new Uint8Array(e)}appendChar(e){this.bufferOffset>=this.buffer.length&&this.flushStringBuffer(),this.buffer[this.bufferOffset++]=e,this.byteLength+=1}appendBuf(e,t=0,s=e.length){const r=s-t;this.bufferOffset+r>this.buffer.length&&this.flushStringBuffer(),this.buffer.set(e.subarray(t,s),this.bufferOffset),this.bufferOffset+=r,this.byteLength+=r}flushStringBuffer(){this.string+=this.decoder.decode(this.buffer.subarray(0,this.bufferOffset)),this.bufferOffset=0}reset(){this.string="",this.bufferOffset=0,this.byteLength=0}toString(){return this.flushStringBuffer(),this.string}}var va,Ia;function Oa(e){return["START","ENDED","ERROR","TRUE1","TRUE2","TRUE3","FALSE1","FALSE2","FALSE3","FALSE4","NULL1","NULL2","NULL3","STRING_DEFAULT","STRING_AFTER_BACKSLASH","STRING_UNICODE_DIGIT_1","STRING_UNICODE_DIGIT_2","STRING_UNICODE_DIGIT_3","STRING_UNICODE_DIGIT_4","STRING_INCOMPLETE_CHAR","NUMBER_AFTER_INITIAL_MINUS","NUMBER_AFTER_INITIAL_ZERO","NUMBER_AFTER_INITIAL_NON_ZERO","NUMBER_AFTER_FULL_STOP","NUMBER_AFTER_DECIMAL","NUMBER_AFTER_E","NUMBER_AFTER_E_AND_SIGN","NUMBER_AFTER_E_AND_DIGIT","SEPARATOR","BOM_OR_START","BOM"][e]}!function(e){e[e.LEFT_BRACE=0]="LEFT_BRACE",e[e.RIGHT_BRACE=1]="RIGHT_BRACE",e[e.LEFT_BRACKET=2]="LEFT_BRACKET",e[e.RIGHT_BRACKET=3]="RIGHT_BRACKET",e[e.COLON=4]="COLON",e[e.COMMA=5]="COMMA",e[e.TRUE=6]="TRUE",e[e.FALSE=7]="FALSE",e[e.NULL=8]="NULL",e[e.STRING=9]="STRING",e[e.NUMBER=10]="NUMBER",e[e.SEPARATOR=11]="SEPARATOR"}(va||(va={})),function(e){e[e.START=0]="START",e[e.ENDED=1]="ENDED",e[e.ERROR=2]="ERROR",e[e.TRUE1=3]="TRUE1",e[e.TRUE2=4]="TRUE2",e[e.TRUE3=5]="TRUE3",e[e.FALSE1=6]="FALSE1",e[e.FALSE2=7]="FALSE2",e[e.FALSE3=8]="FALSE3",e[e.FALSE4=9]="FALSE4",e[e.NULL1=10]="NULL1",e[e.NULL2=11]="NULL2",e[e.NULL3=12]="NULL3",e[e.STRING_DEFAULT=13]="STRING_DEFAULT",e[e.STRING_AFTER_BACKSLASH=14]="STRING_AFTER_BACKSLASH",e[e.STRING_UNICODE_DIGIT_1=15]="STRING_UNICODE_DIGIT_1",e[e.STRING_UNICODE_DIGIT_2=16]="STRING_UNICODE_DIGIT_2",e[e.STRING_UNICODE_DIGIT_3=17]="STRING_UNICODE_DIGIT_3",e[e.STRING_UNICODE_DIGIT_4=18]="STRING_UNICODE_DIGIT_4",e[e.STRING_INCOMPLETE_CHAR=19]="STRING_INCOMPLETE_CHAR",e[e.NUMBER_AFTER_INITIAL_MINUS=20]="NUMBER_AFTER_INITIAL_MINUS",e[e.NUMBER_AFTER_INITIAL_ZERO=21]="NUMBER_AFTER_INITIAL_ZERO",e[e.NUMBER_AFTER_INITIAL_NON_ZERO=22]="NUMBER_AFTER_INITIAL_NON_ZERO",e[e.NUMBER_AFTER_FULL_STOP=23]="NUMBER_AFTER_FULL_STOP",e[e.NUMBER_AFTER_DECIMAL=24]="NUMBER_AFTER_DECIMAL",e[e.NUMBER_AFTER_E=25]="NUMBER_AFTER_E",e[e.NUMBER_AFTER_E_AND_SIGN=26]="NUMBER_AFTER_E_AND_SIGN",e[e.NUMBER_AFTER_E_AND_DIGIT=27]="NUMBER_AFTER_E_AND_DIGIT",e[e.SEPARATOR=28]="SEPARATOR",e[e.BOM_OR_START=29]="BOM_OR_START",e[e.BOM=30]="BOM"}(Ia||(Ia={}));const Na={stringBufferSize:0,numberBufferSize:0,separator:void 0,emitPartialTokens:!1};class Ma extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Ma.prototype)}}class wa{constructor(e){this.state=Ia.BOM_OR_START,this.bomIndex=0,this.separatorIndex=0,this.escapedCharsByteLength=0,this.bytes_remaining=0,this.bytes_in_sequence=0,this.char_split_buffer=new Uint8Array(4),this.encoder=new TextEncoder,this.offset=-1,e=Object.assign(Object.assign({},Na),e),this.emitPartialTokens=!0===e.emitPartialTokens,this.bufferedString=e.stringBufferSize&&e.stringBufferSize>4?new Ca(e.stringBufferSize):new ba,this.bufferedNumber=e.numberBufferSize&&e.numberBufferSize>0?new Ca(e.numberBufferSize):new ba,this.separator=e.separator,this.separatorBytes=e.separator?this.encoder.encode(e.separator):void 0}get isEnded(){return this.state===Ia.ENDED}write(e){try{let t;if(e instanceof Uint8Array)t=e;else if("string"==typeof e)t=this.encoder.encode(e);else if(Array.isArray(e))t=Uint8Array.from(e);else{if(!ArrayBuffer.isView(e))throw new TypeError("Unexpected type. The `write` function only accepts Arrays, TypedArrays and Strings.");t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}for(let s=0;s<t.length;s+=1){const r=t[s];switch(this.state){case Ia.BOM_OR_START:if(e instanceof Uint8Array&&239===r){this.bom=[239,187,191],this.bomIndex+=1,this.state=Ia.BOM;continue}if(e instanceof Uint16Array){if(254===r){this.bom=[254,255],this.bomIndex+=1,this.state=Ia.BOM;continue}if(255===r){this.bom=[255,254],this.bomIndex+=1,this.state=Ia.BOM;continue}}if(e instanceof Uint32Array){if(0===r){this.bom=[0,0,254,255],this.bomIndex+=1,this.state=Ia.BOM;continue}if(255===r){this.bom=[255,254,0,0],this.bomIndex+=1,this.state=Ia.BOM;continue}}case Ia.START:if(this.offset+=1,this.separatorBytes&&r===this.separatorBytes[0]){if(1===this.separatorBytes.length){this.state=Ia.START,this.onToken({token:va.SEPARATOR,value:this.separator,offset:this.offset+this.separatorBytes.length-1});continue}this.state=Ia.SEPARATOR;continue}if(r===Sa.SPACE||r===Sa.NEWLINE||r===Sa.CARRIAGE_RETURN||r===Sa.TAB)continue;if(r===Sa.LEFT_CURLY_BRACKET){this.onToken({token:va.LEFT_BRACE,value:"{",offset:this.offset});continue}if(r===Sa.RIGHT_CURLY_BRACKET){this.onToken({token:va.RIGHT_BRACE,value:"}",offset:this.offset});continue}if(r===Sa.LEFT_SQUARE_BRACKET){this.onToken({token:va.LEFT_BRACKET,value:"[",offset:this.offset});continue}if(r===Sa.RIGHT_SQUARE_BRACKET){this.onToken({token:va.RIGHT_BRACKET,value:"]",offset:this.offset});continue}if(r===Sa.COLON){this.onToken({token:va.COLON,value:":",offset:this.offset});continue}if(r===Sa.COMMA){this.onToken({token:va.COMMA,value:",",offset:this.offset});continue}if(r===Sa.LATIN_SMALL_LETTER_T){this.state=Ia.TRUE1;continue}if(r===Sa.LATIN_SMALL_LETTER_F){this.state=Ia.FALSE1;continue}if(r===Sa.LATIN_SMALL_LETTER_N){this.state=Ia.NULL1;continue}if(r===Sa.QUOTATION_MARK){this.bufferedString.reset(),this.escapedCharsByteLength=0,this.state=Ia.STRING_DEFAULT;continue}if(r>=Sa.DIGIT_ONE&&r<=Sa.DIGIT_NINE){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_INITIAL_NON_ZERO;continue}if(r===Sa.DIGIT_ZERO){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_INITIAL_ZERO;continue}if(r===Sa.HYPHEN_MINUS){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_INITIAL_MINUS;continue}break;case Ia.STRING_DEFAULT:if(r===Sa.QUOTATION_MARK){const e=this.bufferedString.toString();this.state=Ia.START,this.onToken({token:va.STRING,value:e,offset:this.offset}),this.offset+=this.escapedCharsByteLength+this.bufferedString.byteLength+1;continue}if(r===Sa.REVERSE_SOLIDUS){this.state=Ia.STRING_AFTER_BACKSLASH;continue}if(r>=128){if(this.bytes_in_sequence=r>=194&&r<=223?2:r<=239?3:4,this.bytes_in_sequence<=t.length-s){this.bufferedString.appendBuf(t,s,s+this.bytes_in_sequence),s+=this.bytes_in_sequence-1;continue}this.bytes_remaining=s+this.bytes_in_sequence-t.length,this.char_split_buffer.set(t.subarray(s)),s=t.length-1,this.state=Ia.STRING_INCOMPLETE_CHAR;continue}if(r>=Sa.SPACE){this.bufferedString.appendChar(r);continue}break;case Ia.STRING_INCOMPLETE_CHAR:this.char_split_buffer.set(t.subarray(s,s+this.bytes_remaining),this.bytes_in_sequence-this.bytes_remaining),this.bufferedString.appendBuf(this.char_split_buffer,0,this.bytes_in_sequence),s=this.bytes_remaining-1,this.state=Ia.STRING_DEFAULT;continue;case Ia.STRING_AFTER_BACKSLASH:const n=ya[r];if(n){this.bufferedString.appendChar(n),this.escapedCharsByteLength+=1,this.state=Ia.STRING_DEFAULT;continue}if(r===Sa.LATIN_SMALL_LETTER_U){this.unicode="",this.state=Ia.STRING_UNICODE_DIGIT_1;continue}break;case Ia.STRING_UNICODE_DIGIT_1:case Ia.STRING_UNICODE_DIGIT_2:case Ia.STRING_UNICODE_DIGIT_3:if(r>=Sa.DIGIT_ZERO&&r<=Sa.DIGIT_NINE||r>=Sa.LATIN_CAPITAL_LETTER_A&&r<=Sa.LATIN_CAPITAL_LETTER_F||r>=Sa.LATIN_SMALL_LETTER_A&&r<=Sa.LATIN_SMALL_LETTER_F){this.unicode+=String.fromCharCode(r),this.state+=1;continue}break;case Ia.STRING_UNICODE_DIGIT_4:if(r>=Sa.DIGIT_ZERO&&r<=Sa.DIGIT_NINE||r>=Sa.LATIN_CAPITAL_LETTER_A&&r<=Sa.LATIN_CAPITAL_LETTER_F||r>=Sa.LATIN_SMALL_LETTER_A&&r<=Sa.LATIN_SMALL_LETTER_F){const e=parseInt(this.unicode+String.fromCharCode(r),16);let t;if(void 0===this.highSurrogate){if(e>=55296&&e<=56319){this.highSurrogate=e,this.state=Ia.STRING_DEFAULT;continue}t=String.fromCharCode(e)}else t=e>=56320&&e<=57343?String.fromCharCode(this.highSurrogate,e):String.fromCharCode(this.highSurrogate),this.highSurrogate=void 0;const s=this.encoder.encode(t);this.bufferedString.appendBuf(s),this.escapedCharsByteLength+=6-s.byteLength,this.state=Ia.STRING_DEFAULT;continue}break;case Ia.NUMBER_AFTER_INITIAL_MINUS:if(r===Sa.DIGIT_ZERO){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_INITIAL_ZERO;continue}if(r>=Sa.DIGIT_ONE&&r<=Sa.DIGIT_NINE){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_INITIAL_NON_ZERO;continue}break;case Ia.NUMBER_AFTER_INITIAL_ZERO:if(r===Sa.FULL_STOP){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_FULL_STOP;continue}if(r===Sa.LATIN_SMALL_LETTER_E||r===Sa.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_E;continue}s-=1,this.state=Ia.START,this.emitNumber();continue;case Ia.NUMBER_AFTER_INITIAL_NON_ZERO:if(r>=Sa.DIGIT_ZERO&&r<=Sa.DIGIT_NINE){this.bufferedNumber.appendChar(r);continue}if(r===Sa.FULL_STOP){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_FULL_STOP;continue}if(r===Sa.LATIN_SMALL_LETTER_E||r===Sa.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_E;continue}s-=1,this.state=Ia.START,this.emitNumber();continue;case Ia.NUMBER_AFTER_FULL_STOP:if(r>=Sa.DIGIT_ZERO&&r<=Sa.DIGIT_NINE){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_DECIMAL;continue}break;case Ia.NUMBER_AFTER_DECIMAL:if(r>=Sa.DIGIT_ZERO&&r<=Sa.DIGIT_NINE){this.bufferedNumber.appendChar(r);continue}if(r===Sa.LATIN_SMALL_LETTER_E||r===Sa.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_E;continue}s-=1,this.state=Ia.START,this.emitNumber();continue;case Ia.NUMBER_AFTER_E:if(r===Sa.PLUS_SIGN||r===Sa.HYPHEN_MINUS){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_E_AND_SIGN;continue}case Ia.NUMBER_AFTER_E_AND_SIGN:if(r>=Sa.DIGIT_ZERO&&r<=Sa.DIGIT_NINE){this.bufferedNumber.appendChar(r),this.state=Ia.NUMBER_AFTER_E_AND_DIGIT;continue}break;case Ia.NUMBER_AFTER_E_AND_DIGIT:if(r>=Sa.DIGIT_ZERO&&r<=Sa.DIGIT_NINE){this.bufferedNumber.appendChar(r);continue}s-=1,this.state=Ia.START,this.emitNumber();continue;case Ia.TRUE1:if(r===Sa.LATIN_SMALL_LETTER_R){this.state=Ia.TRUE2;continue}break;case Ia.TRUE2:if(r===Sa.LATIN_SMALL_LETTER_U){this.state=Ia.TRUE3;continue}break;case Ia.TRUE3:if(r===Sa.LATIN_SMALL_LETTER_E){this.state=Ia.START,this.onToken({token:va.TRUE,value:!0,offset:this.offset}),this.offset+=3;continue}break;case Ia.FALSE1:if(r===Sa.LATIN_SMALL_LETTER_A){this.state=Ia.FALSE2;continue}break;case Ia.FALSE2:if(r===Sa.LATIN_SMALL_LETTER_L){this.state=Ia.FALSE3;continue}break;case Ia.FALSE3:if(r===Sa.LATIN_SMALL_LETTER_S){this.state=Ia.FALSE4;continue}break;case Ia.FALSE4:if(r===Sa.LATIN_SMALL_LETTER_E){this.state=Ia.START,this.onToken({token:va.FALSE,value:!1,offset:this.offset}),this.offset+=4;continue}break;case Ia.NULL1:if(r===Sa.LATIN_SMALL_LETTER_U){this.state=Ia.NULL2;continue}break;case Ia.NULL2:if(r===Sa.LATIN_SMALL_LETTER_L){this.state=Ia.NULL3;continue}break;case Ia.NULL3:if(r===Sa.LATIN_SMALL_LETTER_L){this.state=Ia.START,this.onToken({token:va.NULL,value:null,offset:this.offset}),this.offset+=3;continue}break;case Ia.SEPARATOR:if(this.separatorIndex+=1,!this.separatorBytes||r!==this.separatorBytes[this.separatorIndex])break;this.separatorIndex===this.separatorBytes.length-1&&(this.state=Ia.START,this.onToken({token:va.SEPARATOR,value:this.separator,offset:this.offset+this.separatorIndex}),this.separatorIndex=0);continue;case Ia.BOM:if(r===this.bom[this.bomIndex]){if(this.bomIndex===this.bom.length-1){this.state=Ia.START,this.bom=void 0,this.bomIndex=0;continue}this.bomIndex+=1;continue}break;case Ia.ENDED:if(r===Sa.SPACE||r===Sa.NEWLINE||r===Sa.CARRIAGE_RETURN||r===Sa.TAB)continue}throw new Ma(`Unexpected "${String.fromCharCode(r)}" at position "${s}" in state ${Oa(this.state)}`)}if(this.emitPartialTokens)switch(this.state){case Ia.TRUE1:case Ia.TRUE2:case Ia.TRUE3:this.onToken({token:va.TRUE,value:!0,offset:this.offset,partial:!0});break;case Ia.FALSE1:case Ia.FALSE2:case Ia.FALSE3:case Ia.FALSE4:this.onToken({token:va.FALSE,value:!1,offset:this.offset,partial:!0});break;case Ia.NULL1:case Ia.NULL2:case Ia.NULL3:this.onToken({token:va.NULL,value:null,offset:this.offset,partial:!0});break;case Ia.STRING_DEFAULT:{const e=this.bufferedString.toString();this.onToken({token:va.STRING,value:e,offset:this.offset,partial:!0});break}case Ia.NUMBER_AFTER_INITIAL_ZERO:case Ia.NUMBER_AFTER_INITIAL_NON_ZERO:case Ia.NUMBER_AFTER_DECIMAL:case Ia.NUMBER_AFTER_E_AND_DIGIT:try{this.onToken({token:va.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset,partial:!0})}catch(e){}}}catch(e){this.error(e)}}emitNumber(){this.onToken({token:va.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset}),this.offset+=this.bufferedNumber.byteLength-1}parseNumber(e){return Number(e)}error(e){this.state!==Ia.ENDED&&(this.state=Ia.ERROR),this.onError(e)}end(){switch(this.state){case Ia.NUMBER_AFTER_INITIAL_ZERO:case Ia.NUMBER_AFTER_INITIAL_NON_ZERO:case Ia.NUMBER_AFTER_DECIMAL:case Ia.NUMBER_AFTER_E_AND_DIGIT:this.state=Ia.ENDED,this.emitNumber(),this.onEnd();break;case Ia.BOM_OR_START:case Ia.START:case Ia.ERROR:case Ia.SEPARATOR:this.state=Ia.ENDED,this.onEnd();break;default:this.error(new Ma(`Tokenizer ended in the middle of a token (state: ${Oa(this.state)}). Either not all the data was received or the data was invalid.`))}}onToken(e){throw new Ma('Can\'t emit tokens before the "onToken" callback has been set up.')}onError(e){throw e}onEnd(){}}var Ua,ka;function Pa(e){return["VALUE","KEY","COLON","COMMA","ENDED","ERROR","SEPARATOR"][e]}!function(e){e[e.OBJECT=0]="OBJECT",e[e.ARRAY=1]="ARRAY"}(Ua||(Ua={})),function(e){e[e.VALUE=0]="VALUE",e[e.KEY=1]="KEY",e[e.COLON=2]="COLON",e[e.COMMA=3]="COMMA",e[e.ENDED=4]="ENDED",e[e.ERROR=5]="ERROR",e[e.SEPARATOR=6]="SEPARATOR"}(ka||(ka={}));const Ba={paths:void 0,keepStack:!0,separator:void 0,emitPartialValues:!1};class ja extends Error{constructor(e){super(e),Object.setPrototypeOf(this,ja.prototype)}}class Da{constructor(e){this.state=ka.VALUE,this.mode=void 0,this.key=void 0,this.value=void 0,this.stack=[],(e=Object.assign(Object.assign({},Ba),e)).paths&&(this.paths=e.paths.map(e=>{if(void 0===e||"$*"===e)return;if(!e.startsWith("$"))throw new ja(`Invalid selector "${e}". Should start with "$".`);const t=e.split(".").slice(1);if(t.includes(""))throw new ja(`Invalid selector "${e}". ".." syntax not supported.`);return t})),this.keepStack=e.keepStack||!1,this.separator=e.separator,e.emitPartialValues||(this.emitPartial=()=>{})}shouldEmit(){return!this.paths||this.paths.some(e=>{var t;if(void 0===e)return!0;if(e.length!==this.stack.length)return!1;for(let t=0;t<e.length-1;t++){const s=e[t],r=this.stack[t+1].key;if("*"!==s&&s!==(null==r?void 0:r.toString()))return!1}const s=e[e.length-1];return"*"===s||s===(null===(t=this.key)||void 0===t?void 0:t.toString())})}push(){this.stack.push({key:this.key,value:this.value,mode:this.mode,emit:this.shouldEmit()})}pop(){const e=this.value;let t;({key:this.key,value:this.value,mode:this.mode,emit:t}=this.stack.pop()),this.state=void 0!==this.mode?ka.COMMA:ka.VALUE,this.emit(e,t)}emit(e,t){!this.keepStack&&this.value&&this.stack.every(e=>!e.emit)&&delete this.value[this.key],t&&this.onValue({value:e,key:this.key,parent:this.value,stack:this.stack}),0===this.stack.length&&(this.separator?this.state=ka.SEPARATOR:void 0===this.separator&&this.end())}emitPartial(e){this.shouldEmit()&&(this.state!==ka.KEY?this.onValue({value:e,key:this.key,parent:this.value,stack:this.stack,partial:!0}):this.onValue({value:void 0,key:e,parent:this.value,stack:this.stack,partial:!0}))}get isEnded(){return this.state===ka.ENDED}write({token:e,value:t,partial:s}){try{if(s)return void this.emitPartial(t);if(this.state===ka.VALUE){if(e===va.STRING||e===va.NUMBER||e===va.TRUE||e===va.FALSE||e===va.NULL)return this.mode===Ua.OBJECT?(this.value[this.key]=t,this.state=ka.COMMA):this.mode===Ua.ARRAY&&(this.value.push(t),this.state=ka.COMMA),void this.emit(t,this.shouldEmit());if(e===va.LEFT_BRACE){if(this.push(),this.mode===Ua.OBJECT)this.value=this.value[this.key]={};else if(this.mode===Ua.ARRAY){const e={};this.value.push(e),this.value=e}else this.value={};return this.mode=Ua.OBJECT,this.state=ka.KEY,this.key=void 0,void this.emitPartial()}if(e===va.LEFT_BRACKET){if(this.push(),this.mode===Ua.OBJECT)this.value=this.value[this.key]=[];else if(this.mode===Ua.ARRAY){const e=[];this.value.push(e),this.value=e}else this.value=[];return this.mode=Ua.ARRAY,this.state=ka.VALUE,this.key=0,void this.emitPartial()}if(this.mode===Ua.ARRAY&&e===va.RIGHT_BRACKET&&0===this.value.length)return void this.pop()}if(this.state===ka.KEY){if(e===va.STRING)return this.key=t,this.state=ka.COLON,void this.emitPartial();if(e===va.RIGHT_BRACE&&0===Object.keys(this.value).length)return void this.pop()}if(this.state===ka.COLON&&e===va.COLON)return void(this.state=ka.VALUE);if(this.state===ka.COMMA){if(e===va.COMMA){if(this.mode===Ua.ARRAY)return this.state=ka.VALUE,void(this.key+=1);if(this.mode===Ua.OBJECT)return void(this.state=ka.KEY)}if(e===va.RIGHT_BRACE&&this.mode===Ua.OBJECT||e===va.RIGHT_BRACKET&&this.mode===Ua.ARRAY)return void this.pop()}if(this.state===ka.SEPARATOR&&e===va.SEPARATOR&&t===this.separator)return void(this.state=ka.VALUE);if(e===va.SEPARATOR&&this.state!==ka.SEPARATOR&&Array.from(t).map(e=>e.charCodeAt(0)).every(e=>e===Sa.SPACE||e===Sa.NEWLINE||e===Sa.CARRIAGE_RETURN||e===Sa.TAB))return;throw new ja(`Unexpected ${va[e]} (${JSON.stringify(t)}) in state ${Pa(this.state)}`)}catch(e){this.error(e)}}error(e){this.state!==ka.ENDED&&(this.state=ka.ERROR),this.onError(e)}end(){this.state!==ka.VALUE&&this.state!==ka.SEPARATOR||this.stack.length>0?this.error(new Error(`Parser ended in mid-parsing (state: ${Pa(this.state)}). Either not all the data was received or the data was invalid.`)):(this.state=ka.ENDED,this.onEnd())}onValue(e){throw new ja('Can\'t emit data before the "onValue" callback has been set up.')}onError(e){throw e}onEnd(){}}class xa{constructor(e={}){this.tokenizer=new wa(e),this.tokenParser=new Da(e),this.tokenizer.onToken=this.tokenParser.write.bind(this.tokenParser),this.tokenizer.onEnd=()=>{this.tokenParser.isEnded||this.tokenParser.end()},this.tokenParser.onError=this.tokenizer.error.bind(this.tokenizer),this.tokenParser.onEnd=()=>{this.tokenizer.isEnded||this.tokenizer.end()}}get isEnded(){return this.tokenizer.isEnded&&this.tokenParser.isEnded}write(e){this.tokenizer.write(e)}end(){this.tokenizer.end()}set onToken(e){this.tokenizer.onToken=t=>{e(t),this.tokenParser.write(t)}}set onValue(e){this.tokenParser.onValue=e}set onError(e){this.tokenizer.onError=e}set onEnd(e){this.tokenParser.onEnd=()=>{this.tokenizer.isEnded||this.tokenizer.end(),e.call(this.tokenParser)}}}var Fa;function qa(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}(Fa||(Fa={})).STREAM_PARSER_JSON_ERROR="chat_sdk_pull_stream_parser_error";class Ga{__init(){this.parserOptions={emitPartialValues:!0,emitPartialTokens:!0,keepStack:!0}}__init2(){this.jsonParserMap={}}__init3(){this.jsonParserMetaMap={}}constructor(e){Ga.prototype.__init.call(this),Ga.prototype.__init2.call(this),Ga.prototype.__init3.call(this),Ga.prototype.__init4.call(this),Ga.prototype.__init5.call(this),Ga.prototype.__init6.call(this),Ga.prototype.__init7.call(this),Ga.prototype.__init8.call(this);const{reportLogWithScope:t}=e;this.reportLogWithScope=t}__init4(){this.getJsonParser=e=>{if(this.jsonParserMap[e])return this.jsonParserMap[e];const t=new xa(this.parserOptions);return this.jsonParserMap[e]=t,this.jsonParserMetaMap[e]={isError:!1},this.jsonParserMap[e]}}__init5(){this.updateJsonParserMeta=(e,t)=>{Zs(this.jsonParserMetaMap,e,t)}}__init6(){this.write=(e,t,{onValue:s,onError:r,onEnd:n,onToken:o})=>{const i=this.getJsonParser(e);qa([this,"access",e=>e.jsonParserMetaMap,"access",t=>t[e],"optionalAccess",e=>e.isError])||i.isEnded||(i.onValue=s,i.onError=t=>{this.updateJsonParserMeta(e,e=>({...e,isError:!0})),qa([r,"optionalCall",e=>e(t)]),this.reportLogWithScope.slardarErrorEvent({error:t,eventName:Fa.STREAM_PARSER_JSON_ERROR,meta:{msgId:e}})},i.onEnd=()=>{this.clearByMsgId(e),qa([n,"optionalCall",e=>e()])},o&&(i.onToken=o),i.write(t))}}__init7(){this.clearParserCallback=e=>{e.onValue=ie,e.onError=ie,e.onEnd=ie,e.onToken=ie}}__init8(){this.clearByMsgId=e=>{const t=this.jsonParserMap[e];t&&this.clearParserCallback(t),delete this.jsonParserMap[e],delete this.jsonParserMetaMap[e]}}destroy(){Object.values(this.jsonParserMap).forEach(this.clearParserCallback),this.jsonParserMap={},this.jsonParserMetaMap={}}}const Ha={toolRequestStreamingParameters:!1},za={v1:{toolRequestStreamingParameters:!0}},Wa=e=>{return"tool_request"===e.type&&(t=e.version,t&&za[t]||Ha).toolRequestStreamingParameters;var t};function $a(e,t){return null!=e?e:t()}function Va(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}class Ka{constructor(e){const{initMessageBuffer:t=[],reportLogWithScope:s}=e;this.streamMessageBuffer=Es(t),this.streamChunkBuffer=Es(t),this.streamParserJson=new Ga({reportLogWithScope:s}),this.streamMessageBuffer.forEach(e=>{Wa(e)&&this.streamParserJson.write(e.msg_id,Va([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters])||"",{onValue:ie})})}pushChunk(e){this.streamChunkBuffer.push(e)}clearMessageBuffer(){this.streamMessageBuffer=[],this.streamChunkBuffer=[],this.streamParserJson.destroy()}getChunkByMessageId(e){return this.streamChunkBuffer.filter(t=>t.msg_id===e)}concatBatchAndUpdateMessage(e){const{msgId:t,chunks:s}=e;if(0===s.length)return;s.forEach(e=>{this.streamChunkBuffer.push(e)});const r=s.at(0),n=this.streamMessageBuffer.findIndex(e=>r?""!==t?e.msg_id===t:""===e.msg_id&&e.type===r.type&&e.query_msg_id===r.query_msg_id:e.msg_id===t),o=-1!==n?this.streamMessageBuffer[n]:void 0,i=Ta(o,s);if(!i)return;const a=Wa(i);return a&&s.forEach(e=>{this.streamParserJson.write(e.msg_id,Va([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters])||"",{onValue:(...e)=>{const t=(e=>{const{key:t,value:s,stack:r,partial:n,parent:o}=e,i=r.slice(1),a=i.at(0);if(Vs(t)||Vs(s))return;const c=Es(o),l=Es(s);if(!a){if(!n)return c||l;if(!c)return;return c[t]=l,c}const u=Es(a.value);return n?(Zs(u,i.map(e=>e.key).filter(e=>!Vs(e)).concat(t),()=>l),u):u})(...e);t&&(i.streamParametersContent=t)}})}),!i.streamParametersContent&&a&&o&&(i.streamParametersContent=o.streamParametersContent),-1===n?this.streamMessageBuffer.push(i):this.streamMessageBuffer.splice(n,1,i),i}}const Ja=1073741823;class Qa{__init(){this.shallowCloneStreamBuffer=()=>({streamMessageBuffer:[...this.streamBuffer.streamMessageBuffer],streamChunkBuffer:[...this.streamBuffer.streamChunkBuffer]})}__init2(){this.getStreamBuffer=()=>this.shallowCloneStreamBuffer()}__init3(){this.getStreamBufferWithMeta=()=>{const e=this.shallowCloneStreamBuffer();return{...e,...this.simpleMessageDump.getBufferMeta(e.streamMessageBuffer)}}}__init4(){this.getStreamBufferSnapshot=()=>this.simpleMessageDump.getStreamBufferSnapshot()}constructor(e){Qa.prototype.__init.call(this),Qa.prototype.__init2.call(this),Qa.prototype.__init3.call(this),Qa.prototype.__init4.call(this),Qa.prototype.__init5.call(this),Qa.prototype.__init6.call(this),Qa.prototype.__init7.call(this),Qa.prototype.__init8.call(this);const{getEnableDebug:t,key:s,reportLogWithScope:r,initMaxSequenceId:n}=e;this.getEnableDebug=t,this.maxSequenceId=$a(n,()=>0),this.enableChunkProcessedCheck=$a(e.enableChunkProcessedCheck,()=>!1),this.streamBuffer=new Ka(e),this.debugLogger=new La({reportLogWithScope:r,getEnableDebug:t,getLogPayload:()=>this.getStreamBuffer(),mark:"ChunkProcessor"}),this.simpleMessageDump=new Ra({key:s})}__init5(){this.startDebugLog=e=>{this.debugLogger.isDebugging||this.debugLogger.startDebugLog(e)}}__init6(){this.stopDebugLog=()=>{this.debugLogger.stopDebugLog()}}isStreamBufferEmpty(){return 0===this.streamBuffer.streamChunkBuffer.length&&0===this.streamBuffer.streamMessageBuffer.length}__init7(){this.clearMessageBuffer=()=>{this.stopDebugLog(),this.simpleMessageDump.recordStreamBuffer(this.shallowCloneStreamBuffer()),this.streamBuffer.clearMessageBuffer()}}addBatchAndProcess(e){const t=e.chunks.at(0);if(t)return this.startDebugLog(t.query_msg_id),this.streamBuffer.concatBatchAndUpdateMessage(e)}checkInBufferProcessed(e){return""===e.msg_id?this.streamBuffer.streamMessageBuffer.some(t=>""===t.msg_id&&t.type===e.type&&t.query_msg_id===e.query_msg_id&&t.sequence_id>=e.sequence_id):this.streamBuffer.streamMessageBuffer.some(t=>t.msg_id===e.msg_id&&t.sequence_id>=e.sequence_id)}checkMessageHasProcessed(e){if(this.checkInBufferProcessed(e))return!0;if(!this.enableChunkProcessedCheck)return!1;if(0===this.maxSequenceId)return this.maxSequenceId=e.sequence_id,!1;const t=this.maxSequenceId,s=e.sequence_id,r=t>Ja,n=s>Ja;return r&&!n?(this.maxSequenceId=s,!1):!(r||!n)||(!(s>=t)||(this.maxSequenceId=s,!1))}getProcessedMessageByChunk(e){return this.streamBuffer.streamMessageBuffer.find(t=>t.msg_id===e.msg_id)}getProcessedMessageByMessageId(e){return this.streamBuffer.streamMessageBuffer.find(t=>t.msg_id===e)}getAckMessageByLocalMessageId(e){return this.streamBuffer.streamMessageBuffer.find(t=>Va([t,"access",e=>e.content,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id])===e&&"message_start"===t.type)}getFirstReplyMessageByChunk(e){if(this.streamBuffer.streamMessageBuffer.some(t=>"message_start"===t.type&&t.query_msg_id===e.query_msg_id))return this.streamBuffer.streamMessageBuffer.find(t=>"message_start"!==t.type&&t.query_msg_id===e.query_msg_id)}getAckMessage(){return this.streamBuffer.streamMessageBuffer.find(e=>"message_start"===e.type)}isFirstReplyMessage(e){return!!this.getAckMessage()&&!this.getFirstReplyMessageByChunk(e)}getReplyMessagesByQueryMsgId(e){return this.streamBuffer.streamMessageBuffer.filter(t=>"message_start"!==t.type&&t.query_msg_id===e)}__init8(){this.destroy=()=>{this.debugLogger.destroy(),this.clearMessageBuffer(),this.simpleMessageDump.clear()}}}var Ya,Za,Xa;!function(e){e.MESSAGE_RECEIVED_AND_UPDATE="message_received_and_update";e.MESSAGE_PULLING_STATUS="message_pulling_status";e.SEND_MESSAGE_ERROR="send_message_error";e.CHANNEL_STATUS="channel_status";e.CONTEXT_CHANGE="context_change";e.SESSION_CHANGED="session_changed"}(Ya||(Ya={})),function(e){e[e.Unknown=0]="Unknown";e[e.Prev=1]="Prev";e[e.Next=2]="Next"}(Za||(Za={}));class ec{__init(){this.timer=null}__init2(){this.timeoutMs=12e4}constructor(e){ec.prototype.__init.call(this),ec.prototype.__init2.call(this),this.reportLogWithScope=e.reportLogWithScope,e.timeoutMs&&(this.timeoutMs=e.timeoutMs),this.getChannelOptions=e.getChannelOptions}flushMessage(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.reportLogWithScope.slardarErrorEvent({eventName:`${this.getChannelOptions().channelName}_OnMessageTimeout`,error:new Error("OnMessageTimeout - 超时未收到消息"),meta:{...this.getChannelOptions(),log_id:e.log_id,query_msg_id:e.query_msg_id,lastMessage:e}}),this.timer=null},this.timeoutMs)}destroy(){this.timer&&(clearTimeout(this.timer),this.timer=null)}}function tc(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}function sc(e,t,s){let r,n;if(2===arguments.length?t&&"object"==typeof t&&("onError"in t||"validate"in t||"throwOnValidationError"in t)?(n=t,r=void 0):(r=t,n=void 0):3===arguments.length&&(r=t,n=s),"object"==typeof e&&null!==e)return e;try{const t=JSON.parse(String(e));if(tc([n,"optionalAccess",e=>e.validate])){if(n.validate(t))return t;{const t=new Error("JSON validation failed");if(tc([n,"access",e=>e.onError,"optionalCall",s=>s(t,e)]),n.throwOnValidationError)throw t;return r}}return t}catch(t){if(t instanceof Error&&"JSON validation failed"===t.message&&tc([n,"optionalAccess",e=>e.throwOnValidationError]))throw t;return tc([n,"optionalAccess",e=>e.onError,"optionalCall",s=>s(t,e)]),r}}!function(e){e.MESSAGE_END="message_end";e.MESSAGE_SEND_SUCCESS="message_send_success";e.MESSAGE_SEND_AND_RECEIVE_ERROR="message_send_and_receive_error";e.MESSAGE_SEND_TIMEOUT="message_send_timeout"}(Xa||(Xa={}));class rc{__init(){this.state="pending"}constructor(){rc.prototype.__init.call(this),this.promise=new Promise((e,t)=>{this.resolve=(...t)=>{this.state="fulfilled",e(...t)},this.reject=(...e)=>{this.state="rejected",t(...e)}}),this.then=this.promise.then.bind(this.promise)}}function nc(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}const oc={message_start:!0,answer:!0,thinking:!0,tool_request:!0,tool_process:!0,tool_response:!0,message_end:!0,deploy:!0,version:!0,context:!0,session_changed:!0,error:!0},ic=e=>{const{type:t}=e;return(e=>e in oc)(t)?Wa({type:t,version:e.version})?{...e,role:"assistant",type:t,streamParametersContent:(n=nc([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters]),o=()=>"",s=null!=n?n:o(),sc(s,void 0,{onError:r}))}:{...e,role:"assistant",type:t}:((e=>{throw new Error(`[chat-area] ${e}`)})(`invalid server message type: ${t}`),{...e,role:"assistant"});var s,r,n,o};class ac extends Error{constructor(e,t){super(e),ac.prototype.__init.call(this),this.name="chatCoreError",this.ext=t||{}}__init(){this.flatten=()=>{const{message:e,ext:t}=this;return{message:e,...t}}}}function cc(e,t){return null!=e?e:t()}function lc(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}const uc=e=>{const{content:t,type:s}=e;switch(s){case"answer":return cc(lc([t,"access",e=>e.answer,"optionalAccess",e=>e.length]),()=>0);case"thinking":return cc(lc([t,"access",e=>e.thinking,"optionalAccess",e=>e.length]),()=>0);case"tool_request":return cc(lc([t,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters,"optionalAccess",e=>e.length]),()=>0);case"tool_process":return(e=>{const t=lc([e,"access",e=>e.content,"access",e=>e.tool_process,"optionalAccess",e=>e.data,"access",e=>e.content]);return fa.reduce((e,s)=>{const r=lc([t,"optionalAccess",e=>e[s]]);return"string"!=typeof r?e:e+r.length},0)})(e);case"tool_response":return cc(lc([t,"access",e=>e.tool_response,"optionalAccess",e=>e.result,"access",e=>e.length]),()=>0);default:return 0}};class hc{__init(){this.bufferMap=new Map}constructor(e,t){hc.prototype.__init.call(this),hc.prototype.__init2.call(this),hc.prototype.__init3.call(this),hc.prototype.__init4.call(this),hc.prototype.__init5.call(this),hc.prototype.__init6.call(this),hc.prototype.__init7.call(this),hc.prototype.__init8.call(this),hc.prototype.__init9.call(this),hc.prototype.__init10.call(this),this.onFlush=e,this.config={lengthThreshold:cc(lc([t,"optionalAccess",e=>e.lengthThreshold]),()=>4096),maxWaitMs:cc(lc([t,"optionalAccess",e=>e.maxWaitMs]),()=>500)}}__init2(){this.createEntry=(e,t)=>({msgId:e,chunks:[],totalLength:0,startSeq:t.sequence_id,maxWaitTimerId:null,hasFirstFlushed:!1})}__init3(){this.enqueue=e=>{const{msg_id:t}=e;let s=this.bufferMap.get(t);if(!s)return s=this.createEntry(t,e),this.bufferMap.set(t,s),this.onFlush({msgId:t,chunks:[e],startSeq:e.sequence_id,reason:"firstChunk"}),void(s.hasFirstFlushed=!0);0===s.chunks.length&&(s.startSeq=e.sequence_id),s.chunks.push(e),s.totalLength+=uc(e),s.totalLength>=this.config.lengthThreshold?this.flush(t,"length"):e.finish?this.flush(t,"finish"):this.armMaxWaitTimer(t)}}__init4(){this.flush=(e,t)=>{const s=this.bufferMap.get(e);if(!s||0===s.chunks.length)return;this.cancelMaxWaitTimer(e);const r=this.buildBatch(s,t);this.onFlush(r),s.chunks=[],s.totalLength=0}}__init5(){this.buildBatch=(e,t)=>({msgId:e.msgId,chunks:[...e.chunks],startSeq:e.startSeq,reason:t})}__init6(){this.armMaxWaitTimer=e=>{const t=this.bufferMap.get(e);t&&(t.maxWaitTimerId||(t.maxWaitTimerId=setTimeout(()=>{this.flush(e,"maxWait")},this.config.maxWaitMs)))}}__init7(){this.cancelMaxWaitTimer=e=>{const t=this.bufferMap.get(e);lc([t,"optionalAccess",e=>e.maxWaitTimerId])&&(clearTimeout(t.maxWaitTimerId),t.maxWaitTimerId=null)}}__init8(){this.forceFlush=e=>{this.flush(e,"force"),this.bufferMap.delete(e)}}__init9(){this.forceFlushAll=()=>{Array.from(this.bufferMap.keys()).forEach(e=>this.forceFlush(e))}}__init10(){this.destroy=()=>{this.bufferMap.forEach((e,t)=>{this.cancelMaxWaitTimer(t)}),this.bufferMap.clear()}}}function pc(e,t){return null!=e?e:t()}function dc(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}class _c{__init(){this.bufferManager=null}constructor({channel:e,reportLogWithScope:t,chunkProcessor:s,preSendLocalMessageEventsManager:r,chatSdkEventEmit:n,chatSdkEventBus:o,reportEventsTracer:i,manualInitChannel:a,enableBuffer:c=!1}){_c.prototype.__init.call(this),_c.prototype.__init2.call(this),_c.prototype.__init3.call(this),_c.prototype.__init4.call(this),_c.prototype.__init5.call(this),_c.prototype.__init6.call(this),_c.prototype.__init7.call(this),_c.prototype.__init8.call(this),_c.prototype.__init9.call(this),_c.prototype.__init10.call(this),_c.prototype.__init11.call(this),_c.prototype.__init12.call(this),_c.prototype.__init13.call(this),_c.prototype.__init14.call(this),_c.prototype.__init15.call(this),this.channel=e,this.reportLogWithScope=t,this.chunkProcessor=s,this.preSendLocalMessageEventsManager=r,this.chatSdkEventEmit=n,this.reportEventsTracer=i,this.chatSdkEventBus=o,this.enableBuffer=c,this.onMessageMonitor=new ec({reportLogWithScope:t,getChannelOptions:()=>({...pc(dc([this,"access",e=>e.channel,"access",e=>e.getChannelOptions,"optionalCall",e=>e()]),()=>({})),channelName:this.channel.channelName}),timeoutMs:12e4}),c&&(this.bufferManager=new hc(this.processChunkBatchAndEmit,void 0)),a||this.initChannel()}onChannelEvents(){this.channel.addEventListener("onmessage",this.handleChannelMessage),this.channel.addEventListener("onerror",this.handleWebSocketChannelError),this.channel.addEventListener("onopen",this.handleChannelOpen),this.channel.addEventListener("onclose",this.handleChannelClose)}__init2(){this.handleChannelMessage=e=>{const t=ic(e);this.onMessageMonitor.flushMessage(t);const{type:s}=t;return"context"===s&&t.content.context?this.handleContextChange(t.content.context):"session_changed"===s&&t.content.session_changed?this.handleSessionChange(t.content.session_changed):this.handleChatMessage(t)}}__init3(){this.handleContextChange=e=>{this.reportLogWithScope.info({message:"context 更新",meta:{context:e}}),this.chatSdkEventEmit(Ya.CONTEXT_CHANGE,{name:Ya.CONTEXT_CHANGE,data:e})}}__init4(){this.handleSessionChange=e=>{this.reportLogWithScope.info({message:"session 更新",meta:{session:e}}),this.chatSdkEventEmit(Ya.SESSION_CHANGED,{name:Ya.SESSION_CHANGED,data:e})}}__init5(){this.handleChatFinish=()=>{dc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]),this.chunkProcessor.clearMessageBuffer(),this.onMessageMonitor.destroy()}}__init6(){this.createSingleChunkBatch=e=>({msgId:e.msg_id,chunks:[e],startSeq:e.sequence_id,reason:"force"})}__init7(){this.processChunkBatchAndEmit=e=>{const{chunks:t}=e;if(0===t.length)return;const s=t.at(0);if(!s)return;const{query_msg_id:r,log_id:n,content:o}=s,i=pc(dc([o,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),()=>"");this.chunkProcessor.isFirstReplyMessage(s)&&dc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.pullStreamTracer,"optionalAccess",e=>e.receiveFirstAnsChunk,"call",e=>e(i,{log_id:n})]);const a=this.chunkProcessor.addBatchAndProcess(e);if(!a)throw new ac("processedMessage is undefined",{local_msg_id:i});this.chatSdkEventEmit(Ya.MESSAGE_PULLING_STATUS,{name:Ya.MESSAGE_PULLING_STATUS,data:{pullingStatus:"pulling",local_msg_id:i,query_msg_id:r}}),this.chatSdkEventEmit(Ya.MESSAGE_RECEIVED_AND_UPDATE,{name:Ya.MESSAGE_RECEIVED_AND_UPDATE,data:[a]})}}__init8(){this.handleChatMessage=e=>{const{content:t,type:s}=e,r=pc(dc([t,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),()=>"");if(!this.chunkProcessor.checkMessageHasProcessed(e)){if("message_end"===s){dc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]);const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new ac("processedMessage is undefined",{local_msg_id:r});return void this.handleMessageEnd(t)}if("message_start"===s){const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new ac("processedMessage is undefined",{local_msg_id:r});return void this.handleMessageStart(t)}if("error"===s){dc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]);const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new ac("processedMessage is undefined",{local_msg_id:r});return void this.handleMessageError(t)}this.enableBuffer&&this.bufferManager?this.bufferManager.enqueue(e):this.processChunkBatchAndEmit(this.createSingleChunkBatch(e))}}}__init9(){this.handleWebSocketChannelError=e=>{!e.ext.willClose&&e.ext.isQosError||(this.onMessageMonitor.destroy(),this.reportLogWithScope.error({message:"信道异常",error:e}),this.chatSdkEventEmit(Ya.MESSAGE_PULLING_STATUS,{name:Ya.MESSAGE_PULLING_STATUS,data:{pullingStatus:"channel_error",wsError:e}}),this.chatSdkEventEmit(Ya.CHANNEL_STATUS,{name:Ya.CHANNEL_STATUS,data:{channelStatus:"disconnected",message:e.message}}),this.handleChatFinish())}}__init10(){this.handleMessageEnd=e=>{const{query_msg_id:t,reply_id:s,content:r}=e,n=this.chunkProcessor.getReplyMessagesByQueryMsgId(t);dc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.pullStreamTracer,"optionalAccess",e=>e.success,"call",e=>e(t,{replyMessageCount:n})]),this.reportLogWithScope.info({message:"拉取回复完成",meta:{query_msg_id:t,message:e}});const o=r.message_end;switch(dc([o,"optionalAccess",e=>e.code])){case"0":this.chatSdkEventEmit(Ya.MESSAGE_PULLING_STATUS,{name:Ya.MESSAGE_PULLING_STATUS,data:{pullingStatus:"success",query_msg_id:t,reply_id:s,messageEndDetail:r.message_end}});break;case"1":this.chatSdkEventEmit(Ya.MESSAGE_PULLING_STATUS,{name:Ya.MESSAGE_PULLING_STATUS,data:{pullingStatus:"cancel",query_msg_id:t,messageEndDetail:r.message_end,reply_id:s}});break;default:this.chatSdkEventEmit(Ya.MESSAGE_PULLING_STATUS,{name:Ya.MESSAGE_PULLING_STATUS,data:{pullingStatus:"error",query_msg_id:t,messageEndDetail:r.message_end,reply_id:s,code:dc([o,"optionalAccess",e=>e.code]),message:dc([o,"optionalAccess",e=>e.message])}})}this.preSendLocalMessageEventsManager.emit(Xa.MESSAGE_END,e),this.handleChatFinish()}}__init11(){this.handleMessageError=e=>{const{query_msg_id:t,content:s}=e,r=dc([s,"access",e=>e.error,"optionalAccess",e=>e.local_msg_id]),n=pc(dc([s,"access",e=>e.error,"optionalAccess",e=>e.error_msg]),()=>""),o=new ac(n,{query_msg_id:t,local_msg_id:r,code:dc([s,"access",e=>e.error,"optionalAccess",e=>e.code])});dc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.pullStreamTracer,"optionalAccess",e=>e.error,"call",e=>e(o)]),this.reportLogWithScope.error({error:o,message:"收到错误消息",meta:{query_msg_id:t,local_msg_id:r,errorMessage:n}}),this.preSendLocalMessageEventsManager.emit(Xa.MESSAGE_SEND_AND_RECEIVE_ERROR,o),this.chatSdkEventEmit(Ya.SEND_MESSAGE_ERROR,{name:Ya.SEND_MESSAGE_ERROR,data:{error:o}}),this.handleChatFinish()}}__init12(){this.handleMessageStart=e=>{const{content:t,query_msg_id:s,log_id:r}=e,n=dc([t,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]);dc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.pullStreamTracer,"optionalAccess",e=>e.start,"call",e=>e(s,{logId:r})]),this.reportLogWithScope.info({message:"开始拉取回复",meta:{local_msg_id:n,query_msg_id:s,log_id:r}}),this.preSendLocalMessageEventsManager.emit(Xa.MESSAGE_SEND_SUCCESS,e),this.chatSdkEventEmit(Ya.MESSAGE_PULLING_STATUS,{name:Ya.MESSAGE_PULLING_STATUS,data:{pullingStatus:"start",local_msg_id:n,query_msg_id:s}})}}__init13(){this.handleChannelOpen=()=>{this.reportLogWithScope.info({message:"信道连接成功"}),this.chatSdkEventEmit(Ya.CHANNEL_STATUS,{name:Ya.CHANNEL_STATUS,data:{channelStatus:"connected"}})}}__init14(){this.handleChannelClose=({code:e,reason:t})=>{this.onMessageMonitor.destroy(),this.reportLogWithScope.info({message:"信道关闭",meta:{code:e,reason:t}}),this.chatSdkEventEmit(Ya.CHANNEL_STATUS,{name:Ya.CHANNEL_STATUS,data:{channelStatus:"disconnected",message:t}})}}__init15(){this.initChannel=async()=>{this.channel.isChannelOpen()||await this.channel.connect()}}destroy(){dc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.destroy,"call",e=>e()]),this.channel.destroy(),this.chatSdkEventBus.all.clear()}}function fc(e,t){return null!=e?e:t()}function gc(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}class mc{constructor({preSendLocalMessageFactory:e,channel:t,preSendLocalMessageEventsManager:s,reportLogWithScope:r,reportEventsTracer:n,chatSdkEventEmit:o}){mc.prototype.__init.call(this),this.preSendLocalMessageFactory=e,this.channel=t,this.preSendLocalMessageEventsManager=s,this.reportLogWithScope=r,this.reportEventsTracer=n,this.chatSdkEventEmit=o}createChannelErrorHandler(e){return()=>{const t=new ac("Error: during send message channel onerror",{local_msg_id:e});throw gc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.error,"call",e=>e(t)]),t}}__init(){this.createAckErrorHandler=e=>t=>{if("0"===t.code)return;const s=new ac(t.msg,{local_msg_id:e});throw this.chatSdkEventEmit(Ya.SEND_MESSAGE_ERROR,{name:Ya.SEND_MESSAGE_ERROR,data:{error:s}}),gc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.error,"call",e=>e(s)]),s}}startMessageTracing(e,t){gc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.start,"call",s=>s(e,{local_msg_id:e,...t})])}completeMessageTracing(e,t){gc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.success,"call",s=>s(e,t)])}traceMessageError(e,t){gc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.error,"call",e=>e(t)])}async sendCommandMessage(e){this.reportLogWithScope.info({message:"开始发送命令消息",meta:{message:e}}),await this.executeCommandMessage(e)}async executeCommandMessage(e){const{local_msg_id:t,type:s}=e;return this.startMessageTracing(t),new Promise((r,n)=>{const o=this.createCommandContext(e,r,n);this.setupCommandEventListeners(o),this.sendMessageWithChannel(e,t).then(()=>this.handleCommandSendSuccess(s,t,o.promiseHandlers.resolve)).catch(e=>this.handleCommandSendError(e,t,o.promiseHandlers.reject))})}createCommandContext(e,t,s){const r={resolve:()=>{a(),t()},reject:e=>{a(),s(e)}},{local_msg_id:n,type:o}=e,i=[],a=()=>{i.forEach(e=>e())};return{localMsgId:n,type:o,eventCleanup:i,cleanup:a,handleMessageEnd:e=>{"cancel"===o&&(this.completeMessageTracing(n,{logId:e.log_id}),r.resolve())},promiseHandlers:r}}setupCommandEventListeners(e){const{localMsgId:t,type:s,eventCleanup:r,handleMessageEnd:n}=e,o=this.createChannelErrorHandler(t),i=this.createAckErrorHandler(t),a=()=>{try{o()}catch(t){e.promiseHandlers.reject(t)}},c=t=>{try{i(t)}catch(t){e.promiseHandlers.reject(t)}};this.channel.addEventListener("onerror",a),this.channel.addEventListener("onack",c),r.push(()=>this.channel.removeEventListener("onerror",a)),r.push(()=>this.channel.removeEventListener("onack",c)),"cancel"===s&&(this.preSendLocalMessageEventsManager.on(Xa.MESSAGE_END,n),r.push(()=>this.preSendLocalMessageEventsManager.off(Xa.MESSAGE_END,n)))}handleCommandSendSuccess(e,t,s){"input"===e&&(this.completeMessageTracing(t),s())}handleCommandSendError(e,t,s){const r=new ac(`Error: channel send command message error: ${String(e)}`,{local_msg_id:t});this.traceMessageError(t,r),s(r)}async sendChatMessage(e,t){this.reportLogWithScope.info({message:"开始发送聊天消息",meta:{message:e}});const s=this.preSendLocalMessageFactory.getSendChatMessageStructure(e,t);return await this.executeChatMessage(s,t)}executeChatMessage(e,t){const{local_msg_id:s}=e,r=fc(gc([t,"optionalAccess",e=>e.sendTimeout]),()=>6e4);return new Promise((t,n)=>{const o=this.createChatContext(e,t,n);this.setupChatEventListeners(o,r),this.startMessageTracing(s),this.sendMessageWithChannel(e,s).catch(e=>this.handleChatSendError(e,s,o.promiseHandlers.reject))})}createChatContext(e,t,s){const r={resolve:e=>{i(),t(e)},reject:e=>{i(),s(e)}},{local_msg_id:n}=e,o=[],i=()=>{o.forEach(e=>e())};return{localMsgId:n,message:e,eventCleanup:o,cleanup:i,promiseHandlers:r}}setupChatEventListeners(e,t){const{localMsgId:s,eventCleanup:r,promiseHandlers:n}=e,o=this.setupTimeoutHandler(s,t,n.reject);r.push(()=>clearTimeout(o));const i=this.createChannelErrorHandler(s),a=this.createAckErrorHandler(s),c=()=>{try{i()}catch(e){n.reject(e)}},l=e=>{try{a(e)}catch(e){n.reject(e)}};this.channel.addEventListener("onerror",c),this.channel.addEventListener("onack",l),r.push(()=>this.channel.removeEventListener("onerror",c)),r.push(()=>this.channel.removeEventListener("onack",l));const u=this.createMessageSuccessHandler(e);this.preSendLocalMessageEventsManager.on(Xa.MESSAGE_SEND_SUCCESS,u),r.push(()=>this.preSendLocalMessageEventsManager.off(Xa.MESSAGE_SEND_SUCCESS,u));const h=this.createMessageFailedHandler(s,n.reject);this.preSendLocalMessageEventsManager.on(Xa.MESSAGE_SEND_AND_RECEIVE_ERROR,h),r.push(()=>this.preSendLocalMessageEventsManager.off(Xa.MESSAGE_SEND_AND_RECEIVE_ERROR,h))}setupTimeoutHandler(e,t,s){return setTimeout(()=>{gc([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.timeout,"call",t=>t(e)]);const t=new ac("send chat message timeout",{local_msg_id:e});this.preSendLocalMessageEventsManager.emit(Xa.MESSAGE_SEND_TIMEOUT,t),s(t)},t)}createMessageSuccessHandler(e){const{localMsgId:t,message:s,promiseHandlers:r}=e;return e=>{const n=gc([e,"access",e=>e.content,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),o=gc([e,"access",e=>e.content,"access",e=>e.message_start,"optionalAccess",e=>e.msg_id]);if(n!==t)return;this.completeMessageTracing(t,{logId:e.log_id});const i={...s,msg_id:fc(o,()=>""),role:"user"};r.resolve({message:i,status:"message_start"})}}createMessageFailedHandler(e,t){return s=>{s.ext.local_msg_id===e&&(this.traceMessageError(e,s),t(s))}}handleChatSendError(e,t,s){const r=new ac(`Error: channel send chat message error: ${String(e)}`,{local_msg_id:t});this.traceMessageError(t,r),s(e)}async sendMessageWithChannel(e,t){try{await this.ensureChannelReadyAndSend(e)}catch(e){const s=new ac((e=>e instanceof Error?e.message:"object"==typeof e?JSON.stringify(e):String(e))(e),{local_msg_id:t});throw this.traceMessageError(t,s),s}}async ensureChannelReadyAndSend(e){return this.channel.isChannelOpenPromise?await this.channel.isChannelOpenPromise:this.channel.isChannelOpen()||await this.channel.connect(),await this.channel.send(e)}}function Ec(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}var Tc;!function(e){e.SDK_INIT="chat_sdk_init";e.SDK_MESSAGE_UPLOAD_FAIL="chat_sdk_message_upload_fail";e.SDK_BREAK_MESSAGE="chat_sdk_break_message";e.SDK_MESSAGE_SEND_TRACER="chat_sdk_message_send_tracer";e.SDK_PULL_STREAM_TRACER="chat_sdk_pull_stream_tracer"}(Tc||(Tc={}));class Ac{__init(){this.eventTracers=new Map}constructor(e){Ac.prototype.__init.call(this),Ac.prototype.__init2.call(this),Ac.prototype.__init3.call(this),this.reporter=e}__init2(){this.sendMessageTracer={start:(e,t)=>{const{trace:s}=this.createTracer(Tc.SDK_MESSAGE_SEND_TRACER);this.setTracer(e,Tc.SDK_MESSAGE_SEND_TRACER,{trace:s}),Ec([s,"optionalCall",e=>e("start",{meta:t})])},success:(e,t)=>{const{trace:s}=this.getTracer(e,Tc.SDK_MESSAGE_SEND_TRACER);Ec([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,Tc.SDK_MESSAGE_SEND_TRACER),this.pullStreamTracer.start(e,t)},inqueue:(e,t)=>{const{trace:s}=this.getTracer(e,Tc.SDK_MESSAGE_SEND_TRACER);Ec([s,"optionalCall",e=>e("inqueue",{meta:t})]),this.deleteTracer(e,Tc.SDK_MESSAGE_SEND_TRACER)},error:e=>{const{local_msg_id:t}=e.ext;if(!t)return;const{trace:s}=this.getTracer(t,Tc.SDK_MESSAGE_SEND_TRACER);Ec([s,"optionalCall",t=>t("error",{meta:e.flatten(),error:e})]),this.deleteTracer(t,Tc.SDK_MESSAGE_SEND_TRACER)},timeout:e=>{const{trace:t}=this.getTracer(e,Tc.SDK_MESSAGE_SEND_TRACER);Ec([t,"optionalCall",e=>e("timeout")]),this.deleteTracer(e,Tc.SDK_MESSAGE_SEND_TRACER)}}}__init3(){this.pullStreamTracer={start:(e,t)=>{const{trace:s}=this.createTracer(Tc.SDK_PULL_STREAM_TRACER);this.setTracer(e,Tc.SDK_PULL_STREAM_TRACER,{trace:s,meta:t}),Ec([s,"optionalCall",e=>e("start",{meta:t})])},success:(e,t)=>{const{trace:s}=this.getTracer(e,Tc.SDK_PULL_STREAM_TRACER);Ec([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,Tc.SDK_PULL_STREAM_TRACER)},break:(e,t)=>{const{trace:s}=this.getTracer(e,Tc.SDK_PULL_STREAM_TRACER);Ec([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,Tc.SDK_PULL_STREAM_TRACER)},error:(e,t)=>{const{query_msg_id:s}=e.ext;if(!s)return;const{trace:r}=this.getTracer(s,Tc.SDK_PULL_STREAM_TRACER);Ec([r,"optionalCall",s=>s("error",{meta:{...e.flatten(),...t},error:e})]),this.deleteTracer(s,Tc.SDK_PULL_STREAM_TRACER)},timeout:e=>{const{query_msg_id:t}=e.ext;if(!t)return;const{trace:s}=this.getTracer(t,Tc.SDK_PULL_STREAM_TRACER);Ec([s,"optionalCall",t=>t("timeout",{meta:e.flatten(),error:e})]),this.deleteTracer(t,Tc.SDK_PULL_STREAM_TRACER)},receiveFirstAnsChunk:(e,t)=>{const{trace:s}=this.getTracer(e,Tc.SDK_PULL_STREAM_TRACER);Ec([s,"optionalCall",e=>e("first_ans_chunk",{meta:t})])}}}static getUniqueKey(e,t){return`${e}_${t}`}getTracer(e,t){return this.eventTracers.get(Ac.getUniqueKey(e,t))||{trace:void 0}}setTracer(e,t,s){const{trace:r,meta:n}=s;this.eventTracers.set(Ac.getUniqueKey(e,t),{trace:r,meta:n})}deleteTracer(e,t){this.eventTracers.delete(Ac.getUniqueKey(e,t))}createTracer(e){return this.reporter.slardarTracer({eventName:e})}}class Rc{static __initStatic(){this.instances=new Map}static __initStatic2(){this.EVENTS=Ya}__init(){this.enableDebug=!1}__init2(){this.eventBus=t()}constructor(e){Rc.prototype.__init.call(this),Rc.prototype.__init2.call(this),Rc.prototype.__init3.call(this),Rc.prototype.__init4.call(this),Rc.prototype.__init5.call(this),Rc.prototype.__init6.call(this),Rc.prototype.__init7.call(this),Rc.prototype.__init8.call(this),Rc.prototype.__init9.call(this),Rc.prototype.__init10.call(this);const{enableDebug:t,logLevel:s,env:r,key:n}=e;this.key=n,this.enableDebug=Boolean(t),this.logLevel=s||"error",this.env=r,this.reportLog=e.reportLog,this.reportLog.init(),this.reportLogWithScope=this.reportLog.createLoggerWith({scope:"chat-sdk",meta:{key:n}}),this.reportEventsTracer=new Ac(this.reportLogWithScope),this.requestManager=new ha({options:e.requestManagerOptions,reportLog:this.reportLog}),this.preSendLocalMessageEventsManager=new pa,this.preSendLocalMessageFactory=new da,this.chunkProcessor=new Qa({getEnableDebug:()=>this.enableDebug,initMessageBuffer:e.initMessageBuffer,initMaxSequenceId:e.initMaxSequenceId,enableChunkProcessedCheck:e.enableChunkProcessedCheck,reportLogWithScope:this.reportLogWithScope,key:n}),this.channel=e.channel,this.createMessageService=new Xs,this.sendMessageService=new mc({preSendLocalMessageFactory:this.preSendLocalMessageFactory,channel:this.channel,preSendLocalMessageEventsManager:this.preSendLocalMessageEventsManager,reportLogWithScope:this.reportLogWithScope,reportEventsTracer:this.reportEventsTracer,chatSdkEventEmit:this.emit}),this.websocketService=new _c({channel:this.channel,reportLogWithScope:this.reportLogWithScope,chunkProcessor:this.chunkProcessor,preSendLocalMessageEventsManager:this.preSendLocalMessageEventsManager,chatSdkEventEmit:this.emit,chatSdkEventBus:this.eventBus,reportEventsTracer:this.reportEventsTracer,manualInitChannel:Boolean(e.manualInitChannel),enableBuffer:Boolean(e.enableBuffer)}),this.onEvents(),this.reportLogWithScope.slardarEvent({eventName:Tc.SDK_INIT,meta:{...e}}),this.reportLogWithScope.info({message:"SDK 初始化完成"})}static create(e){const{key:t}=e;if(Rc.instances.has(t))return console.error("duplicate chat core instance error"),Rc.instances.get(t);const s=new Rc(e);return Rc.instances.set(t,s),s}onEvents(){this.websocketService.onChannelEvents()}destroy(){this.websocketService.destroy(),this.eventBus.all.clear(),this.chunkProcessor.destroy(),Rc.instances.delete(this.key),this.preSendLocalMessageEventsManager.destroy(),this.reportLogWithScope.info({message:"SDK销毁"})}__init3(){this.on=(e,t,s)=>(this.eventBus.all.has(e)&&!s&&this.reportLogWithScope.slardarError({message:"重复监听事件",error:new Error("重复监听"),meta:{event:e}}),this.eventBus.on(e,t),()=>{this.eventBus.off(e,t)})}__init4(){this.off=(e,t)=>{this.eventBus.off(e,t)}}__init5(){this.emit=(e,t)=>{this.eventBus.emit(e,t)}}createQueryMessage(...e){return this.createMessageService.createQueryMessage(...e)}createRetryMessage(...e){return this.createMessageService.createRetryMessage(...e)}createEditMessage(...e){return this.createMessageService.createEditMessage(...e)}createInterruptMessage(...e){return this.createMessageService.createInputMessage(...e)}createCancelMessage(...e){return this.createMessageService.createCancelMessage(...e)}sendChatMessage(e,t){return this.sendMessageService.sendChatMessage(e,t)}sendCommandMessage(e){return this.sendMessageService.sendCommandMessage(e)}__init6(){this.getHistoryMessage=(...e)=>this.requestManager.getSceneConfig(T.GetMessage)(...e)}__init7(){this.isChannelOpen=()=>this.channel.isChannelOpenPromise?"connecting":this.channel.isChannelOpen()?"connected":"disconnected"}__init8(){this.initChannel=()=>this.websocketService.initChannel()}__init9(){this.captureStreamBuffer=()=>this.chunkProcessor.getStreamBufferWithMeta()}__init10(){this.captureStreamBufferSnapshot=()=>this.chunkProcessor.getStreamBufferSnapshot()}}Rc.__initStatic(),Rc.__initStatic2(),exports.ExitCode=void 0,function(e){e[e.SUCCESS=0]="SUCCESS";e[e.GENERAL_ERROR=1]="GENERAL_ERROR";e[e.AUTH_FAILED=2]="AUTH_FAILED";e[e.RESOURCE_NOT_FOUND=3]="RESOURCE_NOT_FOUND";e[e.INVALID_ARGUMENT=4]="INVALID_ARGUMENT";e[e.PERMISSION_DENIED=5]="PERMISSION_DENIED";e[e.NETWORK_ERROR=6]="NETWORK_ERROR";e[e.SERVER_ERROR=7]="SERVER_ERROR";e[e.TIMEOUT=8]="TIMEOUT";e[e.QUOTA_EXCEEDED=9]="QUOTA_EXCEEDED";e[e.CONFLICT=10]="CONFLICT"}(exports.ExitCode||(exports.ExitCode={}));class Lc extends Error{constructor(e,t=exports.ExitCode.GENERAL_ERROR,s){super(e),this.name="CozeError",this.code=t,this.details=s,Object.setPrototypeOf(this,Lc.prototype)}}class Sc{constructor(){Sc.prototype.__init.call(this)}__init(){this.headers={}}setHeaders(t){this.headers=e.merge({},this.headers,t)}getHeaders(){return this.headers}resetHeaders(){this.headers={}}setDispatcher(e){this.dispatcher=e}clearDispatcher(){this.dispatcher=void 0}async fetch(t,s){const r=e.merge({},this.headers,function(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}([s,"optionalAccess",e=>e.headers]));return E.fetch(t,{...s,headers:r,dispatcher:this.dispatcher})}}const yc=new Sc;var bc,Cc,vc,Ic,Oc,Nc,Mc,wc,Uc,kc,Pc,Bc,jc,Dc,xc,Fc,qc,Gc,Hc,zc;function Wc(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}!function(e){e[e.develop=0]="develop";e[e.product=1]="product"}(bc||(bc={})),function(e){e[e.active=0]="active";e[e.creating=1]="creating"}(Cc||(Cc={})),function(e){e[e.postgre=0]="postgre";e[e.supabase=1]="supabase"}(vc||(vc={})),function(e){e[e.SQL=1]="SQL";e[e.REPORT=2]="REPORT";e[e.LOG_SQL=3]="LOG_SQL"}(Ic||(Ic={})),function(e){e[e.NAME=1]="NAME";e[e.INSERTED_AT=2]="INSERTED_AT"}(Oc||(Oc={})),function(e){e[e.ASC=1]="ASC";e[e.DESC=2]="DESC"}(Nc||(Nc={})),function(e){e[e.USER=1]="USER";e[e.PROJECT=2]="PROJECT";e[e.ORG=3]="ORG";e[e.PUBLIC=4]="PUBLIC"}(Mc||(Mc={})),function(e){e.FileBatchDelete="file.batch_delete";e.FileBatchMove="file.batch_move";e.FileChanged="file.changed";e.FileCreate="file.create";e.FileDelete="file.delete";e.FileGrep="file.grep";e.FileList="file.list";e.FileMove="file.move";e.FilePack="file.pack";e.FilePatch="file.patch";e.FileRead="file.read";e.FileReplace="file.replace";e.FileSearch="file.search";e.FileStat="file.stat";e.FileWrite="file.write";e.GetAppLog="log.get_app_log";e.GetCurrentCanvas="canvas.get_current";e.GetExecuteLog="test.get_execute_log";e.GetInOutSchema="canvas.get_inout_schema";e.GetSourceCode="canvas.get_source_code";e.LspCompletion="lsp.completion";e.LspCompletionItemResolve="lsp.completionItemResolve";e.LspDefinition="lsp.definition";e.LspDidChange="lsp.didChange";e.LspDidClose="lsp.didClose";e.LspDidOpen="lsp.didOpen";e.LspGetDiagnosticsCli="lsp.getDiagnosticsCli";e.LspHover="lsp.hover";e.LspOnNotification="lsp.onNotification";e.LspReferences="lsp.references";e.LspRestart="lsp.restart";e.LspSignatureHelp="lsp.signatureHelp";e.NodeDebug="node.debug";e.PageRouterGetPage="page_router.get_routes";e.PreviewReload="preview.reload";e.RepoCommitFileDiff="repo_version.commit.file.diff";e.RepoCommitFileRead="repo_version.commit.file.read";e.RepoCommitList="repo_version.commit.list";e.RepoCommitRetrieve="repo_version.commit.retrieve";e.RepoCommitSearch="repo_version.commit.search";e.RepoCommitStatus="repo_version.commit.status";e.RepoCommitVersionDiff="repo_version.commit.diff";e.RepoCommitVersions="repo_version.commit.versions";e.RepoVersionCodeStage="repo_version.commit.stage";e.RepoVersionCodeUnstage="repo_version.commit.restore";e.RepoVersionEvent="repo_version.event";e.RepoVersionFileRead="repo_version.file.read";e.RepoVersionLatest="repo_version.commit.version.latest";e.SandboxBroadcast="sandbox.broadcast";e.SandboxPing="sandbox.ping";e.SandboxProjectStatus="sandbox.project_status";e.SandboxProjectStatusNotify="sandbox.project_status_notify";e.ShellClose="shell.close";e.ShellCreate="shell.create";e.ShellExecute="shell.execute";e.ShellExited="shell.exited";e.ShellInput="shell.input";e.ShellOutput="shell.output";e.ShellResize="shell.resize";e.TestRun="test.run";e.TestValidate="test.validate";e.WebIsServerStart="web.is_server_start";e.WebStartServer="web.start_server"}(wc||(wc={})),function(e){e[e.text=0]="text";e[e.url=1]="url";e[e.uri=2]="uri"}(Uc||(Uc={})),(kc||(kc={})).PdfTargetFileType="pdf",function(e){e.TabAuthentication="Authentication"}(Pc||(Pc={})),function(e){e.FeatureApp="app";e.FeatureAssistantAgent="assistantagent";e.FeatureSkill="skill";e.FeatureWechatMiniProgram="wechatminiprogram"}(Bc||(Bc={})),function(e){e.SceneRecommendProjectCases="RecommendProjectCases";e.SceneSubmitWorkPoint="SubmitWorkPoint"}(jc||(jc={})),function(e){e[e.CozeSpace=1]="CozeSpace";e[e.Ark=2]="Ark"}(Dc||(Dc={})),function(e){e.ProjectTypeAgent="Agent";e.ProjectTypeApp="App";e.ProjectTypeAssistantAgent="AssistantAgent";e.ProjectTypeAutomation="Automation";e.ProjectTypeGeneralWeb="GeneralWeb";e.ProjectTypeSkill="Skill";e.ProjectTypeWechatMiniProgram="WechatMiniProgram"}(xc||(xc={})),function(e){e[e.Agent=0]="Agent";e[e.Ask=1]="Ask"}(Fc||(Fc={})),exports.VibeProjectType=void 0,function(e){e[e.Agent=1]="Agent";e[e.Automation=2]="Automation";e[e.WebApp=3]="WebApp";e[e.App=4]="App";e[e.Skill=5]="Skill";e[e.GeneralWeb=6]="GeneralWeb";e[e.WechatMiniProgram=7]="WechatMiniProgram";e[e.AssistantAgent=8]="AssistantAgent";e[e.CLIBilling=101]="CLIBilling"}(exports.VibeProjectType||(exports.VibeProjectType={})),function(e){e[e.Unknown=0]="Unknown";e[e.String=1]="String";e[e.Boolean=2]="Boolean";e[e.StringList=11]="StringList";e[e.BooleanList=12]="BooleanList"}(qc||(qc={})),function(e){e[e.Account=1]="Account";e[e.Workspace=2]="Workspace";e[e.VibeProject=38]="VibeProject";e[e.PostgresDatabase=39]="PostgresDatabase";e[e.Storage=40]="Storage"}(Gc||(Gc={})),function(e){e.PdfTargetFileType="pdf";e.XlsxTargetFileType="xlsx"}(Hc||(Hc={})),function(e){e[e.move=0]="move";e[e.copy=1]="copy"}(zc||(zc={}));class $c{__init(){this.request=zi}__init2(){this.baseURL=""}constructor(e){$c.prototype.__init.call(this),$c.prototype.__init2.call(this),this.request=Wc([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Wc([e,"optionalAccess",e=>e.baseURL])||this.baseURL}genBaseURL(e){return"string"==typeof this.baseURL?this.baseURL+e:this.baseURL(e)}GetVibeGlobalSettings(e,t){const s=this.genBaseURL("/api/ideserver_api/project/get_vibe_global_settings");return this.request({url:s,method:"POST"},t)}UpdateVibeGlobalSettings(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/update_vibe_global_settings"),n={global_settings:s.global_settings};return this.request({url:r,method:"POST",data:n},t)}GetVibeProjectCases(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/get_vibe_project_cases"),n={project_type:s.project_type};return this.request({url:r,method:"POST",data:n},t)}UpdateVibeProject(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/project/update_vibe_project"),n={project_id:s.project_id,name:s.name,description:s.description,icon_uri:s.icon_uri,project_settings:s.project_settings};return this.request({url:r,method:"POST",data:n},t)}CopyVibeProject(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/project/copy_vibe_project"),n={project_id:s.project_id,name:s.name,description:s.description,icon_uri:s.icon_uri,icon_url:s.icon_url,target_space_id:s.target_space_id};return this.request({url:r,method:"POST",data:n},t)}ChatCreateVibeProject(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/project/create_vibe_project"),n={space_id:s.space_id,user_query:s.user_query,project_type:s.project_type,agent_tools:s.agent_tools,project_settings:s.project_settings};return this.request({url:r,method:"POST",data:n},t)}UploadFile(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/upload_file"),n={data:s.data},o={"Content-Type":s["Content-Type"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetVibeProject(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/project/get_vibe_project"),n={project_id:s.project_id};return this.request({url:r,method:"POST",data:n},t)}CreatePostgresqlDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/postgresql"),n={project_id:s.project_id,user_id:s.user_id,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}CreateStorageBucket(e,t){const s=e,r=this.genBaseURL("/api/memory/storage/create"),n={project_id:s.project_id,user_id:s.user_id,bucket_name:s.bucket_name,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}ListStorageBucket(e,t){const s=e||{},r=this.genBaseURL("/api/memory/storage/list"),n={project_id:s.project_id,bucket_ids:s.bucket_ids,env:s.env};return this.request({url:r,method:"POST",data:n},t)}ListPostgresqlDatabase(e,t){const s=e||{},r=this.genBaseURL("/api/memory/databases/postgresql/list"),n={project_id:s.project_id,database_ids:s.database_ids,env:s.env};return this.request({url:r,method:"POST",data:n},t)}RestorePostgresqlDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/postgresql/restore"),n={project_id:s.project_id,database_ids:s.database_ids,env:s.env,timestamp:s.timestamp};return this.request({url:r,method:"POST",data:n},t)}DeleteStorageBucket(e,t){const s=e||{},r=this.genBaseURL("/api/memory/storage/delete"),n={project_id:s.project_id,bucket_ids:s.bucket_ids};return this.request({url:r,method:"POST",data:n},t)}DeletePostgresqlDatabase(e,t){const s=e||{},r=this.genBaseURL("/api/memory/databases/postgresql/delete"),n={project_id:s.project_id,database_ids:s.database_ids};return this.request({url:r,method:"POST",data:n},t)}CheckRestorePossibility(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/postgresql/restore/check"),n={project_id:s.project_id,database_ids:s.database_ids,env:s.env,timestamp:s.timestamp};return this.request({url:r,method:"POST",data:n},t)}CreateStorageFolder(e,t){const s=e,r=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/folder/create`),n={folder_name:s.folder_name};return this.request({url:r,method:"POST",data:n},t)}GetFileURL(e,t){const s=e,r=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/get_url`),n={uri_list:s.uri_list,expired_time:s.expired_time};return this.request({url:r,method:"POST",data:n},t)}StorageFileMigrate(e,t){const s=e,r=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/migrate`),n={folder_name_list:s.folder_name_list,obj_name_list:s.obj_name_list,target_folder:s.target_folder,action:s.action};return this.request({url:r,method:"POST",data:n},t)}UploadStorageFile(e,t){const s=e,r=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/upload`),n={body:s.body},o={"Content-Type":s["Content-Type"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}StorageFileRename(e,t){const s=e,r=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/rename`),n={rename_list:s.rename_list};return this.request({url:r,method:"POST",data:n},t)}DeleteStorageFile(e,t){const s=e,r=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/delete`),n={folder_name_list:s.folder_name_list,obj_name_list:s.obj_name_list};return this.request({url:r,method:"POST",data:n},t)}ListStorageObjects(e,t){const s=e,r=this.genBaseURL(`/api/memory/storage/${s.bucket_id}/file/list`),n={prefix:s.prefix,page_size:s.page_size,page_token:s.page_token,search_key:s.search_key};return this.request({url:r,method:"POST",data:n},t)}CreateContent(e,t){const s=e||{},r=this.genBaseURL(`/api/memory/databases/${s.database_id}/content`),n={id:s.id,name:s.name,type:s.type,visibility:s.visibility,description:s.description,favorite:s.favorite,folder_id:s.folder_id,owner_id:s.owner_id,content_json:s.content_json};return this.request({url:r,method:"POST",data:n},t)}UpdateWholeContent(e,t){const s=e||{},r=this.genBaseURL(`/api/memory/databases/${s.database_id}/content`),n={id:s.id,name:s.name,type:s.type,visibility:s.visibility,description:s.description,favorite:s.favorite,folder_id:s.folder_id,owner_id:s.owner_id,content_json:s.content_json};return this.request({url:r,method:"PUT",data:n},t)}DeleteContents(e,t){const s=e||{},r=this.genBaseURL(`/api/memory/databases/${s.database_id}/content`),n={ids:s.ids};return this.request({url:r,method:"DELETE",data:n},t)}GetContentById(e,t){const s=e||{},r=this.genBaseURL(`/api/memory/databases/${s.database_id}/content/${s.item_id}`);return this.request({url:r,method:"GET"},t)}GetContent(e,t){const s=e||{},r=this.genBaseURL(`/api/memory/databases/${s.database_id}/content`),n={cursor:s.cursor,favorite:s.favorite,limit:s.limit,name:s.name,sort_by:s.sort_by,sort_order:s.sort_order,type:s.type,visibility:s.visibility};return this.request({url:r,method:"GET",params:n},t)}UploadProjectFile(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/sandbox/file/upload"),n={body:s.body},o={"Content-Type":s["Content-Type"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}InitSandbox(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/sandbox/init_sandbox"),n={project_id:s.project_id},o={"x-devbox-cli-env":s["x-devbox-cli-env"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetProjectFileUrl(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/sandbox/file/get_url"),n={file_path:s.file_path,project_id:s.project_id};return this.request({url:r,method:"GET",params:n},t)}UpdateRestoreRetention(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/postgresql/restore/retention"),n={database_id:s.database_id,retention_hours:s.retention_hours};return this.request({url:r,method:"POST",data:n},t)}RestoreRepoVersion(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/repository/restore"),n={ProjectID:s.ProjectID,CommitID:s.CommitID,NoConfirm:s.NoConfirm,ConfirmInfos:s.ConfirmInfos};return this.request({url:r,method:"POST",data:n},t)}RefreshVibeProjectCases(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/refresh_vibe_project_cases"),n={refresh_token:s.refresh_token};return this.request({url:r,method:"POST",data:n},t)}GetUserQueryForCreate(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/get_user_query_for_create"),n={query_id:s.query_id,scene:s.scene},o={Cookie:s.Cookie};return this.request({url:r,method:"POST",data:n,headers:o},t)}DeleteVibeProject(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/project/delete_vibe_project"),n={project_id:s.project_id};return this.request({url:r,method:"POST",data:n},t)}CheckUserFeature(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/check_user_feature"),n={feature_keys:s.feature_keys};return this.request({url:r,method:"POST",data:n},t)}UpsertVibeProjectShare(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/upsert_share_info"),n={project_id:s.project_id,is_public_share:s.is_public_share,relative_expired_time:s.relative_expired_time};return this.request({url:r,method:"POST",data:n},t)}GetVibeProjectShare(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/get_share_info"),n={project_id:s.project_id};return this.request({url:r,method:"POST",data:n},t)}GetProtectSchemaList(e,t){const s=this.genBaseURL("/api/memory/databases/postgresql/get_protect_schema");return this.request({url:s,method:"POST"},t)}BatchImportData(e,t){const s=e,r=this.genBaseURL("/v1/knowledge_base/batch_import"),n={dataset:s.dataset,data:s.data,chunk_config:s.chunk_config},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetSchemaTables(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/postgresql/get_schema_tables"),n={project_id:s.project_id,database_env:s.database_env,schema:s.schema};return this.request({url:r,method:"POST",data:n},t)}ConvertFile(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/sandbox/file/convert"),n={file_path:s.file_path,project_id:s.project_id,target_file_type:s.target_file_type};return this.request({url:r,method:"GET",params:n},t)}GetDatabaseSupportVector(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/postgresql/get_support_vector"),n={database_id:s.database_id};return this.request({url:r,method:"POST",data:n},t)}RecallData(e,t){const s=e,r=this.genBaseURL("/v1/knowledge_base/recall"),n={dataset:s.dataset,query:s.query,top_k:s.top_k,min_score:s.min_score},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetFileInterfaceConfig(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/sandbox/file/get_interface_config"),n={project_id:s.project_id};return this.request({url:r,method:"GET",params:n},t)}UpsertProjectCopyType(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/upsert_copy_type"),n={project_id:s.project_id,enable_cross_space_copy:s.enable_cross_space_copy};return this.request({url:r,method:"POST",data:n},t)}OpenGetVibeProjectInfo(e,t){const s=e||{},r=this.genBaseURL(`/v1/vibe_projects/${s.project_id}`);return this.request({url:r,method:"GET"},t)}ImportSpaceDevAgent(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/project/import_space_dev_agent"),n={task_id:s.task_id,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}CreateCommit(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/repository/create_commit"),n={ProjectID:s.ProjectID,message:s.message};return this.request({url:r,method:"POST",data:n},t)}ListBuckets(e,t){const s=e,r=this.genBaseURL("/v1/supabase/buckets/list"),n={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",headers:n},t)}DeleteBucket(e,t){const s=e,r=this.genBaseURL("/v1/supabase/buckets/delete"),n={bucket_id:s.bucket_id},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetEdgeFunction(e,t){const s=e,r=this.genBaseURL("/v1/supabase/functions/get"),n={slug:s.slug},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}DeleteEdgeFunction(e,t){const s=e,r=this.genBaseURL("/v1/supabase/functions/delete"),n={slug:s.slug},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}ListEdgeFunctions(e,t){const s=e,r=this.genBaseURL("/v1/supabase/functions/list"),n={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",headers:n},t)}UpdateAuthConfig(e,t){const s=e,r=this.genBaseURL("/v1/supabase/auth/config/update"),n={config:s.config},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetBucket(e,t){const s=e,r=this.genBaseURL("/v1/supabase/buckets/get"),n={bucket_id:s.bucket_id},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetAuthConfig(e,t){const s=e,r=this.genBaseURL("/v1/supabase/auth/config/get"),n={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",headers:n},t)}UpdateBucket(e,t){const s=e,r=this.genBaseURL("/v1/supabase/buckets/update"),n={bucket_id:s.bucket_id,public:s.public,file_size_limit:s.file_size_limit,allowed_mime_types:s.allowed_mime_types},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}DeployEdgeFunction(e,t){const s=e,r=this.genBaseURL("/v1/supabase/functions/deploy"),n={slug:s.slug,code:s.code,files:s.files,name:s.name,entrypoint:s.entrypoint,verify_jwt:s.verify_jwt},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}CreateBucket(e,t){const s=e,r=this.genBaseURL("/v1/supabase/buckets/create"),n={bucket_id:s.bucket_id,name:s.name,public:s.public,file_size_limit:s.file_size_limit,allowed_mime_types:s.allowed_mime_types},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}OpenConvertFile(e,t){const s=e||{},r=this.genBaseURL("/v1/vibe_projects/files/convert"),n={project_id:s.project_id,file_url:s.file_url,target_file_type:s.target_file_type};return this.request({url:r,method:"POST",data:n},t)}OpenUploadFile(e,t){const s=e||{},r=this.genBaseURL("/v1/vibe_projects/files/upload"),n={body:s.body},o={"Content-Type":s["Content-Type"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetUserAssistantAttrs(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/get_user_assistant_attrs"),n={space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}GetProjectArtifactShare(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/get_artifact_share"),n={project_id:s.project_id};return this.request({url:r,method:"POST",data:n},t)}UpsertProjectArtifactShare(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/upsert_artifact_share"),n={project_id:s.project_id,is_artifact_share:s.is_artifact_share,relative_expired_time:s.relative_expired_time};return this.request({url:r,method:"POST",data:n},t)}GetUserProjectNum(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/get_user_project_num"),n={enterprise_id:s.enterprise_id,organization_id:s.organization_id};return this.request({url:r,method:"POST",data:n},t)}GetLarkTableContent(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/get_content"),n={scene:s.scene};return this.request({url:r,method:"POST",data:n},t)}GetProjectStatus(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/sandbox/project_status"),n={project_id:s.project_id};return this.request({url:r,method:"GET",params:n},t)}UpdateProjectSkillSetting(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/update_project_skill_setting"),n={project_id:s.project_id,add_skills:s.add_skills,remove_skills:s.remove_skills};return this.request({url:r,method:"POST",data:n},t)}ProxySandboxMessage(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/repository/proxy_sandbox_message"),n={ProjectID:s.ProjectID,Method:s.Method,Params:s.Params};return this.request({url:r,method:"POST",data:n},t)}DiagnoseDatabaseHTTP(e,t){const s=e,r=this.genBaseURL("/v1/supabase/database/diagnose"),n={env:s.env},o={"x-coze-token":s["x-coze-token"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetProjectDisplayTabInfo(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/get_display_tab_info"),n={project_id:s.project_id};return this.request({url:r,method:"POST",data:n},t)}GetOrCreateBillingProject(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/get_or_create_billing_project"),n={space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}}$c.prototype.UploadProjectFile=function(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/sandbox/file/upload"),n=s.body;return this.request({url:r,method:"POST",data:n},t)},$c.prototype.UploadFile=function(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/upload_file"),n=s.data;return this.request({url:r,method:"POST",data:n},t)};const Vc=new $c({});function Kc(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}const Jc=/(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g;class Qc{constructor(){Qc.prototype.__init.call(this),Qc.prototype.__init2.call(this),Qc.prototype.__init3.call(this),Qc.prototype.__init4.call(this),Qc.prototype.__init5.call(this),Qc.prototype.__init6.call(this),Qc.prototype.__init7.call(this),Qc.prototype.__init8.call(this),Qc.prototype.__init9.call(this),Qc.prototype.__init10.call(this),Qc.prototype.__init11.call(this),Qc.prototype.__init12.call(this)}__init(){this.ctx={options:{},get:()=>({})}}__init2(){this.init=e.noop}__init3(){this.createLoggerWith=()=>new Qc}__init4(){this.info=e.noop}__init5(){this.error=e.noop}__init6(){this.slardarInfo=e.noop}__init7(){this.slardarSuccess=e.noop}__init8(){this.slardarError=e.noop}__init9(){this.slardarEvent=e.noop}__init10(){this.slardarSuccessEvent=e.noop}__init11(){this.slardarErrorEvent=e.noop}__init12(){this.slardarTracer=()=>({trace:e.noop})}}function Yc(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}const Zc=e=>{const{onData:t}=e,s=e.buffered.split(/\n\n/),r=(n=s.pop(),o=()=>"",null!=n?n:o());var n,o;for(const e of s){const s=e.split(/\r?\n/),r=[];for(const e of s)e.startsWith("data:")&&r.push(e.slice(5).trimStart());if(0===r.length)continue;const n=r.join("\n").trim();n&&"[DONE]"!==n&&t(n)}return{buffered:r}},Xc=async e=>{const{apiBaseUrl:t,request:s,onStart:r,onMessage:n,signal:o,totalTimeoutMs:i,onTotalTimeout:a,betweenChunkTimeoutMs:c,onBetweenChunkTimeout:l}=e,u=new AbortController;((e,t)=>{t&&(t.aborted?e.abort():t.addEventListener("abort",()=>e.abort(),{once:!0}))})(u,o);const h=(e=>{const{controller:t,timeoutMs:s,onTimeout:r}=e;if(!s||s<=0)return()=>{};const n=setTimeout(()=>{Yc([r,"optionalCall",e=>e()]),t.abort()},s);return()=>clearTimeout(n)})({controller:u,timeoutMs:i,onTimeout:a}),p=(e=>{const{controller:t,timeoutMs:s,onTimeout:r}=e;if(!s||s<=0)return{refresh:()=>{},clear:()=>{}};let n=null;const o=()=>{n&&(clearTimeout(n),n=null)};return{refresh:()=>{o(),n=setTimeout(()=>{Yc([r,"optionalCall",e=>e()]),t.abort()},s)},clear:o}})({controller:u,timeoutMs:c,onTimeout:l});try{const e=new URL(`/v1/api/project/${s.project_id}/chat/message/send`,t),o=await yc.fetch(e.toString(),{method:"POST",signal:u.signal,body:JSON.stringify({message:s.message,device_id:s.device_id,project_id:s.project_id})});if(!o.ok)throw new Error(`ChatCLISendMessage failed: ${o.status} ${o.statusText}`);if(!o.body)throw new Error("ChatCLISendMessage response body is empty");await Yc([r,"optionalCall",e=>e(o)]);const i=new TextDecoder("utf-8"),a=o.body.getReader();let c="";for(p.refresh();;){const{done:e,value:t}=await a.read();if(e)break;p.refresh(),c+=i.decode(t,{stream:!0});c=Zc({buffered:c,onData:e=>{const t=JSON.parse(e);n(t)}}).buffered}c+=i.decode(),Zc({buffered:c,onData:e=>{const t=JSON.parse(e);n(t)}})}catch(e){if((e=>!(!e||"object"!=typeof e)&&"AbortError"===e.name)(e))return;throw e}finally{h(),p.clear()}};function el(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}class tl extends Error{constructor(e,t){super(e),tl.prototype.__init.call(this),this.name="ChatCLIChannelError",this.ext=t}__init(){this.flatten=()=>{const{message:e,ext:t}=this;return{message:e,...t}}}}const sl=e=>!(!e||"object"!=typeof e)&&"AbortError"===e.name;class rl{__init2(){this.channelName="ChatCLI"}__init3(){this.isChannelOpenPromise=null}__init4(){this.opened=!1}__init5(){this.destroyed=!1}__init6(){this.abortController=null}__init7(){this.eventBus=t()}constructor(e){rl.prototype.__init2.call(this),rl.prototype.__init3.call(this),rl.prototype.__init4.call(this),rl.prototype.__init5.call(this),rl.prototype.__init6.call(this),rl.prototype.__init7.call(this),rl.prototype.__init8.call(this),rl.prototype.__init9.call(this),rl.prototype.__init10.call(this),rl.prototype.__init11.call(this),rl.prototype.__init12.call(this),rl.prototype.__init13.call(this),rl.prototype.__init14.call(this),rl.prototype.__init15.call(this),rl.prototype.__init16.call(this),this.apiBaseUrl=e.apiBaseUrl,this.deviceId=e.deviceId,this.totalTimeoutMs=e.totalTimeoutMs,this.betweenChunkTimeoutMs=e.betweenChunkTimeoutMs}__init8(){this.getChannelOptions=()=>({apiBaseUrl:this.apiBaseUrl})}__init9(){this.connect=async()=>{this.destroyed||(this.opened=!0,this.isChannelOpenPromise=Promise.resolve(),this.eventBus.emit("onopen",void 0))}}__init10(){this.reconnect=async()=>{await this.connect()}}__init11(){this.isChannelOpen=()=>this.opened}__init12(){this.addEventListener=(e,t)=>{this.eventBus.on(e,t)}}__init13(){this.removeEventListener=(e,t)=>{this.eventBus.off(e,t)}}__init14(){this.send=async e=>{if(this.destroyed)throw new Error("ChatCLIChannel is destroyed");this.opened||await this.connect(),el([this,"access",e=>e.abortController,"optionalAccess",e=>e.abort,"call",e=>e()]);const t=new AbortController;this.abortController=t;const s=e,r={project_id:s.project_id,message:s,device_id:(n=this.deviceId,o=()=>{},null!=n?n:o())};var n,o;let i=!1,a=null;const c=new Promise(e=>{Xc({apiBaseUrl:this.apiBaseUrl,request:r,signal:t.signal,totalTimeoutMs:this.totalTimeoutMs,betweenChunkTimeoutMs:this.betweenChunkTimeoutMs,onTotalTimeout:()=>{this.eventBus.emit("onerror",new tl("ChatCLISendMessage total timeout",{willClose:!0}))},onBetweenChunkTimeout:()=>{this.eventBus.emit("onerror",new tl("ChatCLISendMessage between-chunk timeout",{willClose:!0}))},onStart:()=>{i=!0,this.eventBus.emit("onack",{code:"0",msg:""}),e()},onMessage:e=>{this.eventBus.emit("onmessage",e)}}).then(()=>{this.eventBus.emit("onclose",{code:0,reason:"eof"})}).catch(t=>{if(!i)return a=t,void e();sl(t)?this.eventBus.emit("onclose",{code:1e3,reason:"aborted"}):(this.eventBus.emit("onerror",new tl(`ChatCLISendMessage stream error: ${String(t)}`,{willClose:!0,rawError:t})),this.eventBus.emit("onclose",{code:1,reason:String(t)}))}).finally(()=>{this.abortController===t&&(this.abortController=null)})});if(await c,a){if(sl(a))return;throw this.eventBus.emit("onerror",new tl(`ChatCLISendMessage request error: ${String(a)}`,{willClose:!0,rawError:a})),a}}}__init15(){this.close=()=>{el([this,"access",e=>e.abortController,"optionalAccess",e=>e.abort,"call",e=>e()]),this.abortController=null,this.opened=!1}}__init16(){this.destroy=()=>{this.destroyed||(this.destroyed=!0,this.close(),this.eventBus.all.clear())}}}function nl(e){let t,s=e[0],r=1;for(;r<e.length;){const n=e[r],o=e[r+1];if(r+=2,("optionalAccess"===n||"optionalCall"===n)&&null==s)return;"access"===n||"optionalAccess"===n?(t=s,s=o(s)):"call"!==n&&"optionalCall"!==n||(s=o((...e)=>s.call(t,...e)),t=void 0)}return s}const ol=e=>{const t=e.toLowerCase();return t.includes("localhost")||t.includes("127.0.0.1")||t.includes("0.0.0.0")?"local":t.includes("boe")?"boe":"production"};exports.BuildAgentApi=ua,exports.ChatCoreError=ac,exports.CozeError=Lc,exports.HttpError=sr,exports.IdeApi=Vc,exports.axiosInstance=Gi,exports.createRequestClient=qi,exports.customFetch=yc,exports.isHttpError=function(e){return e instanceof sr},exports.request=zi,exports.safeJsonParse=sc,exports.sendProjectChatMessage=async t=>{const{projectId:s,prompt:n,apiBaseUrl:o,sessionId:i="",key:a=`coze-coding-cli:chat:${s}`,totalTimeoutMs:c,betweenChunkTimeoutMs:l,onMessageItem:u,onWarn:h}=t,p=new rl({apiBaseUrl:o,totalTimeoutMs:c,betweenChunkTimeoutMs:l}),d=new Rc({key:a,env:ol(o),logLevel:"error",channel:p,reportLog:new Qc}),_=new rc;let E=!1;const T=e=>{E||(E=!0,e())};let A;const R=d.on(Ya.MESSAGE_RECEIVED_AND_UPDATE,({data:t})=>{for(const s of t)if(nl([u,"optionalCall",e=>e(s)]),"answer"!==s.type||e.isUndefined(s.content.answer)||(A=s),"message_end"===s.type&&s.finish){const e=nl([s,"access",e=>e.content,"access",e=>e.message_end,"optionalAccess",e=>e.code]);if(e&&"0"!==e){T(()=>{_.reject(new Lc(`Conversation ended with error code: ${e}`,exports.ExitCode.SERVER_ERROR,{message_end:s.content.message_end}))});continue}T(()=>{_.resolve()})}},!0),L=d.on(Ya.SEND_MESSAGE_ERROR,e=>{T(()=>{_.reject(e.data.error)})},!0),S=d.on(Ya.MESSAGE_PULLING_STATUS,({data:e,error:t})=>{const s=e.pullingStatus;"error"!==s&&"channel_error"!==s||T(()=>{_.reject(t)}),"success"!==s&&"cancel"!==s||T(()=>{_.resolve()})},!0);try{const e=await(async(e,t,s,r)=>{const n=[],o=[...e.matchAll(Jc)];if(0===o.length)return[{type:"text",content:{text:e}}];let i=0;for(const a of o){const o=a.index,c=a[0],l=a[1];o>i&&n.push({type:"text",content:{text:e.slice(i,o)}});const u=f.resolve(t,l);let h=!1;if(u.startsWith(f.resolve(t)))try{(await m.stat(u)).isFile()?h=!0:Kc([r,"optionalCall",e=>e(`Uploading directories is not supported: ${l}`)])}catch(e){Kc([r,"optionalCall",e=>e(`File not found: ${l}`)])}if(h)try{const e=await s(u);n.push({type:"upload_file",content:{upload_file:e}})}catch(e){Kc([r,"optionalCall",t=>t(`Failed to upload file: ${l}, ${String(e)}`)]),n.push({type:"text",content:{text:c}})}else n.push({type:"text",content:{text:c}});i=o+c.length}return i<e.length&&n.push({type:"text",content:{text:e.slice(i)}}),n})(n,process.cwd(),(e=>async t=>{const s=f.basename(t),n=new r;n.append("project_id",e),n.append("file_name",s),n.append("file_content",g.createReadStream(t));const o=await Vc.UploadProjectFile({body:n},{headers:{...n.getHeaders()}});if(!o.file)throw new Error(`Upload failed for file: ${t}`);return{file_name:o.file.name,file_path:o.file.file_path,url:o.file.url}})(s),h),t=d.createQueryMessage({query:{prompt:e}},{session_id:i,project_id:s});return await d.sendChatMessage(t),await _.promise,{lastAnswerMessage:A}}finally{R(),L(),S(),d.destroy()}};
|