@coze/cli 0.1.3-alpha.3cc78c → 0.1.3-alpha.fa0063

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";const e=require("mitt"),t=require("crypto"),s=require("form-data"),r=require("url"),n=require("http"),o=require("https"),i=require("http2"),a=require("util"),c=require("stream"),l=require("assert"),u=require("tty"),h=require("zlib"),p=require("events"),d=require("path"),_=require("fs"),f=require("fs/promises"),g=require("lodash"),m=require("undici");var E;!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"}(E||(E={}));let T,A,R=(e=21)=>{var s;s=e-=0,!T||T.length<s?(T=Buffer.allocUnsafe(128*s),t.randomFillSync(T),A=0):A+s>T.length&&(t.randomFillSync(T),A=0),A+=s;let r="";for(let t=A-e;t<A;t++)r+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&T[t]];return r};var S="object"==typeof global&&global&&global.Object===Object&&global,L="object"==typeof self&&self&&self.Object===Object&&self,y=S||L||Function("return this")(),b=y.Symbol,C=Object.prototype,v=C.hasOwnProperty,I=C.toString,O=b?b.toStringTag:void 0;var N=Object.prototype.toString;var M=b?b.toStringTag:void 0;function w(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":M&&M in Object(e)?function(e){var t=v.call(e,O),s=e[O];try{e[O]=void 0;var r=!0}catch(e){}var n=I.call(e);return r&&(t?e[O]=s:delete e[O]),n}(e):function(e){return N.call(e)}(e)}function U(e){return null!=e&&"object"==typeof e}function P(e){return"symbol"==typeof e||U(e)&&"[object Symbol]"==w(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 k=Array.isArray,j=b?b.prototype:void 0,D=j?j.toString:void 0;function x(e){if("string"==typeof e)return e;if(k(e))return B(e,x)+"";if(P(e))return D?D.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function F(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function q(e){return e}function G(e){if(!F(e))return!1;var t=w(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var H,z=y["__core-js_shared__"],W=(H=/[^.]+$/.exec(z&&z.keys&&z.keys.IE_PROTO||""))?"Symbol(src)_1."+H:"";var $=Function.prototype.toString;function V(e){if(null!=e){try{return $.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var K=/^\[object .+?Constructor\]$/,J=Function.prototype,Q=Object.prototype,Y=J.toString,Z=Q.hasOwnProperty,X=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ee(e){return!(!F(e)||(t=e,W&&W in t))&&(G(e)?X:K).test(V(e));var t}function te(e,t){var s=function(e,t){return null==e?void 0:e[t]}(e,t);return ee(s)?s:void 0}var se=te(y,"WeakMap"),re=Object.create,ne=function(){function e(){}return function(t){if(!F(t))return{};if(re)return re(t);e.prototype=t;var s=new e;return e.prototype=void 0,s}}();function oe(){}var ie=Date.now;var ae,ce,le,ue=function(){try{var e=te(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),he=ue?function(e,t){return ue(e,"toString",{configurable:!0,enumerable:!1,value:(s=t,function(){return s}),writable:!0});var s}:q,pe=(ae=he,ce=0,le=0,function(){var e=ie(),t=16-(e-le);if(le=e,t>0){if(++ce>=800)return arguments[0]}else ce=0;return ae.apply(void 0,arguments)});var de=/^(?:0|[1-9]\d*)$/;function _e(e,t){var s=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==s||"symbol"!=s&&de.test(e))&&e>-1&&e%1==0&&e<t}function fe(e,t,s){"__proto__"==t&&ue?ue(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s}function ge(e,t){return e===t||e!=e&&t!=t}var me=Object.prototype.hasOwnProperty;function Ee(e,t,s){var r=e[t];me.call(e,t)&&ge(r,s)&&(void 0!==s||t in e)||fe(e,t,s)}var Te=Math.max;function Ae(e,t){return pe(function(e,t,s){return t=Te(void 0===t?e.length-1:t,0),function(){for(var r=arguments,n=-1,o=Te(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,q),e+"")}function Re(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function Se(e){return null!=e&&Re(e.length)&&!G(e)}function Le(e){return Ae(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(!F(s))return!1;var r=typeof t;return!!("number"==r?Se(s)&&_e(t,s.length):"string"==r&&t in s)&&ge(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 ye=Object.prototype;function be(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||ye)}function Ce(e){return U(e)&&"[object Arguments]"==w(e)}var ve=Object.prototype,Ie=ve.hasOwnProperty,Oe=ve.propertyIsEnumerable,Ne=Ce(function(){return arguments}())?Ce:function(e){return U(e)&&Ie.call(e,"callee")&&!Oe.call(e,"callee")};var Me="object"==typeof exports&&exports&&!exports.nodeType&&exports,we=Me&&"object"==typeof module&&module&&!module.nodeType&&module,Ue=we&&we.exports===Me?y.Buffer:void 0,Pe=(Ue?Ue.isBuffer:void 0)||function(){return!1},Be={};function ke(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 je="object"==typeof exports&&exports&&!exports.nodeType&&exports,De=je&&"object"==typeof module&&module&&!module.nodeType&&module,xe=De&&De.exports===je&&S.process,Fe=function(){try{var e=De&&De.require&&De.require("util").types;return e||xe&&xe.binding&&xe.binding("util")}catch(e){}}(),qe=Fe&&Fe.isTypedArray,Ge=qe?ke(qe):function(e){return U(e)&&Re(e.length)&&!!Be[w(e)]},He=Object.prototype.hasOwnProperty;function ze(e,t){var s=k(e),r=!s&&Ne(e),n=!s&&!r&&Pe(e),o=!s&&!r&&!n&&Ge(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&&!He.call(e,l)||i&&("length"==l||n&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||_e(l,c))||a.push(l);return a}function We(e,t){return function(s){return e(t(s))}}var $e=We(Object.keys,Object),Ve=Object.prototype.hasOwnProperty;function Ke(e){return Se(e)?ze(e):function(e){if(!be(e))return $e(e);var t=[];for(var s in Object(e))Ve.call(e,s)&&"constructor"!=s&&t.push(s);return t}(e)}var Je=Object.prototype.hasOwnProperty;function Qe(e){if(!F(e))return function(e){var t=[];if(null!=e)for(var s in Object(e))t.push(s);return t}(e);var t=be(e),s=[];for(var r in e)("constructor"!=r||!t&&Je.call(e,r))&&s.push(r);return s}function Ye(e){return Se(e)?ze(e,!0):Qe(e)}var Ze=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Xe=/^\w*$/;function et(e,t){if(k(e))return!1;var s=typeof e;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=e&&!P(e))||(Xe.test(e)||!Ze.test(e)||null!=t&&e in Object(t))}var tt=te(Object,"create");var st=Object.prototype.hasOwnProperty;var rt=Object.prototype.hasOwnProperty;function nt(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 ot(e,t){for(var s=e.length;s--;)if(ge(e[s][0],t))return s;return-1}nt.prototype.clear=function(){this.__data__=tt?tt(null):{},this.size=0},nt.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},nt.prototype.get=function(e){var t=this.__data__;if(tt){var s=t[e];return"__lodash_hash_undefined__"===s?void 0:s}return st.call(t,e)?t[e]:void 0},nt.prototype.has=function(e){var t=this.__data__;return tt?void 0!==t[e]:rt.call(t,e)},nt.prototype.set=function(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=tt&&void 0===t?"__lodash_hash_undefined__":t,this};var it=Array.prototype.splice;function at(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])}}at.prototype.clear=function(){this.__data__=[],this.size=0},at.prototype.delete=function(e){var t=this.__data__,s=ot(t,e);return!(s<0)&&(s==t.length-1?t.pop():it.call(t,s,1),--this.size,!0)},at.prototype.get=function(e){var t=this.__data__,s=ot(t,e);return s<0?void 0:t[s][1]},at.prototype.has=function(e){return ot(this.__data__,e)>-1},at.prototype.set=function(e,t){var s=this.__data__,r=ot(s,e);return r<0?(++this.size,s.push([e,t])):s[r][1]=t,this};var ct=te(y,"Map");function lt(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 ut(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])}}ut.prototype.clear=function(){this.size=0,this.__data__={hash:new nt,map:new(ct||at),string:new nt}},ut.prototype.delete=function(e){var t=lt(this,e).delete(e);return this.size-=t?1:0,t},ut.prototype.get=function(e){return lt(this,e).get(e)},ut.prototype.has=function(e){return lt(this,e).has(e)},ut.prototype.set=function(e,t){var s=lt(this,e),r=s.size;return s.set(e,t),this.size+=s.size==r?0:1,this};function ht(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(ht.Cache||ut),s}ht.Cache=ut;var pt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,dt=/\\(\\)?/g,_t=function(e){var t=ht(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(pt,function(e,s,r,n){t.push(r?n.replace(dt,"$1"):s||e)}),t});function ft(e,t){return k(e)?e:et(e,t)?[e]:_t(function(e){return null==e?"":x(e)}(e))}function gt(e){if("string"==typeof e||P(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function mt(e,t){for(var s=0,r=(t=ft(t,e)).length;null!=e&&s<r;)e=e[gt(t[s++])];return s&&s==r?e:void 0}function Et(e,t,s){var r=null==e?void 0:mt(e,t);return void 0===r?s:r}function Tt(e,t){for(var s=-1,r=t.length,n=e.length;++s<r;)e[n+s]=t[s];return e}var At=We(Object.getPrototypeOf,Object),Rt=Function.prototype,St=Object.prototype,Lt=Rt.toString,yt=St.hasOwnProperty,bt=Lt.call(Object);function Ct(e){var t=this.__data__=new at(e);this.size=t.size}Ct.prototype.clear=function(){this.__data__=new at,this.size=0},Ct.prototype.delete=function(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s},Ct.prototype.get=function(e){return this.__data__.get(e)},Ct.prototype.has=function(e){return this.__data__.has(e)},Ct.prototype.set=function(e,t){var s=this.__data__;if(s instanceof at){var r=s.__data__;if(!ct||r.length<199)return r.push([e,t]),this.size=++s.size,this;s=this.__data__=new ut(r)}return s.set(e,t),this.size=s.size,this};var vt="object"==typeof exports&&exports&&!exports.nodeType&&exports,It=vt&&"object"==typeof module&&module&&!module.nodeType&&module,Ot=It&&It.exports===vt?y.Buffer:void 0,Nt=Ot?Ot.allocUnsafe:void 0;function Mt(e,t){if(t)return e.slice();var s=e.length,r=Nt?Nt(s):new e.constructor(s);return e.copy(r),r}function wt(){return[]}var Ut=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 Ut.call(e,t)}))}:wt,kt=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Tt(t,Bt(e)),e=At(e);return t}:wt;function jt(e,t,s){var r=t(e);return k(e)?r:Tt(r,s(e))}function Dt(e){return jt(e,Ke,Bt)}var xt=te(y,"DataView"),Ft=te(y,"Promise"),qt=te(y,"Set"),Gt="[object Map]",Ht="[object Promise]",zt="[object Set]",Wt="[object WeakMap]",$t="[object DataView]",Vt=V(xt),Kt=V(ct),Jt=V(Ft),Qt=V(qt),Yt=V(se),Zt=w;(xt&&Zt(new xt(new ArrayBuffer(1)))!=$t||ct&&Zt(new ct)!=Gt||Ft&&Zt(Ft.resolve())!=Ht||qt&&Zt(new qt)!=zt||se&&Zt(new se)!=Wt)&&(Zt=function(e){var t=w(e),s="[object Object]"==t?e.constructor:void 0,r=s?V(s):"";if(r)switch(r){case Vt:return $t;case Kt:return Gt;case Jt:return Ht;case Qt:return zt;case Yt:return Wt}return t});var Xt=Object.prototype.hasOwnProperty;var es=y.Uint8Array;function ts(e){var t=new e.constructor(e.byteLength);return new es(t).set(new es(e)),t}var ss=/\w*$/;var rs=b?b.prototype:void 0,ns=rs?rs.valueOf:void 0;function os(e,t){var s=t?ts(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function is(e,t,s){var r,n,o,i,a,c=e.constructor;switch(t){case"[object ArrayBuffer]":return ts(e);case"[object Boolean]":case"[object Date]":return new c(+e);case"[object DataView]":return a=ts((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 os(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,ss.exec(n))).lastIndex=n.lastIndex,o;case"[object Symbol]":return r=e,ns?Object(ns.call(r)):{}}}function as(e){return"function"!=typeof e.constructor||be(e)?{}:ne(At(e))}var cs=Fe&&Fe.isMap,ls=cs?ke(cs):function(e){return U(e)&&"[object Map]"==Zt(e)};var us=Fe&&Fe.isSet,hs=us?ke(us):function(e){return U(e)&&"[object Set]"==Zt(e)},ps="[object Arguments]",ds="[object Function]",_s="[object Object]",fs={};function gs(e,t,s,r,n,o){var i,a=1&t;if(void 0!==i)return i;if(!F(e))return e;var c=k(e);if(c)i=function(e){var t=e.length,s=new e.constructor(t);return t&&"string"==typeof e[0]&&Xt.call(e,"index")&&(s.index=e.index,s.input=e.input),s}(e);else{var l=Zt(e),u=l==ds||"[object GeneratorFunction]"==l;if(Pe(e))return Mt(e,a);if(l==_s||l==ps||u&&!n)i=u?{}:as(e);else{if(!fs[l])return n?e:{};i=is(e,l,a)}}o||(o=new Ct);var h=o.get(e);if(h)return h;o.set(e,i),hs(e)?e.forEach(function(r){i.add(gs(r,t,s,r,e,o))}):ls(e)&&e.forEach(function(r,n){i.set(n,gs(r,t,s,n,e,o))});var p=c?void 0:Dt(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]),Ee(i,n,gs(r,t,s,n,e,o))}),i}fs[ps]=fs["[object Array]"]=fs["[object ArrayBuffer]"]=fs["[object DataView]"]=fs["[object Boolean]"]=fs["[object Date]"]=fs["[object Float32Array]"]=fs["[object Float64Array]"]=fs["[object Int8Array]"]=fs["[object Int16Array]"]=fs["[object Int32Array]"]=fs["[object Map]"]=fs["[object Number]"]=fs[_s]=fs["[object RegExp]"]=fs["[object Set]"]=fs["[object String]"]=fs["[object Symbol]"]=fs["[object Uint8Array]"]=fs["[object Uint8ClampedArray]"]=fs["[object Uint16Array]"]=fs["[object Uint32Array]"]=!0,fs["[object Error]"]=fs[ds]=fs["[object WeakMap]"]=!1;function ms(e){return gs(e,5)}function Es(e){var t=-1,s=null==e?0:e.length;for(this.__data__=new ut;++t<s;)this.add(e[t])}function Ts(e,t){for(var s=-1,r=null==e?0:e.length;++s<r;)if(t(e[s],s,e))return!0;return!1}Es.prototype.add=Es.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Es.prototype.has=function(e){return this.__data__.has(e)};function As(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 Es: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(!Ts(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 Rs(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 Ls=b?b.prototype:void 0,ys=Ls?Ls.valueOf:void 0;var bs=Object.prototype.hasOwnProperty;var Cs="[object Arguments]",vs="[object Array]",Is="[object Object]",Os=Object.prototype.hasOwnProperty;function Ns(e,t,s,r,n,o){var i=k(e),a=k(t),c=i?vs:Zt(e),l=a?vs:Zt(t),u=(c=c==Cs?Is:c)==Is,h=(l=l==Cs?Is:l)==Is,p=c==l;if(p&&Pe(e)){if(!Pe(t))return!1;i=!0,u=!1}if(p&&!u)return o||(o=new Ct),i||Ge(e)?As(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 es(e),new es(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ge(+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=Rs;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=As(a(e),a(t),r,n,o,i);return i.delete(e),u;case"[object Symbol]":if(ys)return ys.call(e)==ys.call(t)}return!1}(e,t,c,s,r,n,o);if(!(1&s)){var d=u&&Os.call(e,"__wrapped__"),_=h&&Os.call(t,"__wrapped__");if(d||_){var f=d?e.value():e,g=_?t.value():t;return o||(o=new Ct),n(f,g,s,r,o)}}return!!p&&(o||(o=new Ct),function(e,t,s,r,n,o){var i=1&s,a=Dt(e),c=a.length;if(c!=Dt(t).length&&!i)return!1;for(var l=c;l--;){var u=a[l];if(!(i?u in t:bs.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 Ms(e,t,s,r,n){return e===t||(null==e||null==t||!U(e)&&!U(t)?e!=e&&t!=t:Ns(e,t,s,r,Ms,n))}function ws(e){return e==e&&!F(e)}function Us(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=Ke(e),s=t.length;s--;){var r=t[s],n=e[r];t[s]=[r,n,ws(n)]}return t}(e);return 1==t.length&&t[0][2]?Us(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(!Ms(l,c,3,r,new Ct))return!1}return!0}(s,0,t)}}function Bs(e,t){return null!=e&&t in Object(e)}function ks(e,t){return null!=e&&function(e,t,s){for(var r=-1,n=(t=ft(t,e)).length,o=!1;++r<n;){var i=gt(t[r]);if(!(o=null!=e&&s(e,i)))break;e=e[i]}return o||++r!=n?o:!!(n=null==e?0:e.length)&&Re(n)&&_e(i,n)&&(k(e)||Ne(e))}(e,t,Bs)}function js(e){return et(e)?(t=gt(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return mt(t,e)}}(e);var t}function Ds(e){return"function"==typeof e?e:null==e?q:"object"==typeof e?k(e)?function(e,t){return et(e)&&ws(t)?Us(gt(e),t):function(s){var r=Et(s,e);return void 0===r&&r===t?ks(s,e):Ms(t,r,3)}}(e[0],e[1]):Ps(e):js(e)}var xs=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 Fs(e,t,s){(void 0!==s&&!ge(e[t],s)||void 0===s&&!(t in e))&&fe(e,t,s)}function qs(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function Gs(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?fe(s,i,a):Ee(s,i,a)}return s}(e,Ye(e))}function Hs(e,t,s,r,n,o,i){var a=qs(e,s),c=qs(t,s),l=i.get(c);if(l)Fs(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=k(c),_=!d&&Pe(c),f=!d&&!_&&Ge(c);h=c,d||_||f?k(a)?h=a:U(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=Mt(c,!0)):f?(p=!1,h=os(c,!0)):h=[]:function(e){if(!U(e)||"[object Object]"!=w(e))return!1;var t=At(e);if(null===t)return!0;var s=yt.call(t,"constructor")&&t.constructor;return"function"==typeof s&&s instanceof s&&Lt.call(s)==bt}(c)||Ne(c)?(h=a,Ne(a)?h=Gs(a):F(a)&&!G(a)||(h=as(c))):p=!1}p&&(i.set(c,h),n(h,c,r,o,i),i.delete(c)),Fs(e,s,h)}}function zs(e,t,s,r,n){e!==t&&xs(t,function(o,i){if(n||(n=new Ct),F(o))Hs(e,t,i,s,zs,r,n);else{var a=r?r(qs(e,i),o,i+"",e,t,n):void 0;void 0===a&&(a=o),Fs(e,i,a)}},Ye)}var Ws=Le(function(e,t,s,r){zs(e,t,s,r)});function $s(e){return void 0===e}var Vs=Le(function(e,t,s){zs(e,t,s)});function Ks(e,t,s,r){if(!F(e))return e;for(var n=-1,o=(t=ft(t,e)).length,i=o-1,a=e;null!=a&&++n<o;){var c=gt(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=F(u)?u:_e(t[n+1])?[]:{})}Ee(a,c,l),a=a[c]}return e}function Js(e,t){if(null==e)return{};var s=B(function(e){return jt(e,Ye,kt)}(e),function(e){return[e]});return t=Ds(t),function(e,t,s){for(var r=-1,n=t.length,o={};++r<n;){var i=t[r],a=mt(e,i);s(a,i)&&Ks(o,ft(i,e),a)}return o}(e,s,function(e,s){return t(e,s[0])})}function Qs(e,t,s){return null==e?e:Ks(e,t,s)}function Ys(e,t,s){return null==e?e:function(e,t,s){return Ks(e,t,s(mt(e,t)))}(e,t,"function"==typeof(r=s)?r:q);var r}class Zs{createQueryMessage(e,t){return{content:e,session_id:t.session_id,type:"query",project_id:t.project_id,context:t.context,local_msg_id:R()}}createRetryMessage(e,t){return{content:e,session_id:t.session_id,type:"retry",project_id:t.project_id,context:t.context,local_msg_id:R()}}createEditMessage(e,t){const s=R();return{content:Vs(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:R()}}createCancelMessage(e,t){return{content:e,session_id:t.session_id,type:"cancel",project_id:t.project_id,context:t.context,local_msg_id:R()}}}const Xs=(...e)=>Ws(...e,(e,t)=>{if(k(e))return e.concat(t)});function er(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 tr 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,tr)}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=er([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:er([this,"access",e=>e.config,"optionalAccess",e=>e.url]),method:er([this,"access",e=>e.config,"optionalAccess",e=>e.method]),baseURL:er([this,"access",e=>e.config,"optionalAccess",e=>e.baseURL])}}}function sr(e,t){return function(){return e.apply(t,arguments)}}const{toString:rr}=Object.prototype,{getPrototypeOf:nr}=Object,{iterator:or,toStringTag:ir}=Symbol,ar=(cr=Object.create(null),e=>{const t=rr.call(e);return cr[t]||(cr[t]=t.slice(8,-1).toLowerCase())});var cr;const lr=e=>(e=e.toLowerCase(),t=>ar(t)===e),ur=e=>t=>typeof t===e,{isArray:hr}=Array,pr=ur("undefined");function dr(e){return null!==e&&!pr(e)&&null!==e.constructor&&!pr(e.constructor)&&gr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const _r=lr("ArrayBuffer");const fr=ur("string"),gr=ur("function"),mr=ur("number"),Er=e=>null!==e&&"object"==typeof e,Tr=e=>{if("object"!==ar(e))return!1;const t=nr(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||ir in e||or in e)},Ar=lr("Date"),Rr=lr("File"),Sr=lr("Blob"),Lr=lr("FileList");const yr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},br=void 0!==yr.FormData?yr.FormData:void 0,Cr=lr("URLSearchParams"),[vr,Ir,Or,Nr]=["ReadableStream","Request","Response","Headers"].map(lr);function Mr(e,t,{allOwnKeys:s=!1}={}){if(null==e)return;let r,n;if("object"!=typeof e&&(e=[e]),hr(e))for(r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else{if(dr(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 wr(e,t){if(dr(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 Ur="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Pr=e=>!pr(e)&&e!==Ur;const Br=(kr="undefined"!=typeof Uint8Array&&nr(Uint8Array),e=>kr&&e instanceof kr);var kr;const jr=lr("HTMLFormElement"),Dr=(({hasOwnProperty:e})=>(t,s)=>e.call(t,s))(Object.prototype),xr=lr("RegExp"),Fr=(e,t)=>{const s=Object.getOwnPropertyDescriptors(e),r={};Mr(s,(s,n)=>{let o;!1!==(o=t(s,n,e))&&(r[n]=o||s)}),Object.defineProperties(e,r)};const qr=lr("AsyncFunction"),Gr=(Hr="function"==typeof setImmediate,zr=gr(Ur.postMessage),Hr?setImmediate:zr?(Wr=`axios@${Math.random()}`,$r=[],Ur.addEventListener("message",({source:e,data:t})=>{e===Ur&&t===Wr&&$r.length&&$r.shift()()},!1),e=>{$r.push(e),Ur.postMessage(Wr,"*")}):e=>setTimeout(e));var Hr,zr,Wr,$r;const Vr="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Ur):"undefined"!=typeof process&&process.nextTick||Gr,Kr={isArray:hr,isArrayBuffer:_r,isBuffer:dr,isFormData:e=>{let t;return e&&(br&&e instanceof br||gr(e.append)&&("formdata"===(t=ar(e))||"object"===t&&gr(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&_r(e.buffer),t},isString:fr,isNumber:mr,isBoolean:e=>!0===e||!1===e,isObject:Er,isPlainObject:Tr,isEmptyObject:e=>{if(!Er(e)||dr(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:vr,isRequest:Ir,isResponse:Or,isHeaders:Nr,isUndefined:pr,isDate:Ar,isFile:Rr,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:Sr,isRegExp:xr,isFunction:gr,isStream:e=>Er(e)&&gr(e.pipe),isURLSearchParams:Cr,isTypedArray:Br,isFileList:Lr,forEach:Mr,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&&wr(r,o)||o;Tr(r[i])&&Tr(n)?r[i]=e(r[i],n):Tr(n)?r[i]=e({},n):hr(n)?r[i]=n.slice():s&&pr(n)||(r[i]=n)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Mr(arguments[e],n);return r},extend:(e,t,s,{allOwnKeys:r}={})=>(Mr(t,(t,r)=>{s&&gr(t)?Object.defineProperty(e,r,{value:sr(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&&nr(e)}while(e&&(!s||s(e,t))&&e!==Object.prototype);return t},kindOf:ar,kindOfTest:lr,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(hr(e))return e;let t=e.length;if(!mr(t))return null;const s=new Array(t);for(;t-- >0;)s[t]=e[t];return s},forEachEntry:(e,t)=>{const s=(e&&e[or]).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:jr,hasOwnProperty:Dr,hasOwnProp:Dr,reduceDescriptors:Fr,freezeMethods:e=>{Fr(e,(t,s)=>{if(gr(e)&&-1!==["arguments","caller","callee"].indexOf(s))return!1;const r=e[s];gr(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 hr(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:wr,global:Ur,isContextDefined:Pr,isSpecCompliantForm:function(e){return!!(e&&gr(e.append)&&"FormData"===e[ir]&&e[or])},toJSONObject:e=>{const t=new Array(10),s=(e,r)=>{if(Er(e)){if(t.indexOf(e)>=0)return;if(dr(e))return e;if(!("toJSON"in e)){t[r]=e;const n=hr(e)?[]:{};return Mr(e,(e,t)=>{const o=s(e,r+1);!pr(o)&&(n[t]=o)}),t[r]=void 0,n}}return e};return s(e,0)},isAsyncFn:qr,isThenable:e=>e&&(Er(e)||gr(e))&&gr(e.then)&&gr(e.catch),setImmediate:Gr,asap:Vr,isIterable:e=>null!=e&&gr(e[or])};let Jr=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:Kr.toJSONObject(this.config),code:this.code,status:this.status}}};function Qr(e){return Kr.isPlainObject(e)||Kr.isArray(e)}function Yr(e){return Kr.endsWith(e,"[]")?e.slice(0,-2):e}function Zr(e,t,s){return e?e.concat(t).map(function(e,t){return e=Yr(e),!s&&t?"["+e+"]":e}).join(s?".":""):t}Jr.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Jr.ERR_BAD_OPTION="ERR_BAD_OPTION",Jr.ECONNABORTED="ECONNABORTED",Jr.ETIMEDOUT="ETIMEDOUT",Jr.ERR_NETWORK="ERR_NETWORK",Jr.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Jr.ERR_DEPRECATED="ERR_DEPRECATED",Jr.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Jr.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Jr.ERR_CANCELED="ERR_CANCELED",Jr.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Jr.ERR_INVALID_URL="ERR_INVALID_URL";const Xr=Kr.toFlatObject(Kr,{},null,function(e){return/^is[A-Z]/.test(e)});function en(e,t,r){if(!Kr.isObject(e))throw new TypeError("target must be an object");t=t||new(s||FormData);const n=(r=Kr.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Kr.isUndefined(t[e])})).metaTokens,o=r.visitor||u,i=r.dots,a=r.indexes,c=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Kr.isSpecCompliantForm(t);if(!Kr.isFunction(o))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Kr.isDate(e))return e.toISOString();if(Kr.isBoolean(e))return e.toString();if(!c&&Kr.isBlob(e))throw new Jr("Blob is not supported. Use a Buffer instead.");return Kr.isArrayBuffer(e)||Kr.isTypedArray(e)?c&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,s,r){let o=e;if(Kr.isReactNative(t)&&Kr.isReactNativeBlob(e))return t.append(Zr(r,s,i),l(e)),!1;if(e&&!r&&"object"==typeof e)if(Kr.endsWith(s,"{}"))s=n?s:s.slice(0,-2),e=JSON.stringify(e);else if(Kr.isArray(e)&&function(e){return Kr.isArray(e)&&!e.some(Qr)}(e)||(Kr.isFileList(e)||Kr.endsWith(s,"[]"))&&(o=Kr.toArray(e)))return s=Yr(s),o.forEach(function(e,r){!Kr.isUndefined(e)&&null!==e&&t.append(!0===a?Zr([s],r,i):null===a?s:s+"[]",l(e))}),!1;return!!Qr(e)||(t.append(Zr(r,s,i),l(e)),!1)}const h=[],p=Object.assign(Xr,{defaultVisitor:u,convertValue:l,isVisitable:Qr});if(!Kr.isObject(e))throw new TypeError("data must be an object");return function e(s,r){if(!Kr.isUndefined(s)){if(-1!==h.indexOf(s))throw Error("Circular reference detected in "+r.join("."));h.push(s),Kr.forEach(s,function(s,n){!0===(!(Kr.isUndefined(s)||null===s)&&o.call(t,s,Kr.isString(n)?n.trim():n,r,p))&&e(s,r?r.concat(n):[n])}),h.pop()}}(e),t}function tn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function sn(e,t){this._pairs=[],e&&en(e,this,t)}const rn=sn.prototype;function nn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function on(e,t,s){if(!t)return e;const r=s&&s.encode||nn,n=Kr.isFunction(s)?{serialize:s}:s,o=n&&n.serialize;let i;if(i=o?o(t,n):Kr.isURLSearchParams(t)?t.toString():new sn(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}rn.append=function(e,t){this._pairs.push([e,t])},rn.toString=function(e){const t=e?function(t){return e.call(this,t,tn)}:tn;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class an{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){Kr.forEach(this.handlers,function(t){null!==t&&e(t)})}}const cn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},ln=r.URLSearchParams,un="abcdefghijklmnopqrstuvwxyz",hn="0123456789",pn={DIGIT:hn,ALPHA:un,ALPHA_DIGIT:un+un.toUpperCase()+hn},dn={isNode:!0,classes:{URLSearchParams:ln,FormData:s,Blob:"undefined"!=typeof Blob&&Blob||null},ALPHABET:pn,generateString:(e=16,s=pn.ALPHA_DIGIT)=>{let r="";const{length:n}=s,o=new Uint32Array(e);t.randomFillSync(o);for(let t=0;t<e;t++)r+=s[o[t]%n];return r},protocols:["http","https","file","data"]},_n="undefined"!=typeof window&&"undefined"!=typeof document,fn="object"==typeof navigator&&navigator||void 0,gn=_n&&(!fn||["ReactNative","NativeScript","NS"].indexOf(fn.product)<0),mn="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,En=_n&&window.location.href||"http://localhost",Tn={...Object.freeze({__proto__:null,hasBrowserEnv:_n,hasStandardBrowserEnv:gn,hasStandardBrowserWebWorkerEnv:mn,navigator:fn,origin:En}),...dn};function An(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&&Kr.isArray(r)?r.length:o,a)return Kr.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!i;r[o]&&Kr.isObject(r[o])||(r[o]=[]);return t(e,s,r[o],n)&&Kr.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(Kr.isFormData(e)&&Kr.isFunction(e.entries)){const s={};return Kr.forEachEntry(e,(e,r)=>{t(function(e){return Kr.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,s,0)}),s}return null}const Rn={transitional:cn,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,n=Kr.isObject(e);n&&Kr.isHTMLForm(e)&&(e=new FormData(e));if(Kr.isFormData(e))return r?JSON.stringify(An(e)):e;if(Kr.isArrayBuffer(e)||Kr.isBuffer(e)||Kr.isStream(e)||Kr.isFile(e)||Kr.isBlob(e)||Kr.isReadableStream(e))return e;if(Kr.isArrayBufferView(e))return e.buffer;if(Kr.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 en(e,new Tn.classes.URLSearchParams,{visitor:function(e,t,s,r){return Tn.isNode&&Kr.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=Kr.isFileList(e))||s.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return en(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return n||r?(t.setContentType("application/json",!1),function(e,t,s){if(Kr.isString(e))try{return(t||JSON.parse)(e),Kr.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(s||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Rn.transitional,s=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Kr.isResponse(e)||Kr.isReadableStream(e))return e;if(e&&Kr.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 Jr.from(e,Jr.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:Tn.classes.FormData,Blob:Tn.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Kr.forEach(["delete","get","head","post","put","patch"],e=>{Rn.headers[e]={}});const Sn=Kr.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"]),Ln=Symbol("internals");function yn(e){return e&&String(e).trim().toLowerCase()}function bn(e){return!1===e||null==e?e:Kr.isArray(e)?e.map(bn):String(e)}function Cn(e,t,s,r,n){return Kr.isFunction(r)?r.call(this,t,s):(n&&(t=s),Kr.isString(t)?Kr.isString(r)?-1!==t.indexOf(r):Kr.isRegExp(r)?r.test(t):void 0:void 0)}let vn=class{constructor(e){e&&this.set(e)}set(e,t,s){const r=this;function n(e,t,s){const n=yn(t);if(!n)throw new Error("header name must be a non-empty string");const o=Kr.findKey(r,n);(!o||void 0===r[o]||!0===s||void 0===s&&!1!==r[o])&&(r[o||t]=bn(e))}const o=(e,t)=>Kr.forEach(e,(e,s)=>n(e,s,t));if(Kr.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Kr.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(Kr.isObject(e)&&Kr.isIterable(e)){let s,r,n={};for(const t of e){if(!Kr.isArray(t))throw TypeError("Object iterator must return a key-value pair");n[r=t[0]]=(s=n[r])?Kr.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=yn(e)){const s=Kr.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(Kr.isFunction(t))return t.call(this,e,s);if(Kr.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=yn(e)){const s=Kr.findKey(this,e);return!(!s||void 0===this[s]||t&&!Cn(0,this[s],s,t))}return!1}delete(e,t){const s=this;let r=!1;function n(e){if(e=yn(e)){const n=Kr.findKey(s,e);!n||t&&!Cn(0,s[n],n,t)||(delete s[n],r=!0)}}return Kr.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&&!Cn(0,this[n],n,e,!0)||(delete this[n],r=!0)}return r}normalize(e){const t=this,s={};return Kr.forEach(this,(r,n)=>{const o=Kr.findKey(s,n);if(o)return t[o]=bn(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]=bn(r),s[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Kr.forEach(this,(s,r)=>{null!=s&&!1!==s&&(t[r]=e&&Kr.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[Ln]=this[Ln]={accessors:{}}).accessors,s=this.prototype;function r(e){const r=yn(e);t[r]||(!function(e,t){const s=Kr.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 Kr.isArray(e)?e.forEach(r):r(e),this}};function In(e,t){const s=this||Rn,r=t||s,n=vn.from(r.headers);let o=r.data;return Kr.forEach(e,function(e){o=e.call(s,o,n.normalize(),t?t.status:void 0)}),n.normalize(),o}function On(e){return!(!e||!e.__CANCEL__)}vn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Kr.reduceDescriptors(vn.prototype,({value:e},t)=>{let s=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[s]=e}}}),Kr.freezeMethods(vn);let Nn=class extends Jr{constructor(e,t,s){super(null==e?"canceled":e,Jr.ERR_CANCELED,t,s),this.name="CanceledError",this.__CANCEL__=!0}};function Mn(e,t,s){const r=s.config.validateStatus;s.status&&r&&!r(s.status)?t(new Jr("Request failed with status code "+s.status,[Jr.ERR_BAD_REQUEST,Jr.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):e(s)}function wn(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 Un(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Pn(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var s=function e(){var s=!1;try{s=this instanceof e}catch{}return s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};s.prototype=t.prototype}else s={};return Object.defineProperty(s,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),s}var Bn,kn={};const jn=Un(function(){if(Bn)return kn;Bn=1;var e=r.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 n(e){return process.env[e.toLowerCase()]||process.env[e.toUpperCase()]||""}return kn.getProxyForUrl=function(r){var o="string"==typeof r?e(r):r||{},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 r=(n("npm_config_no_proxy")||n("no_proxy")).toLowerCase();if(!r)return!0;if("*"===r)return!1;return r.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=n("npm_config_"+i+"_proxy")||n(i+"_proxy")||n("npm_config_proxy")||n("all_proxy");return l&&-1===l.indexOf("://")&&(l=i+"://"+l),l},kn}());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={exports:{}};const Jn=(()=>{if(navigator.userAgentData){if(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}([navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e),"optionalAccess",e=>e.version])>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),Qn=0!==Jn&&{level:Jn,hasBasic:!0,has256:Jn>=2,has16m:Jn>=3},Yn={stdout:Qn,stderr:Qn},Zn=Pn(Object.freeze({__proto__:null,default:Yn}));var Xn,eo,to,so,ro;function no(){return Xn||(Xn=1,function(e,t){const s=u,r=a;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} `;s[0]=o+s[0].split("\n").join("\n"+o),s.push(n+"m+"+e.exports.humanize(this.diff)+"")}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=Zn;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)}}(Kn,Kn.exports)),Kn.exports}function oo(){return eo||(eo=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=no()),zn.exports}var io=function(){if(ro)return Hn.exports;ro=1;var e,t,s,i=r,a=i.URL,u=n,h=o,p=c.Writable,d=l,_=function(){return so||(so=1,to=function(){if(!e){try{e=oo()("follow-redirects")}catch(e){}"function"!=typeof e&&(e=function(){})}e.apply(null,arguments)}),to;var e}();e="undefined"!=typeof process,t="undefined"!=typeof window&&"undefined"!=typeof document,s=B(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),S=w("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),L=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):P(e)?e=N(I(e)):(o=r,r=O(e),e={protocol:n}),B(r)&&(o=r,r=null),(r=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,r)).nativeProtocols=s,P(r.host)||P(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(!P((t=O(i.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){B(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 P(e){return"string"==typeof e||e instanceof String}function B(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 L;if(!P(e)&&("object"!=typeof(r=e)||!("length"in r)))throw new TypeError("data should be a string, Buffer or Uint8Array");var r;B(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 S),this.abort()):s&&s()},b.prototype.end=function(e,t,s){if(B(e)?(s=e,e=t=null):B(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 r=this._currentRequest=t.request(this._options,this._onNativeResponse);for(var n of(r._redirectable=this,m))r.on(n,E[n]);if(this._currentUrl=/^\//.test(this._options.path)?i.format(this._options):this._options.path,this._isRedirect){var o=0,a=this,c=this._requestBodyBuffers;!function e(t){if(r===a._currentRequest)if(t)a.emit("error",t);else if(o<c.length){var s=c[o++];r.finished||r.write(s.data,s.encoding,e)}else a._ended&&r.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,r=e.headers.location;if(!r||!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 n=this._options.beforeRedirect;n&&(s=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var o=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(r)?this._currentUrl:i.format(Object.assign(h,{host:p})),m=(c=r,l=g,f?new a(c,l):I(i.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(P(e)&&P(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),B(n)){var E={headers:e.headers,statusCode:t},T={url:g,method:o,headers:s};n(this._options,E,T),this._sanitizeOptions(this._options)}this._performRequest()},Hn.exports=C({http:u,https:h}),Hn.exports.wrap=C,Hn.exports}();const ao=Un(io),co="1.13.6";function lo(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}const uo=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;const ho=Symbol("internals");class po extends c.Transform{constructor(e){super({readableHighWaterMark:(e=Kr.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(e,t)=>!Kr.isUndefined(t[e]))).chunkSize});const t=this[ho]={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[ho];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,s){const r=this[ho],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:_o}=Symbol,fo=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[_o]?yield*e[_o]():yield e},go=Tn.ALPHABET.ALPHA_DIGIT+"-_",mo="function"==typeof TextEncoder?new TextEncoder:new a.TextEncoder,Eo="\r\n",To=mo.encode(Eo);class Ao{constructor(e,t){const{escapeName:s}=this.constructor,r=Kr.isString(t);let n=`Content-Disposition: form-data; name="${s(e)}"${!r&&t.name?`; filename="${s(t.name)}"`:""}${Eo}`;r?t=mo.encode(String(t).replace(/\r?\n|\r\n?/g,Eo)):n+=`Content-Type: ${t.type||"application/octet-stream"}${Eo}`,this.headers=mo.encode(n+Eo),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;Kr.isTypedArray(e)?yield e:yield*fo(e),yield To}static escapeName(e){return String(e).replace(/[\r\n"]/g,e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e]))}}class Ro extends c.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 So=(e,t)=>Kr.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 Lo=(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)},yo=(e,t)=>{const s=null!=e;return[r=>t[0]({lengthComputable:s,total:e,loaded:r}),t[1]]},bo=e=>(...t)=>Kr.asap(()=>e(...t));const Co={flush:h.constants.Z_SYNC_FLUSH,finishFlush:h.constants.Z_SYNC_FLUSH},vo={flush:h.constants.BROTLI_OPERATION_FLUSH,finishFlush:h.constants.BROTLI_OPERATION_FLUSH},Io=Kr.isFunction(h.createBrotliDecompress),{http:Oo,https:No}=ao,Mo=/https:?/,wo=Tn.protocols.map(e=>e+":"),Uo=(e,[t,s])=>(e.on("end",s).on("error",s),t);const Po=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&&a.isDeepStrictEqual(n,t))return e}}const r=i.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))},c=r.request,{sessionTimeout:l}=t;if(null!=l){let e,t=0;r.request=function(){const s=c.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 Bo(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function ko(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 Jr("Invalid proxy authorization",Jr.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){ko(e,t,e.href)}}const jo="undefined"!=typeof process&&"process"===Kr.kindOf(process),Do=(e,t)=>(({address:e,family:t})=>{if(!Kr.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}})(Kr.isObject(e)?e:{address:e,family:t}),xo={request(e,t){const s=e.protocol+"//"+e.hostname+":"+(e.port||("https:"===e.protocol?443:80)),{http2Options:r,headers:n}=e,o=Po.getSession(s,r),{HTTP2_HEADER_SCHEME:a,HTTP2_HEADER_METHOD:c,HTTP2_HEADER_PATH:l,HTTP2_HEADER_STATUS:u}=i.constants,h={[a]:e.protocol.replace(":",""),[c]:e.method,[l]:e.path};Kr.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}},Fo=jo&&function(e){return t=async function(t,s,r){let{data:i,lookup:l,family:u,httpVersion:d=1,http2Options:_}=e;const{responseType:f,responseEncoding:g}=e,m=e.method.toUpperCase();let E,T,A=!1;if(d=+d,Number.isNaN(d))throw TypeError(`Invalid protocol version: '${e.httpVersion}' is not a number`);if(1!==d&&2!==d)throw TypeError(`Unsupported protocol version '${d}'`);const R=2===d;if(l){const e=So(l,e=>Kr.isArray(e)?e:[e]);l=(t,s,r)=>{e(t,s,(e,t,n)=>{if(e)return r(e);const o=Kr.isArray(t)?t.map(e=>Do(e)):[Do(t,n)];s.all?r(e,o):r(e,o[0].address,o[0].family)})}}const S=new p.EventEmitter;function L(t){try{S.emit("abort",!t||t.type?new Nn(null,e,T):t)}catch(e){console.warn("emit error",e)}}S.once("abort",s);const y=()=>{e.cancelToken&&e.cancelToken.unsubscribe(L),e.signal&&e.signal.removeEventListener("abort",L),S.removeAllListeners()};(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(L),e.signal&&(e.signal.aborted?L():e.signal.addEventListener("abort",L))),r((e,t)=>{if(E=!0,t)return A=!0,void y();const{data:s}=e;if(s instanceof c.Readable||s instanceof c.Duplex){const e=c.finished(s,()=>{e(),y()})}else y()});const b=wn(e.baseURL,e.url,e.allowAbsoluteUrls),C=new URL(b,Tn.hasBrowserEnv?Tn.origin:void 0),v=C.protocol||wo[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 Jr("maxContentLength size of "+e.maxContentLength+" exceeded",Jr.ERR_BAD_RESPONSE,e));let r;if("GET"!==m)return Mn(t,s,{status:405,statusText:"method not allowed",headers:{},config:e});try{r=function(e,t,s){const r=s&&s.Blob||Tn.classes.Blob,n=lo(e);if(void 0===t&&r&&(t=!0),"data"===n){e=n.length?e.slice(n.length+1):e;const s=uo.exec(e);if(!s)throw new Jr("Invalid URL",Jr.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 Jr("Blob is not supported",Jr.ERR_NOT_SUPPORT);return new r([c],{type:o})}return c}throw new Jr("Unsupported protocol "+n,Jr.ERR_NOT_SUPPORT)}(e.url,"blob"===f,{Blob:e.env&&e.env.Blob})}catch(t){throw Jr.from(t,Jr.ERR_BAD_REQUEST,e)}return"text"===f?(r=r.toString(g),g&&"utf8"!==g||(r=Kr.stripBOM(r))):"stream"===f&&(r=c.Readable.from(r)),Mn(t,s,{data:r,status:200,statusText:"OK",headers:new vn,config:e})}if(-1===wo.indexOf(v))return s(new Jr("Unsupported protocol "+v,Jr.ERR_BAD_REQUEST,e));const I=vn.from(e.headers).normalize();I.set("User-Agent","axios/"+co,!1);const{onUploadProgress:O,onDownloadProgress:N}=e,M=e.maxRate;let w,U;if(Kr.isSpecCompliantForm(i)){const e=I.getContentType(/boundary=([-_\w\d]{10,70})/i);i=((e,t,s)=>{const{tag:r="form-data-boundary",size:n=25,boundary:o=r+"-"+Tn.generateString(n,go)}=s||{};if(!Kr.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=mo.encode("--"+o+Eo),a=mo.encode("--"+o+"--"+Eo);let l=a.byteLength;const u=Array.from(e.entries()).map(([e,t])=>{const s=new Ao(e,t);return l+=s.size,s});l+=i.byteLength*u.length,l=Kr.toFiniteNumber(l);const h={"Content-Type":`multipart/form-data; boundary=${o}`};return Number.isFinite(l)&&(h["Content-Length"]=l),t&&t(h),c.Readable.from(async function*(){for(const e of u)yield i,yield*e.encode();yield a}())})(i,e=>{I.set(e)},{tag:`axios-${co}-boundary`,boundary:e&&e[1]||void 0})}else if(Kr.isFormData(i)&&Kr.isFunction(i.getHeaders)){if(I.set(i.getHeaders()),!I.hasContentLength())try{const e=await a.promisify(i.getLength).call(i);Number.isFinite(e)&&e>=0&&I.setContentLength(e)}catch(e){}}else if(Kr.isBlob(i)||Kr.isFile(i))i.size&&I.setContentType(i.type||"application/octet-stream"),I.setContentLength(i.size||0),i=c.Readable.from(fo(i));else if(i&&!Kr.isStream(i)){if(Buffer.isBuffer(i));else if(Kr.isArrayBuffer(i))i=Buffer.from(new Uint8Array(i));else{if(!Kr.isString(i))return s(new Jr("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Jr.ERR_BAD_REQUEST,e));i=Buffer.from(i,"utf-8")}if(I.setContentLength(i.length,!1),e.maxBodyLength>-1&&i.length>e.maxBodyLength)return s(new Jr("Request body larger than maxBodyLength limit",Jr.ERR_BAD_REQUEST,e))}const P=Kr.toFiniteNumber(I.getContentLength());let B,k;Kr.isArray(M)?(w=M[0],U=M[1]):w=U=M,i&&(O||w)&&(Kr.isStream(i)||(i=c.Readable.from(i,{objectMode:!1})),i=c.pipeline([i,new po({maxRate:Kr.toFiniteNumber(w)})],Kr.noop),O&&i.on("progress",Uo(i,yo(P,Lo(bo(O),!1,3))))),e.auth&&(B=(e.auth.username||"")+":"+(e.auth.password||"")),!B&&C.username&&(B=C.username+":"+C.password),B&&I.delete("authorization");try{k=on(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"+(Io?", br":""),!1);const j={path:k,method:m,headers:I.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:B,protocol:v,family:u,beforeRedirect:Bo,beforeRedirects:{},http2Options:_};let D;!Kr.isUndefined(l)&&(j.lookup=l),e.socketPath?j.socketPath=e.socketPath:(j.hostname=C.hostname.startsWith("[")?C.hostname.slice(1,-1):C.hostname,j.port=C.port,ko(j,e.proxy,v+"//"+C.hostname+(C.port?":"+C.port:"")+j.path));const x=Mo.test(j.protocol);if(j.agent=x?e.httpsAgent:e.httpAgent,R?D=xo:e.transport?D=e.transport:0===e.maxRedirects?D=x?o:n:(e.maxRedirects&&(j.maxRedirects=e.maxRedirects),e.beforeRedirect&&(j.beforeRedirects.config=e.beforeRedirect),D=x?No:Oo),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=Kr.toFiniteNumber(r.headers["content-length"]);if(N||U){const e=new po({maxRate:Kr.toFiniteNumber(U)});N&&e.on("progress",Uo(e,yo(o,Lo(bo(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(h.createUnzip(Co)),delete r.headers["content-encoding"];break;case"deflate":n.push(new Ro),n.push(h.createUnzip(Co)),delete r.headers["content-encoding"];break;case"br":Io&&(n.push(h.createBrotliDecompress(vo)),delete r.headers["content-encoding"])}i=n.length>1?c.pipeline(n,Kr.noop):n[0];const l={status:r.statusCode,statusText:r.statusMessage,headers:new vn(r.headers),config:e,request:a};if("stream"===f)l.data=i,Mn(t,s,l);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(),L(new Jr("maxContentLength size of "+e.maxContentLength+" exceeded",Jr.ERR_BAD_RESPONSE,e,a)))}),i.on("aborted",function(){if(A)return;const t=new Jr("stream has been aborted",Jr.ERR_BAD_RESPONSE,e,a);i.destroy(t),s(t)}),i.on("error",function(t){T.destroyed||s(Jr.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=Kr.stripBOM(e))),l.data=e}catch(t){return s(Jr.from(t,null,e,l.request,l))}Mn(t,s,l)})}S.once("abort",e=>{i.destroyed||(i.emit("error",e),i.destroy())})}),S.once("abort",e=>{T.close?T.close():T.destroy(e)}),T.on("error",function(t){s(Jr.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 L(new Jr("error trying to parse `config.timeout` to int",Jr.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||cn;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),L(new Jr(t,s.clarifyTimeoutError?Jr.ETIMEDOUT:Jr.ECONNABORTED,e,T))})}else T.setTimeout(0);if(Kr.isStream(i)){let t=!1,s=!1;i.on("end",()=>{t=!0}),i.once("error",e=>{s=!0,T.destroy(e)}),i.on("close",()=>{t||s||L(new Nn("Request stream has been aborted",e,T))}),i.pipe(T)}else i&&T.write(i),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},qo=Tn.hasStandardBrowserEnv?((e,t)=>s=>(s=new URL(s,Tn.origin),e.protocol===s.protocol&&e.host===s.host&&(t||e.port===s.port)))(new URL(Tn.origin),Tn.navigator&&/(msie|trident)/i.test(Tn.navigator.userAgent)):()=>!0,Go=Tn.hasStandardBrowserEnv?{write(e,t,s,r,n,o,i){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Kr.isNumber(s)&&a.push(`expires=${new Date(s).toUTCString()}`),Kr.isString(r)&&a.push(`path=${r}`),Kr.isString(n)&&a.push(`domain=${n}`),!0===o&&a.push("secure"),Kr.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(){}},Ho=e=>e instanceof vn?{...e}:e;function zo(e,t){t=t||{};const s={};function r(e,t,s,r){return Kr.isPlainObject(e)&&Kr.isPlainObject(t)?Kr.merge.call({caseless:r},e,t):Kr.isPlainObject(t)?Kr.merge({},t):Kr.isArray(t)?t.slice():t}function n(e,t,s,n){return Kr.isUndefined(t)?Kr.isUndefined(e)?void 0:r(void 0,e,0,n):r(e,t,0,n)}function o(e,t){if(!Kr.isUndefined(t))return r(void 0,t)}function i(e,t){return Kr.isUndefined(t)?Kr.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(Ho(e),Ho(t),0,!0)};return Kr.forEach(Object.keys({...e,...t}),function(r){if("__proto__"===r||"constructor"===r||"prototype"===r)return;const o=Kr.hasOwnProp(c,r)?c[r]:n,i=o(e[r],t[r],r);Kr.isUndefined(i)&&o!==a||(s[r]=i)}),s}const Wo=e=>{const t=zo({},e);let{data:s,withXSRFToken:r,xsrfHeaderName:n,xsrfCookieName:o,headers:i,auth:a}=t;if(t.headers=i=vn.from(i),t.url=on(wn(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Kr.isFormData(s))if(Tn.hasStandardBrowserEnv||Tn.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Kr.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(Tn.hasStandardBrowserEnv&&(r&&Kr.isFunction(r)&&(r=r(t)),r||!1!==r&&qo(t.url))){const e=n&&o&&Go.read(o);e&&i.set(n,e)}return t},$o="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,s){const r=Wo(e);let n=r.data;const o=vn.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=vn.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());Mn(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 Jr("Request aborted",Jr.ECONNABORTED,e,f)),f=null)},f.onerror=function(t){const r=t&&t.message?t.message:"Network Error",n=new Jr(r,Jr.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||cn;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),s(new Jr(t,n.clarifyTimeoutError?Jr.ETIMEDOUT:Jr.ECONNABORTED,e,f)),f=null},void 0===n&&o.setContentType(null),"setRequestHeader"in f&&Kr.forEach(o.toJSON(),function(e,t){f.setRequestHeader(t,e)}),Kr.isUndefined(r.withCredentials)||(f.withCredentials=!!r.withCredentials),h&&"json"!==h&&(f.responseType=r.responseType),d&&([c,u]=Lo(d,!0),f.addEventListener("progress",c)),p&&f.upload&&([a,l]=Lo(p),f.upload.addEventListener("progress",a),f.upload.addEventListener("loadend",l)),(r.cancelToken||r.signal)&&(i=t=>{f&&(s(!t||t.type?new Nn(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=lo(r.url);m&&-1===Tn.protocols.indexOf(m)?s(new Jr("Unsupported protocol "+m+":",Jr.ERR_BAD_REQUEST,e)):f.send(n||null)})},Vo=(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 Jr?t:new Nn(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,n(new Jr(`timeout of ${t}ms exceeded`,Jr.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=()=>Kr.asap(i),a}},Ko=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},Jo=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()}},Qo=(e,t,s,r)=>{const n=async function*(e,t){for await(const s of Jo(e))yield*Ko(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:Yo}=Kr,Zo=(({Request:e,Response:t})=>({Request:e,Response:t}))(Kr.global),{ReadableStream:Xo,TextEncoder:ei}=Kr.global,ti=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},si=e=>{e=Kr.merge.call({skipUndefined:!0},Zo,e);const{fetch:t,Request:s,Response:r}=e,n=t?Yo(t):"function"==typeof fetch,o=Yo(s),i=Yo(r);if(!n)return!1;const a=n&&Yo(Xo),c=n&&("function"==typeof ei?(l=new ei,e=>l.encode(e)):async e=>new Uint8Array(await new s(e).arrayBuffer()));var l;const u=o&&a&&ti(()=>{let e=!1;const t=new s(Tn.origin,{body:new Xo,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),h=i&&a&&ti(()=>Kr.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 Jr(`Response type '${e}' is not supported`,Jr.ERR_NOT_SUPPORT,s)})});const d=async(e,t)=>{const r=Kr.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Kr.isBlob(e))return e.size;if(Kr.isSpecCompliantForm(e)){const t=new s(Tn.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Kr.isArrayBufferView(e)||Kr.isArrayBuffer(e)?e.byteLength:(Kr.isURLSearchParams(e)&&(e+=""),Kr.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}=Wo(e),R=t||fetch;m=m?(m+"").toLowerCase():"text";let S=Vo([c,l&&l.toAbortSignal()],_),L=null;const y=S&&S.unsubscribe&&(()=>{S.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(Kr.isFormData(a)&&(e=t.headers.get("content-type"))&&E.setContentType(e),t.body){const[e,s]=yo(b,Lo(bo(g)));a=Qo(t.body,65536,e,s)}}Kr.isString(T)||(T=T?"include":"omit");const t=o&&"credentials"in s.prototype,c={...A,signal:S,method:i.toUpperCase(),headers:E.normalize().toJSON(),body:a,duplex:"half",credentials:t?T:void 0};L=o&&new s(n,c);let l=await(o?R(L,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=Kr.toFiniteNumber(l.headers.get("content-length")),[s,n]=f&&yo(t,Lo(bo(f),!0))||[];l=new r(Qo(l.body,65536,s,()=>{n&&n(),y&&y()}),e)}m=m||"text";let C=await p[Kr.findKey(p,m)||"text"](l,e);return!_&&y&&y(),await new Promise((t,s)=>{Mn(t,s,{data:C,headers:vn.from(l.headers),status:l.status,statusText:l.statusText,config:e,request:L})})}catch(t){if(y&&y(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Jr("Network Error",Jr.ERR_NETWORK,e,L,t&&t.response),{cause:t.cause||t});throw Jr.from(t,t&&t.code,e,L,t&&t.response)}}},ri=new Map,ni=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=ri;for(;c--;)i=o[c],a=l.get(i),void 0===a&&l.set(i,a=c?new Map:si(t)),l=a;return a};ni();const oi={http:Fo,xhr:$o,fetch:{get:ni}};Kr.forEach(oi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const ii=e=>`- ${e}`,ai=e=>Kr.isFunction(e)||null===e||!1===e;const ci={getAdapter:function(e,t){e=Kr.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,!ai(r)&&(n=oi[(s=String(r)).toLowerCase()],void 0===n))throw new Jr(`Unknown adapter '${s}'`);if(n&&(Kr.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(ii).join("\n"):" "+ii(e[0]):"as no adapter specified";throw new Jr("There is no suitable adapter to dispatch the request "+t,"ERR_NOT_SUPPORT")}return n},adapters:oi};function li(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Nn(null,e)}function ui(e){li(e),e.headers=vn.from(e.headers),e.data=In.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ci.getAdapter(e.adapter||Rn.adapter,e)(e).then(function(t){return li(e),t.data=In.call(e,e.transformResponse,t),t.headers=vn.from(t.headers),t},function(t){return On(t)||(li(e),t&&t.response&&(t.response.data=In.call(e,e.transformResponse,t.response),t.response.headers=vn.from(t.response.headers))),Promise.reject(t)})}const hi={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{hi[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const pi={};hi.transitional=function(e,t,s){function r(e,t){return"[Axios v"+co+"] Transitional option '"+e+"'"+t+(s?". "+s:"")}return(s,n,o)=>{if(!1===e)throw new Jr(r(n," has been removed"+(t?" in "+t:"")),Jr.ERR_DEPRECATED);return t&&!pi[n]&&(pi[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)}},hi.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};const di={assertOptions:function(e,t,s){if("object"!=typeof e)throw new Jr("options must be an object",Jr.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 Jr("option "+o+" must be "+s,Jr.ERR_BAD_OPTION_VALUE);continue}if(!0!==s)throw new Jr("Unknown option "+o,Jr.ERR_BAD_OPTION)}},validators:hi},_i=di.validators;let fi=class{constructor(e){this.defaults=e||{},this.interceptors={request:new an,response:new an}}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=zo(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:n}=t;void 0!==s&&di.assertOptions(s,{silentJSONParsing:_i.transitional(_i.boolean),forcedJSONParsing:_i.transitional(_i.boolean),clarifyTimeoutError:_i.transitional(_i.boolean),legacyInterceptorReqResOrdering:_i.transitional(_i.boolean)},!1),null!=r&&(Kr.isFunction(r)?t.paramsSerializer={serialize:r}:di.assertOptions(r,{encode:_i.function,serialize:_i.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),di.assertOptions(t,{baseUrl:_i.spelling("baseURL"),withXsrfToken:_i.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=n&&Kr.merge(n.common,n[t.method]);n&&Kr.forEach(["delete","get","head","post","put","patch","common"],e=>{delete n[e]}),t.headers=vn.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||cn;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=[ui.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=ui.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 on(wn((e=zo(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Kr.forEach(["delete","get","head","options"],function(e){fi.prototype[e]=function(t,s){return this.request(zo(s||{},{method:e,url:t,data:(s||{}).data}))}}),Kr.forEach(["post","put","patch"],function(e){function t(t){return function(s,r,n){return this.request(zo(n||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:s,data:r}))}}fi.prototype[e]=t(),fi.prototype[e+"Form"]=t(!0)});const gi={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(gi).forEach(([e,t])=>{gi[t]=e});const mi=function e(t){const s=new fi(t),r=sr(fi.prototype.request,s);return Kr.extend(r,fi.prototype,s,{allOwnKeys:!0}),Kr.extend(r,s,null,{allOwnKeys:!0}),r.create=function(s){return e(zo(t,s))},r}(Rn);mi.Axios=fi,mi.CanceledError=Nn,mi.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 Nn(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}}},mi.isCancel=On,mi.VERSION=co,mi.toFormData=en,mi.AxiosError=Jr,mi.Cancel=mi.CanceledError,mi.all=function(e){return Promise.all(e)},mi.spread=function(e){return function(t){return e.apply(null,t)}},mi.isAxiosError=function(e){return Kr.isObject(e)&&!0===e.isAxiosError},mi.mergeConfig=zo,mi.AxiosHeaders=vn,mi.formToJSON=e=>An(Kr.isHTMLForm(e)?new FormData(e):e),mi.getAdapter=ci.getAdapter,mi.HttpStatusCode=gi,mi.default=mi;const{Axios:Ei,AxiosError:Ti,CanceledError:Ai,isCancel:Ri,CancelToken:Si,VERSION:Li,all:yi,Cancel:bi,isAxiosError:Ci,spread:vi,toFormData:Ii,AxiosHeaders:Oi,HttpStatusCode:Ni,formToJSON:Mi,getAdapter:wi,mergeConfig:Ui}=mi;function Pi(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 Bi(){return function(e={}){const{isSuccess:t=e=>0===e,getCode:s=e=>Pi([e,"access",e=>e.data,"optionalAccess",e=>e.code]),getMessage:r=e=>Pi([e,"access",e=>e.data,"optionalAccess",e=>e.message])||Pi([e,"access",e=>e.data,"optionalAccess",e=>e.msg]),getData:n=e=>Pi([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 tr(c,{status:e.status,code:a,config:e.config,response:e,data:e.data});return e}}}({isSuccess:e=>0===e,getCode:e=>Pi([e,"access",e=>e.data,"optionalAccess",e=>e.code]),getMessage:e=>Pi([e,"access",e=>e.data,"optionalAccess",e=>e.message])||Pi([e,"access",e=>e.data,"optionalAccess",e=>e.msg]),getData:e=>e.data})}function ki(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 ji={"/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 Di(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=ms(e);for(const e of t){const t=Et(s,e);if("string"==typeof t){const r=Number(t);Number.isInteger(r)&&Qs(s,e,r)}else Array.isArray(t)&&Qs(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 xi(e={}){const t=mi.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 ki([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=ki([e,"access",e=>e.method,"optionalAccess",e=>e.toLowerCase,"call",e=>e()])||"get";var a;return s.includes(i)&&(a="content-type",!("function"==typeof ki([e,"access",e=>e.headers,"optionalAccess",e=>e.get])?e.headers.get(a):ki([e,"access",e=>e.headers,"optionalAccess",e=>e[a]])))&&(o("content-type",r),n&&!e.data&&(e.data={})),e}}}(),Di({config:ji}),Bi(),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 Fi=xi({baseURL:"/",headers:{"Agw-Js-Conv":"str"}}),qi=Fi,Gi=(e,t)=>qi({...e,...t});var Hi,zi,Wi,$i,Vi,Ki,Ji,Qi,Yi,Zi,Xi,ea,ta,sa,ra,na,oa;function ia(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";e[e.OpenClawChannelTypeWeCom=3]="OpenClawChannelTypeWeCom"}(Hi||(Hi={})),function(e){e[e.OpenClawLarkAuthStatusAuthorized=1]="OpenClawLarkAuthStatusAuthorized";e[e.OpenClawLarkAuthStatusUnauthorized=2]="OpenClawLarkAuthStatusUnauthorized"}(zi||(zi={})),function(e){e[e.OpenClawLarkConfigStatusNotCreated=1]="OpenClawLarkConfigStatusNotCreated";e[e.OpenClawLarkConfigStatusCreated=2]="OpenClawLarkConfigStatusCreated";e[e.OpenClawLarkConfigStatusConfigured=3]="OpenClawLarkConfigStatusConfigured"}(Wi||(Wi={})),function(e){e[e.OpenClawUpdateStatusNoUpdate=1]="OpenClawUpdateStatusNoUpdate";e[e.OpenClawUpdateStatusPending=2]="OpenClawUpdateStatusPending";e[e.OpenClawUpdateStatusUpdating=3]="OpenClawUpdateStatusUpdating"}($i||($i={})),function(e){e[e.OpenClawVersionTypeFull=1]="OpenClawVersionTypeFull";e[e.OpenClawVersionTypeLite=2]="OpenClawVersionTypeLite"}(Vi||(Vi={})),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"}(Ki||(Ki={})),function(e){e[e.Unknown=0]="Unknown";e[e.Like=1]="Like";e[e.Dislike=2]="Dislike"}(Ji||(Ji={})),function(e){e[e.Wait=0]="Wait";e[e.Done=1]="Done"}(Qi||(Qi={})),function(e){e[e.RoleTypeUnknown=0]="RoleTypeUnknown";e[e.RoleTypeUser=1]="RoleTypeUser";e[e.RoleTypeAssistant=2]="RoleTypeAssistant"}(Yi||(Yi={})),function(e){e[e.AddAttributes=1]="AddAttributes";e[e.RemoveAttributes=2]="RemoveAttributes"}(Zi||(Zi={})),function(e){e[e.CloseConnection=1]="CloseConnection"}(Xi||(Xi={})),function(e){e[e.ON_LINE=0]="ON_LINE";e[e.OFF_LINE=1]="OFF_LINE";e[e.TOUCH=2]="TOUCH"}(ea||(ea={})),function(e){e[e.AddGroups=1]="AddGroups";e[e.RemoveGroups=2]="RemoveGroups";e[e.ReplaceWithGroups=3]="ReplaceWithGroups"}(ta||(ta={})),function(e){e[e.App=0]="App";e[e.Service=1]="Service";e[e.Method=2]="Method"}(sa||(sa={})),function(e){e[e.ApiKey=1]="ApiKey";e[e.WechatOfficialAccount=2]="WechatOfficialAccount";e[e.OAuth=3]="OAuth"}(ra||(ra={})),function(e){e[e.PROJECT_COPY=1]="PROJECT_COPY";e[e.SKILL_STORE=2]="SKILL_STORE"}(na||(na={})),function(e){e[e.PENDING=1]="PENDING";e[e.SUCCESS=2]="SUCCESS";e[e.FAILED=3]="FAILED"}(oa||(oa={}));class aa{__init(){this.request=Gi}__init2(){this.baseURL=""}constructor(e){aa.prototype.__init.call(this),aa.prototype.__init2.call(this),this.request=ia([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=ia([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)}ConnectOpenClawFeishu(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/connect_feishu`),n={app_name:s.app_name,recreate:s.recreate,avatar_url:s.avatar_url};return this.request({url:r,method:"POST",data:n},t)}ConnectOpenClawWeChat(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/connect_wechat`);return this.request({url:r,method:"POST"},t)}ConnectOpenClawWeCom(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/connect_wecom`),n={bot_id:s.bot_id,secret:s.secret};return this.request({url:r,method:"POST",data:n},t)}}const ca=new aa({});class la{constructor({options:e,reportLog:t}){this.mergedBaseOptions=Xs({scenes:{[E.GetMessage]:async(...e)=>await ca.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=Xs(this.mergedBaseOptions,e)}getSceneConfig(e){const{scenes:t}=this.mergedBaseOptions;return t[e]}}class ua{constructor(){ua.prototype.__init.call(this)}__init(){this.preSendLocalMessageEvents=e()}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 ha{getSendChatMessageStructure(e,t){const s=Vs(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 Js(s,e=>null!=e&&""!==e)}}function pa(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 da=["console","file","text"],_a="generate_image";function fa(e,t){return null!=e?e:t()}function ga(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 ma=(e,t)=>{const s=t.at(0);if(!s)return e;if("message_start"===s.type||"message_end"===s.type)return ms(s);const r=ms(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=>fa(e.content.answer,()=>""));r.content.answer=fa(r.content.answer,()=>"")+e.join("")}else if("thinking"===r.type){const e=o.map(e=>fa(e.content.thinking,()=>""));r.content.thinking=fa(r.content.thinking,()=>"")+e.join("")}else if("tool_request"===r.type&&r.content.tool_request){const e=o.map(e=>fa(ga([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters]),()=>""));r.content.tool_request.stream_parameters=fa(r.content.tool_request.stream_parameters,()=>"")+e.join("")}else if("tool_process"===r.type){const e=o.map(e=>ga([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=>pa([e,"optionalAccess",e=>e[_a],"optionalAccess",e=>e.images])||[]).flat();return(n.length>0||!$s(pa([e,"optionalAccess",e=>e[_a]])))&&(s[_a]={images:(pa([e,"optionalAccess",e=>e[_a],"optionalAccess",e=>e.images])||[]).concat(n)},r=!0),da.forEach(n=>{const o=t.filter(e=>!$s(pa([e,"optionalAccess",e=>e[n]]))).map(e=>pa([e,"optionalAccess",e=>e[n]])||"");(o.length>0||!$s(pa([e,"optionalAccess",e=>e[n]])))&&(s[n]=(pa([e,"optionalAccess",e=>e[n]])||"")+o.join(""),r=!0)}),r?s:e||{}}(ga([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 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}class Ta{__init(){this.streamBufferSnapshot=null}constructor(e){Ta.prototype.__init.call(this),Ta.prototype.__init2.call(this),Ta.prototype.__init3.call(this),this.key=e.key}__init2(){this.getBufferMeta=e=>{return{query_msg_id:(t=Ea([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 Aa{__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){Aa.prototype.__init.call(this),Aa.prototype.__init2.call(this),Aa.prototype.__init3.call(this),Aa.prototype.__init4.call(this),Aa.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 Ra;!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"}(Ra||(Ra={}));const Sa={[Ra.QUOTATION_MARK]:Ra.QUOTATION_MARK,[Ra.REVERSE_SOLIDUS]:Ra.REVERSE_SOLIDUS,[Ra.SOLIDUS]:Ra.SOLIDUS,[Ra.LATIN_SMALL_LETTER_B]:Ra.BACKSPACE,[Ra.LATIN_SMALL_LETTER_F]:Ra.FORM_FEED,[Ra.LATIN_SMALL_LETTER_N]:Ra.NEWLINE,[Ra.LATIN_SMALL_LETTER_R]:Ra.CARRIAGE_RETURN,[Ra.LATIN_SMALL_LETTER_T]:Ra.TAB};class La{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 ya{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 ba,Ca;function va(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"}(ba||(ba={})),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"}(Ca||(Ca={}));const Ia={stringBufferSize:0,numberBufferSize:0,separator:void 0,emitPartialTokens:!1};class Oa extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Oa.prototype)}}class Na{constructor(e){this.state=Ca.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({},Ia),e),this.emitPartialTokens=!0===e.emitPartialTokens,this.bufferedString=e.stringBufferSize&&e.stringBufferSize>4?new ya(e.stringBufferSize):new La,this.bufferedNumber=e.numberBufferSize&&e.numberBufferSize>0?new ya(e.numberBufferSize):new La,this.separator=e.separator,this.separatorBytes=e.separator?this.encoder.encode(e.separator):void 0}get isEnded(){return this.state===Ca.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 Ca.BOM_OR_START:if(e instanceof Uint8Array&&239===r){this.bom=[239,187,191],this.bomIndex+=1,this.state=Ca.BOM;continue}if(e instanceof Uint16Array){if(254===r){this.bom=[254,255],this.bomIndex+=1,this.state=Ca.BOM;continue}if(255===r){this.bom=[255,254],this.bomIndex+=1,this.state=Ca.BOM;continue}}if(e instanceof Uint32Array){if(0===r){this.bom=[0,0,254,255],this.bomIndex+=1,this.state=Ca.BOM;continue}if(255===r){this.bom=[255,254,0,0],this.bomIndex+=1,this.state=Ca.BOM;continue}}case Ca.START:if(this.offset+=1,this.separatorBytes&&r===this.separatorBytes[0]){if(1===this.separatorBytes.length){this.state=Ca.START,this.onToken({token:ba.SEPARATOR,value:this.separator,offset:this.offset+this.separatorBytes.length-1});continue}this.state=Ca.SEPARATOR;continue}if(r===Ra.SPACE||r===Ra.NEWLINE||r===Ra.CARRIAGE_RETURN||r===Ra.TAB)continue;if(r===Ra.LEFT_CURLY_BRACKET){this.onToken({token:ba.LEFT_BRACE,value:"{",offset:this.offset});continue}if(r===Ra.RIGHT_CURLY_BRACKET){this.onToken({token:ba.RIGHT_BRACE,value:"}",offset:this.offset});continue}if(r===Ra.LEFT_SQUARE_BRACKET){this.onToken({token:ba.LEFT_BRACKET,value:"[",offset:this.offset});continue}if(r===Ra.RIGHT_SQUARE_BRACKET){this.onToken({token:ba.RIGHT_BRACKET,value:"]",offset:this.offset});continue}if(r===Ra.COLON){this.onToken({token:ba.COLON,value:":",offset:this.offset});continue}if(r===Ra.COMMA){this.onToken({token:ba.COMMA,value:",",offset:this.offset});continue}if(r===Ra.LATIN_SMALL_LETTER_T){this.state=Ca.TRUE1;continue}if(r===Ra.LATIN_SMALL_LETTER_F){this.state=Ca.FALSE1;continue}if(r===Ra.LATIN_SMALL_LETTER_N){this.state=Ca.NULL1;continue}if(r===Ra.QUOTATION_MARK){this.bufferedString.reset(),this.escapedCharsByteLength=0,this.state=Ca.STRING_DEFAULT;continue}if(r>=Ra.DIGIT_ONE&&r<=Ra.DIGIT_NINE){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_NON_ZERO;continue}if(r===Ra.DIGIT_ZERO){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_ZERO;continue}if(r===Ra.HYPHEN_MINUS){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_MINUS;continue}break;case Ca.STRING_DEFAULT:if(r===Ra.QUOTATION_MARK){const e=this.bufferedString.toString();this.state=Ca.START,this.onToken({token:ba.STRING,value:e,offset:this.offset}),this.offset+=this.escapedCharsByteLength+this.bufferedString.byteLength+1;continue}if(r===Ra.REVERSE_SOLIDUS){this.state=Ca.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=Ca.STRING_INCOMPLETE_CHAR;continue}if(r>=Ra.SPACE){this.bufferedString.appendChar(r);continue}break;case Ca.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=Ca.STRING_DEFAULT;continue;case Ca.STRING_AFTER_BACKSLASH:const n=Sa[r];if(n){this.bufferedString.appendChar(n),this.escapedCharsByteLength+=1,this.state=Ca.STRING_DEFAULT;continue}if(r===Ra.LATIN_SMALL_LETTER_U){this.unicode="",this.state=Ca.STRING_UNICODE_DIGIT_1;continue}break;case Ca.STRING_UNICODE_DIGIT_1:case Ca.STRING_UNICODE_DIGIT_2:case Ca.STRING_UNICODE_DIGIT_3:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE||r>=Ra.LATIN_CAPITAL_LETTER_A&&r<=Ra.LATIN_CAPITAL_LETTER_F||r>=Ra.LATIN_SMALL_LETTER_A&&r<=Ra.LATIN_SMALL_LETTER_F){this.unicode+=String.fromCharCode(r),this.state+=1;continue}break;case Ca.STRING_UNICODE_DIGIT_4:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE||r>=Ra.LATIN_CAPITAL_LETTER_A&&r<=Ra.LATIN_CAPITAL_LETTER_F||r>=Ra.LATIN_SMALL_LETTER_A&&r<=Ra.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=Ca.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=Ca.STRING_DEFAULT;continue}break;case Ca.NUMBER_AFTER_INITIAL_MINUS:if(r===Ra.DIGIT_ZERO){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_ZERO;continue}if(r>=Ra.DIGIT_ONE&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_NON_ZERO;continue}break;case Ca.NUMBER_AFTER_INITIAL_ZERO:if(r===Ra.FULL_STOP){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_FULL_STOP;continue}if(r===Ra.LATIN_SMALL_LETTER_E||r===Ra.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E;continue}s-=1,this.state=Ca.START,this.emitNumber();continue;case Ca.NUMBER_AFTER_INITIAL_NON_ZERO:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r);continue}if(r===Ra.FULL_STOP){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_FULL_STOP;continue}if(r===Ra.LATIN_SMALL_LETTER_E||r===Ra.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E;continue}s-=1,this.state=Ca.START,this.emitNumber();continue;case Ca.NUMBER_AFTER_FULL_STOP:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_DECIMAL;continue}break;case Ca.NUMBER_AFTER_DECIMAL:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r);continue}if(r===Ra.LATIN_SMALL_LETTER_E||r===Ra.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E;continue}s-=1,this.state=Ca.START,this.emitNumber();continue;case Ca.NUMBER_AFTER_E:if(r===Ra.PLUS_SIGN||r===Ra.HYPHEN_MINUS){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E_AND_SIGN;continue}case Ca.NUMBER_AFTER_E_AND_SIGN:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E_AND_DIGIT;continue}break;case Ca.NUMBER_AFTER_E_AND_DIGIT:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r);continue}s-=1,this.state=Ca.START,this.emitNumber();continue;case Ca.TRUE1:if(r===Ra.LATIN_SMALL_LETTER_R){this.state=Ca.TRUE2;continue}break;case Ca.TRUE2:if(r===Ra.LATIN_SMALL_LETTER_U){this.state=Ca.TRUE3;continue}break;case Ca.TRUE3:if(r===Ra.LATIN_SMALL_LETTER_E){this.state=Ca.START,this.onToken({token:ba.TRUE,value:!0,offset:this.offset}),this.offset+=3;continue}break;case Ca.FALSE1:if(r===Ra.LATIN_SMALL_LETTER_A){this.state=Ca.FALSE2;continue}break;case Ca.FALSE2:if(r===Ra.LATIN_SMALL_LETTER_L){this.state=Ca.FALSE3;continue}break;case Ca.FALSE3:if(r===Ra.LATIN_SMALL_LETTER_S){this.state=Ca.FALSE4;continue}break;case Ca.FALSE4:if(r===Ra.LATIN_SMALL_LETTER_E){this.state=Ca.START,this.onToken({token:ba.FALSE,value:!1,offset:this.offset}),this.offset+=4;continue}break;case Ca.NULL1:if(r===Ra.LATIN_SMALL_LETTER_U){this.state=Ca.NULL2;continue}break;case Ca.NULL2:if(r===Ra.LATIN_SMALL_LETTER_L){this.state=Ca.NULL3;continue}break;case Ca.NULL3:if(r===Ra.LATIN_SMALL_LETTER_L){this.state=Ca.START,this.onToken({token:ba.NULL,value:null,offset:this.offset}),this.offset+=3;continue}break;case Ca.SEPARATOR:if(this.separatorIndex+=1,!this.separatorBytes||r!==this.separatorBytes[this.separatorIndex])break;this.separatorIndex===this.separatorBytes.length-1&&(this.state=Ca.START,this.onToken({token:ba.SEPARATOR,value:this.separator,offset:this.offset+this.separatorIndex}),this.separatorIndex=0);continue;case Ca.BOM:if(r===this.bom[this.bomIndex]){if(this.bomIndex===this.bom.length-1){this.state=Ca.START,this.bom=void 0,this.bomIndex=0;continue}this.bomIndex+=1;continue}break;case Ca.ENDED:if(r===Ra.SPACE||r===Ra.NEWLINE||r===Ra.CARRIAGE_RETURN||r===Ra.TAB)continue}throw new Oa(`Unexpected "${String.fromCharCode(r)}" at position "${s}" in state ${va(this.state)}`)}if(this.emitPartialTokens)switch(this.state){case Ca.TRUE1:case Ca.TRUE2:case Ca.TRUE3:this.onToken({token:ba.TRUE,value:!0,offset:this.offset,partial:!0});break;case Ca.FALSE1:case Ca.FALSE2:case Ca.FALSE3:case Ca.FALSE4:this.onToken({token:ba.FALSE,value:!1,offset:this.offset,partial:!0});break;case Ca.NULL1:case Ca.NULL2:case Ca.NULL3:this.onToken({token:ba.NULL,value:null,offset:this.offset,partial:!0});break;case Ca.STRING_DEFAULT:{const e=this.bufferedString.toString();this.onToken({token:ba.STRING,value:e,offset:this.offset,partial:!0});break}case Ca.NUMBER_AFTER_INITIAL_ZERO:case Ca.NUMBER_AFTER_INITIAL_NON_ZERO:case Ca.NUMBER_AFTER_DECIMAL:case Ca.NUMBER_AFTER_E_AND_DIGIT:try{this.onToken({token:ba.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset,partial:!0})}catch(e){}}}catch(e){this.error(e)}}emitNumber(){this.onToken({token:ba.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!==Ca.ENDED&&(this.state=Ca.ERROR),this.onError(e)}end(){switch(this.state){case Ca.NUMBER_AFTER_INITIAL_ZERO:case Ca.NUMBER_AFTER_INITIAL_NON_ZERO:case Ca.NUMBER_AFTER_DECIMAL:case Ca.NUMBER_AFTER_E_AND_DIGIT:this.state=Ca.ENDED,this.emitNumber(),this.onEnd();break;case Ca.BOM_OR_START:case Ca.START:case Ca.ERROR:case Ca.SEPARATOR:this.state=Ca.ENDED,this.onEnd();break;default:this.error(new Oa(`Tokenizer ended in the middle of a token (state: ${va(this.state)}). Either not all the data was received or the data was invalid.`))}}onToken(e){throw new Oa('Can\'t emit tokens before the "onToken" callback has been set up.')}onError(e){throw e}onEnd(){}}var Ma,wa;function Ua(e){return["VALUE","KEY","COLON","COMMA","ENDED","ERROR","SEPARATOR"][e]}!function(e){e[e.OBJECT=0]="OBJECT",e[e.ARRAY=1]="ARRAY"}(Ma||(Ma={})),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"}(wa||(wa={}));const Pa={paths:void 0,keepStack:!0,separator:void 0,emitPartialValues:!1};class Ba extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Ba.prototype)}}class ka{constructor(e){this.state=wa.VALUE,this.mode=void 0,this.key=void 0,this.value=void 0,this.stack=[],(e=Object.assign(Object.assign({},Pa),e)).paths&&(this.paths=e.paths.map(e=>{if(void 0===e||"$*"===e)return;if(!e.startsWith("$"))throw new Ba(`Invalid selector "${e}". Should start with "$".`);const t=e.split(".").slice(1);if(t.includes(""))throw new Ba(`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?wa.COMMA:wa.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=wa.SEPARATOR:void 0===this.separator&&this.end())}emitPartial(e){this.shouldEmit()&&(this.state!==wa.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===wa.ENDED}write({token:e,value:t,partial:s}){try{if(s)return void this.emitPartial(t);if(this.state===wa.VALUE){if(e===ba.STRING||e===ba.NUMBER||e===ba.TRUE||e===ba.FALSE||e===ba.NULL)return this.mode===Ma.OBJECT?(this.value[this.key]=t,this.state=wa.COMMA):this.mode===Ma.ARRAY&&(this.value.push(t),this.state=wa.COMMA),void this.emit(t,this.shouldEmit());if(e===ba.LEFT_BRACE){if(this.push(),this.mode===Ma.OBJECT)this.value=this.value[this.key]={};else if(this.mode===Ma.ARRAY){const e={};this.value.push(e),this.value=e}else this.value={};return this.mode=Ma.OBJECT,this.state=wa.KEY,this.key=void 0,void this.emitPartial()}if(e===ba.LEFT_BRACKET){if(this.push(),this.mode===Ma.OBJECT)this.value=this.value[this.key]=[];else if(this.mode===Ma.ARRAY){const e=[];this.value.push(e),this.value=e}else this.value=[];return this.mode=Ma.ARRAY,this.state=wa.VALUE,this.key=0,void this.emitPartial()}if(this.mode===Ma.ARRAY&&e===ba.RIGHT_BRACKET&&0===this.value.length)return void this.pop()}if(this.state===wa.KEY){if(e===ba.STRING)return this.key=t,this.state=wa.COLON,void this.emitPartial();if(e===ba.RIGHT_BRACE&&0===Object.keys(this.value).length)return void this.pop()}if(this.state===wa.COLON&&e===ba.COLON)return void(this.state=wa.VALUE);if(this.state===wa.COMMA){if(e===ba.COMMA){if(this.mode===Ma.ARRAY)return this.state=wa.VALUE,void(this.key+=1);if(this.mode===Ma.OBJECT)return void(this.state=wa.KEY)}if(e===ba.RIGHT_BRACE&&this.mode===Ma.OBJECT||e===ba.RIGHT_BRACKET&&this.mode===Ma.ARRAY)return void this.pop()}if(this.state===wa.SEPARATOR&&e===ba.SEPARATOR&&t===this.separator)return void(this.state=wa.VALUE);if(e===ba.SEPARATOR&&this.state!==wa.SEPARATOR&&Array.from(t).map(e=>e.charCodeAt(0)).every(e=>e===Ra.SPACE||e===Ra.NEWLINE||e===Ra.CARRIAGE_RETURN||e===Ra.TAB))return;throw new Ba(`Unexpected ${ba[e]} (${JSON.stringify(t)}) in state ${Ua(this.state)}`)}catch(e){this.error(e)}}error(e){this.state!==wa.ENDED&&(this.state=wa.ERROR),this.onError(e)}end(){this.state!==wa.VALUE&&this.state!==wa.SEPARATOR||this.stack.length>0?this.error(new Error(`Parser ended in mid-parsing (state: ${Ua(this.state)}). Either not all the data was received or the data was invalid.`)):(this.state=wa.ENDED,this.onEnd())}onValue(e){throw new Ba('Can\'t emit data before the "onValue" callback has been set up.')}onError(e){throw e}onEnd(){}}class ja{constructor(e={}){this.tokenizer=new Na(e),this.tokenParser=new ka(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 Da;function xa(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}(Da||(Da={})).STREAM_PARSER_JSON_ERROR="chat_sdk_pull_stream_parser_error";class Fa{__init(){this.parserOptions={emitPartialValues:!0,emitPartialTokens:!0,keepStack:!0}}__init2(){this.jsonParserMap={}}__init3(){this.jsonParserMetaMap={}}constructor(e){Fa.prototype.__init.call(this),Fa.prototype.__init2.call(this),Fa.prototype.__init3.call(this),Fa.prototype.__init4.call(this),Fa.prototype.__init5.call(this),Fa.prototype.__init6.call(this),Fa.prototype.__init7.call(this),Fa.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 ja(this.parserOptions);return this.jsonParserMap[e]=t,this.jsonParserMetaMap[e]={isError:!1},this.jsonParserMap[e]}}__init5(){this.updateJsonParserMeta=(e,t)=>{Ys(this.jsonParserMetaMap,e,t)}}__init6(){this.write=(e,t,{onValue:s,onError:r,onEnd:n,onToken:o})=>{const i=this.getJsonParser(e);xa([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})),xa([r,"optionalCall",e=>e(t)]),this.reportLogWithScope.slardarErrorEvent({error:t,eventName:Da.STREAM_PARSER_JSON_ERROR,meta:{msgId:e}})},i.onEnd=()=>{this.clearByMsgId(e),xa([n,"optionalCall",e=>e()])},o&&(i.onToken=o),i.write(t))}}__init7(){this.clearParserCallback=e=>{e.onValue=oe,e.onError=oe,e.onEnd=oe,e.onToken=oe}}__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 qa={toolRequestStreamingParameters:!1},Ga={v1:{toolRequestStreamingParameters:!0}},Ha=e=>{return"tool_request"===e.type&&(t=e.version,t&&Ga[t]||qa).toolRequestStreamingParameters;var t};function za(e,t){return null!=e?e:t()}function Wa(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 $a{constructor(e){const{initMessageBuffer:t=[],reportLogWithScope:s}=e;this.streamMessageBuffer=ms(t),this.streamChunkBuffer=ms(t),this.streamParserJson=new Fa({reportLogWithScope:s}),this.streamMessageBuffer.forEach(e=>{Ha(e)&&this.streamParserJson.write(e.msg_id,Wa([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters])||"",{onValue:oe})})}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=ma(o,s);if(!i)return;const a=Ha(i);return a&&s.forEach(e=>{this.streamParserJson.write(e.msg_id,Wa([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($s(t)||$s(s))return;const c=ms(o),l=ms(s);if(!a){if(!n)return c||l;if(!c)return;return c[t]=l,c}const u=ms(a.value);return n?(Ys(u,i.map(e=>e.key).filter(e=>!$s(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 Va=1073741823;class Ka{__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){Ka.prototype.__init.call(this),Ka.prototype.__init2.call(this),Ka.prototype.__init3.call(this),Ka.prototype.__init4.call(this),Ka.prototype.__init5.call(this),Ka.prototype.__init6.call(this),Ka.prototype.__init7.call(this),Ka.prototype.__init8.call(this);const{getEnableDebug:t,key:s,reportLogWithScope:r,initMaxSequenceId:n}=e;this.getEnableDebug=t,this.maxSequenceId=za(n,()=>0),this.enableChunkProcessedCheck=za(e.enableChunkProcessedCheck,()=>!1),this.streamBuffer=new $a(e),this.debugLogger=new Aa({reportLogWithScope:r,getEnableDebug:t,getLogPayload:()=>this.getStreamBuffer(),mark:"ChunkProcessor"}),this.simpleMessageDump=new Ta({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>Va,n=s>Va;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=>Wa([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 Ja,Qa,Ya;!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"}(Ja||(Ja={})),function(e){e[e.Unknown=0]="Unknown";e[e.Prev=1]="Prev";e[e.Next=2]="Next"}(Qa||(Qa={}));class Za{__init(){this.timer=null}__init2(){this.timeoutMs=12e4}constructor(e){Za.prototype.__init.call(this),Za.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 Xa(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 ec(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(Xa([n,"optionalAccess",e=>e.validate])){if(n.validate(t))return t;{const t=new Error("JSON validation failed");if(Xa([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&&Xa([n,"optionalAccess",e=>e.throwOnValidationError]))throw t;return Xa([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"}(Ya||(Ya={}));class tc{__init(){this.state="pending"}constructor(){tc.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 sc(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 rc={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},nc=e=>{const{type:t}=e;return(e=>e in rc)(t)?Ha({type:t,version:e.version})?{...e,role:"assistant",type:t,streamParametersContent:(n=sc([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters]),o=()=>"",s=null!=n?n:o(),ec(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 oc extends Error{constructor(e,t){super(e),oc.prototype.__init.call(this),this.name="chatCoreError",this.ext=t||{}}__init(){this.flatten=()=>{const{message:e,ext:t}=this;return{message:e,...t}}}}function ic(e,t){return null!=e?e:t()}function ac(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 cc=e=>{const{content:t,type:s}=e;switch(s){case"answer":return ic(ac([t,"access",e=>e.answer,"optionalAccess",e=>e.length]),()=>0);case"thinking":return ic(ac([t,"access",e=>e.thinking,"optionalAccess",e=>e.length]),()=>0);case"tool_request":return ic(ac([t,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters,"optionalAccess",e=>e.length]),()=>0);case"tool_process":return(e=>{const t=ac([e,"access",e=>e.content,"access",e=>e.tool_process,"optionalAccess",e=>e.data,"access",e=>e.content]);return da.reduce((e,s)=>{const r=ac([t,"optionalAccess",e=>e[s]]);return"string"!=typeof r?e:e+r.length},0)})(e);case"tool_response":return ic(ac([t,"access",e=>e.tool_response,"optionalAccess",e=>e.result,"access",e=>e.length]),()=>0);default:return 0}};class lc{__init(){this.bufferMap=new Map}constructor(e,t){lc.prototype.__init.call(this),lc.prototype.__init2.call(this),lc.prototype.__init3.call(this),lc.prototype.__init4.call(this),lc.prototype.__init5.call(this),lc.prototype.__init6.call(this),lc.prototype.__init7.call(this),lc.prototype.__init8.call(this),lc.prototype.__init9.call(this),lc.prototype.__init10.call(this),this.onFlush=e,this.config={lengthThreshold:ic(ac([t,"optionalAccess",e=>e.lengthThreshold]),()=>4096),maxWaitMs:ic(ac([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+=cc(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);ac([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 uc(e,t){return null!=e?e:t()}function hc(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 pc{__init(){this.bufferManager=null}constructor({channel:e,reportLogWithScope:t,chunkProcessor:s,preSendLocalMessageEventsManager:r,chatSdkEventEmit:n,chatSdkEventBus:o,reportEventsTracer:i,manualInitChannel:a,enableBuffer:c=!1}){pc.prototype.__init.call(this),pc.prototype.__init2.call(this),pc.prototype.__init3.call(this),pc.prototype.__init4.call(this),pc.prototype.__init5.call(this),pc.prototype.__init6.call(this),pc.prototype.__init7.call(this),pc.prototype.__init8.call(this),pc.prototype.__init9.call(this),pc.prototype.__init10.call(this),pc.prototype.__init11.call(this),pc.prototype.__init12.call(this),pc.prototype.__init13.call(this),pc.prototype.__init14.call(this),pc.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 Za({reportLogWithScope:t,getChannelOptions:()=>({...uc(hc([this,"access",e=>e.channel,"access",e=>e.getChannelOptions,"optionalCall",e=>e()]),()=>({})),channelName:this.channel.channelName}),timeoutMs:12e4}),c&&(this.bufferManager=new lc(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=nc(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(Ja.CONTEXT_CHANGE,{name:Ja.CONTEXT_CHANGE,data:e})}}__init4(){this.handleSessionChange=e=>{this.reportLogWithScope.info({message:"session 更新",meta:{session:e}}),this.chatSdkEventEmit(Ja.SESSION_CHANGED,{name:Ja.SESSION_CHANGED,data:e})}}__init5(){this.handleChatFinish=()=>{hc([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=uc(hc([o,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),()=>"");this.chunkProcessor.isFirstReplyMessage(s)&&hc([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 oc("processedMessage is undefined",{local_msg_id:i});this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"pulling",local_msg_id:i,query_msg_id:r}}),this.chatSdkEventEmit(Ja.MESSAGE_RECEIVED_AND_UPDATE,{name:Ja.MESSAGE_RECEIVED_AND_UPDATE,data:[a]})}}__init8(){this.handleChatMessage=e=>{const{content:t,type:s}=e,r=uc(hc([t,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),()=>"");if(!this.chunkProcessor.checkMessageHasProcessed(e)){if("message_end"===s){hc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]);const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new oc("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 oc("processedMessage is undefined",{local_msg_id:r});return void this.handleMessageStart(t)}if("error"===s){hc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]);const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new oc("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(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"channel_error",wsError:e}}),this.chatSdkEventEmit(Ja.CHANNEL_STATUS,{name:Ja.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);hc([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(hc([o,"optionalAccess",e=>e.code])){case"0":this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"success",query_msg_id:t,reply_id:s,messageEndDetail:r.message_end}});break;case"1":this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"cancel",query_msg_id:t,messageEndDetail:r.message_end,reply_id:s}});break;default:this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"error",query_msg_id:t,messageEndDetail:r.message_end,reply_id:s,code:hc([o,"optionalAccess",e=>e.code]),message:hc([o,"optionalAccess",e=>e.message])}})}this.preSendLocalMessageEventsManager.emit(Ya.MESSAGE_END,e),this.handleChatFinish()}}__init11(){this.handleMessageError=e=>{const{query_msg_id:t,content:s}=e,r=hc([s,"access",e=>e.error,"optionalAccess",e=>e.local_msg_id]),n=uc(hc([s,"access",e=>e.error,"optionalAccess",e=>e.error_msg]),()=>""),o=new oc(n,{query_msg_id:t,local_msg_id:r,code:hc([s,"access",e=>e.error,"optionalAccess",e=>e.code])});hc([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(Ya.MESSAGE_SEND_AND_RECEIVE_ERROR,o),this.chatSdkEventEmit(Ja.SEND_MESSAGE_ERROR,{name:Ja.SEND_MESSAGE_ERROR,data:{error:o}}),this.handleChatFinish()}}__init12(){this.handleMessageStart=e=>{const{content:t,query_msg_id:s,log_id:r}=e,n=hc([t,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]);hc([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(Ya.MESSAGE_SEND_SUCCESS,e),this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"start",local_msg_id:n,query_msg_id:s}})}}__init13(){this.handleChannelOpen=()=>{this.reportLogWithScope.info({message:"信道连接成功"}),this.chatSdkEventEmit(Ja.CHANNEL_STATUS,{name:Ja.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(Ja.CHANNEL_STATUS,{name:Ja.CHANNEL_STATUS,data:{channelStatus:"disconnected",message:t}})}}__init15(){this.initChannel=async()=>{this.channel.isChannelOpen()||await this.channel.connect()}}destroy(){hc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.destroy,"call",e=>e()]),this.channel.destroy(),this.chatSdkEventBus.all.clear()}}function dc(e,t){return null!=e?e:t()}function _c(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 fc{constructor({preSendLocalMessageFactory:e,channel:t,preSendLocalMessageEventsManager:s,reportLogWithScope:r,reportEventsTracer:n,chatSdkEventEmit:o}){fc.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 oc("Error: during send message channel onerror",{local_msg_id:e});throw _c([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 oc(t.msg,{local_msg_id:e});throw this.chatSdkEventEmit(Ja.SEND_MESSAGE_ERROR,{name:Ja.SEND_MESSAGE_ERROR,data:{error:s}}),_c([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.error,"call",e=>e(s)]),s}}startMessageTracing(e,t){_c([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){_c([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.success,"call",s=>s(e,t)])}traceMessageError(e,t){_c([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(Ya.MESSAGE_END,n),r.push(()=>this.preSendLocalMessageEventsManager.off(Ya.MESSAGE_END,n)))}handleCommandSendSuccess(e,t,s){"input"===e&&(this.completeMessageTracing(t),s())}handleCommandSendError(e,t,s){const r=new oc(`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=dc(_c([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(Ya.MESSAGE_SEND_SUCCESS,u),r.push(()=>this.preSendLocalMessageEventsManager.off(Ya.MESSAGE_SEND_SUCCESS,u));const h=this.createMessageFailedHandler(s,n.reject);this.preSendLocalMessageEventsManager.on(Ya.MESSAGE_SEND_AND_RECEIVE_ERROR,h),r.push(()=>this.preSendLocalMessageEventsManager.off(Ya.MESSAGE_SEND_AND_RECEIVE_ERROR,h))}setupTimeoutHandler(e,t,s){return setTimeout(()=>{_c([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.timeout,"call",t=>t(e)]);const t=new oc("send chat message timeout",{local_msg_id:e});this.preSendLocalMessageEventsManager.emit(Ya.MESSAGE_SEND_TIMEOUT,t),s(t)},t)}createMessageSuccessHandler(e){const{localMsgId:t,message:s,promiseHandlers:r}=e;return e=>{const n=_c([e,"access",e=>e.content,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),o=_c([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:dc(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 oc(`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 oc((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 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}var mc;!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"}(mc||(mc={}));class Ec{__init(){this.eventTracers=new Map}constructor(e){Ec.prototype.__init.call(this),Ec.prototype.__init2.call(this),Ec.prototype.__init3.call(this),this.reporter=e}__init2(){this.sendMessageTracer={start:(e,t)=>{const{trace:s}=this.createTracer(mc.SDK_MESSAGE_SEND_TRACER);this.setTracer(e,mc.SDK_MESSAGE_SEND_TRACER,{trace:s}),gc([s,"optionalCall",e=>e("start",{meta:t})])},success:(e,t)=>{const{trace:s}=this.getTracer(e,mc.SDK_MESSAGE_SEND_TRACER);gc([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,mc.SDK_MESSAGE_SEND_TRACER),this.pullStreamTracer.start(e,t)},inqueue:(e,t)=>{const{trace:s}=this.getTracer(e,mc.SDK_MESSAGE_SEND_TRACER);gc([s,"optionalCall",e=>e("inqueue",{meta:t})]),this.deleteTracer(e,mc.SDK_MESSAGE_SEND_TRACER)},error:e=>{const{local_msg_id:t}=e.ext;if(!t)return;const{trace:s}=this.getTracer(t,mc.SDK_MESSAGE_SEND_TRACER);gc([s,"optionalCall",t=>t("error",{meta:e.flatten(),error:e})]),this.deleteTracer(t,mc.SDK_MESSAGE_SEND_TRACER)},timeout:e=>{const{trace:t}=this.getTracer(e,mc.SDK_MESSAGE_SEND_TRACER);gc([t,"optionalCall",e=>e("timeout")]),this.deleteTracer(e,mc.SDK_MESSAGE_SEND_TRACER)}}}__init3(){this.pullStreamTracer={start:(e,t)=>{const{trace:s}=this.createTracer(mc.SDK_PULL_STREAM_TRACER);this.setTracer(e,mc.SDK_PULL_STREAM_TRACER,{trace:s,meta:t}),gc([s,"optionalCall",e=>e("start",{meta:t})])},success:(e,t)=>{const{trace:s}=this.getTracer(e,mc.SDK_PULL_STREAM_TRACER);gc([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,mc.SDK_PULL_STREAM_TRACER)},break:(e,t)=>{const{trace:s}=this.getTracer(e,mc.SDK_PULL_STREAM_TRACER);gc([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,mc.SDK_PULL_STREAM_TRACER)},error:(e,t)=>{const{query_msg_id:s}=e.ext;if(!s)return;const{trace:r}=this.getTracer(s,mc.SDK_PULL_STREAM_TRACER);gc([r,"optionalCall",s=>s("error",{meta:{...e.flatten(),...t},error:e})]),this.deleteTracer(s,mc.SDK_PULL_STREAM_TRACER)},timeout:e=>{const{query_msg_id:t}=e.ext;if(!t)return;const{trace:s}=this.getTracer(t,mc.SDK_PULL_STREAM_TRACER);gc([s,"optionalCall",t=>t("timeout",{meta:e.flatten(),error:e})]),this.deleteTracer(t,mc.SDK_PULL_STREAM_TRACER)},receiveFirstAnsChunk:(e,t)=>{const{trace:s}=this.getTracer(e,mc.SDK_PULL_STREAM_TRACER);gc([s,"optionalCall",e=>e("first_ans_chunk",{meta:t})])}}}static getUniqueKey(e,t){return`${e}_${t}`}getTracer(e,t){return this.eventTracers.get(Ec.getUniqueKey(e,t))||{trace:void 0}}setTracer(e,t,s){const{trace:r,meta:n}=s;this.eventTracers.set(Ec.getUniqueKey(e,t),{trace:r,meta:n})}deleteTracer(e,t){this.eventTracers.delete(Ec.getUniqueKey(e,t))}createTracer(e){return this.reporter.slardarTracer({eventName:e})}}class Tc{static __initStatic(){this.instances=new Map}static __initStatic2(){this.EVENTS=Ja}__init(){this.enableDebug=!1}__init2(){this.eventBus=e()}constructor(e){Tc.prototype.__init.call(this),Tc.prototype.__init2.call(this),Tc.prototype.__init3.call(this),Tc.prototype.__init4.call(this),Tc.prototype.__init5.call(this),Tc.prototype.__init6.call(this),Tc.prototype.__init7.call(this),Tc.prototype.__init8.call(this),Tc.prototype.__init9.call(this),Tc.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 Ec(this.reportLogWithScope),this.requestManager=new la({options:e.requestManagerOptions,reportLog:this.reportLog}),this.preSendLocalMessageEventsManager=new ua,this.preSendLocalMessageFactory=new ha,this.chunkProcessor=new Ka({getEnableDebug:()=>this.enableDebug,initMessageBuffer:e.initMessageBuffer,initMaxSequenceId:e.initMaxSequenceId,enableChunkProcessedCheck:e.enableChunkProcessedCheck,reportLogWithScope:this.reportLogWithScope,key:n}),this.channel=e.channel,this.createMessageService=new Zs,this.sendMessageService=new fc({preSendLocalMessageFactory:this.preSendLocalMessageFactory,channel:this.channel,preSendLocalMessageEventsManager:this.preSendLocalMessageEventsManager,reportLogWithScope:this.reportLogWithScope,reportEventsTracer:this.reportEventsTracer,chatSdkEventEmit:this.emit}),this.websocketService=new pc({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:mc.SDK_INIT,meta:{...e}}),this.reportLogWithScope.info({message:"SDK 初始化完成"})}static create(e){const{key:t}=e;if(Tc.instances.has(t))return console.error("duplicate chat core instance error"),Tc.instances.get(t);const s=new Tc(e);return Tc.instances.set(t,s),s}onEvents(){this.websocketService.onChannelEvents()}destroy(){this.websocketService.destroy(),this.eventBus.all.clear(),this.chunkProcessor.destroy(),Tc.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(E.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()}}Tc.__initStatic(),Tc.__initStatic2();const Ac={E1000:"E1000",E1001:"E1001",E1002:"E1002",E1003:"E1003",E1004:"E1004",E1005:"E1005",E1006:"E1006",E1007:"E1007",E1100:"E1100",E1101:"E1101",E1102:"E1102",E1103:"E1103",E2001:"E2001",E2002:"E2002",E2003:"E2003",E3000:"E3000",E3001:"E3001",E3002:"E3002",E3003:"E3003",E3004:"E3004",E3005:"E3005",E3006:"E3006",E3007:"E3007",E3008:"E3008",E3009:"E3009",E3010:"E3010",E3011:"E3011",E3012:"E3012",E3013:"E3013",E4001:"E4001",E4002:"E4002",E5000:"E5000",E5001:"E5001",E5002:"E5002",E5003:"E5003",E5004:"E5004",E5005:"E5005",E5006:"E5006",E5007:"E5007"},Rc={E1000:"INVALID_ARGUMENT",E1001:"MISSING_PROJECT_ID",E1002:"MISSING_MESSAGE",E1003:"MISSING_SPACE_ID",E1004:"INVALID_DOMAIN",E1005:"INVALID_PROJECT_TYPE",E1006:"UNSUPPORTED_PROJECT_TYPE",E1007:"DB_SQL_DANGEROUS",E1100:"UNKNOWN_OPTION",E1101:"UNKNOWN_COMMAND",E1102:"MISSING_ARGUMENT",E1103:"MISSING_OPTION",E2001:"AUTH_FAILED",E2002:"MINIPROGRAM_NOT_AUTHORIZED",E2003:"PERMISSION_DENIED",E3000:"RESOURCE_NOT_FOUND",E3001:"PROJECT_NOT_FOUND",E3002:"SKILL_NOT_FOUND",E3003:"SECRET_NOT_FOUND",E3004:"SKILL_NOT_INSTALLED",E3005:"DELETE_FAILED",E3006:"NO_DEPLOYMENT_HISTORY",E3007:"MISSING_COMMIT_HASH",E3008:"SKILL_PROJECT_NOT_SUPPORTED",E3009:"CONFLICT",E3010:"DB_NOT_FOUND",E3011:"DB_CREATING",E3012:"DB_RESTORE_WINDOW_EXCEEDED",E3013:"DB_RESTORE_IN_PROGRESS",E4001:"QUOTA_EXCEEDED",E4002:"DB_QUOTA_EXCEEDED",E5000:"UNEXPECTED_ERROR",E5001:"NETWORK_ERROR",E5002:"SERVER_ERROR",E5003:"TIMEOUT",E5004:"DB_SQL_EXECUTION_FAILED",E5005:"DB_CONNECTION_FAILED",E5006:"DB_GEN_TYPES_FAILED",E5007:"DB_DUMP_FAILED"};function Sc(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}exports.ExitCode=void 0,function(e){e[e.SUCCESS=0]="SUCCESS";e[e.FAILURE=1]="FAILURE";e[e.AUTH_ERROR=2]="AUTH_ERROR";e[e.INPUT_ERROR=4]="INPUT_ERROR"}(exports.ExitCode||(exports.ExitCode={}));class yc extends Error{constructor(e,t,s,r){const n=Sc(Rc[e],()=>"UNKNOWN_ERROR"),o=Sc(t,()=>n);super(o),this.name="CozeError",this.code=e,this.errorName=n,this.desc=o,this.details=s,this.trigger=Lc([r,"optionalAccess",e=>e.trigger]),this.fix=Lc([r,"optionalAccess",e=>e.fix]),this.example=Lc([r,"optionalAccess",e=>e.example]),this.isMessageExplicit=void 0!==t,Object.setPrototypeOf(this,yc.prototype)}}class bc{constructor(){bc.prototype.__init.call(this)}__init(){this.headers={}}setHeaders(e){this.headers=g.merge({},this.headers,e)}getHeaders(){return this.headers}resetHeaders(){this.headers={}}setDispatcher(e){this.dispatcher=e}clearDispatcher(){this.dispatcher=void 0}async fetch(e,t){const s=g.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}([t,"optionalAccess",e=>e.headers]));return m.fetch(e,{...t,headers:s,dispatcher:this.dispatcher})}}const Cc=new bc;var vc,Ic,Oc,Nc,Mc,wc,Uc,Pc,Bc,kc,jc,Dc,xc,Fc,qc,Gc,Hc,zc,Wc,$c,Vc,Kc,Jc,Qc;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}!function(e){e[e.develop=0]="develop";e[e.product=1]="product"}(vc||(vc={})),function(e){e[e.restoring=0]="restoring";e[e.success=1]="success";e[e.failed=2]="failed"}(Ic||(Ic={})),function(e){e[e.active=0]="active";e[e.creating=1]="creating"}(Oc||(Oc={})),function(e){e[e.postgre=0]="postgre";e[e.supabase=1]="supabase"}(Nc||(Nc={})),function(e){e[e.SQL=1]="SQL";e[e.REPORT=2]="REPORT";e[e.LOG_SQL=3]="LOG_SQL"}(Mc||(Mc={})),function(e){e[e.NAME=1]="NAME";e[e.INSERTED_AT=2]="INSERTED_AT"}(wc||(wc={})),function(e){e[e.ASC=1]="ASC";e[e.DESC=2]="DESC"}(Uc||(Uc={})),function(e){e[e.USER=1]="USER";e[e.PROJECT=2]="PROJECT";e[e.ORG=3]="ORG";e[e.PUBLIC=4]="PUBLIC"}(Pc||(Pc={})),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.FileExist="file.exist";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.RepoVersionConflictResolve="repo_version.conflict.resolve";e.RepoVersionEvent="repo_version.event";e.RepoVersionFileRead="repo_version.file.read";e.RepoVersionLatest="repo_version.commit.version.latest";e.RepoVersionNotify="repo_version.notify";e.RepoVersionRemoteAdd="repo_version.remote.add";e.RepoVersionRemoteFetch="repo_version.remote.fetch";e.RepoVersionRemoteOutgoingCommits="repo_version.remote.outgoing_commits";e.RepoVersionRemotePull="repo_version.remote.pull";e.RepoVersionRemotePush="repo_version.remote.push";e.RepoVersionRemoteRemove="repo_version.remote.remove";e.SandboxBroadcast="sandbox.broadcast";e.SandboxPing="sandbox.ping";e.SandboxProjectStatus="sandbox.project_status";e.SandboxProjectStatusNotify="sandbox.project_status_notify";e.SandboxVersion="sandbox.version";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"}(Bc||(Bc={})),function(e){e[e.text=0]="text";e[e.url=1]="url";e[e.uri=2]="uri"}(kc||(kc={})),(jc||(jc={})).PdfTargetFileType="pdf",function(e){e.TabAuthentication="Authentication"}(Dc||(Dc={})),function(e){e.FeatureApp="app";e.FeatureAssistantAgent="assistantagent";e.FeatureGeneral="general";e.FeatureSkill="skill";e.FeatureWechatMiniProgram="wechatminiprogram"}(xc||(xc={})),function(e){e.SceneRecommendProjectCases="RecommendProjectCases";e.SceneSubmitWorkPoint="SubmitWorkPoint"}(Fc||(Fc={})),function(e){e[e.CozeSpace=1]="CozeSpace";e[e.Ark=2]="Ark"}(qc||(qc={})),function(e){e[e.LocalFile=1]="LocalFile";e[e.GithubRepo=2]="GithubRepo"}(Gc||(Gc={})),function(e){e.ProjectTypeAgent="Agent";e.ProjectTypeApp="App";e.ProjectTypeAssistantAgent="AssistantAgent";e.ProjectTypeAutomation="Automation";e.ProjectTypeGeneral="General";e.ProjectTypeGeneralWeb="GeneralWeb";e.ProjectTypeSkill="Skill";e.ProjectTypeWechatMiniProgram="WechatMiniProgram"}(Hc||(Hc={})),function(e){e[e.Agent=0]="Agent";e[e.Ask=1]="Ask"}(zc||(zc={})),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.General=9]="General";e[e.CLIBilling=101]="CLIBilling"}(exports.VibeProjectType||(exports.VibeProjectType={})),function(e){e[e.UnAuth=1]="UnAuth";e[e.AuthButNoBind=2]="AuthButNoBind";e[e.AuthAndBind=3]="AuthAndBind"}(Wc||(Wc={})),function(e){e[e.Inactive=1]="Inactive";e[e.Active=2]="Active"}($c||($c={})),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"}(Vc||(Vc={})),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"}(Kc||(Kc={})),function(e){e.PdfTargetFileType="pdf";e.XlsxTargetFileType="xlsx"}(Jc||(Jc={})),function(e){e[e.move=0]="move";e[e.copy=1]="copy"}(Qc||(Qc={}));class Zc{__init(){this.request=Gi}__init2(){this.baseURL=""}constructor(e){Zc.prototype.__init.call(this),Zc.prototype.__init2.call(this),this.request=Yc([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Yc([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)}GetOauthStatus(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/oauth/status"),n={integration_id:s.integration_id,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}SearchRepo(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/search_repo"),n={space_id:s.space_id,name_search:s.name_search,per_page:s.per_page,page:s.page};return this.request({url:r,method:"POST",data:n},t)}AddRemote(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/add_remote"),n={project_id:s.project_id,integration_id:s.integration_id,repo_full_name:s.repo_full_name,has_add_in_devbox:s.has_add_in_devbox};return this.request({url:r,method:"POST",data:n},t)}RemoveRemote(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/remove_remote"),n={project_id:s.project_id};return this.request({url:r,method:"POST",data:n},t)}ListIntegration(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/list"),n={space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}CreateRepo(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/create_repo"),n={space_id:s.space_id,name:s.name,private:s.private};return this.request({url:r,method:"POST",data:n},t)}CancelOauth(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/oauth/cancel"),n={integration_id:s.integration_id,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}GetOauthConfig(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/oauth/oauth_config"),n={integration_id:s.integration_id,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}ListDatabaseRestoreHistory(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/postgresql/restore/history"),n={project_id:s.project_id,commit_id:s.commit_id,env:s.env,limit:s.limit,cursor:s.cursor};return this.request({url:r,method:"POST",data:n},t)}ImportProject(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/import_project"),n={space_id:s.space_id,import_source:s.import_source,data:s.data,git_url:s.git_url,git_repo_name:s.git_repo_name},o={"Content-Type":s["Content-Type"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetUser(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/user"),n={space_id:s.space_id,integration_id:s.integration_id};return this.request({url:r,method:"POST",data:n},t)}GetRemote(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/get_remote"),n={project_id:s.project_id};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)}CreateSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/create"),n={space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}GetSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/get"),n={space_id:s.space_id,database_id:s.database_id};return this.request({url:r,method:"POST",data:n},t)}ListSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/list"),n={space_id:s.space_id,cursor_id:s.cursor_id,limit:s.limit};return this.request({url:r,method:"POST",data:n},t)}GetSpaceDatabaseStatus(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/status"),n={space_id:s.space_id,database_id:s.database_id};return this.request({url:r,method:"POST",data:n},t)}DeleteSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/delete"),n={space_id:s.space_id,database_id:s.database_id};return this.request({url:r,method:"POST",data:n},t)}RollbackSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/rollback"),n={space_id:s.space_id,database_id:s.database_id,timestamp:s.timestamp};return this.request({url:r,method:"POST",data:n},t)}}Zc.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)},Zc.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 Xc=new Zc({});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}const tl=/(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g;class sl{constructor(){sl.prototype.__init.call(this),sl.prototype.__init2.call(this),sl.prototype.__init3.call(this),sl.prototype.__init4.call(this),sl.prototype.__init5.call(this),sl.prototype.__init6.call(this),sl.prototype.__init7.call(this),sl.prototype.__init8.call(this),sl.prototype.__init9.call(this),sl.prototype.__init10.call(this),sl.prototype.__init11.call(this),sl.prototype.__init12.call(this)}__init(){this.ctx={options:{},get:()=>({})}}__init2(){this.init=g.noop}__init3(){this.createLoggerWith=()=>new sl}__init4(){this.info=g.noop}__init5(){this.error=g.noop}__init6(){this.slardarInfo=g.noop}__init7(){this.slardarSuccess=g.noop}__init8(){this.slardarError=g.noop}__init9(){this.slardarEvent=g.noop}__init10(){this.slardarSuccessEvent=g.noop}__init11(){this.slardarErrorEvent=g.noop}__init12(){this.slardarTracer=()=>({trace:g.noop})}}function rl(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 nl=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}},ol=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(()=>{rl([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(()=>{rl([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 Cc.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 rl([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=nl({buffered:c,onData:e=>{const t=JSON.parse(e);n(t)}}).buffered}c+=i.decode(),nl({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 il(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 al extends Error{constructor(e,t){super(e),al.prototype.__init.call(this),this.name="ChatCLIChannelError",this.ext=t}__init(){this.flatten=()=>{const{message:e,ext:t}=this;return{message:e,...t}}}}const cl=e=>!(!e||"object"!=typeof e)&&"AbortError"===e.name;class ll{__init2(){this.channelName="ChatCLI"}__init3(){this.isChannelOpenPromise=null}__init4(){this.opened=!1}__init5(){this.destroyed=!1}__init6(){this.abortController=null}__init7(){this.eventBus=e()}constructor(e){ll.prototype.__init2.call(this),ll.prototype.__init3.call(this),ll.prototype.__init4.call(this),ll.prototype.__init5.call(this),ll.prototype.__init6.call(this),ll.prototype.__init7.call(this),ll.prototype.__init8.call(this),ll.prototype.__init9.call(this),ll.prototype.__init10.call(this),ll.prototype.__init11.call(this),ll.prototype.__init12.call(this),ll.prototype.__init13.call(this),ll.prototype.__init14.call(this),ll.prototype.__init15.call(this),ll.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(),il([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=>{ol({apiBaseUrl:this.apiBaseUrl,request:r,signal:t.signal,totalTimeoutMs:this.totalTimeoutMs,betweenChunkTimeoutMs:this.betweenChunkTimeoutMs,onTotalTimeout:()=>{this.eventBus.emit("onerror",new al("ChatCLISendMessage total timeout",{willClose:!0}))},onBetweenChunkTimeout:()=>{this.eventBus.emit("onerror",new al("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();cl(t)?this.eventBus.emit("onclose",{code:1e3,reason:"aborted"}):(this.eventBus.emit("onerror",new al(`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(cl(a))return;throw this.eventBus.emit("onerror",new al(`ChatCLISendMessage request error: ${String(a)}`,{willClose:!0,rawError:a})),a}}}__init15(){this.close=()=>{il([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 ul(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 hl=e=>{const{key:t,apiBaseUrl:s,totalTimeoutMs:r,betweenChunkTimeoutMs:n}=e,o=new ll({apiBaseUrl:s,totalTimeoutMs:r,betweenChunkTimeoutMs:n});return new Tc({key:t,env:"production",logLevel:"error",channel:o,reportLog:new sl})};exports.BuildAgentApi=ca,exports.ChatCoreError=oc,exports.CozeError=yc,exports.ErrorCode=Ac,exports.ErrorNameByCode=Rc,exports.HttpError=tr,exports.IdeApi=Xc,exports.axiosInstance=Fi,exports.createChatCore=hl,exports.createRequestClient=xi,exports.customFetch=Cc,exports.exitCodeForError=function(e){const t=Number.parseInt(e.slice(1),10);return t>=1e3&&t<2e3?exports.ExitCode.INPUT_ERROR:t>=2e3&&t<3e3?exports.ExitCode.AUTH_ERROR:exports.ExitCode.FAILURE},exports.getDefaultExportFromCjs=Un,exports.isHttpError=function(e){return e instanceof tr},exports.request=Gi,exports.safeJsonParse=ec,exports.sendProjectChatMessage=async e=>{const{projectId:t,prompt:r,apiBaseUrl:n,sessionId:o="",key:i=`coze-coding-cli:chat:${t}`,totalTimeoutMs:a,betweenChunkTimeoutMs:c,onMessageItem:l,onWarn:u,waitForResponse:h=!0}=e,p=hl({key:i,apiBaseUrl:n,totalTimeoutMs:a,betweenChunkTimeoutMs:c}),g=new tc;let m=!1;const E=e=>{m||(m=!0,e())};let T;const A=p.on(Ja.MESSAGE_RECEIVED_AND_UPDATE,({data:e})=>{for(const t of e)if(ul([l,"optionalCall",e=>e(t)]),"answer"===t.type&&t.content.answer&&(T=t),"message_end"===t.type&&t.finish){const e=ul([t,"access",e=>e.content,"access",e=>e.message_end,"optionalAccess",e=>e.code]);if(e&&"0"!==e){E(()=>{g.reject(new yc(Ac.E5002,`Conversation ended with error code: ${e}`,{message_end:t.content.message_end}))});continue}E(()=>{g.resolve()})}},!0),R=p.on(Ja.SEND_MESSAGE_ERROR,e=>{E(()=>{g.reject(e.data.error)})},!0),S=p.on(Ja.MESSAGE_PULLING_STATUS,({data:e,error:t})=>{const s=e.pullingStatus;"error"!==s&&"channel_error"!==s||E(()=>{g.reject(t)}),("success"===s||"cancel"===s||!h&&"start"===s)&&E(()=>{g.resolve()})},!0);try{const e=await(async(e,t,s,r)=>{const n=[],o=[...e.matchAll(tl)];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=d.resolve(t,l);let h=!1;if(u.startsWith(d.resolve(t)))try{(await f.stat(u)).isFile()?h=!0:el([r,"optionalCall",e=>e(`Uploading directories is not supported: ${l}`)])}catch(e){el([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){el([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})(r,process.cwd(),(e=>async t=>{const r=d.basename(t),n=new s;n.append("project_id",e),n.append("file_name",r),n.append("file_content",_.createReadStream(t));const o=await Xc.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}})(t),u),n=p.createQueryMessage({query:{prompt:e}},{session_id:o,project_id:t});return await p.sendChatMessage(n),await g.promise,{lastAnswerMessage:T}}finally{A(),R(),S(),p.destroy()}};
1
+ "use strict";const e=require("mitt"),t=require("crypto"),s=require("form-data"),r=require("url"),n=require("http"),o=require("https"),i=require("http2"),a=require("util"),c=require("stream"),l=require("assert"),u=require("tty"),h=require("zlib"),p=require("events"),d=require("path"),_=require("fs"),f=require("fs/promises"),m=require("lodash"),g=require("undici");var E;!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"}(E||(E={}));let T,A,R=(e=21)=>{var s;s=e-=0,!T||T.length<s?(T=Buffer.allocUnsafe(128*s),t.randomFillSync(T),A=0):A+s>T.length&&(t.randomFillSync(T),A=0),A+=s;let r="";for(let t=A-e;t<A;t++)r+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&T[t]];return r};var S="object"==typeof global&&global&&global.Object===Object&&global,L="object"==typeof self&&self&&self.Object===Object&&self,y=S||L||Function("return this")(),b=y.Symbol,C=Object.prototype,v=C.hasOwnProperty,I=C.toString,O=b?b.toStringTag:void 0;var N=Object.prototype.toString;var M=b?b.toStringTag:void 0;function w(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":M&&M in Object(e)?function(e){var t=v.call(e,O),s=e[O];try{e[O]=void 0;var r=!0}catch(e){}var n=I.call(e);return r&&(t?e[O]=s:delete e[O]),n}(e):function(e){return N.call(e)}(e)}function U(e){return null!=e&&"object"==typeof e}function P(e){return"symbol"==typeof e||U(e)&&"[object Symbol]"==w(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 k=Array.isArray,j=b?b.prototype:void 0,D=j?j.toString:void 0;function x(e){if("string"==typeof e)return e;if(k(e))return B(e,x)+"";if(P(e))return D?D.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function F(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function q(e){return e}function G(e){if(!F(e))return!1;var t=w(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var H,z=y["__core-js_shared__"],W=(H=/[^.]+$/.exec(z&&z.keys&&z.keys.IE_PROTO||""))?"Symbol(src)_1."+H:"";var $=Function.prototype.toString;function V(e){if(null!=e){try{return $.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var K=/^\[object .+?Constructor\]$/,J=Function.prototype,Q=Object.prototype,Y=J.toString,Z=Q.hasOwnProperty,X=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ee(e){return!(!F(e)||(t=e,W&&W in t))&&(G(e)?X:K).test(V(e));var t}function te(e,t){var s=function(e,t){return null==e?void 0:e[t]}(e,t);return ee(s)?s:void 0}var se=te(y,"WeakMap"),re=Object.create,ne=function(){function e(){}return function(t){if(!F(t))return{};if(re)return re(t);e.prototype=t;var s=new e;return e.prototype=void 0,s}}();function oe(){}var ie=Date.now;var ae,ce,le,ue=function(){try{var e=te(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),he=ue?function(e,t){return ue(e,"toString",{configurable:!0,enumerable:!1,value:(s=t,function(){return s}),writable:!0});var s}:q,pe=(ae=he,ce=0,le=0,function(){var e=ie(),t=16-(e-le);if(le=e,t>0){if(++ce>=800)return arguments[0]}else ce=0;return ae.apply(void 0,arguments)});var de=/^(?:0|[1-9]\d*)$/;function _e(e,t){var s=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==s||"symbol"!=s&&de.test(e))&&e>-1&&e%1==0&&e<t}function fe(e,t,s){"__proto__"==t&&ue?ue(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 ge=Object.prototype.hasOwnProperty;function Ee(e,t,s){var r=e[t];ge.call(e,t)&&me(r,s)&&(void 0!==s||t in e)||fe(e,t,s)}var Te=Math.max;function Ae(e,t){return pe(function(e,t,s){return t=Te(void 0===t?e.length-1:t,0),function(){for(var r=arguments,n=-1,o=Te(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,q),e+"")}function Re(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function Se(e){return null!=e&&Re(e.length)&&!G(e)}function Le(e){return Ae(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(!F(s))return!1;var r=typeof t;return!!("number"==r?Se(s)&&_e(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 ye=Object.prototype;function be(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||ye)}function Ce(e){return U(e)&&"[object Arguments]"==w(e)}var ve=Object.prototype,Ie=ve.hasOwnProperty,Oe=ve.propertyIsEnumerable,Ne=Ce(function(){return arguments}())?Ce:function(e){return U(e)&&Ie.call(e,"callee")&&!Oe.call(e,"callee")};var Me="object"==typeof exports&&exports&&!exports.nodeType&&exports,we=Me&&"object"==typeof module&&module&&!module.nodeType&&module,Ue=we&&we.exports===Me?y.Buffer:void 0,Pe=(Ue?Ue.isBuffer:void 0)||function(){return!1},Be={};function ke(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 je="object"==typeof exports&&exports&&!exports.nodeType&&exports,De=je&&"object"==typeof module&&module&&!module.nodeType&&module,xe=De&&De.exports===je&&S.process,Fe=function(){try{var e=De&&De.require&&De.require("util").types;return e||xe&&xe.binding&&xe.binding("util")}catch(e){}}(),qe=Fe&&Fe.isTypedArray,Ge=qe?ke(qe):function(e){return U(e)&&Re(e.length)&&!!Be[w(e)]},He=Object.prototype.hasOwnProperty;function ze(e,t){var s=k(e),r=!s&&Ne(e),n=!s&&!r&&Pe(e),o=!s&&!r&&!n&&Ge(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&&!He.call(e,l)||i&&("length"==l||n&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||_e(l,c))||a.push(l);return a}function We(e,t){return function(s){return e(t(s))}}var $e=We(Object.keys,Object),Ve=Object.prototype.hasOwnProperty;function Ke(e){return Se(e)?ze(e):function(e){if(!be(e))return $e(e);var t=[];for(var s in Object(e))Ve.call(e,s)&&"constructor"!=s&&t.push(s);return t}(e)}var Je=Object.prototype.hasOwnProperty;function Qe(e){if(!F(e))return function(e){var t=[];if(null!=e)for(var s in Object(e))t.push(s);return t}(e);var t=be(e),s=[];for(var r in e)("constructor"!=r||!t&&Je.call(e,r))&&s.push(r);return s}function Ye(e){return Se(e)?ze(e,!0):Qe(e)}var Ze=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Xe=/^\w*$/;function et(e,t){if(k(e))return!1;var s=typeof e;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=e&&!P(e))||(Xe.test(e)||!Ze.test(e)||null!=t&&e in Object(t))}var tt=te(Object,"create");var st=Object.prototype.hasOwnProperty;var rt=Object.prototype.hasOwnProperty;function nt(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 ot(e,t){for(var s=e.length;s--;)if(me(e[s][0],t))return s;return-1}nt.prototype.clear=function(){this.__data__=tt?tt(null):{},this.size=0},nt.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},nt.prototype.get=function(e){var t=this.__data__;if(tt){var s=t[e];return"__lodash_hash_undefined__"===s?void 0:s}return st.call(t,e)?t[e]:void 0},nt.prototype.has=function(e){var t=this.__data__;return tt?void 0!==t[e]:rt.call(t,e)},nt.prototype.set=function(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=tt&&void 0===t?"__lodash_hash_undefined__":t,this};var it=Array.prototype.splice;function at(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])}}at.prototype.clear=function(){this.__data__=[],this.size=0},at.prototype.delete=function(e){var t=this.__data__,s=ot(t,e);return!(s<0)&&(s==t.length-1?t.pop():it.call(t,s,1),--this.size,!0)},at.prototype.get=function(e){var t=this.__data__,s=ot(t,e);return s<0?void 0:t[s][1]},at.prototype.has=function(e){return ot(this.__data__,e)>-1},at.prototype.set=function(e,t){var s=this.__data__,r=ot(s,e);return r<0?(++this.size,s.push([e,t])):s[r][1]=t,this};var ct=te(y,"Map");function lt(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 ut(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])}}ut.prototype.clear=function(){this.size=0,this.__data__={hash:new nt,map:new(ct||at),string:new nt}},ut.prototype.delete=function(e){var t=lt(this,e).delete(e);return this.size-=t?1:0,t},ut.prototype.get=function(e){return lt(this,e).get(e)},ut.prototype.has=function(e){return lt(this,e).has(e)},ut.prototype.set=function(e,t){var s=lt(this,e),r=s.size;return s.set(e,t),this.size+=s.size==r?0:1,this};function ht(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(ht.Cache||ut),s}ht.Cache=ut;var pt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,dt=/\\(\\)?/g,_t=function(e){var t=ht(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(pt,function(e,s,r,n){t.push(r?n.replace(dt,"$1"):s||e)}),t});function ft(e,t){return k(e)?e:et(e,t)?[e]:_t(function(e){return null==e?"":x(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 gt(e,t){for(var s=0,r=(t=ft(t,e)).length;null!=e&&s<r;)e=e[mt(t[s++])];return s&&s==r?e:void 0}function Et(e,t,s){var r=null==e?void 0:gt(e,t);return void 0===r?s:r}function Tt(e,t){for(var s=-1,r=t.length,n=e.length;++s<r;)e[n+s]=t[s];return e}var At=We(Object.getPrototypeOf,Object),Rt=Function.prototype,St=Object.prototype,Lt=Rt.toString,yt=St.hasOwnProperty,bt=Lt.call(Object);function Ct(e){var t=this.__data__=new at(e);this.size=t.size}Ct.prototype.clear=function(){this.__data__=new at,this.size=0},Ct.prototype.delete=function(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s},Ct.prototype.get=function(e){return this.__data__.get(e)},Ct.prototype.has=function(e){return this.__data__.has(e)},Ct.prototype.set=function(e,t){var s=this.__data__;if(s instanceof at){var r=s.__data__;if(!ct||r.length<199)return r.push([e,t]),this.size=++s.size,this;s=this.__data__=new ut(r)}return s.set(e,t),this.size=s.size,this};var vt="object"==typeof exports&&exports&&!exports.nodeType&&exports,It=vt&&"object"==typeof module&&module&&!module.nodeType&&module,Ot=It&&It.exports===vt?y.Buffer:void 0,Nt=Ot?Ot.allocUnsafe:void 0;function Mt(e,t){if(t)return e.slice();var s=e.length,r=Nt?Nt(s):new e.constructor(s);return e.copy(r),r}function wt(){return[]}var Ut=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 Ut.call(e,t)}))}:wt,kt=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)Tt(t,Bt(e)),e=At(e);return t}:wt;function jt(e,t,s){var r=t(e);return k(e)?r:Tt(r,s(e))}function Dt(e){return jt(e,Ke,Bt)}var xt=te(y,"DataView"),Ft=te(y,"Promise"),qt=te(y,"Set"),Gt="[object Map]",Ht="[object Promise]",zt="[object Set]",Wt="[object WeakMap]",$t="[object DataView]",Vt=V(xt),Kt=V(ct),Jt=V(Ft),Qt=V(qt),Yt=V(se),Zt=w;(xt&&Zt(new xt(new ArrayBuffer(1)))!=$t||ct&&Zt(new ct)!=Gt||Ft&&Zt(Ft.resolve())!=Ht||qt&&Zt(new qt)!=zt||se&&Zt(new se)!=Wt)&&(Zt=function(e){var t=w(e),s="[object Object]"==t?e.constructor:void 0,r=s?V(s):"";if(r)switch(r){case Vt:return $t;case Kt:return Gt;case Jt:return Ht;case Qt:return zt;case Yt:return Wt}return t});var Xt=Object.prototype.hasOwnProperty;var es=y.Uint8Array;function ts(e){var t=new e.constructor(e.byteLength);return new es(t).set(new es(e)),t}var ss=/\w*$/;var rs=b?b.prototype:void 0,ns=rs?rs.valueOf:void 0;function os(e,t){var s=t?ts(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)}function is(e,t,s){var r,n,o,i,a,c=e.constructor;switch(t){case"[object ArrayBuffer]":return ts(e);case"[object Boolean]":case"[object Date]":return new c(+e);case"[object DataView]":return a=ts((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 os(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,ss.exec(n))).lastIndex=n.lastIndex,o;case"[object Symbol]":return r=e,ns?Object(ns.call(r)):{}}}function as(e){return"function"!=typeof e.constructor||be(e)?{}:ne(At(e))}var cs=Fe&&Fe.isMap,ls=cs?ke(cs):function(e){return U(e)&&"[object Map]"==Zt(e)};var us=Fe&&Fe.isSet,hs=us?ke(us):function(e){return U(e)&&"[object Set]"==Zt(e)},ps="[object Arguments]",ds="[object Function]",_s="[object Object]",fs={};function ms(e,t,s,r,n,o){var i,a=1&t;if(void 0!==i)return i;if(!F(e))return e;var c=k(e);if(c)i=function(e){var t=e.length,s=new e.constructor(t);return t&&"string"==typeof e[0]&&Xt.call(e,"index")&&(s.index=e.index,s.input=e.input),s}(e);else{var l=Zt(e),u=l==ds||"[object GeneratorFunction]"==l;if(Pe(e))return Mt(e,a);if(l==_s||l==ps||u&&!n)i=u?{}:as(e);else{if(!fs[l])return n?e:{};i=is(e,l,a)}}o||(o=new Ct);var h=o.get(e);if(h)return h;o.set(e,i),hs(e)?e.forEach(function(r){i.add(ms(r,t,s,r,e,o))}):ls(e)&&e.forEach(function(r,n){i.set(n,ms(r,t,s,n,e,o))});var p=c?void 0:Dt(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]),Ee(i,n,ms(r,t,s,n,e,o))}),i}fs[ps]=fs["[object Array]"]=fs["[object ArrayBuffer]"]=fs["[object DataView]"]=fs["[object Boolean]"]=fs["[object Date]"]=fs["[object Float32Array]"]=fs["[object Float64Array]"]=fs["[object Int8Array]"]=fs["[object Int16Array]"]=fs["[object Int32Array]"]=fs["[object Map]"]=fs["[object Number]"]=fs[_s]=fs["[object RegExp]"]=fs["[object Set]"]=fs["[object String]"]=fs["[object Symbol]"]=fs["[object Uint8Array]"]=fs["[object Uint8ClampedArray]"]=fs["[object Uint16Array]"]=fs["[object Uint32Array]"]=!0,fs["[object Error]"]=fs[ds]=fs["[object WeakMap]"]=!1;function gs(e){return ms(e,5)}function Es(e){var t=-1,s=null==e?0:e.length;for(this.__data__=new ut;++t<s;)this.add(e[t])}function Ts(e,t){for(var s=-1,r=null==e?0:e.length;++s<r;)if(t(e[s],s,e))return!0;return!1}Es.prototype.add=Es.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Es.prototype.has=function(e){return this.__data__.has(e)};function As(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 Es:void 0;for(o.set(e,t),o.set(t,e);++h<a;){var _=e[h],f=t[h];if(r)var m=i?r(f,_,h,t,e,o):r(_,f,h,e,t,o);if(void 0!==m){if(m)continue;p=!1;break}if(d){if(!Ts(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 Rs(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 Ls=b?b.prototype:void 0,ys=Ls?Ls.valueOf:void 0;var bs=Object.prototype.hasOwnProperty;var Cs="[object Arguments]",vs="[object Array]",Is="[object Object]",Os=Object.prototype.hasOwnProperty;function Ns(e,t,s,r,n,o){var i=k(e),a=k(t),c=i?vs:Zt(e),l=a?vs:Zt(t),u=(c=c==Cs?Is:c)==Is,h=(l=l==Cs?Is:l)==Is,p=c==l;if(p&&Pe(e)){if(!Pe(t))return!1;i=!0,u=!1}if(p&&!u)return o||(o=new Ct),i||Ge(e)?As(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 es(e),new es(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=Rs;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=As(a(e),a(t),r,n,o,i);return i.delete(e),u;case"[object Symbol]":if(ys)return ys.call(e)==ys.call(t)}return!1}(e,t,c,s,r,n,o);if(!(1&s)){var d=u&&Os.call(e,"__wrapped__"),_=h&&Os.call(t,"__wrapped__");if(d||_){var f=d?e.value():e,m=_?t.value():t;return o||(o=new Ct),n(f,m,s,r,o)}}return!!p&&(o||(o=new Ct),function(e,t,s,r,n,o){var i=1&s,a=Dt(e),c=a.length;if(c!=Dt(t).length&&!i)return!1;for(var l=c;l--;){var u=a[l];if(!(i?u in t:bs.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]],m=t[u];if(r)var g=i?r(m,f,u,t,e,o):r(f,m,u,e,t,o);if(!(void 0===g?f===m||n(f,m,s,r,o):g)){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 Ms(e,t,s,r,n){return e===t||(null==e||null==t||!U(e)&&!U(t)?e!=e&&t!=t:Ns(e,t,s,r,Ms,n))}function ws(e){return e==e&&!F(e)}function Us(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=Ke(e),s=t.length;s--;){var r=t[s],n=e[r];t[s]=[r,n,ws(n)]}return t}(e);return 1==t.length&&t[0][2]?Us(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(!Ms(l,c,3,r,new Ct))return!1}return!0}(s,0,t)}}function Bs(e,t){return null!=e&&t in Object(e)}function ks(e,t){return null!=e&&function(e,t,s){for(var r=-1,n=(t=ft(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)&&Re(n)&&_e(i,n)&&(k(e)||Ne(e))}(e,t,Bs)}function js(e){return et(e)?(t=mt(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return gt(t,e)}}(e);var t}function Ds(e){return"function"==typeof e?e:null==e?q:"object"==typeof e?k(e)?function(e,t){return et(e)&&ws(t)?Us(mt(e),t):function(s){var r=Et(s,e);return void 0===r&&r===t?ks(s,e):Ms(t,r,3)}}(e[0],e[1]):Ps(e):js(e)}var xs=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 Fs(e,t,s){(void 0!==s&&!me(e[t],s)||void 0===s&&!(t in e))&&fe(e,t,s)}function qs(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}function Gs(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?fe(s,i,a):Ee(s,i,a)}return s}(e,Ye(e))}function Hs(e,t,s,r,n,o,i){var a=qs(e,s),c=qs(t,s),l=i.get(c);if(l)Fs(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=k(c),_=!d&&Pe(c),f=!d&&!_&&Ge(c);h=c,d||_||f?k(a)?h=a:U(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=Mt(c,!0)):f?(p=!1,h=os(c,!0)):h=[]:function(e){if(!U(e)||"[object Object]"!=w(e))return!1;var t=At(e);if(null===t)return!0;var s=yt.call(t,"constructor")&&t.constructor;return"function"==typeof s&&s instanceof s&&Lt.call(s)==bt}(c)||Ne(c)?(h=a,Ne(a)?h=Gs(a):F(a)&&!G(a)||(h=as(c))):p=!1}p&&(i.set(c,h),n(h,c,r,o,i),i.delete(c)),Fs(e,s,h)}}function zs(e,t,s,r,n){e!==t&&xs(t,function(o,i){if(n||(n=new Ct),F(o))Hs(e,t,i,s,zs,r,n);else{var a=r?r(qs(e,i),o,i+"",e,t,n):void 0;void 0===a&&(a=o),Fs(e,i,a)}},Ye)}var Ws=Le(function(e,t,s,r){zs(e,t,s,r)});function $s(e){return void 0===e}var Vs=Le(function(e,t,s){zs(e,t,s)});function Ks(e,t,s,r){if(!F(e))return e;for(var n=-1,o=(t=ft(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=F(u)?u:_e(t[n+1])?[]:{})}Ee(a,c,l),a=a[c]}return e}function Js(e,t){if(null==e)return{};var s=B(function(e){return jt(e,Ye,kt)}(e),function(e){return[e]});return t=Ds(t),function(e,t,s){for(var r=-1,n=t.length,o={};++r<n;){var i=t[r],a=gt(e,i);s(a,i)&&Ks(o,ft(i,e),a)}return o}(e,s,function(e,s){return t(e,s[0])})}function Qs(e,t,s){return null==e?e:Ks(e,t,s)}function Ys(e,t,s){return null==e?e:function(e,t,s){return Ks(e,t,s(gt(e,t)))}(e,t,"function"==typeof(r=s)?r:q);var r}class Zs{createQueryMessage(e,t){return{content:e,session_id:t.session_id,type:"query",project_id:t.project_id,context:t.context,local_msg_id:R()}}createRetryMessage(e,t){return{content:e,session_id:t.session_id,type:"retry",project_id:t.project_id,context:t.context,local_msg_id:R()}}createEditMessage(e,t){const s=R();return{content:Vs(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:R()}}createCancelMessage(e,t){return{content:e,session_id:t.session_id,type:"cancel",project_id:t.project_id,context:t.context,local_msg_id:R()}}}const Xs=(...e)=>Ws(...e,(e,t)=>{if(k(e))return e.concat(t)});function er(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 tr 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,tr)}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=er([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:er([this,"access",e=>e.config,"optionalAccess",e=>e.url]),method:er([this,"access",e=>e.config,"optionalAccess",e=>e.method]),baseURL:er([this,"access",e=>e.config,"optionalAccess",e=>e.baseURL])}}}function sr(e,t){return function(){return e.apply(t,arguments)}}const{toString:rr}=Object.prototype,{getPrototypeOf:nr}=Object,{iterator:or,toStringTag:ir}=Symbol,ar=(cr=Object.create(null),e=>{const t=rr.call(e);return cr[t]||(cr[t]=t.slice(8,-1).toLowerCase())});var cr;const lr=e=>(e=e.toLowerCase(),t=>ar(t)===e),ur=e=>t=>typeof t===e,{isArray:hr}=Array,pr=ur("undefined");function dr(e){return null!==e&&!pr(e)&&null!==e.constructor&&!pr(e.constructor)&&mr(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const _r=lr("ArrayBuffer");const fr=ur("string"),mr=ur("function"),gr=ur("number"),Er=e=>null!==e&&"object"==typeof e,Tr=e=>{if("object"!==ar(e))return!1;const t=nr(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||ir in e||or in e)},Ar=lr("Date"),Rr=lr("File"),Sr=lr("Blob"),Lr=lr("FileList");const yr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},br=void 0!==yr.FormData?yr.FormData:void 0,Cr=lr("URLSearchParams"),[vr,Ir,Or,Nr]=["ReadableStream","Request","Response","Headers"].map(lr);function Mr(e,t,{allOwnKeys:s=!1}={}){if(null==e)return;let r,n;if("object"!=typeof e&&(e=[e]),hr(e))for(r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else{if(dr(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 wr(e,t){if(dr(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 Ur="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Pr=e=>!pr(e)&&e!==Ur;const Br=(kr="undefined"!=typeof Uint8Array&&nr(Uint8Array),e=>kr&&e instanceof kr);var kr;const jr=lr("HTMLFormElement"),Dr=(({hasOwnProperty:e})=>(t,s)=>e.call(t,s))(Object.prototype),xr=lr("RegExp"),Fr=(e,t)=>{const s=Object.getOwnPropertyDescriptors(e),r={};Mr(s,(s,n)=>{let o;!1!==(o=t(s,n,e))&&(r[n]=o||s)}),Object.defineProperties(e,r)};const qr=lr("AsyncFunction"),Gr=(Hr="function"==typeof setImmediate,zr=mr(Ur.postMessage),Hr?setImmediate:zr?(Wr=`axios@${Math.random()}`,$r=[],Ur.addEventListener("message",({source:e,data:t})=>{e===Ur&&t===Wr&&$r.length&&$r.shift()()},!1),e=>{$r.push(e),Ur.postMessage(Wr,"*")}):e=>setTimeout(e));var Hr,zr,Wr,$r;const Vr="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Ur):"undefined"!=typeof process&&process.nextTick||Gr,Kr={isArray:hr,isArrayBuffer:_r,isBuffer:dr,isFormData:e=>{let t;return e&&(br&&e instanceof br||mr(e.append)&&("formdata"===(t=ar(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&&_r(e.buffer),t},isString:fr,isNumber:gr,isBoolean:e=>!0===e||!1===e,isObject:Er,isPlainObject:Tr,isEmptyObject:e=>{if(!Er(e)||dr(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(e){return!1}},isReadableStream:vr,isRequest:Ir,isResponse:Or,isHeaders:Nr,isUndefined:pr,isDate:Ar,isFile:Rr,isReactNativeBlob:e=>!(!e||void 0===e.uri),isReactNative:e=>e&&void 0!==e.getParts,isBlob:Sr,isRegExp:xr,isFunction:mr,isStream:e=>Er(e)&&mr(e.pipe),isURLSearchParams:Cr,isTypedArray:Br,isFileList:Lr,forEach:Mr,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&&wr(r,o)||o;Tr(r[i])&&Tr(n)?r[i]=e(r[i],n):Tr(n)?r[i]=e({},n):hr(n)?r[i]=n.slice():s&&pr(n)||(r[i]=n)};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Mr(arguments[e],n);return r},extend:(e,t,s,{allOwnKeys:r}={})=>(Mr(t,(t,r)=>{s&&mr(t)?Object.defineProperty(e,r,{value:sr(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&&nr(e)}while(e&&(!s||s(e,t))&&e!==Object.prototype);return t},kindOf:ar,kindOfTest:lr,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(hr(e))return e;let t=e.length;if(!gr(t))return null;const s=new Array(t);for(;t-- >0;)s[t]=e[t];return s},forEachEntry:(e,t)=>{const s=(e&&e[or]).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:jr,hasOwnProperty:Dr,hasOwnProp:Dr,reduceDescriptors:Fr,freezeMethods:e=>{Fr(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 hr(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:wr,global:Ur,isContextDefined:Pr,isSpecCompliantForm:function(e){return!!(e&&mr(e.append)&&"FormData"===e[ir]&&e[or])},toJSONObject:e=>{const t=new Array(10),s=(e,r)=>{if(Er(e)){if(t.indexOf(e)>=0)return;if(dr(e))return e;if(!("toJSON"in e)){t[r]=e;const n=hr(e)?[]:{};return Mr(e,(e,t)=>{const o=s(e,r+1);!pr(o)&&(n[t]=o)}),t[r]=void 0,n}}return e};return s(e,0)},isAsyncFn:qr,isThenable:e=>e&&(Er(e)||mr(e))&&mr(e.then)&&mr(e.catch),setImmediate:Gr,asap:Vr,isIterable:e=>null!=e&&mr(e[or])};let Jr=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:Kr.toJSONObject(this.config),code:this.code,status:this.status}}};function Qr(e){return Kr.isPlainObject(e)||Kr.isArray(e)}function Yr(e){return Kr.endsWith(e,"[]")?e.slice(0,-2):e}function Zr(e,t,s){return e?e.concat(t).map(function(e,t){return e=Yr(e),!s&&t?"["+e+"]":e}).join(s?".":""):t}Jr.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",Jr.ERR_BAD_OPTION="ERR_BAD_OPTION",Jr.ECONNABORTED="ECONNABORTED",Jr.ETIMEDOUT="ETIMEDOUT",Jr.ERR_NETWORK="ERR_NETWORK",Jr.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",Jr.ERR_DEPRECATED="ERR_DEPRECATED",Jr.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",Jr.ERR_BAD_REQUEST="ERR_BAD_REQUEST",Jr.ERR_CANCELED="ERR_CANCELED",Jr.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",Jr.ERR_INVALID_URL="ERR_INVALID_URL";const Xr=Kr.toFlatObject(Kr,{},null,function(e){return/^is[A-Z]/.test(e)});function en(e,t,r){if(!Kr.isObject(e))throw new TypeError("target must be an object");t=t||new(s||FormData);const n=(r=Kr.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!Kr.isUndefined(t[e])})).metaTokens,o=r.visitor||u,i=r.dots,a=r.indexes,c=(r.Blob||"undefined"!=typeof Blob&&Blob)&&Kr.isSpecCompliantForm(t);if(!Kr.isFunction(o))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Kr.isDate(e))return e.toISOString();if(Kr.isBoolean(e))return e.toString();if(!c&&Kr.isBlob(e))throw new Jr("Blob is not supported. Use a Buffer instead.");return Kr.isArrayBuffer(e)||Kr.isTypedArray(e)?c&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,s,r){let o=e;if(Kr.isReactNative(t)&&Kr.isReactNativeBlob(e))return t.append(Zr(r,s,i),l(e)),!1;if(e&&!r&&"object"==typeof e)if(Kr.endsWith(s,"{}"))s=n?s:s.slice(0,-2),e=JSON.stringify(e);else if(Kr.isArray(e)&&function(e){return Kr.isArray(e)&&!e.some(Qr)}(e)||(Kr.isFileList(e)||Kr.endsWith(s,"[]"))&&(o=Kr.toArray(e)))return s=Yr(s),o.forEach(function(e,r){!Kr.isUndefined(e)&&null!==e&&t.append(!0===a?Zr([s],r,i):null===a?s:s+"[]",l(e))}),!1;return!!Qr(e)||(t.append(Zr(r,s,i),l(e)),!1)}const h=[],p=Object.assign(Xr,{defaultVisitor:u,convertValue:l,isVisitable:Qr});if(!Kr.isObject(e))throw new TypeError("data must be an object");return function e(s,r){if(!Kr.isUndefined(s)){if(-1!==h.indexOf(s))throw Error("Circular reference detected in "+r.join("."));h.push(s),Kr.forEach(s,function(s,n){!0===(!(Kr.isUndefined(s)||null===s)&&o.call(t,s,Kr.isString(n)?n.trim():n,r,p))&&e(s,r?r.concat(n):[n])}),h.pop()}}(e),t}function tn(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function sn(e,t){this._pairs=[],e&&en(e,this,t)}const rn=sn.prototype;function nn(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function on(e,t,s){if(!t)return e;const r=s&&s.encode||nn,n=Kr.isFunction(s)?{serialize:s}:s,o=n&&n.serialize;let i;if(i=o?o(t,n):Kr.isURLSearchParams(t)?t.toString():new sn(t,n).toString(r),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}rn.append=function(e,t){this._pairs.push([e,t])},rn.toString=function(e){const t=e?function(t){return e.call(this,t,tn)}:tn;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class an{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){Kr.forEach(this.handlers,function(t){null!==t&&e(t)})}}const cn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},ln=r.URLSearchParams,un="abcdefghijklmnopqrstuvwxyz",hn="0123456789",pn={DIGIT:hn,ALPHA:un,ALPHA_DIGIT:un+un.toUpperCase()+hn},dn={isNode:!0,classes:{URLSearchParams:ln,FormData:s,Blob:"undefined"!=typeof Blob&&Blob||null},ALPHABET:pn,generateString:(e=16,s=pn.ALPHA_DIGIT)=>{let r="";const{length:n}=s,o=new Uint32Array(e);t.randomFillSync(o);for(let t=0;t<e;t++)r+=s[o[t]%n];return r},protocols:["http","https","file","data"]},_n="undefined"!=typeof window&&"undefined"!=typeof document,fn="object"==typeof navigator&&navigator||void 0,mn=_n&&(!fn||["ReactNative","NativeScript","NS"].indexOf(fn.product)<0),gn="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,En=_n&&window.location.href||"http://localhost",Tn={...Object.freeze({__proto__:null,hasBrowserEnv:_n,hasStandardBrowserEnv:mn,hasStandardBrowserWebWorkerEnv:gn,navigator:fn,origin:En}),...dn};function An(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&&Kr.isArray(r)?r.length:o,a)return Kr.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!i;r[o]&&Kr.isObject(r[o])||(r[o]=[]);return t(e,s,r[o],n)&&Kr.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(Kr.isFormData(e)&&Kr.isFunction(e.entries)){const s={};return Kr.forEachEntry(e,(e,r)=>{t(function(e){return Kr.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),r,s,0)}),s}return null}const Rn={transitional:cn,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,n=Kr.isObject(e);n&&Kr.isHTMLForm(e)&&(e=new FormData(e));if(Kr.isFormData(e))return r?JSON.stringify(An(e)):e;if(Kr.isArrayBuffer(e)||Kr.isBuffer(e)||Kr.isStream(e)||Kr.isFile(e)||Kr.isBlob(e)||Kr.isReadableStream(e))return e;if(Kr.isArrayBufferView(e))return e.buffer;if(Kr.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 en(e,new Tn.classes.URLSearchParams,{visitor:function(e,t,s,r){return Tn.isNode&&Kr.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((o=Kr.isFileList(e))||s.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return en(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return n||r?(t.setContentType("application/json",!1),function(e,t,s){if(Kr.isString(e))try{return(t||JSON.parse)(e),Kr.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(s||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Rn.transitional,s=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Kr.isResponse(e)||Kr.isReadableStream(e))return e;if(e&&Kr.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 Jr.from(e,Jr.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:Tn.classes.FormData,Blob:Tn.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Kr.forEach(["delete","get","head","post","put","patch"],e=>{Rn.headers[e]={}});const Sn=Kr.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"]),Ln=Symbol("internals");function yn(e){return e&&String(e).trim().toLowerCase()}function bn(e){return!1===e||null==e?e:Kr.isArray(e)?e.map(bn):String(e)}function Cn(e,t,s,r,n){return Kr.isFunction(r)?r.call(this,t,s):(n&&(t=s),Kr.isString(t)?Kr.isString(r)?-1!==t.indexOf(r):Kr.isRegExp(r)?r.test(t):void 0:void 0)}let vn=class{constructor(e){e&&this.set(e)}set(e,t,s){const r=this;function n(e,t,s){const n=yn(t);if(!n)throw new Error("header name must be a non-empty string");const o=Kr.findKey(r,n);(!o||void 0===r[o]||!0===s||void 0===s&&!1!==r[o])&&(r[o||t]=bn(e))}const o=(e,t)=>Kr.forEach(e,(e,s)=>n(e,s,t));if(Kr.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Kr.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(Kr.isObject(e)&&Kr.isIterable(e)){let s,r,n={};for(const t of e){if(!Kr.isArray(t))throw TypeError("Object iterator must return a key-value pair");n[r=t[0]]=(s=n[r])?Kr.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=yn(e)){const s=Kr.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(Kr.isFunction(t))return t.call(this,e,s);if(Kr.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=yn(e)){const s=Kr.findKey(this,e);return!(!s||void 0===this[s]||t&&!Cn(0,this[s],s,t))}return!1}delete(e,t){const s=this;let r=!1;function n(e){if(e=yn(e)){const n=Kr.findKey(s,e);!n||t&&!Cn(0,s[n],n,t)||(delete s[n],r=!0)}}return Kr.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&&!Cn(0,this[n],n,e,!0)||(delete this[n],r=!0)}return r}normalize(e){const t=this,s={};return Kr.forEach(this,(r,n)=>{const o=Kr.findKey(s,n);if(o)return t[o]=bn(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]=bn(r),s[i]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Kr.forEach(this,(s,r)=>{null!=s&&!1!==s&&(t[r]=e&&Kr.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[Ln]=this[Ln]={accessors:{}}).accessors,s=this.prototype;function r(e){const r=yn(e);t[r]||(!function(e,t){const s=Kr.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 Kr.isArray(e)?e.forEach(r):r(e),this}};function In(e,t){const s=this||Rn,r=t||s,n=vn.from(r.headers);let o=r.data;return Kr.forEach(e,function(e){o=e.call(s,o,n.normalize(),t?t.status:void 0)}),n.normalize(),o}function On(e){return!(!e||!e.__CANCEL__)}vn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Kr.reduceDescriptors(vn.prototype,({value:e},t)=>{let s=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[s]=e}}}),Kr.freezeMethods(vn);let Nn=class extends Jr{constructor(e,t,s){super(null==e?"canceled":e,Jr.ERR_CANCELED,t,s),this.name="CanceledError",this.__CANCEL__=!0}};function Mn(e,t,s){const r=s.config.validateStatus;s.status&&r&&!r(s.status)?t(new Jr("Request failed with status code "+s.status,[Jr.ERR_BAD_REQUEST,Jr.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s)):e(s)}function wn(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 Un(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Pn(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var s=function e(){var s=!1;try{s=this instanceof e}catch{}return s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};s.prototype=t.prototype}else s={};return Object.defineProperty(s,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(s,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}),s}var Bn,kn={};const jn=Un(function(){if(Bn)return kn;Bn=1;var e=r.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 n(e){return process.env[e.toLowerCase()]||process.env[e.toUpperCase()]||""}return kn.getProxyForUrl=function(r){var o="string"==typeof r?e(r):r||{},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 r=(n("npm_config_no_proxy")||n("no_proxy")).toLowerCase();if(!r)return!0;if("*"===r)return!1;return r.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=n("npm_config_"+i+"_proxy")||n(i+"_proxy")||n("npm_config_proxy")||n("all_proxy");return l&&-1===l.indexOf("://")&&(l=i+"://"+l),l},kn}());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={exports:{}};const Jn=(()=>{if(navigator.userAgentData){if(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}([navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e),"optionalAccess",e=>e.version])>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),Qn=0!==Jn&&{level:Jn,hasBasic:!0,has256:Jn>=2,has16m:Jn>=3},Yn={stdout:Qn,stderr:Qn},Zn=Pn(Object.freeze({__proto__:null,default:Yn}));var Xn,eo,to,so,ro;function no(){return Xn||(Xn=1,function(e,t){const s=u,r=a;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} `;s[0]=o+s[0].split("\n").join("\n"+o),s.push(n+"m+"+e.exports.humanize(this.diff)+"")}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=Zn;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)}}(Kn,Kn.exports)),Kn.exports}function oo(){return eo||(eo=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=no()),zn.exports}var io=function(){if(ro)return Hn.exports;ro=1;var e,t,s,i=r,a=i.URL,u=n,h=o,p=c.Writable,d=l,_=function(){return so||(so=1,to=function(){if(!e){try{e=oo()("follow-redirects")}catch(e){}"function"!=typeof e&&(e=function(){})}e.apply(null,arguments)}),to;var e}();e="undefined"!=typeof process,t="undefined"!=typeof window&&"undefined"!=typeof document,s=B(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 m=["auth","host","hostname","href","path","pathname","port","protocol","query","search","hash"],g=["abort","aborted","connect","error","socket","timeout"],E=Object.create(null);g.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),S=w("ERR_FR_MAX_BODY_LENGTH_EXCEEDED","Request body larger than maxBodyLength limit"),L=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):P(e)?e=N(I(e)):(o=r,r=O(e),e={protocol:n}),B(r)&&(o=r,r=null),(r=Object.assign({maxRedirects:t.maxRedirects,maxBodyLength:t.maxBodyLength},e,r)).nativeProtocols=s,P(r.host)||P(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(!P((t=O(i.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 m)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){B(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 g)e.removeListener(s,E[s]);e.on("error",v),e.destroy(t)}function P(e){return"string"==typeof e||e instanceof String}function B(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 L;if(!P(e)&&("object"!=typeof(r=e)||!("length"in r)))throw new TypeError("data should be a string, Buffer or Uint8Array");var r;B(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 S),this.abort()):s&&s()},b.prototype.end=function(e,t,s){if(B(e)?(s=e,e=t=null):B(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 r=this._currentRequest=t.request(this._options,this._onNativeResponse);for(var n of(r._redirectable=this,g))r.on(n,E[n]);if(this._currentUrl=/^\//.test(this._options.path)?i.format(this._options):this._options.path,this._isRedirect){var o=0,a=this,c=this._requestBodyBuffers;!function e(t){if(r===a._currentRequest)if(t)a.emit("error",t);else if(o<c.length){var s=c[o++];r.finished||r.write(s.data,s.encoding,e)}else a._ended&&r.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,r=e.headers.location;if(!r||!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 n=this._options.beforeRedirect;n&&(s=Object.assign({Host:e.req.getHeader("host")},this._options.headers));var o=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,m=/^\w+:/.test(r)?this._currentUrl:i.format(Object.assign(h,{host:p})),g=(c=r,l=m,f?new a(c,l):I(i.resolve(l,c)));if(_("redirecting to",g.href),this._isRedirect=!0,N(g,this._options),(g.protocol!==h.protocol&&"https:"!==g.protocol||g.host!==p&&!function(e,t){d(P(e)&&P(t));var s=e.length-t.length-1;return s>0&&"."===e[s]&&e.endsWith(t)}(g.host,p))&&M(/^(?:(?:proxy-)?authorization|cookie)$/i,this._options.headers),B(n)){var E={headers:e.headers,statusCode:t},T={url:m,method:o,headers:s};n(this._options,E,T),this._sanitizeOptions(this._options)}this._performRequest()},Hn.exports=C({http:u,https:h}),Hn.exports.wrap=C,Hn.exports}();const ao=Un(io),co="1.13.6";function lo(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}const uo=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;const ho=Symbol("internals");class po extends c.Transform{constructor(e){super({readableHighWaterMark:(e=Kr.toFlatObject(e,{maxRate:0,chunkSize:65536,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(e,t)=>!Kr.isUndefined(t[e]))).chunkSize});const t=this[ho]={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[ho];return t.onReadCallback&&t.onReadCallback(),super._read(e)}_transform(e,t,s){const r=this[ho],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:_o}=Symbol,fo=async function*(e){e.stream?yield*e.stream():e.arrayBuffer?yield await e.arrayBuffer():e[_o]?yield*e[_o]():yield e},mo=Tn.ALPHABET.ALPHA_DIGIT+"-_",go="function"==typeof TextEncoder?new TextEncoder:new a.TextEncoder,Eo="\r\n",To=go.encode(Eo);class Ao{constructor(e,t){const{escapeName:s}=this.constructor,r=Kr.isString(t);let n=`Content-Disposition: form-data; name="${s(e)}"${!r&&t.name?`; filename="${s(t.name)}"`:""}${Eo}`;r?t=go.encode(String(t).replace(/\r?\n|\r\n?/g,Eo)):n+=`Content-Type: ${t.type||"application/octet-stream"}${Eo}`,this.headers=go.encode(n+Eo),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;Kr.isTypedArray(e)?yield e:yield*fo(e),yield To}static escapeName(e){return String(e).replace(/[\r\n"]/g,e=>({"\r":"%0D","\n":"%0A",'"':"%22"}[e]))}}class Ro extends c.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 So=(e,t)=>Kr.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 Lo=(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)},yo=(e,t)=>{const s=null!=e;return[r=>t[0]({lengthComputable:s,total:e,loaded:r}),t[1]]},bo=e=>(...t)=>Kr.asap(()=>e(...t));const Co={flush:h.constants.Z_SYNC_FLUSH,finishFlush:h.constants.Z_SYNC_FLUSH},vo={flush:h.constants.BROTLI_OPERATION_FLUSH,finishFlush:h.constants.BROTLI_OPERATION_FLUSH},Io=Kr.isFunction(h.createBrotliDecompress),{http:Oo,https:No}=ao,Mo=/https:?/,wo=Tn.protocols.map(e=>e+":"),Uo=(e,[t,s])=>(e.on("end",s).on("error",s),t);const Po=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&&a.isDeepStrictEqual(n,t))return e}}const r=i.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))},c=r.request,{sessionTimeout:l}=t;if(null!=l){let e,t=0;r.request=function(){const s=c.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 Bo(e,t){e.beforeRedirects.proxy&&e.beforeRedirects.proxy(e),e.beforeRedirects.config&&e.beforeRedirects.config(e,t)}function ko(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 Jr("Invalid proxy authorization",Jr.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){ko(e,t,e.href)}}const jo="undefined"!=typeof process&&"process"===Kr.kindOf(process),Do=(e,t)=>(({address:e,family:t})=>{if(!Kr.isString(e))throw TypeError("address must be a string");return{address:e,family:t||(e.indexOf(".")<0?6:4)}})(Kr.isObject(e)?e:{address:e,family:t}),xo={request(e,t){const s=e.protocol+"//"+e.hostname+":"+(e.port||("https:"===e.protocol?443:80)),{http2Options:r,headers:n}=e,o=Po.getSession(s,r),{HTTP2_HEADER_SCHEME:a,HTTP2_HEADER_METHOD:c,HTTP2_HEADER_PATH:l,HTTP2_HEADER_STATUS:u}=i.constants,h={[a]:e.protocol.replace(":",""),[c]:e.method,[l]:e.path};Kr.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}},Fo=jo&&function(e){return t=async function(t,s,r){let{data:i,lookup:l,family:u,httpVersion:d=1,http2Options:_}=e;const{responseType:f,responseEncoding:m}=e,g=e.method.toUpperCase();let E,T,A=!1;if(d=+d,Number.isNaN(d))throw TypeError(`Invalid protocol version: '${e.httpVersion}' is not a number`);if(1!==d&&2!==d)throw TypeError(`Unsupported protocol version '${d}'`);const R=2===d;if(l){const e=So(l,e=>Kr.isArray(e)?e:[e]);l=(t,s,r)=>{e(t,s,(e,t,n)=>{if(e)return r(e);const o=Kr.isArray(t)?t.map(e=>Do(e)):[Do(t,n)];s.all?r(e,o):r(e,o[0].address,o[0].family)})}}const S=new p.EventEmitter;function L(t){try{S.emit("abort",!t||t.type?new Nn(null,e,T):t)}catch(e){console.warn("emit error",e)}}S.once("abort",s);const y=()=>{e.cancelToken&&e.cancelToken.unsubscribe(L),e.signal&&e.signal.removeEventListener("abort",L),S.removeAllListeners()};(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(L),e.signal&&(e.signal.aborted?L():e.signal.addEventListener("abort",L))),r((e,t)=>{if(E=!0,t)return A=!0,void y();const{data:s}=e;if(s instanceof c.Readable||s instanceof c.Duplex){const e=c.finished(s,()=>{e(),y()})}else y()});const b=wn(e.baseURL,e.url,e.allowAbsoluteUrls),C=new URL(b,Tn.hasBrowserEnv?Tn.origin:void 0),v=C.protocol||wo[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 Jr("maxContentLength size of "+e.maxContentLength+" exceeded",Jr.ERR_BAD_RESPONSE,e));let r;if("GET"!==g)return Mn(t,s,{status:405,statusText:"method not allowed",headers:{},config:e});try{r=function(e,t,s){const r=s&&s.Blob||Tn.classes.Blob,n=lo(e);if(void 0===t&&r&&(t=!0),"data"===n){e=n.length?e.slice(n.length+1):e;const s=uo.exec(e);if(!s)throw new Jr("Invalid URL",Jr.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 Jr("Blob is not supported",Jr.ERR_NOT_SUPPORT);return new r([c],{type:o})}return c}throw new Jr("Unsupported protocol "+n,Jr.ERR_NOT_SUPPORT)}(e.url,"blob"===f,{Blob:e.env&&e.env.Blob})}catch(t){throw Jr.from(t,Jr.ERR_BAD_REQUEST,e)}return"text"===f?(r=r.toString(m),m&&"utf8"!==m||(r=Kr.stripBOM(r))):"stream"===f&&(r=c.Readable.from(r)),Mn(t,s,{data:r,status:200,statusText:"OK",headers:new vn,config:e})}if(-1===wo.indexOf(v))return s(new Jr("Unsupported protocol "+v,Jr.ERR_BAD_REQUEST,e));const I=vn.from(e.headers).normalize();I.set("User-Agent","axios/"+co,!1);const{onUploadProgress:O,onDownloadProgress:N}=e,M=e.maxRate;let w,U;if(Kr.isSpecCompliantForm(i)){const e=I.getContentType(/boundary=([-_\w\d]{10,70})/i);i=((e,t,s)=>{const{tag:r="form-data-boundary",size:n=25,boundary:o=r+"-"+Tn.generateString(n,mo)}=s||{};if(!Kr.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=go.encode("--"+o+Eo),a=go.encode("--"+o+"--"+Eo);let l=a.byteLength;const u=Array.from(e.entries()).map(([e,t])=>{const s=new Ao(e,t);return l+=s.size,s});l+=i.byteLength*u.length,l=Kr.toFiniteNumber(l);const h={"Content-Type":`multipart/form-data; boundary=${o}`};return Number.isFinite(l)&&(h["Content-Length"]=l),t&&t(h),c.Readable.from(async function*(){for(const e of u)yield i,yield*e.encode();yield a}())})(i,e=>{I.set(e)},{tag:`axios-${co}-boundary`,boundary:e&&e[1]||void 0})}else if(Kr.isFormData(i)&&Kr.isFunction(i.getHeaders)){if(I.set(i.getHeaders()),!I.hasContentLength())try{const e=await a.promisify(i.getLength).call(i);Number.isFinite(e)&&e>=0&&I.setContentLength(e)}catch(e){}}else if(Kr.isBlob(i)||Kr.isFile(i))i.size&&I.setContentType(i.type||"application/octet-stream"),I.setContentLength(i.size||0),i=c.Readable.from(fo(i));else if(i&&!Kr.isStream(i)){if(Buffer.isBuffer(i));else if(Kr.isArrayBuffer(i))i=Buffer.from(new Uint8Array(i));else{if(!Kr.isString(i))return s(new Jr("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",Jr.ERR_BAD_REQUEST,e));i=Buffer.from(i,"utf-8")}if(I.setContentLength(i.length,!1),e.maxBodyLength>-1&&i.length>e.maxBodyLength)return s(new Jr("Request body larger than maxBodyLength limit",Jr.ERR_BAD_REQUEST,e))}const P=Kr.toFiniteNumber(I.getContentLength());let B,k;Kr.isArray(M)?(w=M[0],U=M[1]):w=U=M,i&&(O||w)&&(Kr.isStream(i)||(i=c.Readable.from(i,{objectMode:!1})),i=c.pipeline([i,new po({maxRate:Kr.toFiniteNumber(w)})],Kr.noop),O&&i.on("progress",Uo(i,yo(P,Lo(bo(O),!1,3))))),e.auth&&(B=(e.auth.username||"")+":"+(e.auth.password||"")),!B&&C.username&&(B=C.username+":"+C.password),B&&I.delete("authorization");try{k=on(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"+(Io?", br":""),!1);const j={path:k,method:g,headers:I.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:B,protocol:v,family:u,beforeRedirect:Bo,beforeRedirects:{},http2Options:_};let D;!Kr.isUndefined(l)&&(j.lookup=l),e.socketPath?j.socketPath=e.socketPath:(j.hostname=C.hostname.startsWith("[")?C.hostname.slice(1,-1):C.hostname,j.port=C.port,ko(j,e.proxy,v+"//"+C.hostname+(C.port?":"+C.port:"")+j.path));const x=Mo.test(j.protocol);if(j.agent=x?e.httpsAgent:e.httpAgent,R?D=xo:e.transport?D=e.transport:0===e.maxRedirects?D=x?o:n:(e.maxRedirects&&(j.maxRedirects=e.maxRedirects),e.beforeRedirect&&(j.beforeRedirects.config=e.beforeRedirect),D=x?No:Oo),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=Kr.toFiniteNumber(r.headers["content-length"]);if(N||U){const e=new po({maxRate:Kr.toFiniteNumber(U)});N&&e.on("progress",Uo(e,yo(o,Lo(bo(N),!0,3)))),n.push(e)}let i=r;const a=r.req||T;if(!1!==e.decompress&&r.headers["content-encoding"])switch("HEAD"!==g&&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(h.createUnzip(Co)),delete r.headers["content-encoding"];break;case"deflate":n.push(new Ro),n.push(h.createUnzip(Co)),delete r.headers["content-encoding"];break;case"br":Io&&(n.push(h.createBrotliDecompress(vo)),delete r.headers["content-encoding"])}i=n.length>1?c.pipeline(n,Kr.noop):n[0];const l={status:r.statusCode,statusText:r.statusMessage,headers:new vn(r.headers),config:e,request:a};if("stream"===f)l.data=i,Mn(t,s,l);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(),L(new Jr("maxContentLength size of "+e.maxContentLength+" exceeded",Jr.ERR_BAD_RESPONSE,e,a)))}),i.on("aborted",function(){if(A)return;const t=new Jr("stream has been aborted",Jr.ERR_BAD_RESPONSE,e,a);i.destroy(t),s(t)}),i.on("error",function(t){T.destroyed||s(Jr.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(m),m&&"utf8"!==m||(e=Kr.stripBOM(e))),l.data=e}catch(t){return s(Jr.from(t,null,e,l.request,l))}Mn(t,s,l)})}S.once("abort",e=>{i.destroyed||(i.emit("error",e),i.destroy())})}),S.once("abort",e=>{T.close?T.close():T.destroy(e)}),T.on("error",function(t){s(Jr.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 L(new Jr("error trying to parse `config.timeout` to int",Jr.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||cn;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),L(new Jr(t,s.clarifyTimeoutError?Jr.ETIMEDOUT:Jr.ECONNABORTED,e,T))})}else T.setTimeout(0);if(Kr.isStream(i)){let t=!1,s=!1;i.on("end",()=>{t=!0}),i.once("error",e=>{s=!0,T.destroy(e)}),i.on("close",()=>{t||s||L(new Nn("Request stream has been aborted",e,T))}),i.pipe(T)}else i&&T.write(i),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},qo=Tn.hasStandardBrowserEnv?((e,t)=>s=>(s=new URL(s,Tn.origin),e.protocol===s.protocol&&e.host===s.host&&(t||e.port===s.port)))(new URL(Tn.origin),Tn.navigator&&/(msie|trident)/i.test(Tn.navigator.userAgent)):()=>!0,Go=Tn.hasStandardBrowserEnv?{write(e,t,s,r,n,o,i){if("undefined"==typeof document)return;const a=[`${e}=${encodeURIComponent(t)}`];Kr.isNumber(s)&&a.push(`expires=${new Date(s).toUTCString()}`),Kr.isString(r)&&a.push(`path=${r}`),Kr.isString(n)&&a.push(`domain=${n}`),!0===o&&a.push("secure"),Kr.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(){}},Ho=e=>e instanceof vn?{...e}:e;function zo(e,t){t=t||{};const s={};function r(e,t,s,r){return Kr.isPlainObject(e)&&Kr.isPlainObject(t)?Kr.merge.call({caseless:r},e,t):Kr.isPlainObject(t)?Kr.merge({},t):Kr.isArray(t)?t.slice():t}function n(e,t,s,n){return Kr.isUndefined(t)?Kr.isUndefined(e)?void 0:r(void 0,e,0,n):r(e,t,0,n)}function o(e,t){if(!Kr.isUndefined(t))return r(void 0,t)}function i(e,t){return Kr.isUndefined(t)?Kr.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(Ho(e),Ho(t),0,!0)};return Kr.forEach(Object.keys({...e,...t}),function(r){if("__proto__"===r||"constructor"===r||"prototype"===r)return;const o=Kr.hasOwnProp(c,r)?c[r]:n,i=o(e[r],t[r],r);Kr.isUndefined(i)&&o!==a||(s[r]=i)}),s}const Wo=e=>{const t=zo({},e);let{data:s,withXSRFToken:r,xsrfHeaderName:n,xsrfCookieName:o,headers:i,auth:a}=t;if(t.headers=i=vn.from(i),t.url=on(wn(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),Kr.isFormData(s))if(Tn.hasStandardBrowserEnv||Tn.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(Kr.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(Tn.hasStandardBrowserEnv&&(r&&Kr.isFunction(r)&&(r=r(t)),r||!1!==r&&qo(t.url))){const e=n&&o&&Go.read(o);e&&i.set(n,e)}return t},$o="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,s){const r=Wo(e);let n=r.data;const o=vn.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 m(){if(!f)return;const r=vn.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders());Mn(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=m:f.onreadystatechange=function(){f&&4===f.readyState&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))&&setTimeout(m)},f.onabort=function(){f&&(s(new Jr("Request aborted",Jr.ECONNABORTED,e,f)),f=null)},f.onerror=function(t){const r=t&&t.message?t.message:"Network Error",n=new Jr(r,Jr.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||cn;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),s(new Jr(t,n.clarifyTimeoutError?Jr.ETIMEDOUT:Jr.ECONNABORTED,e,f)),f=null},void 0===n&&o.setContentType(null),"setRequestHeader"in f&&Kr.forEach(o.toJSON(),function(e,t){f.setRequestHeader(t,e)}),Kr.isUndefined(r.withCredentials)||(f.withCredentials=!!r.withCredentials),h&&"json"!==h&&(f.responseType=r.responseType),d&&([c,u]=Lo(d,!0),f.addEventListener("progress",c)),p&&f.upload&&([a,l]=Lo(p),f.upload.addEventListener("progress",a),f.upload.addEventListener("loadend",l)),(r.cancelToken||r.signal)&&(i=t=>{f&&(s(!t||t.type?new Nn(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 g=lo(r.url);g&&-1===Tn.protocols.indexOf(g)?s(new Jr("Unsupported protocol "+g+":",Jr.ERR_BAD_REQUEST,e)):f.send(n||null)})},Vo=(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 Jr?t:new Nn(t instanceof Error?t.message:t))}};let o=t&&setTimeout(()=>{o=null,n(new Jr(`timeout of ${t}ms exceeded`,Jr.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=()=>Kr.asap(i),a}},Ko=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},Jo=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()}},Qo=(e,t,s,r)=>{const n=async function*(e,t){for await(const s of Jo(e))yield*Ko(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:Yo}=Kr,Zo=(({Request:e,Response:t})=>({Request:e,Response:t}))(Kr.global),{ReadableStream:Xo,TextEncoder:ei}=Kr.global,ti=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},si=e=>{e=Kr.merge.call({skipUndefined:!0},Zo,e);const{fetch:t,Request:s,Response:r}=e,n=t?Yo(t):"function"==typeof fetch,o=Yo(s),i=Yo(r);if(!n)return!1;const a=n&&Yo(Xo),c=n&&("function"==typeof ei?(l=new ei,e=>l.encode(e)):async e=>new Uint8Array(await new s(e).arrayBuffer()));var l;const u=o&&a&&ti(()=>{let e=!1;const t=new s(Tn.origin,{body:new Xo,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),h=i&&a&&ti(()=>Kr.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 Jr(`Response type '${e}' is not supported`,Jr.ERR_NOT_SUPPORT,s)})});const d=async(e,t)=>{const r=Kr.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(Kr.isBlob(e))return e.size;if(Kr.isSpecCompliantForm(e)){const t=new s(Tn.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Kr.isArrayBufferView(e)||Kr.isArrayBuffer(e)?e.byteLength:(Kr.isURLSearchParams(e)&&(e+=""),Kr.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:m,responseType:g,headers:E,withCredentials:T="same-origin",fetchOptions:A}=Wo(e),R=t||fetch;g=g?(g+"").toLowerCase():"text";let S=Vo([c,l&&l.toAbortSignal()],_),L=null;const y=S&&S.unsubscribe&&(()=>{S.unsubscribe()});let b;try{if(m&&u&&"get"!==i&&"head"!==i&&0!==(b=await d(E,a))){let e,t=new s(n,{method:"POST",body:a,duplex:"half"});if(Kr.isFormData(a)&&(e=t.headers.get("content-type"))&&E.setContentType(e),t.body){const[e,s]=yo(b,Lo(bo(m)));a=Qo(t.body,65536,e,s)}}Kr.isString(T)||(T=T?"include":"omit");const t=o&&"credentials"in s.prototype,c={...A,signal:S,method:i.toUpperCase(),headers:E.normalize().toJSON(),body:a,duplex:"half",credentials:t?T:void 0};L=o&&new s(n,c);let l=await(o?R(L,A):R(n,c));const _=h&&("stream"===g||"response"===g);if(h&&(f||_&&y)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=l[t]});const t=Kr.toFiniteNumber(l.headers.get("content-length")),[s,n]=f&&yo(t,Lo(bo(f),!0))||[];l=new r(Qo(l.body,65536,s,()=>{n&&n(),y&&y()}),e)}g=g||"text";let C=await p[Kr.findKey(p,g)||"text"](l,e);return!_&&y&&y(),await new Promise((t,s)=>{Mn(t,s,{data:C,headers:vn.from(l.headers),status:l.status,statusText:l.statusText,config:e,request:L})})}catch(t){if(y&&y(),t&&"TypeError"===t.name&&/Load failed|fetch/i.test(t.message))throw Object.assign(new Jr("Network Error",Jr.ERR_NETWORK,e,L,t&&t.response),{cause:t.cause||t});throw Jr.from(t,t&&t.code,e,L,t&&t.response)}}},ri=new Map,ni=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=ri;for(;c--;)i=o[c],a=l.get(i),void 0===a&&l.set(i,a=c?new Map:si(t)),l=a;return a};ni();const oi={http:Fo,xhr:$o,fetch:{get:ni}};Kr.forEach(oi,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}});const ii=e=>`- ${e}`,ai=e=>Kr.isFunction(e)||null===e||!1===e;const ci={getAdapter:function(e,t){e=Kr.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,!ai(r)&&(n=oi[(s=String(r)).toLowerCase()],void 0===n))throw new Jr(`Unknown adapter '${s}'`);if(n&&(Kr.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(ii).join("\n"):" "+ii(e[0]):"as no adapter specified";throw new Jr("There is no suitable adapter to dispatch the request "+t,"ERR_NOT_SUPPORT")}return n},adapters:oi};function li(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Nn(null,e)}function ui(e){li(e),e.headers=vn.from(e.headers),e.data=In.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return ci.getAdapter(e.adapter||Rn.adapter,e)(e).then(function(t){return li(e),t.data=In.call(e,e.transformResponse,t),t.headers=vn.from(t.headers),t},function(t){return On(t)||(li(e),t&&t.response&&(t.response.data=In.call(e,e.transformResponse,t.response),t.response.headers=vn.from(t.response.headers))),Promise.reject(t)})}const hi={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{hi[e]=function(s){return typeof s===e||"a"+(t<1?"n ":" ")+e}});const pi={};hi.transitional=function(e,t,s){function r(e,t){return"[Axios v"+co+"] Transitional option '"+e+"'"+t+(s?". "+s:"")}return(s,n,o)=>{if(!1===e)throw new Jr(r(n," has been removed"+(t?" in "+t:"")),Jr.ERR_DEPRECATED);return t&&!pi[n]&&(pi[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)}},hi.spelling=function(e){return(t,s)=>(console.warn(`${s} is likely a misspelling of ${e}`),!0)};const di={assertOptions:function(e,t,s){if("object"!=typeof e)throw new Jr("options must be an object",Jr.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 Jr("option "+o+" must be "+s,Jr.ERR_BAD_OPTION_VALUE);continue}if(!0!==s)throw new Jr("Unknown option "+o,Jr.ERR_BAD_OPTION)}},validators:hi},_i=di.validators;let fi=class{constructor(e){this.defaults=e||{},this.interceptors={request:new an,response:new an}}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=zo(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:n}=t;void 0!==s&&di.assertOptions(s,{silentJSONParsing:_i.transitional(_i.boolean),forcedJSONParsing:_i.transitional(_i.boolean),clarifyTimeoutError:_i.transitional(_i.boolean),legacyInterceptorReqResOrdering:_i.transitional(_i.boolean)},!1),null!=r&&(Kr.isFunction(r)?t.paramsSerializer={serialize:r}:di.assertOptions(r,{encode:_i.function,serialize:_i.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),di.assertOptions(t,{baseUrl:_i.spelling("baseURL"),withXsrfToken:_i.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=n&&Kr.merge(n.common,n[t.method]);n&&Kr.forEach(["delete","get","head","post","put","patch","common"],e=>{delete n[e]}),t.headers=vn.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||cn;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=[ui.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=ui.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 on(wn((e=zo(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};Kr.forEach(["delete","get","head","options"],function(e){fi.prototype[e]=function(t,s){return this.request(zo(s||{},{method:e,url:t,data:(s||{}).data}))}}),Kr.forEach(["post","put","patch"],function(e){function t(t){return function(s,r,n){return this.request(zo(n||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:s,data:r}))}}fi.prototype[e]=t(),fi.prototype[e+"Form"]=t(!0)});const mi={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(mi).forEach(([e,t])=>{mi[t]=e});const gi=function e(t){const s=new fi(t),r=sr(fi.prototype.request,s);return Kr.extend(r,fi.prototype,s,{allOwnKeys:!0}),Kr.extend(r,s,null,{allOwnKeys:!0}),r.create=function(s){return e(zo(t,s))},r}(Rn);gi.Axios=fi,gi.CanceledError=Nn,gi.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 Nn(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}}},gi.isCancel=On,gi.VERSION=co,gi.toFormData=en,gi.AxiosError=Jr,gi.Cancel=gi.CanceledError,gi.all=function(e){return Promise.all(e)},gi.spread=function(e){return function(t){return e.apply(null,t)}},gi.isAxiosError=function(e){return Kr.isObject(e)&&!0===e.isAxiosError},gi.mergeConfig=zo,gi.AxiosHeaders=vn,gi.formToJSON=e=>An(Kr.isHTMLForm(e)?new FormData(e):e),gi.getAdapter=ci.getAdapter,gi.HttpStatusCode=mi,gi.default=gi;const{Axios:Ei,AxiosError:Ti,CanceledError:Ai,isCancel:Ri,CancelToken:Si,VERSION:Li,all:yi,Cancel:bi,isAxiosError:Ci,spread:vi,toFormData:Ii,AxiosHeaders:Oi,HttpStatusCode:Ni,formToJSON:Mi,getAdapter:wi,mergeConfig:Ui}=gi;function Pi(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 Bi(){return function(e={}){const{isSuccess:t=e=>0===e,getCode:s=e=>Pi([e,"access",e=>e.data,"optionalAccess",e=>e.code]),getMessage:r=e=>Pi([e,"access",e=>e.data,"optionalAccess",e=>e.message])||Pi([e,"access",e=>e.data,"optionalAccess",e=>e.msg]),getData:n=e=>Pi([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 tr(c,{status:e.status,code:a,config:e.config,response:e,data:e.data});return e}}}({isSuccess:e=>0===e,getCode:e=>Pi([e,"access",e=>e.data,"optionalAccess",e=>e.code]),getMessage:e=>Pi([e,"access",e=>e.data,"optionalAccess",e=>e.message])||Pi([e,"access",e=>e.data,"optionalAccess",e=>e.msg]),getData:e=>e.data})}function ki(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 ji={"/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 Di(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=gs(e);for(const e of t){const t=Et(s,e);if("string"==typeof t){const r=Number(t);Number.isInteger(r)&&Qs(s,e,r)}else Array.isArray(t)&&Qs(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 xi(e={}){const t=gi.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 ki([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=ki([e,"access",e=>e.method,"optionalAccess",e=>e.toLowerCase,"call",e=>e()])||"get";var a;return s.includes(i)&&(a="content-type",!("function"==typeof ki([e,"access",e=>e.headers,"optionalAccess",e=>e.get])?e.headers.get(a):ki([e,"access",e=>e.headers,"optionalAccess",e=>e[a]])))&&(o("content-type",r),n&&!e.data&&(e.data={})),e}}}(),Di({config:ji}),Bi(),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 Fi=xi({baseURL:"/",headers:{"Agw-Js-Conv":"str"}}),qi=Fi,Gi=(e,t)=>qi({...e,...t});var Hi,zi,Wi,$i,Vi,Ki,Ji,Qi,Yi,Zi,Xi,ea,ta,sa,ra,na,oa;function ia(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";e[e.OpenClawChannelTypeWeCom=3]="OpenClawChannelTypeWeCom"}(Hi||(Hi={})),function(e){e[e.OpenClawLarkAuthStatusAuthorized=1]="OpenClawLarkAuthStatusAuthorized";e[e.OpenClawLarkAuthStatusUnauthorized=2]="OpenClawLarkAuthStatusUnauthorized"}(zi||(zi={})),function(e){e[e.OpenClawLarkConfigStatusNotCreated=1]="OpenClawLarkConfigStatusNotCreated";e[e.OpenClawLarkConfigStatusCreated=2]="OpenClawLarkConfigStatusCreated";e[e.OpenClawLarkConfigStatusConfigured=3]="OpenClawLarkConfigStatusConfigured"}(Wi||(Wi={})),function(e){e[e.OpenClawUpdateStatusNoUpdate=1]="OpenClawUpdateStatusNoUpdate";e[e.OpenClawUpdateStatusPending=2]="OpenClawUpdateStatusPending";e[e.OpenClawUpdateStatusUpdating=3]="OpenClawUpdateStatusUpdating"}($i||($i={})),function(e){e[e.OpenClawVersionTypeFull=1]="OpenClawVersionTypeFull";e[e.OpenClawVersionTypeLite=2]="OpenClawVersionTypeLite"}(Vi||(Vi={})),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"}(Ki||(Ki={})),function(e){e[e.Unknown=0]="Unknown";e[e.Like=1]="Like";e[e.Dislike=2]="Dislike"}(Ji||(Ji={})),function(e){e[e.Wait=0]="Wait";e[e.Done=1]="Done"}(Qi||(Qi={})),function(e){e[e.RoleTypeUnknown=0]="RoleTypeUnknown";e[e.RoleTypeUser=1]="RoleTypeUser";e[e.RoleTypeAssistant=2]="RoleTypeAssistant"}(Yi||(Yi={})),function(e){e[e.AddAttributes=1]="AddAttributes";e[e.RemoveAttributes=2]="RemoveAttributes"}(Zi||(Zi={})),function(e){e[e.CloseConnection=1]="CloseConnection"}(Xi||(Xi={})),function(e){e[e.ON_LINE=0]="ON_LINE";e[e.OFF_LINE=1]="OFF_LINE";e[e.TOUCH=2]="TOUCH"}(ea||(ea={})),function(e){e[e.AddGroups=1]="AddGroups";e[e.RemoveGroups=2]="RemoveGroups";e[e.ReplaceWithGroups=3]="ReplaceWithGroups"}(ta||(ta={})),function(e){e[e.App=0]="App";e[e.Service=1]="Service";e[e.Method=2]="Method"}(sa||(sa={})),function(e){e[e.ApiKey=1]="ApiKey";e[e.WechatOfficialAccount=2]="WechatOfficialAccount";e[e.OAuth=3]="OAuth"}(ra||(ra={})),function(e){e[e.PROJECT_COPY=1]="PROJECT_COPY";e[e.SKILL_STORE=2]="SKILL_STORE"}(na||(na={})),function(e){e[e.PENDING=1]="PENDING";e[e.SUCCESS=2]="SUCCESS";e[e.FAILED=3]="FAILED"}(oa||(oa={}));class aa{__init(){this.request=Gi}__init2(){this.baseURL=""}constructor(e){aa.prototype.__init.call(this),aa.prototype.__init2.call(this),this.request=ia([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=ia([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)}ConnectOpenClawFeishu(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/connect_feishu`),n={app_name:s.app_name,recreate:s.recreate,avatar_url:s.avatar_url};return this.request({url:r,method:"POST",data:n},t)}ConnectOpenClawWeChat(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/connect_wechat`);return this.request({url:r,method:"POST"},t)}ConnectOpenClawWeCom(e,t){const s=e,r=this.genBaseURL(`/v1/api/project/${s.project_id}/assistant/openclaw/connect_wecom`),n={bot_id:s.bot_id,secret:s.secret};return this.request({url:r,method:"POST",data:n},t)}}const ca=new aa({});class la{constructor({options:e,reportLog:t}){this.mergedBaseOptions=Xs({scenes:{[E.GetMessage]:async(...e)=>await ca.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=Xs(this.mergedBaseOptions,e)}getSceneConfig(e){const{scenes:t}=this.mergedBaseOptions;return t[e]}}class ua{constructor(){ua.prototype.__init.call(this)}__init(){this.preSendLocalMessageEvents=e()}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 ha{getSendChatMessageStructure(e,t){const s=Vs(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 Js(s,e=>null!=e&&""!==e)}}function pa(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 da=["console","file","text"],_a="generate_image";function fa(e,t){return null!=e?e:t()}function ma(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 ga=(e,t)=>{const s=t.at(0);if(!s)return e;if("message_start"===s.type||"message_end"===s.type)return gs(s);const r=gs(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=>fa(e.content.answer,()=>""));r.content.answer=fa(r.content.answer,()=>"")+e.join("")}else if("thinking"===r.type){const e=o.map(e=>fa(e.content.thinking,()=>""));r.content.thinking=fa(r.content.thinking,()=>"")+e.join("")}else if("tool_request"===r.type&&r.content.tool_request){const e=o.map(e=>fa(ma([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters]),()=>""));r.content.tool_request.stream_parameters=fa(r.content.tool_request.stream_parameters,()=>"")+e.join("")}else if("tool_process"===r.type){const e=o.map(e=>ma([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=>pa([e,"optionalAccess",e=>e[_a],"optionalAccess",e=>e.images])||[]).flat();return(n.length>0||!$s(pa([e,"optionalAccess",e=>e[_a]])))&&(s[_a]={images:(pa([e,"optionalAccess",e=>e[_a],"optionalAccess",e=>e.images])||[]).concat(n)},r=!0),da.forEach(n=>{const o=t.filter(e=>!$s(pa([e,"optionalAccess",e=>e[n]]))).map(e=>pa([e,"optionalAccess",e=>e[n]])||"");(o.length>0||!$s(pa([e,"optionalAccess",e=>e[n]])))&&(s[n]=(pa([e,"optionalAccess",e=>e[n]])||"")+o.join(""),r=!0)}),r?s:e||{}}(ma([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 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}class Ta{__init(){this.streamBufferSnapshot=null}constructor(e){Ta.prototype.__init.call(this),Ta.prototype.__init2.call(this),Ta.prototype.__init3.call(this),this.key=e.key}__init2(){this.getBufferMeta=e=>{return{query_msg_id:(t=Ea([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 Aa{__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){Aa.prototype.__init.call(this),Aa.prototype.__init2.call(this),Aa.prototype.__init3.call(this),Aa.prototype.__init4.call(this),Aa.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 Ra;!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"}(Ra||(Ra={}));const Sa={[Ra.QUOTATION_MARK]:Ra.QUOTATION_MARK,[Ra.REVERSE_SOLIDUS]:Ra.REVERSE_SOLIDUS,[Ra.SOLIDUS]:Ra.SOLIDUS,[Ra.LATIN_SMALL_LETTER_B]:Ra.BACKSPACE,[Ra.LATIN_SMALL_LETTER_F]:Ra.FORM_FEED,[Ra.LATIN_SMALL_LETTER_N]:Ra.NEWLINE,[Ra.LATIN_SMALL_LETTER_R]:Ra.CARRIAGE_RETURN,[Ra.LATIN_SMALL_LETTER_T]:Ra.TAB};class La{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 ya{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 ba,Ca;function va(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"}(ba||(ba={})),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"}(Ca||(Ca={}));const Ia={stringBufferSize:0,numberBufferSize:0,separator:void 0,emitPartialTokens:!1};class Oa extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Oa.prototype)}}class Na{constructor(e){this.state=Ca.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({},Ia),e),this.emitPartialTokens=!0===e.emitPartialTokens,this.bufferedString=e.stringBufferSize&&e.stringBufferSize>4?new ya(e.stringBufferSize):new La,this.bufferedNumber=e.numberBufferSize&&e.numberBufferSize>0?new ya(e.numberBufferSize):new La,this.separator=e.separator,this.separatorBytes=e.separator?this.encoder.encode(e.separator):void 0}get isEnded(){return this.state===Ca.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 Ca.BOM_OR_START:if(e instanceof Uint8Array&&239===r){this.bom=[239,187,191],this.bomIndex+=1,this.state=Ca.BOM;continue}if(e instanceof Uint16Array){if(254===r){this.bom=[254,255],this.bomIndex+=1,this.state=Ca.BOM;continue}if(255===r){this.bom=[255,254],this.bomIndex+=1,this.state=Ca.BOM;continue}}if(e instanceof Uint32Array){if(0===r){this.bom=[0,0,254,255],this.bomIndex+=1,this.state=Ca.BOM;continue}if(255===r){this.bom=[255,254,0,0],this.bomIndex+=1,this.state=Ca.BOM;continue}}case Ca.START:if(this.offset+=1,this.separatorBytes&&r===this.separatorBytes[0]){if(1===this.separatorBytes.length){this.state=Ca.START,this.onToken({token:ba.SEPARATOR,value:this.separator,offset:this.offset+this.separatorBytes.length-1});continue}this.state=Ca.SEPARATOR;continue}if(r===Ra.SPACE||r===Ra.NEWLINE||r===Ra.CARRIAGE_RETURN||r===Ra.TAB)continue;if(r===Ra.LEFT_CURLY_BRACKET){this.onToken({token:ba.LEFT_BRACE,value:"{",offset:this.offset});continue}if(r===Ra.RIGHT_CURLY_BRACKET){this.onToken({token:ba.RIGHT_BRACE,value:"}",offset:this.offset});continue}if(r===Ra.LEFT_SQUARE_BRACKET){this.onToken({token:ba.LEFT_BRACKET,value:"[",offset:this.offset});continue}if(r===Ra.RIGHT_SQUARE_BRACKET){this.onToken({token:ba.RIGHT_BRACKET,value:"]",offset:this.offset});continue}if(r===Ra.COLON){this.onToken({token:ba.COLON,value:":",offset:this.offset});continue}if(r===Ra.COMMA){this.onToken({token:ba.COMMA,value:",",offset:this.offset});continue}if(r===Ra.LATIN_SMALL_LETTER_T){this.state=Ca.TRUE1;continue}if(r===Ra.LATIN_SMALL_LETTER_F){this.state=Ca.FALSE1;continue}if(r===Ra.LATIN_SMALL_LETTER_N){this.state=Ca.NULL1;continue}if(r===Ra.QUOTATION_MARK){this.bufferedString.reset(),this.escapedCharsByteLength=0,this.state=Ca.STRING_DEFAULT;continue}if(r>=Ra.DIGIT_ONE&&r<=Ra.DIGIT_NINE){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_NON_ZERO;continue}if(r===Ra.DIGIT_ZERO){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_ZERO;continue}if(r===Ra.HYPHEN_MINUS){this.bufferedNumber.reset(),this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_MINUS;continue}break;case Ca.STRING_DEFAULT:if(r===Ra.QUOTATION_MARK){const e=this.bufferedString.toString();this.state=Ca.START,this.onToken({token:ba.STRING,value:e,offset:this.offset}),this.offset+=this.escapedCharsByteLength+this.bufferedString.byteLength+1;continue}if(r===Ra.REVERSE_SOLIDUS){this.state=Ca.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=Ca.STRING_INCOMPLETE_CHAR;continue}if(r>=Ra.SPACE){this.bufferedString.appendChar(r);continue}break;case Ca.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=Ca.STRING_DEFAULT;continue;case Ca.STRING_AFTER_BACKSLASH:const n=Sa[r];if(n){this.bufferedString.appendChar(n),this.escapedCharsByteLength+=1,this.state=Ca.STRING_DEFAULT;continue}if(r===Ra.LATIN_SMALL_LETTER_U){this.unicode="",this.state=Ca.STRING_UNICODE_DIGIT_1;continue}break;case Ca.STRING_UNICODE_DIGIT_1:case Ca.STRING_UNICODE_DIGIT_2:case Ca.STRING_UNICODE_DIGIT_3:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE||r>=Ra.LATIN_CAPITAL_LETTER_A&&r<=Ra.LATIN_CAPITAL_LETTER_F||r>=Ra.LATIN_SMALL_LETTER_A&&r<=Ra.LATIN_SMALL_LETTER_F){this.unicode+=String.fromCharCode(r),this.state+=1;continue}break;case Ca.STRING_UNICODE_DIGIT_4:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE||r>=Ra.LATIN_CAPITAL_LETTER_A&&r<=Ra.LATIN_CAPITAL_LETTER_F||r>=Ra.LATIN_SMALL_LETTER_A&&r<=Ra.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=Ca.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=Ca.STRING_DEFAULT;continue}break;case Ca.NUMBER_AFTER_INITIAL_MINUS:if(r===Ra.DIGIT_ZERO){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_ZERO;continue}if(r>=Ra.DIGIT_ONE&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_INITIAL_NON_ZERO;continue}break;case Ca.NUMBER_AFTER_INITIAL_ZERO:if(r===Ra.FULL_STOP){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_FULL_STOP;continue}if(r===Ra.LATIN_SMALL_LETTER_E||r===Ra.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E;continue}s-=1,this.state=Ca.START,this.emitNumber();continue;case Ca.NUMBER_AFTER_INITIAL_NON_ZERO:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r);continue}if(r===Ra.FULL_STOP){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_FULL_STOP;continue}if(r===Ra.LATIN_SMALL_LETTER_E||r===Ra.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E;continue}s-=1,this.state=Ca.START,this.emitNumber();continue;case Ca.NUMBER_AFTER_FULL_STOP:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_DECIMAL;continue}break;case Ca.NUMBER_AFTER_DECIMAL:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r);continue}if(r===Ra.LATIN_SMALL_LETTER_E||r===Ra.LATIN_CAPITAL_LETTER_E){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E;continue}s-=1,this.state=Ca.START,this.emitNumber();continue;case Ca.NUMBER_AFTER_E:if(r===Ra.PLUS_SIGN||r===Ra.HYPHEN_MINUS){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E_AND_SIGN;continue}case Ca.NUMBER_AFTER_E_AND_SIGN:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r),this.state=Ca.NUMBER_AFTER_E_AND_DIGIT;continue}break;case Ca.NUMBER_AFTER_E_AND_DIGIT:if(r>=Ra.DIGIT_ZERO&&r<=Ra.DIGIT_NINE){this.bufferedNumber.appendChar(r);continue}s-=1,this.state=Ca.START,this.emitNumber();continue;case Ca.TRUE1:if(r===Ra.LATIN_SMALL_LETTER_R){this.state=Ca.TRUE2;continue}break;case Ca.TRUE2:if(r===Ra.LATIN_SMALL_LETTER_U){this.state=Ca.TRUE3;continue}break;case Ca.TRUE3:if(r===Ra.LATIN_SMALL_LETTER_E){this.state=Ca.START,this.onToken({token:ba.TRUE,value:!0,offset:this.offset}),this.offset+=3;continue}break;case Ca.FALSE1:if(r===Ra.LATIN_SMALL_LETTER_A){this.state=Ca.FALSE2;continue}break;case Ca.FALSE2:if(r===Ra.LATIN_SMALL_LETTER_L){this.state=Ca.FALSE3;continue}break;case Ca.FALSE3:if(r===Ra.LATIN_SMALL_LETTER_S){this.state=Ca.FALSE4;continue}break;case Ca.FALSE4:if(r===Ra.LATIN_SMALL_LETTER_E){this.state=Ca.START,this.onToken({token:ba.FALSE,value:!1,offset:this.offset}),this.offset+=4;continue}break;case Ca.NULL1:if(r===Ra.LATIN_SMALL_LETTER_U){this.state=Ca.NULL2;continue}break;case Ca.NULL2:if(r===Ra.LATIN_SMALL_LETTER_L){this.state=Ca.NULL3;continue}break;case Ca.NULL3:if(r===Ra.LATIN_SMALL_LETTER_L){this.state=Ca.START,this.onToken({token:ba.NULL,value:null,offset:this.offset}),this.offset+=3;continue}break;case Ca.SEPARATOR:if(this.separatorIndex+=1,!this.separatorBytes||r!==this.separatorBytes[this.separatorIndex])break;this.separatorIndex===this.separatorBytes.length-1&&(this.state=Ca.START,this.onToken({token:ba.SEPARATOR,value:this.separator,offset:this.offset+this.separatorIndex}),this.separatorIndex=0);continue;case Ca.BOM:if(r===this.bom[this.bomIndex]){if(this.bomIndex===this.bom.length-1){this.state=Ca.START,this.bom=void 0,this.bomIndex=0;continue}this.bomIndex+=1;continue}break;case Ca.ENDED:if(r===Ra.SPACE||r===Ra.NEWLINE||r===Ra.CARRIAGE_RETURN||r===Ra.TAB)continue}throw new Oa(`Unexpected "${String.fromCharCode(r)}" at position "${s}" in state ${va(this.state)}`)}if(this.emitPartialTokens)switch(this.state){case Ca.TRUE1:case Ca.TRUE2:case Ca.TRUE3:this.onToken({token:ba.TRUE,value:!0,offset:this.offset,partial:!0});break;case Ca.FALSE1:case Ca.FALSE2:case Ca.FALSE3:case Ca.FALSE4:this.onToken({token:ba.FALSE,value:!1,offset:this.offset,partial:!0});break;case Ca.NULL1:case Ca.NULL2:case Ca.NULL3:this.onToken({token:ba.NULL,value:null,offset:this.offset,partial:!0});break;case Ca.STRING_DEFAULT:{const e=this.bufferedString.toString();this.onToken({token:ba.STRING,value:e,offset:this.offset,partial:!0});break}case Ca.NUMBER_AFTER_INITIAL_ZERO:case Ca.NUMBER_AFTER_INITIAL_NON_ZERO:case Ca.NUMBER_AFTER_DECIMAL:case Ca.NUMBER_AFTER_E_AND_DIGIT:try{this.onToken({token:ba.NUMBER,value:this.parseNumber(this.bufferedNumber.toString()),offset:this.offset,partial:!0})}catch(e){}}}catch(e){this.error(e)}}emitNumber(){this.onToken({token:ba.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!==Ca.ENDED&&(this.state=Ca.ERROR),this.onError(e)}end(){switch(this.state){case Ca.NUMBER_AFTER_INITIAL_ZERO:case Ca.NUMBER_AFTER_INITIAL_NON_ZERO:case Ca.NUMBER_AFTER_DECIMAL:case Ca.NUMBER_AFTER_E_AND_DIGIT:this.state=Ca.ENDED,this.emitNumber(),this.onEnd();break;case Ca.BOM_OR_START:case Ca.START:case Ca.ERROR:case Ca.SEPARATOR:this.state=Ca.ENDED,this.onEnd();break;default:this.error(new Oa(`Tokenizer ended in the middle of a token (state: ${va(this.state)}). Either not all the data was received or the data was invalid.`))}}onToken(e){throw new Oa('Can\'t emit tokens before the "onToken" callback has been set up.')}onError(e){throw e}onEnd(){}}var Ma,wa;function Ua(e){return["VALUE","KEY","COLON","COMMA","ENDED","ERROR","SEPARATOR"][e]}!function(e){e[e.OBJECT=0]="OBJECT",e[e.ARRAY=1]="ARRAY"}(Ma||(Ma={})),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"}(wa||(wa={}));const Pa={paths:void 0,keepStack:!0,separator:void 0,emitPartialValues:!1};class Ba extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Ba.prototype)}}class ka{constructor(e){this.state=wa.VALUE,this.mode=void 0,this.key=void 0,this.value=void 0,this.stack=[],(e=Object.assign(Object.assign({},Pa),e)).paths&&(this.paths=e.paths.map(e=>{if(void 0===e||"$*"===e)return;if(!e.startsWith("$"))throw new Ba(`Invalid selector "${e}". Should start with "$".`);const t=e.split(".").slice(1);if(t.includes(""))throw new Ba(`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?wa.COMMA:wa.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=wa.SEPARATOR:void 0===this.separator&&this.end())}emitPartial(e){this.shouldEmit()&&(this.state!==wa.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===wa.ENDED}write({token:e,value:t,partial:s}){try{if(s)return void this.emitPartial(t);if(this.state===wa.VALUE){if(e===ba.STRING||e===ba.NUMBER||e===ba.TRUE||e===ba.FALSE||e===ba.NULL)return this.mode===Ma.OBJECT?(this.value[this.key]=t,this.state=wa.COMMA):this.mode===Ma.ARRAY&&(this.value.push(t),this.state=wa.COMMA),void this.emit(t,this.shouldEmit());if(e===ba.LEFT_BRACE){if(this.push(),this.mode===Ma.OBJECT)this.value=this.value[this.key]={};else if(this.mode===Ma.ARRAY){const e={};this.value.push(e),this.value=e}else this.value={};return this.mode=Ma.OBJECT,this.state=wa.KEY,this.key=void 0,void this.emitPartial()}if(e===ba.LEFT_BRACKET){if(this.push(),this.mode===Ma.OBJECT)this.value=this.value[this.key]=[];else if(this.mode===Ma.ARRAY){const e=[];this.value.push(e),this.value=e}else this.value=[];return this.mode=Ma.ARRAY,this.state=wa.VALUE,this.key=0,void this.emitPartial()}if(this.mode===Ma.ARRAY&&e===ba.RIGHT_BRACKET&&0===this.value.length)return void this.pop()}if(this.state===wa.KEY){if(e===ba.STRING)return this.key=t,this.state=wa.COLON,void this.emitPartial();if(e===ba.RIGHT_BRACE&&0===Object.keys(this.value).length)return void this.pop()}if(this.state===wa.COLON&&e===ba.COLON)return void(this.state=wa.VALUE);if(this.state===wa.COMMA){if(e===ba.COMMA){if(this.mode===Ma.ARRAY)return this.state=wa.VALUE,void(this.key+=1);if(this.mode===Ma.OBJECT)return void(this.state=wa.KEY)}if(e===ba.RIGHT_BRACE&&this.mode===Ma.OBJECT||e===ba.RIGHT_BRACKET&&this.mode===Ma.ARRAY)return void this.pop()}if(this.state===wa.SEPARATOR&&e===ba.SEPARATOR&&t===this.separator)return void(this.state=wa.VALUE);if(e===ba.SEPARATOR&&this.state!==wa.SEPARATOR&&Array.from(t).map(e=>e.charCodeAt(0)).every(e=>e===Ra.SPACE||e===Ra.NEWLINE||e===Ra.CARRIAGE_RETURN||e===Ra.TAB))return;throw new Ba(`Unexpected ${ba[e]} (${JSON.stringify(t)}) in state ${Ua(this.state)}`)}catch(e){this.error(e)}}error(e){this.state!==wa.ENDED&&(this.state=wa.ERROR),this.onError(e)}end(){this.state!==wa.VALUE&&this.state!==wa.SEPARATOR||this.stack.length>0?this.error(new Error(`Parser ended in mid-parsing (state: ${Ua(this.state)}). Either not all the data was received or the data was invalid.`)):(this.state=wa.ENDED,this.onEnd())}onValue(e){throw new Ba('Can\'t emit data before the "onValue" callback has been set up.')}onError(e){throw e}onEnd(){}}class ja{constructor(e={}){this.tokenizer=new Na(e),this.tokenParser=new ka(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 Da;function xa(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}(Da||(Da={})).STREAM_PARSER_JSON_ERROR="chat_sdk_pull_stream_parser_error";class Fa{__init(){this.parserOptions={emitPartialValues:!0,emitPartialTokens:!0,keepStack:!0}}__init2(){this.jsonParserMap={}}__init3(){this.jsonParserMetaMap={}}constructor(e){Fa.prototype.__init.call(this),Fa.prototype.__init2.call(this),Fa.prototype.__init3.call(this),Fa.prototype.__init4.call(this),Fa.prototype.__init5.call(this),Fa.prototype.__init6.call(this),Fa.prototype.__init7.call(this),Fa.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 ja(this.parserOptions);return this.jsonParserMap[e]=t,this.jsonParserMetaMap[e]={isError:!1},this.jsonParserMap[e]}}__init5(){this.updateJsonParserMeta=(e,t)=>{Ys(this.jsonParserMetaMap,e,t)}}__init6(){this.write=(e,t,{onValue:s,onError:r,onEnd:n,onToken:o})=>{const i=this.getJsonParser(e);xa([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})),xa([r,"optionalCall",e=>e(t)]),this.reportLogWithScope.slardarErrorEvent({error:t,eventName:Da.STREAM_PARSER_JSON_ERROR,meta:{msgId:e}})},i.onEnd=()=>{this.clearByMsgId(e),xa([n,"optionalCall",e=>e()])},o&&(i.onToken=o),i.write(t))}}__init7(){this.clearParserCallback=e=>{e.onValue=oe,e.onError=oe,e.onEnd=oe,e.onToken=oe}}__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 qa={toolRequestStreamingParameters:!1},Ga={v1:{toolRequestStreamingParameters:!0}},Ha=e=>{return"tool_request"===e.type&&(t=e.version,t&&Ga[t]||qa).toolRequestStreamingParameters;var t};function za(e,t){return null!=e?e:t()}function Wa(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 $a{constructor(e){const{initMessageBuffer:t=[],reportLogWithScope:s}=e;this.streamMessageBuffer=gs(t),this.streamChunkBuffer=gs(t),this.streamParserJson=new Fa({reportLogWithScope:s}),this.streamMessageBuffer.forEach(e=>{Ha(e)&&this.streamParserJson.write(e.msg_id,Wa([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters])||"",{onValue:oe})})}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=ga(o,s);if(!i)return;const a=Ha(i);return a&&s.forEach(e=>{this.streamParserJson.write(e.msg_id,Wa([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($s(t)||$s(s))return;const c=gs(o),l=gs(s);if(!a){if(!n)return c||l;if(!c)return;return c[t]=l,c}const u=gs(a.value);return n?(Ys(u,i.map(e=>e.key).filter(e=>!$s(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 Va=1073741823;class Ka{__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){Ka.prototype.__init.call(this),Ka.prototype.__init2.call(this),Ka.prototype.__init3.call(this),Ka.prototype.__init4.call(this),Ka.prototype.__init5.call(this),Ka.prototype.__init6.call(this),Ka.prototype.__init7.call(this),Ka.prototype.__init8.call(this);const{getEnableDebug:t,key:s,reportLogWithScope:r,initMaxSequenceId:n}=e;this.getEnableDebug=t,this.maxSequenceId=za(n,()=>0),this.enableChunkProcessedCheck=za(e.enableChunkProcessedCheck,()=>!1),this.streamBuffer=new $a(e),this.debugLogger=new Aa({reportLogWithScope:r,getEnableDebug:t,getLogPayload:()=>this.getStreamBuffer(),mark:"ChunkProcessor"}),this.simpleMessageDump=new Ta({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>Va,n=s>Va;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=>Wa([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 Ja,Qa,Ya;!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"}(Ja||(Ja={})),function(e){e[e.Unknown=0]="Unknown";e[e.Prev=1]="Prev";e[e.Next=2]="Next"}(Qa||(Qa={}));class Za{__init(){this.timer=null}__init2(){this.timeoutMs=12e4}constructor(e){Za.prototype.__init.call(this),Za.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 Xa(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 ec(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(Xa([n,"optionalAccess",e=>e.validate])){if(n.validate(t))return t;{const t=new Error("JSON validation failed");if(Xa([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&&Xa([n,"optionalAccess",e=>e.throwOnValidationError]))throw t;return Xa([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"}(Ya||(Ya={}));class tc{__init(){this.state="pending"}constructor(){tc.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 sc(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 rc={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},nc=e=>{const{type:t}=e;return(e=>e in rc)(t)?Ha({type:t,version:e.version})?{...e,role:"assistant",type:t,streamParametersContent:(n=sc([e,"access",e=>e.content,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters]),o=()=>"",s=null!=n?n:o(),ec(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 oc extends Error{constructor(e,t){super(e),oc.prototype.__init.call(this),this.name="chatCoreError",this.ext=t||{}}__init(){this.flatten=()=>{const{message:e,ext:t}=this;return{message:e,...t}}}}function ic(e,t){return null!=e?e:t()}function ac(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 cc=e=>{const{content:t,type:s}=e;switch(s){case"answer":return ic(ac([t,"access",e=>e.answer,"optionalAccess",e=>e.length]),()=>0);case"thinking":return ic(ac([t,"access",e=>e.thinking,"optionalAccess",e=>e.length]),()=>0);case"tool_request":return ic(ac([t,"access",e=>e.tool_request,"optionalAccess",e=>e.stream_parameters,"optionalAccess",e=>e.length]),()=>0);case"tool_process":return(e=>{const t=ac([e,"access",e=>e.content,"access",e=>e.tool_process,"optionalAccess",e=>e.data,"access",e=>e.content]);return da.reduce((e,s)=>{const r=ac([t,"optionalAccess",e=>e[s]]);return"string"!=typeof r?e:e+r.length},0)})(e);case"tool_response":return ic(ac([t,"access",e=>e.tool_response,"optionalAccess",e=>e.result,"access",e=>e.length]),()=>0);default:return 0}};class lc{__init(){this.bufferMap=new Map}constructor(e,t){lc.prototype.__init.call(this),lc.prototype.__init2.call(this),lc.prototype.__init3.call(this),lc.prototype.__init4.call(this),lc.prototype.__init5.call(this),lc.prototype.__init6.call(this),lc.prototype.__init7.call(this),lc.prototype.__init8.call(this),lc.prototype.__init9.call(this),lc.prototype.__init10.call(this),this.onFlush=e,this.config={lengthThreshold:ic(ac([t,"optionalAccess",e=>e.lengthThreshold]),()=>4096),maxWaitMs:ic(ac([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+=cc(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);ac([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 uc(e,t){return null!=e?e:t()}function hc(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 pc{__init(){this.bufferManager=null}constructor({channel:e,reportLogWithScope:t,chunkProcessor:s,preSendLocalMessageEventsManager:r,chatSdkEventEmit:n,chatSdkEventBus:o,reportEventsTracer:i,manualInitChannel:a,enableBuffer:c=!1}){pc.prototype.__init.call(this),pc.prototype.__init2.call(this),pc.prototype.__init3.call(this),pc.prototype.__init4.call(this),pc.prototype.__init5.call(this),pc.prototype.__init6.call(this),pc.prototype.__init7.call(this),pc.prototype.__init8.call(this),pc.prototype.__init9.call(this),pc.prototype.__init10.call(this),pc.prototype.__init11.call(this),pc.prototype.__init12.call(this),pc.prototype.__init13.call(this),pc.prototype.__init14.call(this),pc.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 Za({reportLogWithScope:t,getChannelOptions:()=>({...uc(hc([this,"access",e=>e.channel,"access",e=>e.getChannelOptions,"optionalCall",e=>e()]),()=>({})),channelName:this.channel.channelName}),timeoutMs:12e4}),c&&(this.bufferManager=new lc(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=nc(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(Ja.CONTEXT_CHANGE,{name:Ja.CONTEXT_CHANGE,data:e})}}__init4(){this.handleSessionChange=e=>{this.reportLogWithScope.info({message:"session 更新",meta:{session:e}}),this.chatSdkEventEmit(Ja.SESSION_CHANGED,{name:Ja.SESSION_CHANGED,data:e})}}__init5(){this.handleChatFinish=()=>{hc([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=uc(hc([o,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),()=>"");this.chunkProcessor.isFirstReplyMessage(s)&&hc([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 oc("processedMessage is undefined",{local_msg_id:i});this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"pulling",local_msg_id:i,query_msg_id:r}}),this.chatSdkEventEmit(Ja.MESSAGE_RECEIVED_AND_UPDATE,{name:Ja.MESSAGE_RECEIVED_AND_UPDATE,data:[a]})}}__init8(){this.handleChatMessage=e=>{const{content:t,type:s}=e,r=uc(hc([t,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),()=>"");if(!this.chunkProcessor.checkMessageHasProcessed(e)){if("message_end"===s){hc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]);const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new oc("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 oc("processedMessage is undefined",{local_msg_id:r});return void this.handleMessageStart(t)}if("error"===s){hc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.forceFlushAll,"call",e=>e()]);const t=this.chunkProcessor.addBatchAndProcess(this.createSingleChunkBatch(e));if(!t)throw new oc("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(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"channel_error",wsError:e}}),this.chatSdkEventEmit(Ja.CHANNEL_STATUS,{name:Ja.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);hc([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(hc([o,"optionalAccess",e=>e.code])){case"0":this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"success",query_msg_id:t,reply_id:s,messageEndDetail:r.message_end}});break;case"1":this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"cancel",query_msg_id:t,messageEndDetail:r.message_end,reply_id:s}});break;default:this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"error",query_msg_id:t,messageEndDetail:r.message_end,reply_id:s,code:hc([o,"optionalAccess",e=>e.code]),message:hc([o,"optionalAccess",e=>e.message])}})}this.preSendLocalMessageEventsManager.emit(Ya.MESSAGE_END,e),this.handleChatFinish()}}__init11(){this.handleMessageError=e=>{const{query_msg_id:t,content:s}=e,r=hc([s,"access",e=>e.error,"optionalAccess",e=>e.local_msg_id]),n=uc(hc([s,"access",e=>e.error,"optionalAccess",e=>e.error_msg]),()=>""),o=new oc(n,{query_msg_id:t,local_msg_id:r,code:hc([s,"access",e=>e.error,"optionalAccess",e=>e.code])});hc([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(Ya.MESSAGE_SEND_AND_RECEIVE_ERROR,o),this.chatSdkEventEmit(Ja.SEND_MESSAGE_ERROR,{name:Ja.SEND_MESSAGE_ERROR,data:{error:o}}),this.handleChatFinish()}}__init12(){this.handleMessageStart=e=>{const{content:t,query_msg_id:s,log_id:r}=e,n=hc([t,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]);hc([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(Ya.MESSAGE_SEND_SUCCESS,e),this.chatSdkEventEmit(Ja.MESSAGE_PULLING_STATUS,{name:Ja.MESSAGE_PULLING_STATUS,data:{pullingStatus:"start",local_msg_id:n,query_msg_id:s}})}}__init13(){this.handleChannelOpen=()=>{this.reportLogWithScope.info({message:"信道连接成功"}),this.chatSdkEventEmit(Ja.CHANNEL_STATUS,{name:Ja.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(Ja.CHANNEL_STATUS,{name:Ja.CHANNEL_STATUS,data:{channelStatus:"disconnected",message:t}})}}__init15(){this.initChannel=async()=>{this.channel.isChannelOpen()||await this.channel.connect()}}destroy(){hc([this,"access",e=>e.bufferManager,"optionalAccess",e=>e.destroy,"call",e=>e()]),this.channel.destroy(),this.chatSdkEventBus.all.clear()}}function dc(e,t){return null!=e?e:t()}function _c(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 fc{constructor({preSendLocalMessageFactory:e,channel:t,preSendLocalMessageEventsManager:s,reportLogWithScope:r,reportEventsTracer:n,chatSdkEventEmit:o}){fc.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 oc("Error: during send message channel onerror",{local_msg_id:e});throw _c([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 oc(t.msg,{local_msg_id:e});throw this.chatSdkEventEmit(Ja.SEND_MESSAGE_ERROR,{name:Ja.SEND_MESSAGE_ERROR,data:{error:s}}),_c([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.error,"call",e=>e(s)]),s}}startMessageTracing(e,t){_c([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){_c([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.success,"call",s=>s(e,t)])}traceMessageError(e,t){_c([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(Ya.MESSAGE_END,n),r.push(()=>this.preSendLocalMessageEventsManager.off(Ya.MESSAGE_END,n)))}handleCommandSendSuccess(e,t,s){"input"===e&&(this.completeMessageTracing(t),s())}handleCommandSendError(e,t,s){const r=new oc(`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=dc(_c([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(Ya.MESSAGE_SEND_SUCCESS,u),r.push(()=>this.preSendLocalMessageEventsManager.off(Ya.MESSAGE_SEND_SUCCESS,u));const h=this.createMessageFailedHandler(s,n.reject);this.preSendLocalMessageEventsManager.on(Ya.MESSAGE_SEND_AND_RECEIVE_ERROR,h),r.push(()=>this.preSendLocalMessageEventsManager.off(Ya.MESSAGE_SEND_AND_RECEIVE_ERROR,h))}setupTimeoutHandler(e,t,s){return setTimeout(()=>{_c([this,"access",e=>e.reportEventsTracer,"optionalAccess",e=>e.sendMessageTracer,"access",e=>e.timeout,"call",t=>t(e)]);const t=new oc("send chat message timeout",{local_msg_id:e});this.preSendLocalMessageEventsManager.emit(Ya.MESSAGE_SEND_TIMEOUT,t),s(t)},t)}createMessageSuccessHandler(e){const{localMsgId:t,message:s,promiseHandlers:r}=e;return e=>{const n=_c([e,"access",e=>e.content,"access",e=>e.message_start,"optionalAccess",e=>e.local_msg_id]),o=_c([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:dc(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 oc(`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 oc((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 mc(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 gc;!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"}(gc||(gc={}));class Ec{__init(){this.eventTracers=new Map}constructor(e){Ec.prototype.__init.call(this),Ec.prototype.__init2.call(this),Ec.prototype.__init3.call(this),this.reporter=e}__init2(){this.sendMessageTracer={start:(e,t)=>{const{trace:s}=this.createTracer(gc.SDK_MESSAGE_SEND_TRACER);this.setTracer(e,gc.SDK_MESSAGE_SEND_TRACER,{trace:s}),mc([s,"optionalCall",e=>e("start",{meta:t})])},success:(e,t)=>{const{trace:s}=this.getTracer(e,gc.SDK_MESSAGE_SEND_TRACER);mc([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,gc.SDK_MESSAGE_SEND_TRACER),this.pullStreamTracer.start(e,t)},inqueue:(e,t)=>{const{trace:s}=this.getTracer(e,gc.SDK_MESSAGE_SEND_TRACER);mc([s,"optionalCall",e=>e("inqueue",{meta:t})]),this.deleteTracer(e,gc.SDK_MESSAGE_SEND_TRACER)},error:e=>{const{local_msg_id:t}=e.ext;if(!t)return;const{trace:s}=this.getTracer(t,gc.SDK_MESSAGE_SEND_TRACER);mc([s,"optionalCall",t=>t("error",{meta:e.flatten(),error:e})]),this.deleteTracer(t,gc.SDK_MESSAGE_SEND_TRACER)},timeout:e=>{const{trace:t}=this.getTracer(e,gc.SDK_MESSAGE_SEND_TRACER);mc([t,"optionalCall",e=>e("timeout")]),this.deleteTracer(e,gc.SDK_MESSAGE_SEND_TRACER)}}}__init3(){this.pullStreamTracer={start:(e,t)=>{const{trace:s}=this.createTracer(gc.SDK_PULL_STREAM_TRACER);this.setTracer(e,gc.SDK_PULL_STREAM_TRACER,{trace:s,meta:t}),mc([s,"optionalCall",e=>e("start",{meta:t})])},success:(e,t)=>{const{trace:s}=this.getTracer(e,gc.SDK_PULL_STREAM_TRACER);mc([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,gc.SDK_PULL_STREAM_TRACER)},break:(e,t)=>{const{trace:s}=this.getTracer(e,gc.SDK_PULL_STREAM_TRACER);mc([s,"optionalCall",e=>e("success",{meta:t})]),this.deleteTracer(e,gc.SDK_PULL_STREAM_TRACER)},error:(e,t)=>{const{query_msg_id:s}=e.ext;if(!s)return;const{trace:r}=this.getTracer(s,gc.SDK_PULL_STREAM_TRACER);mc([r,"optionalCall",s=>s("error",{meta:{...e.flatten(),...t},error:e})]),this.deleteTracer(s,gc.SDK_PULL_STREAM_TRACER)},timeout:e=>{const{query_msg_id:t}=e.ext;if(!t)return;const{trace:s}=this.getTracer(t,gc.SDK_PULL_STREAM_TRACER);mc([s,"optionalCall",t=>t("timeout",{meta:e.flatten(),error:e})]),this.deleteTracer(t,gc.SDK_PULL_STREAM_TRACER)},receiveFirstAnsChunk:(e,t)=>{const{trace:s}=this.getTracer(e,gc.SDK_PULL_STREAM_TRACER);mc([s,"optionalCall",e=>e("first_ans_chunk",{meta:t})])}}}static getUniqueKey(e,t){return`${e}_${t}`}getTracer(e,t){return this.eventTracers.get(Ec.getUniqueKey(e,t))||{trace:void 0}}setTracer(e,t,s){const{trace:r,meta:n}=s;this.eventTracers.set(Ec.getUniqueKey(e,t),{trace:r,meta:n})}deleteTracer(e,t){this.eventTracers.delete(Ec.getUniqueKey(e,t))}createTracer(e){return this.reporter.slardarTracer({eventName:e})}}class Tc{static __initStatic(){this.instances=new Map}static __initStatic2(){this.EVENTS=Ja}__init(){this.enableDebug=!1}__init2(){this.eventBus=e()}constructor(e){Tc.prototype.__init.call(this),Tc.prototype.__init2.call(this),Tc.prototype.__init3.call(this),Tc.prototype.__init4.call(this),Tc.prototype.__init5.call(this),Tc.prototype.__init6.call(this),Tc.prototype.__init7.call(this),Tc.prototype.__init8.call(this),Tc.prototype.__init9.call(this),Tc.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 Ec(this.reportLogWithScope),this.requestManager=new la({options:e.requestManagerOptions,reportLog:this.reportLog}),this.preSendLocalMessageEventsManager=new ua,this.preSendLocalMessageFactory=new ha,this.chunkProcessor=new Ka({getEnableDebug:()=>this.enableDebug,initMessageBuffer:e.initMessageBuffer,initMaxSequenceId:e.initMaxSequenceId,enableChunkProcessedCheck:e.enableChunkProcessedCheck,reportLogWithScope:this.reportLogWithScope,key:n}),this.channel=e.channel,this.createMessageService=new Zs,this.sendMessageService=new fc({preSendLocalMessageFactory:this.preSendLocalMessageFactory,channel:this.channel,preSendLocalMessageEventsManager:this.preSendLocalMessageEventsManager,reportLogWithScope:this.reportLogWithScope,reportEventsTracer:this.reportEventsTracer,chatSdkEventEmit:this.emit}),this.websocketService=new pc({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:gc.SDK_INIT,meta:{...e}}),this.reportLogWithScope.info({message:"SDK 初始化完成"})}static create(e){const{key:t}=e;if(Tc.instances.has(t))return console.error("duplicate chat core instance error"),Tc.instances.get(t);const s=new Tc(e);return Tc.instances.set(t,s),s}onEvents(){this.websocketService.onChannelEvents()}destroy(){this.websocketService.destroy(),this.eventBus.all.clear(),this.chunkProcessor.destroy(),Tc.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(E.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()}}Tc.__initStatic(),Tc.__initStatic2();const Ac={E1000:"E1000",E1001:"E1001",E1002:"E1002",E1003:"E1003",E1004:"E1004",E1005:"E1005",E1006:"E1006",E1007:"E1007",E1100:"E1100",E1101:"E1101",E1102:"E1102",E1103:"E1103",E2001:"E2001",E2002:"E2002",E2003:"E2003",E3000:"E3000",E3001:"E3001",E3002:"E3002",E3003:"E3003",E3004:"E3004",E3005:"E3005",E3006:"E3006",E3007:"E3007",E3008:"E3008",E3009:"E3009",E3010:"E3010",E3011:"E3011",E3012:"E3012",E3013:"E3013",E4001:"E4001",E4002:"E4002",E5000:"E5000",E5001:"E5001",E5002:"E5002",E5003:"E5003",E5004:"E5004",E5005:"E5005",E5006:"E5006",E5007:"E5007"},Rc={E1000:"INVALID_ARGUMENT",E1001:"MISSING_PROJECT_ID",E1002:"MISSING_MESSAGE",E1003:"MISSING_SPACE_ID",E1004:"INVALID_DOMAIN",E1005:"INVALID_PROJECT_TYPE",E1006:"UNSUPPORTED_PROJECT_TYPE",E1007:"DB_SQL_DANGEROUS",E1100:"UNKNOWN_OPTION",E1101:"UNKNOWN_COMMAND",E1102:"MISSING_ARGUMENT",E1103:"MISSING_OPTION",E2001:"AUTH_FAILED",E2002:"MINIPROGRAM_NOT_AUTHORIZED",E2003:"PERMISSION_DENIED",E3000:"RESOURCE_NOT_FOUND",E3001:"PROJECT_NOT_FOUND",E3002:"SKILL_NOT_FOUND",E3003:"SECRET_NOT_FOUND",E3004:"SKILL_NOT_INSTALLED",E3005:"DELETE_FAILED",E3006:"NO_DEPLOYMENT_HISTORY",E3007:"MISSING_COMMIT_HASH",E3008:"SKILL_PROJECT_NOT_SUPPORTED",E3009:"CONFLICT",E3010:"DB_NOT_FOUND",E3011:"DB_CREATING",E3012:"DB_RESTORE_WINDOW_EXCEEDED",E3013:"DB_RESTORE_IN_PROGRESS",E4001:"QUOTA_EXCEEDED",E4002:"DB_QUOTA_EXCEEDED",E5000:"UNEXPECTED_ERROR",E5001:"NETWORK_ERROR",E5002:"SERVER_ERROR",E5003:"TIMEOUT",E5004:"DB_SQL_EXECUTION_FAILED",E5005:"DB_CONNECTION_FAILED",E5006:"DB_GEN_TYPES_FAILED",E5007:"DB_DUMP_FAILED"};function Sc(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}exports.ExitCode=void 0,function(e){e[e.SUCCESS=0]="SUCCESS";e[e.FAILURE=1]="FAILURE";e[e.AUTH_ERROR=2]="AUTH_ERROR";e[e.INPUT_ERROR=4]="INPUT_ERROR"}(exports.ExitCode||(exports.ExitCode={}));class yc extends Error{constructor(e,t,s,r){const n=Sc(Rc[e],()=>"UNKNOWN_ERROR"),o=Sc(t,()=>n);super(o),this.name="CozeError",this.code=e,this.errorName=n,this.desc=o,this.details=s,this.trigger=Lc([r,"optionalAccess",e=>e.trigger]),this.fix=Lc([r,"optionalAccess",e=>e.fix]),this.example=Lc([r,"optionalAccess",e=>e.example]),this.isMessageExplicit=void 0!==t,Object.setPrototypeOf(this,yc.prototype)}}class bc{constructor(){bc.prototype.__init.call(this)}__init(){this.headers={}}setHeaders(e){this.headers=m.merge({},this.headers,e)}getHeaders(){return this.headers}resetHeaders(){this.headers={}}setDispatcher(e){this.dispatcher=e}clearDispatcher(){this.dispatcher=void 0}async fetch(e,t){const s=m.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}([t,"optionalAccess",e=>e.headers]));return g.fetch(e,{...t,headers:s,dispatcher:this.dispatcher})}}const Cc=new bc;var vc,Ic,Oc,Nc,Mc,wc,Uc,Pc,Bc,kc,jc,Dc,xc,Fc,qc,Gc,Hc,zc,Wc,$c,Vc,Kc,Jc,Qc;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}!function(e){e[e.develop=0]="develop";e[e.product=1]="product"}(vc||(vc={})),function(e){e[e.restoring=0]="restoring";e[e.success=1]="success";e[e.failed=2]="failed"}(Ic||(Ic={})),function(e){e[e.active=0]="active";e[e.creating=1]="creating"}(Oc||(Oc={})),function(e){e[e.postgre=0]="postgre";e[e.supabase=1]="supabase"}(Nc||(Nc={})),function(e){e[e.SQL=1]="SQL";e[e.REPORT=2]="REPORT";e[e.LOG_SQL=3]="LOG_SQL"}(Mc||(Mc={})),function(e){e[e.NAME=1]="NAME";e[e.INSERTED_AT=2]="INSERTED_AT"}(wc||(wc={})),function(e){e[e.ASC=1]="ASC";e[e.DESC=2]="DESC"}(Uc||(Uc={})),function(e){e[e.USER=1]="USER";e[e.PROJECT=2]="PROJECT";e[e.ORG=3]="ORG";e[e.PUBLIC=4]="PUBLIC"}(Pc||(Pc={})),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.FileExist="file.exist";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.RepoVersionConflictResolve="repo_version.conflict.resolve";e.RepoVersionEvent="repo_version.event";e.RepoVersionFileRead="repo_version.file.read";e.RepoVersionLatest="repo_version.commit.version.latest";e.RepoVersionNotify="repo_version.notify";e.RepoVersionRemoteAdd="repo_version.remote.add";e.RepoVersionRemoteFetch="repo_version.remote.fetch";e.RepoVersionRemoteOutgoingCommits="repo_version.remote.outgoing_commits";e.RepoVersionRemotePull="repo_version.remote.pull";e.RepoVersionRemotePush="repo_version.remote.push";e.RepoVersionRemoteRemove="repo_version.remote.remove";e.SandboxBroadcast="sandbox.broadcast";e.SandboxPing="sandbox.ping";e.SandboxProjectStatus="sandbox.project_status";e.SandboxProjectStatusNotify="sandbox.project_status_notify";e.SandboxVersion="sandbox.version";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"}(Bc||(Bc={})),function(e){e[e.text=0]="text";e[e.url=1]="url";e[e.uri=2]="uri"}(kc||(kc={})),(jc||(jc={})).PdfTargetFileType="pdf",function(e){e.TabAuthentication="Authentication"}(Dc||(Dc={})),function(e){e.FeatureApp="app";e.FeatureAssistantAgent="assistantagent";e.FeatureGeneral="general";e.FeatureSkill="skill";e.FeatureWechatMiniProgram="wechatminiprogram"}(xc||(xc={})),function(e){e.SceneRecommendProjectCases="RecommendProjectCases";e.SceneSubmitWorkPoint="SubmitWorkPoint"}(Fc||(Fc={})),function(e){e[e.CozeSpace=1]="CozeSpace";e[e.Ark=2]="Ark"}(qc||(qc={})),function(e){e[e.LocalFile=1]="LocalFile";e[e.GithubRepo=2]="GithubRepo"}(Gc||(Gc={})),function(e){e.ProjectTypeAgent="Agent";e.ProjectTypeApp="App";e.ProjectTypeAssistantAgent="AssistantAgent";e.ProjectTypeAutomation="Automation";e.ProjectTypeGeneral="General";e.ProjectTypeGeneralWeb="GeneralWeb";e.ProjectTypeSkill="Skill";e.ProjectTypeWechatMiniProgram="WechatMiniProgram"}(Hc||(Hc={})),function(e){e[e.Agent=0]="Agent";e[e.Ask=1]="Ask";e[e.DangerousConfirm=2]="DangerousConfirm"}(zc||(zc={})),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.General=9]="General";e[e.CLIBilling=101]="CLIBilling"}(exports.VibeProjectType||(exports.VibeProjectType={})),function(e){e[e.UnAuth=1]="UnAuth";e[e.AuthButNoBind=2]="AuthButNoBind";e[e.AuthAndBind=3]="AuthAndBind"}(Wc||(Wc={})),function(e){e[e.Inactive=1]="Inactive";e[e.Active=2]="Active"}($c||($c={})),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"}(Vc||(Vc={})),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"}(Kc||(Kc={})),function(e){e.PdfTargetFileType="pdf";e.XlsxTargetFileType="xlsx"}(Jc||(Jc={})),function(e){e[e.move=0]="move";e[e.copy=1]="copy"}(Qc||(Qc={}));class Zc{__init(){this.request=Gi}__init2(){this.baseURL=""}constructor(e){Zc.prototype.__init.call(this),Zc.prototype.__init2.call(this),this.request=Yc([e,"optionalAccess",e=>e.request])||this.request,this.baseURL=Yc([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)}GetOauthStatus(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/oauth/status"),n={integration_id:s.integration_id,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}SearchRepo(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/search_repo"),n={space_id:s.space_id,name_search:s.name_search,per_page:s.per_page,page:s.page};return this.request({url:r,method:"POST",data:n},t)}AddRemote(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/add_remote"),n={project_id:s.project_id,integration_id:s.integration_id,repo_full_name:s.repo_full_name,has_add_in_devbox:s.has_add_in_devbox};return this.request({url:r,method:"POST",data:n},t)}RemoveRemote(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/remove_remote"),n={project_id:s.project_id};return this.request({url:r,method:"POST",data:n},t)}ListIntegration(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/list"),n={space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}CreateRepo(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/create_repo"),n={space_id:s.space_id,name:s.name,private:s.private};return this.request({url:r,method:"POST",data:n},t)}CancelOauth(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/oauth/cancel"),n={integration_id:s.integration_id,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}GetOauthConfig(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/oauth/oauth_config"),n={integration_id:s.integration_id,space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}ListDatabaseRestoreHistory(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/postgresql/restore/history"),n={project_id:s.project_id,commit_id:s.commit_id,env:s.env,limit:s.limit,cursor:s.cursor};return this.request({url:r,method:"POST",data:n},t)}ImportProject(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/project/import_project"),n={space_id:s.space_id,import_source:s.import_source,data:s.data,git_url:s.git_url,git_repo_name:s.git_repo_name},o={"Content-Type":s["Content-Type"]};return this.request({url:r,method:"POST",data:n,headers:o},t)}GetUser(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/user"),n={space_id:s.space_id,integration_id:s.integration_id};return this.request({url:r,method:"POST",data:n},t)}GetRemote(e,t){const s=e||{},r=this.genBaseURL("/api/ideserver_api/repository/integration/get_remote"),n={project_id:s.project_id};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)}UpdatePermissionSetting(e,t){const s=e,r=this.genBaseURL("/api/ideserver_api/project/update_permission_setting"),n={project_id:s.project_id,add_commands:s.add_commands,remove_commands:s.remove_commands};return this.request({url:r,method:"POST",data:n},t)}CreateSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/create"),n={space_id:s.space_id};return this.request({url:r,method:"POST",data:n},t)}GetSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/get"),n={space_id:s.space_id,database_id:s.database_id};return this.request({url:r,method:"POST",data:n},t)}ListSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/list"),n={space_id:s.space_id,cursor_id:s.cursor_id,limit:s.limit};return this.request({url:r,method:"POST",data:n},t)}GetSpaceDatabaseStatus(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/status"),n={space_id:s.space_id,database_id:s.database_id};return this.request({url:r,method:"POST",data:n},t)}DeleteSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/delete"),n={space_id:s.space_id,database_id:s.database_id};return this.request({url:r,method:"POST",data:n},t)}RollbackSpaceDatabase(e,t){const s=e,r=this.genBaseURL("/api/memory/databases/space/rollback"),n={space_id:s.space_id,database_id:s.database_id,timestamp:s.timestamp};return this.request({url:r,method:"POST",data:n},t)}}Zc.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)},Zc.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 Xc=new Zc({});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}const tl=/(?<![\w`])@(\.?[^\s`,.]*(?:\.[^\s`,.]+)*)/g;class sl{constructor(){sl.prototype.__init.call(this),sl.prototype.__init2.call(this),sl.prototype.__init3.call(this),sl.prototype.__init4.call(this),sl.prototype.__init5.call(this),sl.prototype.__init6.call(this),sl.prototype.__init7.call(this),sl.prototype.__init8.call(this),sl.prototype.__init9.call(this),sl.prototype.__init10.call(this),sl.prototype.__init11.call(this),sl.prototype.__init12.call(this)}__init(){this.ctx={options:{},get:()=>({})}}__init2(){this.init=m.noop}__init3(){this.createLoggerWith=()=>new sl}__init4(){this.info=m.noop}__init5(){this.error=m.noop}__init6(){this.slardarInfo=m.noop}__init7(){this.slardarSuccess=m.noop}__init8(){this.slardarError=m.noop}__init9(){this.slardarEvent=m.noop}__init10(){this.slardarSuccessEvent=m.noop}__init11(){this.slardarErrorEvent=m.noop}__init12(){this.slardarTracer=()=>({trace:m.noop})}}function rl(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 nl=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}},ol=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(()=>{rl([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(()=>{rl([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 Cc.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 rl([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=nl({buffered:c,onData:e=>{const t=JSON.parse(e);n(t)}}).buffered}c+=i.decode(),nl({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 il(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 al extends Error{constructor(e,t){super(e),al.prototype.__init.call(this),this.name="ChatCLIChannelError",this.ext=t}__init(){this.flatten=()=>{const{message:e,ext:t}=this;return{message:e,...t}}}}const cl=e=>!(!e||"object"!=typeof e)&&"AbortError"===e.name;class ll{__init2(){this.channelName="ChatCLI"}__init3(){this.isChannelOpenPromise=null}__init4(){this.opened=!1}__init5(){this.destroyed=!1}__init6(){this.abortController=null}__init7(){this.eventBus=e()}constructor(e){ll.prototype.__init2.call(this),ll.prototype.__init3.call(this),ll.prototype.__init4.call(this),ll.prototype.__init5.call(this),ll.prototype.__init6.call(this),ll.prototype.__init7.call(this),ll.prototype.__init8.call(this),ll.prototype.__init9.call(this),ll.prototype.__init10.call(this),ll.prototype.__init11.call(this),ll.prototype.__init12.call(this),ll.prototype.__init13.call(this),ll.prototype.__init14.call(this),ll.prototype.__init15.call(this),ll.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(),il([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=>{ol({apiBaseUrl:this.apiBaseUrl,request:r,signal:t.signal,totalTimeoutMs:this.totalTimeoutMs,betweenChunkTimeoutMs:this.betweenChunkTimeoutMs,onTotalTimeout:()=>{this.eventBus.emit("onerror",new al("ChatCLISendMessage total timeout",{willClose:!0}))},onBetweenChunkTimeout:()=>{this.eventBus.emit("onerror",new al("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();cl(t)?this.eventBus.emit("onclose",{code:1e3,reason:"aborted"}):(this.eventBus.emit("onerror",new al(`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(cl(a))return;throw this.eventBus.emit("onerror",new al(`ChatCLISendMessage request error: ${String(a)}`,{willClose:!0,rawError:a})),a}}}__init15(){this.close=()=>{il([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 ul(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 hl=e=>{const{key:t,apiBaseUrl:s,totalTimeoutMs:r,betweenChunkTimeoutMs:n}=e,o=new ll({apiBaseUrl:s,totalTimeoutMs:r,betweenChunkTimeoutMs:n});return new Tc({key:t,env:"production",logLevel:"error",channel:o,reportLog:new sl})};exports.BuildAgentApi=ca,exports.ChatCoreError=oc,exports.CozeError=yc,exports.ErrorCode=Ac,exports.ErrorNameByCode=Rc,exports.HttpError=tr,exports.IdeApi=Xc,exports.axiosInstance=Fi,exports.createChatCore=hl,exports.createRequestClient=xi,exports.customFetch=Cc,exports.exitCodeForError=function(e){const t=Number.parseInt(e.slice(1),10);return t>=1e3&&t<2e3?exports.ExitCode.INPUT_ERROR:t>=2e3&&t<3e3?exports.ExitCode.AUTH_ERROR:exports.ExitCode.FAILURE},exports.getDefaultExportFromCjs=Un,exports.isHttpError=function(e){return e instanceof tr},exports.request=Gi,exports.safeJsonParse=ec,exports.sendProjectChatMessage=async e=>{const{projectId:t,prompt:r,apiBaseUrl:n,sessionId:o="",key:i=`coze-coding-cli:chat:${t}`,totalTimeoutMs:a,betweenChunkTimeoutMs:c,onMessageItem:l,onWarn:u,waitForResponse:h=!0}=e,p=hl({key:i,apiBaseUrl:n,totalTimeoutMs:a,betweenChunkTimeoutMs:c}),m=new tc;let g=!1;const E=e=>{g||(g=!0,e())};let T;const A=p.on(Ja.MESSAGE_RECEIVED_AND_UPDATE,({data:e})=>{for(const t of e)if(ul([l,"optionalCall",e=>e(t)]),"answer"===t.type&&t.content.answer&&(T=t),"message_end"===t.type&&t.finish){const e=ul([t,"access",e=>e.content,"access",e=>e.message_end,"optionalAccess",e=>e.code]);if(e&&"0"!==e){E(()=>{m.reject(new yc(Ac.E5002,`Conversation ended with error code: ${e}`,{message_end:t.content.message_end}))});continue}E(()=>{m.resolve()})}},!0),R=p.on(Ja.SEND_MESSAGE_ERROR,e=>{E(()=>{m.reject(e.data.error)})},!0),S=p.on(Ja.MESSAGE_PULLING_STATUS,({data:e,error:t})=>{const s=e.pullingStatus;"error"!==s&&"channel_error"!==s||E(()=>{m.reject(t)}),("success"===s||"cancel"===s||!h&&"start"===s)&&E(()=>{m.resolve()})},!0);try{const e=await(async(e,t,s,r)=>{const n=[],o=[...e.matchAll(tl)];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=d.resolve(t,l);let h=!1;if(u.startsWith(d.resolve(t)))try{(await f.stat(u)).isFile()?h=!0:el([r,"optionalCall",e=>e(`Uploading directories is not supported: ${l}`)])}catch(e){el([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){el([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})(r,process.cwd(),(e=>async t=>{const r=d.basename(t),n=new s;n.append("project_id",e),n.append("file_name",r),n.append("file_content",_.createReadStream(t));const o=await Xc.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}})(t),u),n=p.createQueryMessage({query:{prompt:e}},{session_id:o,project_id:t});return await p.sendChatMessage(n),await m.promise,{lastAnswerMessage:T}}finally{A(),R(),S(),p.destroy()}};