@kivox/client 0.1.0-beta.36 → 0.1.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -6
- package/dist/index.d.ts +1985 -680
- package/dist/index.mjs +1 -6
- package/package.json +2 -3
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
var r1=Object.defineProperty;var o1=($)=>$;function e1($,Q){this[$]=o1.bind(null,Q)}var N1=($,Q)=>{for(var Y in Q)r1($,Y,{get:Q[Y],enumerable:!0,configurable:!0,set:e1.bind(Q,Y)})};function s($,Q){return function(){return $.apply(Q,arguments)}}var{toString:$4}=Object.prototype,{getPrototypeOf:k0}=Object,{iterator:B0,toStringTag:H1}=Symbol,P0=(($)=>(Q)=>{let Y=$4.call(Q);return $[Y]||($[Y]=Y.slice(8,-1).toLowerCase())})(Object.create(null)),j=($)=>{return $=$.toLowerCase(),(Q)=>P0(Q)===$},L0=($)=>(Q)=>typeof Q===$,{isArray:p}=Array,l=L0("undefined");function r($){return $!==null&&!l($)&&$.constructor!==null&&!l($.constructor)&&T($.constructor.isBuffer)&&$.constructor.isBuffer($)}var B1=j("ArrayBuffer");function Q4($){let Q;if(typeof ArrayBuffer<"u"&&ArrayBuffer.isView)Q=ArrayBuffer.isView($);else Q=$&&$.buffer&&B1($.buffer);return Q}var Y4=L0("string"),T=L0("function"),P1=L0("number"),o=($)=>$!==null&&typeof $==="object",Z4=($)=>$===!0||$===!1,H0=($)=>{if(P0($)!=="object")return!1;let Q=k0($);return(Q===null||Q===Object.prototype||Object.getPrototypeOf(Q)===null)&&!(H1 in $)&&!(B0 in $)},G4=($)=>{if(!o($)||r($))return!1;try{return Object.keys($).length===0&&Object.getPrototypeOf($)===Object.prototype}catch(Q){return!1}},z4=j("Date"),X4=j("File"),W4=($)=>{return!!($&&typeof $.uri<"u")},J4=($)=>$&&typeof $.getParts<"u",N4=j("Blob"),M4=j("FileList"),K4=($)=>o($)&&T($.pipe);function V4(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;return{}}var M1=V4(),K1=typeof M1.FormData<"u"?M1.FormData:void 0,H4=($)=>{let Q;return $&&(K1&&$ instanceof K1||T($.append)&&((Q=P0($))==="formdata"||Q==="object"&&T($.toString)&&$.toString()==="[object FormData]"))},B4=j("URLSearchParams"),[P4,L4,_4,w4]=["ReadableStream","Request","Response","Headers"].map(j),F4=($)=>{return $.trim?$.trim():$.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function e($,Q,{allOwnKeys:Y=!1}={}){if($===null||typeof $>"u")return;let Z,G;if(typeof $!=="object")$=[$];if(p($))for(Z=0,G=$.length;Z<G;Z++)Q.call(null,$[Z],Z,$);else{if(r($))return;let W=Y?Object.getOwnPropertyNames($):Object.keys($),z=W.length,J;for(Z=0;Z<z;Z++)J=W[Z],Q.call(null,$[J],J,$)}}function L1($,Q){if(r($))return null;Q=Q.toLowerCase();let Y=Object.keys($),Z=Y.length,G;while(Z-- >0)if(G=Y[Z],Q===G.toLowerCase())return G;return null}var c=(()=>{if(typeof globalThis<"u")return globalThis;return typeof self<"u"?self:typeof window<"u"?window:global})(),_1=($)=>!l($)&&$!==c;function A0(){let{caseless:$,skipUndefined:Q}=_1(this)&&this||{},Y={},Z=(G,W)=>{if(W==="__proto__"||W==="constructor"||W==="prototype")return;let z=$&&L1(Y,W)||W;if(H0(Y[z])&&H0(G))Y[z]=A0(Y[z],G);else if(H0(G))Y[z]=A0({},G);else if(p(G))Y[z]=G.slice();else if(!Q||!l(G))Y[z]=G};for(let G=0,W=arguments.length;G<W;G++)arguments[G]&&e(arguments[G],Z);return Y}var U4=($,Q,Y,{allOwnKeys:Z}={})=>{return e(Q,(G,W)=>{if(Y&&T(G))Object.defineProperty($,W,{value:s(G,Y),writable:!0,enumerable:!0,configurable:!0});else Object.defineProperty($,W,{value:G,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:Z}),$},I4=($)=>{if($.charCodeAt(0)===65279)$=$.slice(1);return $},R4=($,Q,Y,Z)=>{$.prototype=Object.create(Q.prototype,Z),Object.defineProperty($.prototype,"constructor",{value:$,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty($,"super",{value:Q.prototype}),Y&&Object.assign($.prototype,Y)},q4=($,Q,Y,Z)=>{let G,W,z,J={};if(Q=Q||{},$==null)return Q;do{G=Object.getOwnPropertyNames($),W=G.length;while(W-- >0)if(z=G[W],(!Z||Z(z,$,Q))&&!J[z])Q[z]=$[z],J[z]=!0;$=Y!==!1&&k0($)}while($&&(!Y||Y($,Q))&&$!==Object.prototype);return Q},S4=($,Q,Y)=>{if($=String($),Y===void 0||Y>$.length)Y=$.length;Y-=Q.length;let Z=$.indexOf(Q,Y);return Z!==-1&&Z===Y},D4=($)=>{if(!$)return null;if(p($))return $;let Q=$.length;if(!P1(Q))return null;let Y=Array(Q);while(Q-- >0)Y[Q]=$[Q];return Y},E4=(($)=>{return(Q)=>{return $&&Q instanceof $}})(typeof Uint8Array<"u"&&k0(Uint8Array)),O4=($,Q)=>{let Z=($&&$[B0]).call($),G;while((G=Z.next())&&!G.done){let W=G.value;Q.call($,W[0],W[1])}},T4=($,Q)=>{let Y,Z=[];while((Y=$.exec(Q))!==null)Z.push(Y);return Z},C4=j("HTMLFormElement"),A4=($)=>{return $.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(Y,Z,G){return Z.toUpperCase()+G})},V1=(({hasOwnProperty:$})=>(Q,Y)=>$.call(Q,Y))(Object.prototype),k4=j("RegExp"),w1=($,Q)=>{let Y=Object.getOwnPropertyDescriptors($),Z={};e(Y,(G,W)=>{let z;if((z=Q(G,W,$))!==!1)Z[W]=z||G}),Object.defineProperties($,Z)},x4=($)=>{w1($,(Q,Y)=>{if(T($)&&["arguments","caller","callee"].indexOf(Y)!==-1)return!1;let Z=$[Y];if(!T(Z))return;if(Q.enumerable=!1,"writable"in Q){Q.writable=!1;return}if(!Q.set)Q.set=()=>{throw Error("Can not rewrite read-only method '"+Y+"'")}})},j4=($,Q)=>{let Y={},Z=(G)=>{G.forEach((W)=>{Y[W]=!0})};return p($)?Z($):Z(String($).split(Q)),Y},y4=()=>{},b4=($,Q)=>{return $!=null&&Number.isFinite($=+$)?$:Q};function v4($){return!!($&&T($.append)&&$[H1]==="FormData"&&$[B0])}var m4=($)=>{let Q=[,,,,,,,,,,],Y=(Z,G)=>{if(o(Z)){if(Q.indexOf(Z)>=0)return;if(r(Z))return Z;if(!("toJSON"in Z)){Q[G]=Z;let W=p(Z)?[]:{};return e(Z,(z,J)=>{let V=Y(z,G+1);!l(V)&&(W[J]=V)}),Q[G]=void 0,W}}return Z};return Y($,0)},h4=j("AsyncFunction"),f4=($)=>$&&(o($)||T($))&&T($.then)&&T($.catch),F1=(($,Q)=>{if($)return setImmediate;return Q?((Y,Z)=>{return c.addEventListener("message",({source:G,data:W})=>{if(G===c&&W===Y)Z.length&&Z.shift()()},!1),(G)=>{Z.push(G),c.postMessage(Y,"*")}})(`axios@${Math.random()}`,[]):(Y)=>setTimeout(Y)})(typeof setImmediate==="function",T(c.postMessage)),g4=typeof queueMicrotask<"u"?queueMicrotask.bind(c):typeof process<"u"&&process.nextTick||F1,u4=($)=>$!=null&&T($[B0]),X={isArray:p,isArrayBuffer:B1,isBuffer:r,isFormData:H4,isArrayBufferView:Q4,isString:Y4,isNumber:P1,isBoolean:Z4,isObject:o,isPlainObject:H0,isEmptyObject:G4,isReadableStream:P4,isRequest:L4,isResponse:_4,isHeaders:w4,isUndefined:l,isDate:z4,isFile:X4,isReactNativeBlob:W4,isReactNative:J4,isBlob:N4,isRegExp:k4,isFunction:T,isStream:K4,isURLSearchParams:B4,isTypedArray:E4,isFileList:M4,forEach:e,merge:A0,extend:U4,trim:F4,stripBOM:I4,inherits:R4,toFlatObject:q4,kindOf:P0,kindOfTest:j,endsWith:S4,toArray:D4,forEachEntry:O4,matchAll:T4,isHTMLForm:C4,hasOwnProperty:V1,hasOwnProp:V1,reduceDescriptors:w1,freezeMethods:x4,toObjectSet:j4,toCamelCase:A4,noop:y4,toFiniteNumber:b4,findKey:L1,global:c,isContextDefined:_1,isSpecCompliantForm:v4,toJSONObject:m4,isAsyncFn:h4,isThenable:f4,setImmediate:F1,asap:g4,isIterable:u4};class D extends Error{static from($,Q,Y,Z,G,W){let z=new D($.message,Q||$.code,Y,Z,G);if(z.cause=$,z.name=$.name,$.status!=null&&z.status==null)z.status=$.status;return W&&Object.assign(z,W),z}constructor($,Q,Y,Z,G){super($);if(Object.defineProperty(this,"message",{value:$,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,Q&&(this.code=Q),Y&&(this.config=Y),Z&&(this.request=Z),G)this.response=G,this.status=G.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:X.toJSONObject(this.config),code:this.code,status:this.status}}}D.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";D.ERR_BAD_OPTION="ERR_BAD_OPTION";D.ECONNABORTED="ECONNABORTED";D.ETIMEDOUT="ETIMEDOUT";D.ERR_NETWORK="ERR_NETWORK";D.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";D.ERR_DEPRECATED="ERR_DEPRECATED";D.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";D.ERR_BAD_REQUEST="ERR_BAD_REQUEST";D.ERR_CANCELED="ERR_CANCELED";D.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";D.ERR_INVALID_URL="ERR_INVALID_URL";var P=D;var _0=null;function j0($){return X.isPlainObject($)||X.isArray($)}function U1($){return X.endsWith($,"[]")?$.slice(0,-2):$}function x0($,Q,Y){if(!$)return Q;return $.concat(Q).map(function(G,W){return G=U1(G),!Y&&W?"["+G+"]":G}).join(Y?".":"")}function c4($){return X.isArray($)&&!$.some(j0)}var d4=X.toFlatObject(X,{},null,function(Q){return/^is[A-Z]/.test(Q)});function l4($,Q,Y){if(!X.isObject($))throw TypeError("target must be an object");Q=Q||new(_0||FormData),Y=X.toFlatObject(Y,{metaTokens:!0,dots:!1,indexes:!1},!1,function(_,H){return!X.isUndefined(H[_])});let Z=Y.metaTokens,G=Y.visitor||M,W=Y.dots,z=Y.indexes,V=(Y.Blob||typeof Blob<"u"&&Blob)&&X.isSpecCompliantForm(Q);if(!X.isFunction(G))throw TypeError("visitor must be a function");function N(K){if(K===null)return"";if(X.isDate(K))return K.toISOString();if(X.isBoolean(K))return K.toString();if(!V&&X.isBlob(K))throw new P("Blob is not supported. Use a Buffer instead.");if(X.isArrayBuffer(K)||X.isTypedArray(K))return V&&typeof Blob==="function"?new Blob([K]):Buffer.from(K);return K}function M(K,_,H){let R=K;if(X.isReactNative(Q)&&X.isReactNativeBlob(K))return Q.append(x0(H,_,W),N(K)),!1;if(K&&!H&&typeof K==="object"){if(X.endsWith(_,"{}"))_=Z?_:_.slice(0,-2),K=JSON.stringify(K);else if(X.isArray(K)&&c4(K)||(X.isFileList(K)||X.endsWith(_,"[]"))&&(R=X.toArray(K)))return _=U1(_),R.forEach(function(S,E){!(X.isUndefined(S)||S===null)&&Q.append(z===!0?x0([_],E,W):z===null?_:_+"[]",N(S))}),!1}if(j0(K))return!0;return Q.append(x0(H,_,W),N(K)),!1}let L=[],F=Object.assign(d4,{defaultVisitor:M,convertValue:N,isVisitable:j0});function w(K,_){if(X.isUndefined(K))return;if(L.indexOf(K)!==-1)throw Error("Circular reference detected in "+_.join("."));L.push(K),X.forEach(K,function(R,C){if((!(X.isUndefined(R)||R===null)&&G.call(Q,R,X.isString(C)?C.trim():C,_,F))===!0)w(R,_?_.concat(C):[C])}),L.pop()}if(!X.isObject($))throw TypeError("data must be an object");return w($),Q}var h=l4;function I1($){let Q={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\x00"};return encodeURIComponent($).replace(/[!'()~]|%20|%00/g,function(Z){return Q[Z]})}function R1($,Q){this._pairs=[],$&&h($,this,Q)}var q1=R1.prototype;q1.append=function(Q,Y){this._pairs.push([Q,Y])};q1.toString=function(Q){let Y=Q?function(Z){return Q.call(this,Z,I1)}:I1;return this._pairs.map(function(G){return Y(G[0])+"="+Y(G[1])},"").join("&")};var w0=R1;function p4($){return encodeURIComponent($).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function $0($,Q,Y){if(!Q)return $;let Z=Y&&Y.encode||p4,G=X.isFunction(Y)?{serialize:Y}:Y,W=G&&G.serialize,z;if(W)z=W(Q,G);else z=X.isURLSearchParams(Q)?Q.toString():new w0(Q,G).toString(Z);if(z){let J=$.indexOf("#");if(J!==-1)$=$.slice(0,J);$+=($.indexOf("?")===-1?"?":"&")+z}return $}class S1{constructor(){this.handlers=[]}use($,Q,Y){return this.handlers.push({fulfilled:$,rejected:Q,synchronous:Y?Y.synchronous:!1,runWhen:Y?Y.runWhen:null}),this.handlers.length-1}eject($){if(this.handlers[$])this.handlers[$]=null}clear(){if(this.handlers)this.handlers=[]}forEach($){X.forEach(this.handlers,function(Y){if(Y!==null)$(Y)})}}var y0=S1;var i={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0};var D1=typeof URLSearchParams<"u"?URLSearchParams:w0;var E1=typeof FormData<"u"?FormData:null;var O1=typeof Blob<"u"?Blob:null;var T1={isBrowser:!0,classes:{URLSearchParams:D1,FormData:E1,Blob:O1},protocols:["http","https","file","blob","url","data"]};var m0={};N1(m0,{origin:()=>t4,navigator:()=>b0,hasStandardBrowserWebWorkerEnv:()=>n4,hasStandardBrowserEnv:()=>i4,hasBrowserEnv:()=>v0});var v0=typeof window<"u"&&typeof document<"u",b0=typeof navigator==="object"&&navigator||void 0,i4=v0&&(!b0||["ReactNative","NativeScript","NS"].indexOf(b0.product)<0),n4=(()=>{return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts==="function"})(),t4=v0&&window.location.href||"http://localhost";var U={...m0,...T1};function h0($,Q){return h($,new U.classes.URLSearchParams,{visitor:function(Y,Z,G,W){if(U.isNode&&X.isBuffer(Y))return this.append(Z,Y.toString("base64")),!1;return W.defaultVisitor.apply(this,arguments)},...Q})}function a4($){return X.matchAll(/\w+|\[(\w*)]/g,$).map((Q)=>{return Q[0]==="[]"?"":Q[1]||Q[0]})}function s4($){let Q={},Y=Object.keys($),Z,G=Y.length,W;for(Z=0;Z<G;Z++)W=Y[Z],Q[W]=$[W];return Q}function r4($){function Q(Y,Z,G,W){let z=Y[W++];if(z==="__proto__")return!0;let J=Number.isFinite(+z),V=W>=Y.length;if(z=!z&&X.isArray(G)?G.length:z,V){if(X.hasOwnProp(G,z))G[z]=[G[z],Z];else G[z]=Z;return!J}if(!G[z]||!X.isObject(G[z]))G[z]=[];if(Q(Y,Z,G[z],W)&&X.isArray(G[z]))G[z]=s4(G[z]);return!J}if(X.isFormData($)&&X.isFunction($.entries)){let Y={};return X.forEachEntry($,(Z,G)=>{Q(a4(Z),G,Y,0)}),Y}return null}var F0=r4;function o4($,Q,Y){if(X.isString($))try{return(Q||JSON.parse)($),X.trim($)}catch(Z){if(Z.name!=="SyntaxError")throw Z}return(Y||JSON.stringify)($)}var f0={transitional:i,adapter:["xhr","http","fetch"],transformRequest:[function(Q,Y){let Z=Y.getContentType()||"",G=Z.indexOf("application/json")>-1,W=X.isObject(Q);if(W&&X.isHTMLForm(Q))Q=new FormData(Q);if(X.isFormData(Q))return G?JSON.stringify(F0(Q)):Q;if(X.isArrayBuffer(Q)||X.isBuffer(Q)||X.isStream(Q)||X.isFile(Q)||X.isBlob(Q)||X.isReadableStream(Q))return Q;if(X.isArrayBufferView(Q))return Q.buffer;if(X.isURLSearchParams(Q))return Y.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),Q.toString();let J;if(W){if(Z.indexOf("application/x-www-form-urlencoded")>-1)return h0(Q,this.formSerializer).toString();if((J=X.isFileList(Q))||Z.indexOf("multipart/form-data")>-1){let V=this.env&&this.env.FormData;return h(J?{"files[]":Q}:Q,V&&new V,this.formSerializer)}}if(W||G)return Y.setContentType("application/json",!1),o4(Q);return Q}],transformResponse:[function(Q){let Y=this.transitional||f0.transitional,Z=Y&&Y.forcedJSONParsing,G=this.responseType==="json";if(X.isResponse(Q)||X.isReadableStream(Q))return Q;if(Q&&X.isString(Q)&&(Z&&!this.responseType||G)){let z=!(Y&&Y.silentJSONParsing)&&G;try{return JSON.parse(Q,this.parseReviver)}catch(J){if(z){if(J.name==="SyntaxError")throw P.from(J,P.ERR_BAD_RESPONSE,this,null,this.response);throw J}}}return Q}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:U.classes.FormData,Blob:U.classes.Blob},validateStatus:function(Q){return Q>=200&&Q<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};X.forEach(["delete","get","head","post","put","patch"],($)=>{f0.headers[$]={}});var n=f0;var e4=X.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"]),C1=($)=>{let Q={},Y,Z,G;return $&&$.split(`
|
|
2
|
-
`).forEach(function(z){if(G=z.indexOf(":"),Y=z.substring(0,G).trim().toLowerCase(),Z=z.substring(G+1).trim(),!Y||Q[Y]&&e4[Y])return;if(Y==="set-cookie")if(Q[Y])Q[Y].push(Z);else Q[Y]=[Z];else Q[Y]=Q[Y]?Q[Y]+", "+Z:Z}),Q};var A1=Symbol("internals");function Q0($){return $&&String($).trim().toLowerCase()}function U0($){if($===!1||$==null)return $;return X.isArray($)?$.map(U0):String($)}function $5($){let Q=Object.create(null),Y=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,Z;while(Z=Y.exec($))Q[Z[1]]=Z[2];return Q}var Q5=($)=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test($.trim());function g0($,Q,Y,Z,G){if(X.isFunction(Z))return Z.call(this,Q,Y);if(G)Q=Y;if(!X.isString(Q))return;if(X.isString(Z))return Q.indexOf(Z)!==-1;if(X.isRegExp(Z))return Z.test(Q)}function Y5($){return $.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(Q,Y,Z)=>{return Y.toUpperCase()+Z})}function Z5($,Q){let Y=X.toCamelCase(" "+Q);["get","set","has"].forEach((Z)=>{Object.defineProperty($,Z+Y,{value:function(G,W,z){return this[Z].call(this,Q,G,W,z)},configurable:!0})})}class Y0{constructor($){$&&this.set($)}set($,Q,Y){let Z=this;function G(z,J,V){let N=Q0(J);if(!N)throw Error("header name must be a non-empty string");let M=X.findKey(Z,N);if(!M||Z[M]===void 0||V===!0||V===void 0&&Z[M]!==!1)Z[M||J]=U0(z)}let W=(z,J)=>X.forEach(z,(V,N)=>G(V,N,J));if(X.isPlainObject($)||$ instanceof this.constructor)W($,Q);else if(X.isString($)&&($=$.trim())&&!Q5($))W(C1($),Q);else if(X.isObject($)&&X.isIterable($)){let z={},J,V;for(let N of $){if(!X.isArray(N))throw TypeError("Object iterator must return a key-value pair");z[V=N[0]]=(J=z[V])?X.isArray(J)?[...J,N[1]]:[J,N[1]]:N[1]}W(z,Q)}else $!=null&&G(Q,$,Y);return this}get($,Q){if($=Q0($),$){let Y=X.findKey(this,$);if(Y){let Z=this[Y];if(!Q)return Z;if(Q===!0)return $5(Z);if(X.isFunction(Q))return Q.call(this,Z,Y);if(X.isRegExp(Q))return Q.exec(Z);throw TypeError("parser must be boolean|regexp|function")}}}has($,Q){if($=Q0($),$){let Y=X.findKey(this,$);return!!(Y&&this[Y]!==void 0&&(!Q||g0(this,this[Y],Y,Q)))}return!1}delete($,Q){let Y=this,Z=!1;function G(W){if(W=Q0(W),W){let z=X.findKey(Y,W);if(z&&(!Q||g0(Y,Y[z],z,Q)))delete Y[z],Z=!0}}if(X.isArray($))$.forEach(G);else G($);return Z}clear($){let Q=Object.keys(this),Y=Q.length,Z=!1;while(Y--){let G=Q[Y];if(!$||g0(this,this[G],G,$,!0))delete this[G],Z=!0}return Z}normalize($){let Q=this,Y={};return X.forEach(this,(Z,G)=>{let W=X.findKey(Y,G);if(W){Q[W]=U0(Z),delete Q[G];return}let z=$?Y5(G):String(G).trim();if(z!==G)delete Q[G];Q[z]=U0(Z),Y[z]=!0}),this}concat(...$){return this.constructor.concat(this,...$)}toJSON($){let Q=Object.create(null);return X.forEach(this,(Y,Z)=>{Y!=null&&Y!==!1&&(Q[Z]=$&&X.isArray(Y)?Y.join(", "):Y)}),Q}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([$,Q])=>$+": "+Q).join(`
|
|
3
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from($){return $ instanceof this?$:new this($)}static concat($,...Q){let Y=new this($);return Q.forEach((Z)=>Y.set(Z)),Y}static accessor($){let Y=(this[A1]=this[A1]={accessors:{}}).accessors,Z=this.prototype;function G(W){let z=Q0(W);if(!Y[z])Z5(Z,W),Y[z]=!0}return X.isArray($)?$.forEach(G):G($),this}}Y0.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);X.reduceDescriptors(Y0.prototype,({value:$},Q)=>{let Y=Q[0].toUpperCase()+Q.slice(1);return{get:()=>$,set(Z){this[Y]=Z}}});X.freezeMethods(Y0);var q=Y0;function Z0($,Q){let Y=this||n,Z=Q||Y,G=q.from(Z.headers),W=Z.data;return X.forEach($,function(J){W=J.call(Y,W,G.normalize(),Q?Q.status:void 0)}),G.normalize(),W}function G0($){return!!($&&$.__CANCEL__)}class k1 extends P{constructor($,Q,Y){super($==null?"canceled":$,P.ERR_CANCELED,Q,Y);this.name="CanceledError",this.__CANCEL__=!0}}var b=k1;function z0($,Q,Y){let Z=Y.config.validateStatus;if(!Y.status||!Z||Z(Y.status))$(Y);else Q(new P("Request failed with status code "+Y.status,[P.ERR_BAD_REQUEST,P.ERR_BAD_RESPONSE][Math.floor(Y.status/100)-4],Y.config,Y.request,Y))}function u0($){let Q=/^([-+\w]{1,25})(:?\/\/|:)/.exec($);return Q&&Q[1]||""}function G5($,Q){$=$||10;let Y=Array($),Z=Array($),G=0,W=0,z;return Q=Q!==void 0?Q:1000,function(V){let N=Date.now(),M=Z[W];if(!z)z=N;Y[G]=V,Z[G]=N;let L=W,F=0;while(L!==G)F+=Y[L++],L=L%$;if(G=(G+1)%$,G===W)W=(W+1)%$;if(N-z<Q)return;let w=M&&N-M;return w?Math.round(F*1000/w):void 0}}var x1=G5;function z5($,Q){let Y=0,Z=1000/Q,G,W,z=(N,M=Date.now())=>{if(Y=M,G=null,W)clearTimeout(W),W=null;$(...N)};return[(...N)=>{let M=Date.now(),L=M-Y;if(L>=Z)z(N,M);else if(G=N,!W)W=setTimeout(()=>{W=null,z(G)},Z-L)},()=>G&&z(G)]}var j1=z5;var t=($,Q,Y=3)=>{let Z=0,G=x1(50,250);return j1((W)=>{let z=W.loaded,J=W.lengthComputable?W.total:void 0,V=z-Z,N=G(V),M=z<=J;Z=z;let L={loaded:z,total:J,progress:J?z/J:void 0,bytes:V,rate:N?N:void 0,estimated:N&&J&&M?(J-z)/N:void 0,event:W,lengthComputable:J!=null,[Q?"download":"upload"]:!0};$(L)},Y)},c0=($,Q)=>{let Y=$!=null;return[(Z)=>Q[0]({lengthComputable:Y,total:$,loaded:Z}),Q[1]]},d0=($)=>(...Q)=>X.asap(()=>$(...Q));var y1=U.hasStandardBrowserEnv?(($,Q)=>(Y)=>{return Y=new URL(Y,U.origin),$.protocol===Y.protocol&&$.host===Y.host&&(Q||$.port===Y.port)})(new URL(U.origin),U.navigator&&/(msie|trident)/i.test(U.navigator.userAgent)):()=>!0;var b1=U.hasStandardBrowserEnv?{write($,Q,Y,Z,G,W,z){if(typeof document>"u")return;let J=[`${$}=${encodeURIComponent(Q)}`];if(X.isNumber(Y))J.push(`expires=${new Date(Y).toUTCString()}`);if(X.isString(Z))J.push(`path=${Z}`);if(X.isString(G))J.push(`domain=${G}`);if(W===!0)J.push("secure");if(X.isString(z))J.push(`SameSite=${z}`);document.cookie=J.join("; ")},read($){if(typeof document>"u")return null;let Q=document.cookie.match(new RegExp("(?:^|; )"+$+"=([^;]*)"));return Q?decodeURIComponent(Q[1]):null},remove($){this.write($,"",Date.now()-86400000,"/")}}:{write(){},read(){return null},remove(){}};function l0($){if(typeof $!=="string")return!1;return/^([a-z][a-z\d+\-.]*:)?\/\//i.test($)}function p0($,Q){return Q?$.replace(/\/?\/$/,"")+"/"+Q.replace(/^\/+/,""):$}function X0($,Q,Y){let Z=!l0(Q);if($&&(Z||Y==!1))return p0($,Q);return Q}var v1=($)=>$ instanceof q?{...$}:$;function y($,Q){Q=Q||{};let Y={};function Z(N,M,L,F){if(X.isPlainObject(N)&&X.isPlainObject(M))return X.merge.call({caseless:F},N,M);else if(X.isPlainObject(M))return X.merge({},M);else if(X.isArray(M))return M.slice();return M}function G(N,M,L,F){if(!X.isUndefined(M))return Z(N,M,L,F);else if(!X.isUndefined(N))return Z(void 0,N,L,F)}function W(N,M){if(!X.isUndefined(M))return Z(void 0,M)}function z(N,M){if(!X.isUndefined(M))return Z(void 0,M);else if(!X.isUndefined(N))return Z(void 0,N)}function J(N,M,L){if(L in Q)return Z(N,M);else if(L in $)return Z(void 0,N)}let V={url:W,method:W,data:W,baseURL:z,transformRequest:z,transformResponse:z,paramsSerializer:z,timeout:z,timeoutMessage:z,withCredentials:z,withXSRFToken:z,adapter:z,responseType:z,xsrfCookieName:z,xsrfHeaderName:z,onUploadProgress:z,onDownloadProgress:z,decompress:z,maxContentLength:z,maxBodyLength:z,beforeRedirect:z,transport:z,httpAgent:z,httpsAgent:z,cancelToken:z,socketPath:z,responseEncoding:z,validateStatus:J,headers:(N,M,L)=>G(v1(N),v1(M),L,!0)};return X.forEach(Object.keys({...$,...Q}),function(M){if(M==="__proto__"||M==="constructor"||M==="prototype")return;let L=X.hasOwnProp(V,M)?V[M]:G,F=L($[M],Q[M],M);X.isUndefined(F)&&L!==J||(Y[M]=F)}),Y}var I0=($)=>{let Q=y({},$),{data:Y,withXSRFToken:Z,xsrfHeaderName:G,xsrfCookieName:W,headers:z,auth:J}=Q;if(Q.headers=z=q.from(z),Q.url=$0(X0(Q.baseURL,Q.url,Q.allowAbsoluteUrls),$.params,$.paramsSerializer),J)z.set("Authorization","Basic "+btoa((J.username||"")+":"+(J.password?unescape(encodeURIComponent(J.password)):"")));if(X.isFormData(Y)){if(U.hasStandardBrowserEnv||U.hasStandardBrowserWebWorkerEnv)z.setContentType(void 0);else if(X.isFunction(Y.getHeaders)){let V=Y.getHeaders(),N=["content-type","content-length"];Object.entries(V).forEach(([M,L])=>{if(N.includes(M.toLowerCase()))z.set(M,L)})}}if(U.hasStandardBrowserEnv){if(Z&&X.isFunction(Z)&&(Z=Z(Q)),Z||Z!==!1&&y1(Q.url)){let V=G&&W&&b1.read(W);if(V)z.set(G,V)}}return Q};var X5=typeof XMLHttpRequest<"u",m1=X5&&function($){return new Promise(function(Y,Z){let G=I0($),W=G.data,z=q.from(G.headers).normalize(),{responseType:J,onUploadProgress:V,onDownloadProgress:N}=G,M,L,F,w,K;function _(){w&&w(),K&&K(),G.cancelToken&&G.cancelToken.unsubscribe(M),G.signal&&G.signal.removeEventListener("abort",M)}let H=new XMLHttpRequest;H.open(G.method.toUpperCase(),G.url,!0),H.timeout=G.timeout;function R(){if(!H)return;let S=q.from("getAllResponseHeaders"in H&&H.getAllResponseHeaders()),x={data:!J||J==="text"||J==="json"?H.responseText:H.response,status:H.status,statusText:H.statusText,headers:S,config:$,request:H};z0(function(A){Y(A),_()},function(A){Z(A),_()},x),H=null}if("onloadend"in H)H.onloadend=R;else H.onreadystatechange=function(){if(!H||H.readyState!==4)return;if(H.status===0&&!(H.responseURL&&H.responseURL.indexOf("file:")===0))return;setTimeout(R)};if(H.onabort=function(){if(!H)return;Z(new P("Request aborted",P.ECONNABORTED,$,H)),H=null},H.onerror=function(E){let x=E&&E.message?E.message:"Network Error",g=new P(x,P.ERR_NETWORK,$,H);g.event=E||null,Z(g),H=null},H.ontimeout=function(){let E=G.timeout?"timeout of "+G.timeout+"ms exceeded":"timeout exceeded",x=G.transitional||i;if(G.timeoutErrorMessage)E=G.timeoutErrorMessage;Z(new P(E,x.clarifyTimeoutError?P.ETIMEDOUT:P.ECONNABORTED,$,H)),H=null},W===void 0&&z.setContentType(null),"setRequestHeader"in H)X.forEach(z.toJSON(),function(E,x){H.setRequestHeader(x,E)});if(!X.isUndefined(G.withCredentials))H.withCredentials=!!G.withCredentials;if(J&&J!=="json")H.responseType=G.responseType;if(N)[F,K]=t(N,!0),H.addEventListener("progress",F);if(V&&H.upload)[L,w]=t(V),H.upload.addEventListener("progress",L),H.upload.addEventListener("loadend",w);if(G.cancelToken||G.signal){if(M=(S)=>{if(!H)return;Z(!S||S.type?new b(null,$,H):S),H.abort(),H=null},G.cancelToken&&G.cancelToken.subscribe(M),G.signal)G.signal.aborted?M():G.signal.addEventListener("abort",M)}let C=u0(G.url);if(C&&U.protocols.indexOf(C)===-1){Z(new P("Unsupported protocol "+C+":",P.ERR_BAD_REQUEST,$));return}H.send(W||null)})};var W5=($,Q)=>{let{length:Y}=$=$?$.filter(Boolean):[];if(Q||Y){let Z=new AbortController,G,W=function(N){if(!G){G=!0,J();let M=N instanceof Error?N:this.reason;Z.abort(M instanceof P?M:new b(M instanceof Error?M.message:M))}},z=Q&&setTimeout(()=>{z=null,W(new P(`timeout of ${Q}ms exceeded`,P.ETIMEDOUT))},Q),J=()=>{if($)z&&clearTimeout(z),z=null,$.forEach((N)=>{N.unsubscribe?N.unsubscribe(W):N.removeEventListener("abort",W)}),$=null};$.forEach((N)=>N.addEventListener("abort",W));let{signal:V}=Z;return V.unsubscribe=()=>X.asap(J),V}},h1=W5;var J5=function*($,Q){let Y=$.byteLength;if(!Q||Y<Q){yield $;return}let Z=0,G;while(Z<Y)G=Z+Q,yield $.slice(Z,G),Z=G},N5=async function*($,Q){for await(let Y of M5($))yield*J5(Y,Q)},M5=async function*($){if($[Symbol.asyncIterator]){yield*$;return}let Q=$.getReader();try{for(;;){let{done:Y,value:Z}=await Q.read();if(Y)break;yield Z}}finally{await Q.cancel()}},i0=($,Q,Y,Z)=>{let G=N5($,Q),W=0,z,J=(V)=>{if(!z)z=!0,Z&&Z(V)};return new ReadableStream({async pull(V){try{let{done:N,value:M}=await G.next();if(N){J(),V.close();return}let L=M.byteLength;if(Y){let F=W+=L;Y(F)}V.enqueue(new Uint8Array(M))}catch(N){throw J(N),N}},cancel(V){return J(V),G.return()}},{highWaterMark:2})};var f1=65536,{isFunction:R0}=X,K5=(({Request:$,Response:Q})=>({Request:$,Response:Q}))(X.global),{ReadableStream:g1,TextEncoder:u1}=X.global,c1=($,...Q)=>{try{return!!$(...Q)}catch(Y){return!1}},V5=($)=>{$=X.merge.call({skipUndefined:!0},K5,$);let{fetch:Q,Request:Y,Response:Z}=$,G=Q?R0(Q):typeof fetch==="function",W=R0(Y),z=R0(Z);if(!G)return!1;let J=G&&R0(g1),V=G&&(typeof u1==="function"?((K)=>(_)=>K.encode(_))(new u1):async(K)=>new Uint8Array(await new Y(K).arrayBuffer())),N=W&&J&&c1(()=>{let K=!1,_=new Y(U.origin,{body:new g1,method:"POST",get duplex(){return K=!0,"half"}}).headers.has("Content-Type");return K&&!_}),M=z&&J&&c1(()=>X.isReadableStream(new Z("").body)),L={stream:M&&((K)=>K.body)};G&&(()=>{["text","arrayBuffer","blob","formData","stream"].forEach((K)=>{!L[K]&&(L[K]=(_,H)=>{let R=_&&_[K];if(R)return R.call(_);throw new P(`Response type '${K}' is not supported`,P.ERR_NOT_SUPPORT,H)})})})();let F=async(K)=>{if(K==null)return 0;if(X.isBlob(K))return K.size;if(X.isSpecCompliantForm(K))return(await new Y(U.origin,{method:"POST",body:K}).arrayBuffer()).byteLength;if(X.isArrayBufferView(K)||X.isArrayBuffer(K))return K.byteLength;if(X.isURLSearchParams(K))K=K+"";if(X.isString(K))return(await V(K)).byteLength},w=async(K,_)=>{let H=X.toFiniteNumber(K.getContentLength());return H==null?F(_):H};return async(K)=>{let{url:_,method:H,data:R,signal:C,cancelToken:S,timeout:E,onDownloadProgress:x,onUploadProgress:g,responseType:A,headers:T0,withCredentials:M0="same-origin",fetchOptions:Z1}=I0(K),G1=Q||fetch;A=A?(A+"").toLowerCase():"text";let K0=h1([C,S&&S.toAbortSignal()],E),a=null,u=K0&&K0.unsubscribe&&(()=>{K0.unsubscribe()}),z1;try{if(g&&N&&H!=="get"&&H!=="head"&&(z1=await w(T0,R))!==0){let m=new Y(_,{method:"POST",body:R,duplex:"half"}),d;if(X.isFormData(R)&&(d=m.headers.get("content-type")))T0.setContentType(d);if(m.body){let[C0,V0]=c0(z1,t(d0(g)));R=i0(m.body,f1,C0,V0)}}if(!X.isString(M0))M0=M0?"include":"omit";let O=W&&"credentials"in Y.prototype,X1={...Z1,signal:K0,method:H.toUpperCase(),headers:T0.normalize().toJSON(),body:R,duplex:"half",credentials:O?M0:void 0};a=W&&new Y(_,X1);let v=await(W?G1(a,Z1):G1(_,X1)),W1=M&&(A==="stream"||A==="response");if(M&&(x||W1&&u)){let m={};["status","statusText","headers"].forEach((J1)=>{m[J1]=v[J1]});let d=X.toFiniteNumber(v.headers.get("content-length")),[C0,V0]=x&&c0(d,t(d0(x),!0))||[];v=new Z(i0(v.body,f1,C0,()=>{V0&&V0(),u&&u()}),m)}A=A||"text";let s1=await L[X.findKey(L,A)||"text"](v,K);return!W1&&u&&u(),await new Promise((m,d)=>{z0(m,d,{data:s1,headers:q.from(v.headers),status:v.status,statusText:v.statusText,config:K,request:a})})}catch(O){if(u&&u(),O&&O.name==="TypeError"&&/Load failed|fetch/i.test(O.message))throw Object.assign(new P("Network Error",P.ERR_NETWORK,K,a,O&&O.response),{cause:O.cause||O});throw P.from(O,O&&O.code,K,a,O&&O.response)}}},H5=new Map,n0=($)=>{let Q=$&&$.env||{},{fetch:Y,Request:Z,Response:G}=Q,W=[Z,G,Y],z=W.length,J=z,V,N,M=H5;while(J--)V=W[J],N=M.get(V),N===void 0&&M.set(V,N=J?new Map:V5(Q)),M=N;return N},K8=n0();var t0={http:_0,xhr:m1,fetch:{get:n0}};X.forEach(t0,($,Q)=>{if($){try{Object.defineProperty($,"name",{value:Q})}catch(Y){}Object.defineProperty($,"adapterName",{value:Q})}});var d1=($)=>`- ${$}`,P5=($)=>X.isFunction($)||$===null||$===!1;function L5($,Q){$=X.isArray($)?$:[$];let{length:Y}=$,Z,G,W={};for(let z=0;z<Y;z++){Z=$[z];let J;if(G=Z,!P5(Z)){if(G=t0[(J=String(Z)).toLowerCase()],G===void 0)throw new P(`Unknown adapter '${J}'`)}if(G&&(X.isFunction(G)||(G=G.get(Q))))break;W[J||"#"+z]=G}if(!G){let z=Object.entries(W).map(([V,N])=>`adapter ${V} `+(N===!1?"is not supported by the environment":"is not available in the build")),J=Y?z.length>1?`since :
|
|
4
|
-
`+z.map(d1).join(`
|
|
5
|
-
`):" "+d1(z[0]):"as no adapter specified";throw new P("There is no suitable adapter to dispatch the request "+J,"ERR_NOT_SUPPORT")}return G}var q0={getAdapter:L5,adapters:t0};function a0($){if($.cancelToken)$.cancelToken.throwIfRequested();if($.signal&&$.signal.aborted)throw new b(null,$)}function S0($){if(a0($),$.headers=q.from($.headers),$.data=Z0.call($,$.transformRequest),["post","put","patch"].indexOf($.method)!==-1)$.headers.setContentType("application/x-www-form-urlencoded",!1);return q0.getAdapter($.adapter||n.adapter,$)($).then(function(Z){return a0($),Z.data=Z0.call($,$.transformResponse,Z),Z.headers=q.from(Z.headers),Z},function(Z){if(!G0(Z)){if(a0($),Z&&Z.response)Z.response.data=Z0.call($,$.transformResponse,Z.response),Z.response.headers=q.from(Z.response.headers)}return Promise.reject(Z)})}var D0="1.13.6";var E0={};["object","boolean","number","function","string","symbol"].forEach(($,Q)=>{E0[$]=function(Z){return typeof Z===$||"a"+(Q<1?"n ":" ")+$}});var l1={};E0.transitional=function(Q,Y,Z){function G(W,z){return"[Axios v"+D0+"] Transitional option '"+W+"'"+z+(Z?". "+Z:"")}return(W,z,J)=>{if(Q===!1)throw new P(G(z," has been removed"+(Y?" in "+Y:"")),P.ERR_DEPRECATED);if(Y&&!l1[z])l1[z]=!0,console.warn(G(z," has been deprecated since v"+Y+" and will be removed in the near future"));return Q?Q(W,z,J):!0}};E0.spelling=function(Q){return(Y,Z)=>{return console.warn(`${Z} is likely a misspelling of ${Q}`),!0}};function _5($,Q,Y){if(typeof $!=="object")throw new P("options must be an object",P.ERR_BAD_OPTION_VALUE);let Z=Object.keys($),G=Z.length;while(G-- >0){let W=Z[G],z=Q[W];if(z){let J=$[W],V=J===void 0||z(J,W,$);if(V!==!0)throw new P("option "+W+" must be "+V,P.ERR_BAD_OPTION_VALUE);continue}if(Y!==!0)throw new P("Unknown option "+W,P.ERR_BAD_OPTION)}}var W0={assertOptions:_5,validators:E0};var k=W0.validators;class J0{constructor($){this.defaults=$||{},this.interceptors={request:new y0,response:new y0}}async request($,Q){try{return await this._request($,Q)}catch(Y){if(Y instanceof Error){let Z={};Error.captureStackTrace?Error.captureStackTrace(Z):Z=Error();let G=Z.stack?Z.stack.replace(/^.+\n/,""):"";try{if(!Y.stack)Y.stack=G;else if(G&&!String(Y.stack).endsWith(G.replace(/^.+\n.+\n/,"")))Y.stack+=`
|
|
6
|
-
`+G}catch(W){}}throw Y}}_request($,Q){if(typeof $==="string")Q=Q||{},Q.url=$;else Q=$||{};Q=y(this.defaults,Q);let{transitional:Y,paramsSerializer:Z,headers:G}=Q;if(Y!==void 0)W0.assertOptions(Y,{silentJSONParsing:k.transitional(k.boolean),forcedJSONParsing:k.transitional(k.boolean),clarifyTimeoutError:k.transitional(k.boolean),legacyInterceptorReqResOrdering:k.transitional(k.boolean)},!1);if(Z!=null)if(X.isFunction(Z))Q.paramsSerializer={serialize:Z};else W0.assertOptions(Z,{encode:k.function,serialize:k.function},!0);if(Q.allowAbsoluteUrls!==void 0);else if(this.defaults.allowAbsoluteUrls!==void 0)Q.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls;else Q.allowAbsoluteUrls=!0;W0.assertOptions(Q,{baseUrl:k.spelling("baseURL"),withXsrfToken:k.spelling("withXSRFToken")},!0),Q.method=(Q.method||this.defaults.method||"get").toLowerCase();let W=G&&X.merge(G.common,G[Q.method]);G&&X.forEach(["delete","get","head","post","put","patch","common"],(w)=>{delete G[w]}),Q.headers=q.concat(W,G);let z=[],J=!0;this.interceptors.request.forEach(function(K){if(typeof K.runWhen==="function"&&K.runWhen(Q)===!1)return;J=J&&K.synchronous;let _=Q.transitional||i;if(_&&_.legacyInterceptorReqResOrdering)z.unshift(K.fulfilled,K.rejected);else z.push(K.fulfilled,K.rejected)});let V=[];this.interceptors.response.forEach(function(K){V.push(K.fulfilled,K.rejected)});let N,M=0,L;if(!J){let w=[S0.bind(this),void 0];w.unshift(...z),w.push(...V),L=w.length,N=Promise.resolve(Q);while(M<L)N=N.then(w[M++],w[M++]);return N}L=z.length;let F=Q;while(M<L){let w=z[M++],K=z[M++];try{F=w(F)}catch(_){K.call(this,_);break}}try{N=S0.call(this,F)}catch(w){return Promise.reject(w)}M=0,L=V.length;while(M<L)N=N.then(V[M++],V[M++]);return N}getUri($){$=y(this.defaults,$);let Q=X0($.baseURL,$.url,$.allowAbsoluteUrls);return $0(Q,$.params,$.paramsSerializer)}}X.forEach(["delete","get","head","options"],function(Q){J0.prototype[Q]=function(Y,Z){return this.request(y(Z||{},{method:Q,url:Y,data:(Z||{}).data}))}});X.forEach(["post","put","patch"],function(Q){function Y(Z){return function(W,z,J){return this.request(y(J||{},{method:Q,headers:Z?{"Content-Type":"multipart/form-data"}:{},url:W,data:z}))}}J0.prototype[Q]=Y(),J0.prototype[Q+"Form"]=Y(!0)});var N0=J0;class s0{constructor($){if(typeof $!=="function")throw TypeError("executor must be a function.");let Q;this.promise=new Promise(function(G){Q=G});let Y=this;this.promise.then((Z)=>{if(!Y._listeners)return;let G=Y._listeners.length;while(G-- >0)Y._listeners[G](Z);Y._listeners=null}),this.promise.then=(Z)=>{let G,W=new Promise((z)=>{Y.subscribe(z),G=z}).then(Z);return W.cancel=function(){Y.unsubscribe(G)},W},$(function(G,W,z){if(Y.reason)return;Y.reason=new b(G,W,z),Q(Y.reason)})}throwIfRequested(){if(this.reason)throw this.reason}subscribe($){if(this.reason){$(this.reason);return}if(this._listeners)this._listeners.push($);else this._listeners=[$]}unsubscribe($){if(!this._listeners)return;let Q=this._listeners.indexOf($);if(Q!==-1)this._listeners.splice(Q,1)}toAbortSignal(){let $=new AbortController,Q=(Y)=>{$.abort(Y)};return this.subscribe(Q),$.signal.unsubscribe=()=>this.unsubscribe(Q),$.signal}static source(){let $;return{token:new s0(function(Z){$=Z}),cancel:$}}}var p1=s0;function r0($){return function(Y){return $.apply(null,Y)}}function o0($){return X.isObject($)&&$.isAxiosError===!0}var e0={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(e0).forEach(([$,Q])=>{e0[Q]=$});var i1=e0;function n1($){let Q=new N0($),Y=s(N0.prototype.request,Q);return X.extend(Y,N0.prototype,Q,{allOwnKeys:!0}),X.extend(Y,Q,null,{allOwnKeys:!0}),Y.create=function(G){return n1(y($,G))},Y}var I=n1(n);I.Axios=N0;I.CanceledError=b;I.CancelToken=p1;I.isCancel=G0;I.VERSION=D0;I.toFormData=h;I.AxiosError=P;I.Cancel=I.CanceledError;I.all=function(Q){return Promise.all(Q)};I.spread=r0;I.isAxiosError=o0;I.mergeConfig=y;I.AxiosHeaders=q;I.formToJSON=($)=>F0(X.isHTMLForm($)?new FormData($):$);I.getAdapter=q0.getAdapter;I.HttpStatusCode=i1;I.default=I;var B=I;var $1={};N1($1,{updateTemplate:()=>o5,updateOrgMember:()=>n5,updateOrg:()=>u5,updateCurrentUserEmail:()=>G2,updateCurrentUser:()=>Q2,updateAgentStatus:()=>E5,updateAgent:()=>q5,signup:()=>j5,revokeApiKey:()=>C5,removeOrgMember:()=>i5,logoutAll:()=>A5,logout:()=>x5,login:()=>k5,listUserTemplates:()=>z2,listUserAgents:()=>Y2,listOrgs:()=>m5,listOrgTemplates:()=>t5,listOrgMembers:()=>l5,listOrgAgents:()=>c5,listMessages:()=>v5,listConversations:()=>S5,listApiKeys:()=>O5,lintAgent:()=>D5,getUser:()=>W2,getTemplate:()=>r5,getOrg:()=>g5,getCurrentUser:()=>$2,getConversation:()=>b5,getAgent:()=>R5,deleteTemplate:()=>s5,deleteOrg:()=>f5,deleteCurrentUser:()=>e5,deleteConversation:()=>y5,deleteAgent:()=>I5,createUserTemplate:()=>X2,createUserAgent:()=>Z2,createOrgTemplate:()=>a5,createOrgAgent:()=>d5,createOrg:()=>h5,createApiKey:()=>T5,addOrgMember:()=>p5,UpdateMemberInBodyRole:()=>U5,UpdateAgentStatusInBodyStatus:()=>F5,AddMemberInBodyRole:()=>w5});var w5={admin:"admin",member:"member",viewer:"viewer"},F5={draft:"draft",live:"live",archived:"archived"},U5={owner:"owner",admin:"admin",member:"member",viewer:"viewer"},I5=($,Q)=>{return B.delete(`/agents/${$}`,Q)},R5=($,Q)=>{return B.get(`/agents/${$}`,Q)},q5=($,Q,Y)=>{return B.patch(`/agents/${$}`,Q,Y)},S5=($,Q,Y)=>{return B.get(`/agents/${$}/conversations`,{...Y,params:{...Q,...Y?.params}})},D5=($,Q,Y)=>{return B.post(`/agents/${$}/lint`,Q,Y)},E5=($,Q,Y)=>{return B.patch(`/agents/${$}/status`,Q,Y)},O5=($)=>{return B.get("/auth/api-keys",$)},T5=($,Q)=>{return B.post("/auth/api-keys",$,Q)},C5=($,Q)=>{return B.delete(`/auth/api-keys/${$}`,Q)},A5=($)=>{return B.delete("/auth/sessions",$)},k5=($,Q)=>{return B.post("/auth/sessions",$,Q)},x5=($)=>{return B.delete("/auth/sessions/me",$)},j5=($,Q)=>{return B.post("/auth/signup",$,Q)},y5=($,Q)=>{return B.delete(`/conversations/${$}`,Q)},b5=($,Q)=>{return B.get(`/conversations/${$}`,Q)},v5=($,Q,Y)=>{return B.get(`/conversations/${$}/messages`,{...Y,params:{...Q,...Y?.params}})},m5=($)=>{return B.get("/orgs",$)},h5=($,Q)=>{return B.post("/orgs",$,Q)},f5=($,Q)=>{return B.delete(`/orgs/${$}`,Q)},g5=($,Q)=>{return B.get(`/orgs/${$}`,Q)},u5=($,Q,Y)=>{return B.patch(`/orgs/${$}`,Q,Y)},c5=($,Q,Y)=>{return B.get(`/orgs/${$}/agents`,{...Y,params:{...Q,...Y?.params}})},d5=($,Q,Y)=>{return B.post(`/orgs/${$}/agents`,Q,Y)},l5=($,Q)=>{return B.get(`/orgs/${$}/members`,Q)},p5=($,Q,Y)=>{return B.post(`/orgs/${$}/members`,Q,Y)},i5=($,Q,Y)=>{return B.delete(`/orgs/${$}/members/${Q}`,Y)},n5=($,Q,Y,Z)=>{return B.patch(`/orgs/${$}/members/${Q}`,Y,Z)},t5=($,Q,Y)=>{return B.get(`/orgs/${$}/templates`,{...Y,params:{...Q,...Y?.params}})},a5=($,Q,Y)=>{return B.post(`/orgs/${$}/templates`,Q,Y)},s5=($,Q)=>{return B.delete(`/templates/${$}`,Q)},r5=($,Q)=>{return B.get(`/templates/${$}`,Q)},o5=($,Q,Y)=>{return B.patch(`/templates/${$}`,Q,Y)},e5=($)=>{return B.delete("/users/me",$)},$2=($)=>{return B.get("/users/me",$)},Q2=($,Q)=>{return B.patch("/users/me",$,Q)},Y2=($,Q)=>{return B.get("/users/me/agents",{...Q,params:{...$,...Q?.params}})},Z2=($,Q)=>{return B.post("/users/me/agents",$,Q)},G2=($,Q)=>{return B.patch("/users/me/email",$,Q)},z2=($,Q)=>{return B.get("/users/me/templates",{...Q,params:{...$,...Q?.params}})},X2=($,Q)=>{return B.post("/users/me/templates",$,Q)},W2=($,Q)=>{return B.get(`/users/${$}`,Q)};class O0{_transport;_conversationId;_closed=!1;_onEvent;_pendingAudioMetadata=null;_remainingMs=0;_elapsedMs=0;get conversationId(){return this._conversationId}get remainingMs(){return this._remainingMs}get elapsedMs(){return this._elapsedMs}get closed(){return this._closed}constructor($,Q,Y){this._transport=$,this._conversationId=Q,this._onEvent=Y.onEvent,this.#$()}sendText($){if(this._closed){console.warn("Cannot send text: session is closed");return}this._transport.send({type:"input_text",text:$})}sendAudio($){if(this._closed){console.warn("Cannot send audio: session is closed");return}this._transport.send({type:"input_audio"}),this._transport.sendBinary($)}streamAudio($){if(this._closed){console.warn("Cannot stream audio: session is closed");return}this._transport.send({type:"input_audio_stream"}),this._transport.sendBinary($)}cancelRequest(){if(this._closed){console.warn("Cannot cancel request: session is closed");return}this._transport.send({type:"cancel"})}end(){if(this._closed){console.warn("Cannot end session: session is closed");return}this._transport.send({type:"end"})}close(){if(this._closed)return;this._closed=!0,this._transport.close()}#$(){this._transport.onMessage(($)=>{let Q=$;if(Q.type==="audio_delta"){this._pendingAudioMetadata={size:Q.size};return}if(Q.type==="tick")this._remainingMs=Q.remaining_ms,this._elapsedMs=Q.elapsed_ms;if(Q.type==="session_closed")this._closed=!0;this._onEvent?.(Q)}),this._transport.onBinary(($)=>{if(this._pendingAudioMetadata){let Q={type:"audio_delta",size:this._pendingAudioMetadata.size,audio:$};this._pendingAudioMetadata=null,this._onEvent?.(Q)}}),this._transport.onClose(()=>{if(this._closed)return;this._closed=!0,this._onEvent?.({type:"connection_lost",reason:"socket_closed"})}),this._transport.onError(()=>{if(this._closed)return;this._closed=!0,this._onEvent?.({type:"connection_lost",reason:"socket_error"})})}}class f extends Error{code;constructor($,Q="TRANSPORT_ERROR"){super($);this.code=Q;this.name="ConversationTransportError"}}class Q1{_ws;_closed=!1;_onMessage=null;_onBinary=null;_onError=null;_onClose=null;constructor($){this._ws=$}async connect(){if(this._ws.readyState===WebSocket.OPEN)throw new f("Already connected","ALREADY_CONNECTED");if(this._ws.readyState===WebSocket.CLOSING||this._ws.readyState===WebSocket.CLOSED)throw new f("Socket is closing or closed","SOCKET_CLOSED");return new Promise(($,Q)=>{let Y,Z;Y=()=>{this._ws.removeEventListener("open",Y),this._ws.removeEventListener("error",Z),this.#$(),$()},Z=()=>{this._ws.removeEventListener("open",Y),this._ws.removeEventListener("error",Z),Q(new f("Connection failed","CONNECTION_FAILED"))},this._ws.addEventListener("open",Y),this._ws.addEventListener("error",Z)})}send($){if(this._ws.readyState!==WebSocket.OPEN)throw new f("Not connected","NOT_CONNECTED");this._ws.send(JSON.stringify($))}async sendBinary($){if(this._ws.readyState!==WebSocket.OPEN)throw new f("Not connected","NOT_CONNECTED");let Q=await $.arrayBuffer();this._ws.send(Q)}onMessage($){this._onMessage=$}onBinary($){this._onBinary=$}onError($){this._onError=$}onClose($){this._onClose=$}close(){if(this._closed)return;if(this._closed=!0,this._ws.readyState===WebSocket.OPEN||this._ws.readyState===WebSocket.CONNECTING)this._ws.close();this._onClose?.()}#$(){this._ws.addEventListener("message",($)=>{if($.data instanceof Blob)this._onBinary?.($.data);else if($.data instanceof ArrayBuffer)this._onBinary?.(new Blob([$.data]));else if(typeof $.data==="string")try{let Q=JSON.parse($.data);this._onMessage?.(Q)}catch(Q){console.warn("Failed to parse JSON message:",$.data,Q)}}),this._ws.addEventListener("error",()=>{if(this._closed)return;this._onError?.(new f("WebSocket error")),this.close()}),this._ws.addEventListener("close",()=>{if(this._closed)return;this.close()})}}class Y1{#$;constructor($){this.#$=$}async connect($){let Q=this.#Q("/conversations/ws"),Y=new Q1(new WebSocket(Q));return await Y.connect(),Y.send({type:"handshake",agent_id:$.agent_id,channel:$.channel}),new Promise((Z,G)=>{let W=!1;Y.onMessage((z)=>{switch(z.type){case"handshake_ok":W=!0,$.onConnection?.(z),Z(new O0(Y,z.conversation_id,$));break;case"handshake_error":W=!0,$.onConnection?.(z),Y.close(),G(Error(`Handshake rejected: ${z.reason}`));break;default:}}),Y.onError((z)=>{if(!W)G(z)}),Y.onClose(()=>{if(!W)G(Error("Connection lost during handshake"))})})}#Q($){return`${this.#$.replace(/^https:\/\//,"wss://").replace(/^http:\/\//,"ws://").replace(/\/$/,"")}${$}`}}var t1="https://server.kivox.com.co";function a1($,Q){$.interceptors.request.use((G)=>G),B.defaults.baseURL=Q,B.defaults.withCredentials=$.defaults.withCredentials??!1;let Y=$.defaults.headers?.Authorization;if(Y)B.defaults.headers.common.Authorization=Y;let Z={realtime:new Y1(Q)};return new Proxy({...Z},{get(G,W){if(W in G)return G[W];let z=$1[W];if(typeof z==="function")return(...J)=>z(...J,{axios:$});return z}})}function w7({baseUrl:$=t1}={}){let Q=B.create({baseURL:$,withCredentials:!0});return a1(Q,$)}function F7({apiKey:$,baseUrl:Q=t1}){let Y=B.create({baseURL:Q,headers:{Authorization:`Bearer ${$}`}});return a1(Y,Q)}export{w7 as createSessionClient,F7 as createApiKeyClient,f as ConversationTransportError,O0 as ConversationSession};
|
|
1
|
+
var YG=/\{[^{}]+\}/g,ZG=()=>{return typeof process==="object"&&Number.parseInt(process?.versions?.node?.substring(0,2))>=18&&process.versions.undici};function $G(){return Math.random().toString(36).slice(2,11)}function i(G){let{baseUrl:V="",Request:X=globalThis.Request,fetch:Z=globalThis.fetch,querySerializer:Y,bodySerializer:$,pathSerializer:J,headers:_,requestInitExt:S=void 0,...r}={...G};S=ZG()?S:void 0,V=o(V);let T=[];async function Q(N,K){let{baseUrl:F,fetch:y=Z,Request:c=X,headers:v,params:k={},parseAs:A="json",querySerializer:j,bodySerializer:h=$??KG,pathSerializer:e,body:d,middleware:GG=[],...z}=K||{},U=V;if(F)U=o(F)??V;let g=typeof Y==="function"?Y:p(Y);if(j)g=typeof j==="function"?j:p({...typeof Y==="object"?Y:{},...j});let m=e||J||JG,P=d===void 0?void 0:h(d,l(_,v,k.header)),VG=l(P===void 0||P instanceof FormData?{}:{"Content-Type":"application/json"},_,v,k.header),O=[...T,...GG],XG={redirect:"follow",...r,...z,body:P,headers:VG},x,R,B=new c(NG(N,{baseUrl:U,params:k,querySerializer:g,pathSerializer:m}),XG),W;for(let I in z)if(!(I in B))B[I]=z[I];if(O.length){x=$G(),R=Object.freeze({baseUrl:U,fetch:y,parseAs:A,querySerializer:g,bodySerializer:h,pathSerializer:m});for(let I of O)if(I&&typeof I==="object"&&typeof I.onRequest==="function"){let D=await I.onRequest({request:B,schemaPath:N,params:k,options:R,id:x});if(D)if(D instanceof c)B=D;else if(D instanceof Response){W=D;break}else throw Error("onRequest: must return new Request() or Response() when modifying the request")}}if(!W){try{W=await y(B,S)}catch(I){let D=I;if(O.length)for(let M=O.length-1;M>=0;M--){let E=O[M];if(E&&typeof E==="object"&&typeof E.onError==="function"){let L=await E.onError({request:B,error:D,schemaPath:N,params:k,options:R,id:x});if(L){if(L instanceof Response){D=void 0,W=L;break}if(L instanceof Error){D=L;continue}throw Error("onError: must return new Response() or instance of Error")}}}if(D)throw D}if(O.length)for(let I=O.length-1;I>=0;I--){let D=O[I];if(D&&typeof D==="object"&&typeof D.onResponse==="function"){let M=await D.onResponse({request:B,response:W,schemaPath:N,params:k,options:R,id:x});if(M){if(!(M instanceof Response))throw Error("onResponse: must return new Response() when modifying the response");W=M}}}}let u=W.headers.get("Content-Length");if(W.status===204||B.method==="HEAD"||u==="0"&&!W.headers.get("Transfer-Encoding")?.includes("chunked"))return W.ok?{data:void 0,response:W}:{error:void 0,response:W};if(W.ok)return{data:await(async()=>{if(A==="stream")return W.body;if(A==="json"&&!u){let D=await W.text();return D?JSON.parse(D):void 0}return await W[A]()})(),response:W};let f=await W.text();try{f=JSON.parse(f)}catch{}return{error:f,response:W}}return{request(N,K,F){return Q(K,{...F,method:N.toUpperCase()})},GET(N,K){return Q(N,{...K,method:"GET"})},PUT(N,K){return Q(N,{...K,method:"PUT"})},POST(N,K){return Q(N,{...K,method:"POST"})},DELETE(N,K){return Q(N,{...K,method:"DELETE"})},OPTIONS(N,K){return Q(N,{...K,method:"OPTIONS"})},HEAD(N,K){return Q(N,{...K,method:"HEAD"})},PATCH(N,K){return Q(N,{...K,method:"PATCH"})},TRACE(N,K){return Q(N,{...K,method:"TRACE"})},use(...N){for(let K of N){if(!K)continue;if(typeof K!=="object"||!(("onRequest"in K)||("onResponse"in K)||("onError"in K)))throw Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");T.push(K)}},eject(...N){for(let K of N){let F=T.indexOf(K);if(F!==-1)T.splice(F,1)}}}}function w(G,V,X){if(V===void 0||V===null)return"";if(typeof V==="object")throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${G}=${X?.allowReserved===!0?V:encodeURIComponent(V)}`}function n(G,V,X){if(!V||typeof V!=="object")return"";let Z=[],Y={simple:",",label:".",matrix:";"}[X.style]||"&";if(X.style!=="deepObject"&&X.explode===!1){for(let _ in V)Z.push(_,X.allowReserved===!0?V[_]:encodeURIComponent(V[_]));let J=Z.join(",");switch(X.style){case"form":return`${G}=${J}`;case"label":return`.${J}`;case"matrix":return`;${G}=${J}`;default:return J}}for(let J in V){let _=X.style==="deepObject"?`${G}[${J}]`:J;Z.push(w(_,V[J],X))}let $=Z.join(Y);return X.style==="label"||X.style==="matrix"?`${Y}${$}`:$}function s(G,V,X){if(!Array.isArray(V))return"";if(X.explode===!1){let $={form:",",spaceDelimited:"%20",pipeDelimited:"|"}[X.style]||",",J=(X.allowReserved===!0?V:V.map((_)=>encodeURIComponent(_))).join($);switch(X.style){case"simple":return J;case"label":return`.${J}`;case"matrix":return`;${G}=${J}`;default:return`${G}=${J}`}}let Z={simple:",",label:".",matrix:";"}[X.style]||"&",Y=[];for(let $ of V)if(X.style==="simple"||X.style==="label")Y.push(X.allowReserved===!0?$:encodeURIComponent($));else Y.push(w(G,$,X));return X.style==="label"||X.style==="matrix"?`${Z}${Y.join(Z)}`:Y.join(Z)}function p(G){return function(X){let Z=[];if(X&&typeof X==="object")for(let Y in X){let $=X[Y];if($===void 0||$===null)continue;if(Array.isArray($)){if($.length===0)continue;Z.push(s(Y,$,{style:"form",explode:!0,...G?.array,allowReserved:G?.allowReserved||!1}));continue}if(typeof $==="object"){Z.push(n(Y,$,{style:"deepObject",explode:!0,...G?.object,allowReserved:G?.allowReserved||!1}));continue}Z.push(w(Y,$,G))}return Z.join("&")}}function JG(G,V){let X=G;for(let Z of G.match(YG)??[]){let Y=Z.substring(1,Z.length-1),$=!1,J="simple";if(Y.endsWith("*"))$=!0,Y=Y.substring(0,Y.length-1);if(Y.startsWith("."))J="label",Y=Y.substring(1);else if(Y.startsWith(";"))J="matrix",Y=Y.substring(1);if(!V||V[Y]===void 0||V[Y]===null)continue;let _=V[Y];if(Array.isArray(_)){X=X.replace(Z,s(Y,_,{style:J,explode:$}));continue}if(typeof _==="object"){X=X.replace(Z,n(Y,_,{style:J,explode:$}));continue}if(J==="matrix"){X=X.replace(Z,`;${w(Y,_)}`);continue}X=X.replace(Z,J==="label"?`.${encodeURIComponent(_)}`:encodeURIComponent(_))}return X}function KG(G,V){if(G instanceof FormData)return G;if(V){if((V.get instanceof Function?V.get("Content-Type")??V.get("content-type"):V["Content-Type"]??V["content-type"])==="application/x-www-form-urlencoded")return new URLSearchParams(G).toString()}return JSON.stringify(G)}function NG(G,V){let X=`${V.baseUrl}${G}`;if(V.params?.path)X=V.pathSerializer(X,V.params.path);let Z=V.querySerializer(V.params.query??{});if(Z.startsWith("?"))Z=Z.substring(1);if(Z)X+=`?${Z}`;return X}function l(...G){let V=new Headers;for(let X of G){if(!X||typeof X!=="object")continue;let Z=X instanceof Headers?X.entries():Object.entries(X);for(let[Y,$]of Z)if($===null)V.delete(Y);else if(Array.isArray($))for(let J of $)V.append(Y,J);else if($!==void 0)V.set(Y,$)}return V}function o(G){if(G.endsWith("/"))return G.substring(0,G.length-1);return G}class q{_transport;_conversationId;_closed=!1;_onEvent;_pendingAudioMetadata=null;_remainingMs=0;_elapsedMs=0;get conversationId(){return this._conversationId}get remainingMs(){return this._remainingMs}get elapsedMs(){return this._elapsedMs}get closed(){return this._closed}constructor(G,V,X){this._transport=G,this._conversationId=V,this._onEvent=X.onEvent,this.#G()}sendText(G){if(this._closed){console.warn("Cannot send text: session is closed");return}this._transport.send({type:"input_text",text:G})}sendAudio(G){if(this._closed){console.warn("Cannot send audio: session is closed");return}this._transport.send({type:"input_audio"}),this._transport.sendBinary(G)}streamAudio(G){if(this._closed){console.warn("Cannot stream audio: session is closed");return}this._transport.send({type:"input_audio_stream"}),this._transport.sendBinary(G)}cancelRequest(){if(this._closed){console.warn("Cannot cancel request: session is closed");return}this._transport.send({type:"cancel"})}end(){if(this._closed){console.warn("Cannot end session: session is closed");return}this._transport.send({type:"end"})}close(){if(this._closed)return;this._closed=!0,this._transport.close()}#G(){this._transport.onMessage((G)=>{let V=G;if(V.type==="audio_delta"){this._pendingAudioMetadata={size:V.size};return}if(V.type==="tick")this._remainingMs=V.remaining_ms,this._elapsedMs=V.elapsed_ms;if(V.type==="session_closed")this._closed=!0;this._onEvent?.(V)}),this._transport.onBinary((G)=>{if(this._pendingAudioMetadata){let V={type:"audio_delta",size:this._pendingAudioMetadata.size,audio:G};this._pendingAudioMetadata=null,this._onEvent?.(V)}}),this._transport.onClose(()=>{if(this._closed)return;this._closed=!0,this._onEvent?.({type:"connection_lost",reason:"socket_closed"})}),this._transport.onError(()=>{if(this._closed)return;this._closed=!0,this._onEvent?.({type:"connection_lost",reason:"socket_error"})})}}class H extends Error{code;constructor(G,V="TRANSPORT_ERROR"){super(G);this.code=V;this.name="ConversationTransportError"}}class b{_ws;_closed=!1;_onMessage=null;_onBinary=null;_onError=null;_onClose=null;constructor(G){this._ws=G}async connect(){if(this._ws.readyState===WebSocket.OPEN)throw new H("Already connected","ALREADY_CONNECTED");if(this._ws.readyState===WebSocket.CLOSING||this._ws.readyState===WebSocket.CLOSED)throw new H("Socket is closing or closed","SOCKET_CLOSED");return new Promise((G,V)=>{let X,Z;X=()=>{this._ws.removeEventListener("open",X),this._ws.removeEventListener("error",Z),this.#G(),G()},Z=()=>{this._ws.removeEventListener("open",X),this._ws.removeEventListener("error",Z),V(new H("Connection failed","CONNECTION_FAILED"))},this._ws.addEventListener("open",X),this._ws.addEventListener("error",Z)})}send(G){if(this._ws.readyState!==WebSocket.OPEN)throw new H("Not connected","NOT_CONNECTED");this._ws.send(JSON.stringify(G))}async sendBinary(G){if(this._ws.readyState!==WebSocket.OPEN)throw new H("Not connected","NOT_CONNECTED");let V=await G.arrayBuffer();this._ws.send(V)}onMessage(G){this._onMessage=G}onBinary(G){this._onBinary=G}onError(G){this._onError=G}onClose(G){this._onClose=G}close(){if(this._closed)return;if(this._closed=!0,this._ws.readyState===WebSocket.OPEN||this._ws.readyState===WebSocket.CONNECTING)this._ws.close();this._onClose?.()}#G(){this._ws.addEventListener("message",(G)=>{if(G.data instanceof Blob)this._onBinary?.(G.data);else if(G.data instanceof ArrayBuffer)this._onBinary?.(new Blob([G.data]));else if(typeof G.data==="string")try{let V=JSON.parse(G.data);this._onMessage?.(V)}catch(V){console.warn("Failed to parse JSON message:",G.data,V)}}),this._ws.addEventListener("error",()=>{if(this._closed)return;this._onError?.(new H("WebSocket error")),this.close()}),this._ws.addEventListener("close",()=>{if(this._closed)return;this.close()})}}class C{#G;constructor(G){this.#G=G}async connect(G){let V=this.#V("/conversations/ws"),X=new b(new WebSocket(V));return await X.connect(),X.send({type:"handshake",agent_id:G.agent_id,channel:G.channel}),new Promise((Z,Y)=>{let $=!1;X.onMessage((J)=>{switch(J.type){case"handshake_ok":$=!0,G.onConnection?.(J),Z(new q(X,J.conversation_id,G));break;case"handshake_error":$=!0,G.onConnection?.(J),X.close(),Y(Error(`Handshake rejected: ${J.reason}`));break;default:}}),X.onError((J)=>{if(!$)Y(J)}),X.onClose(()=>{if(!$)Y(Error("Connection lost during handshake"))})})}#V(G){return`${this.#G.replace(/^https:\/\//,"wss://").replace(/^http:\/\//,"ws://").replace(/\/$/,"")}${G}`}}var t="https://server.kivox.com.co";function a(G){return i(G)}function FG({baseUrl:G=t}={}){return{api:a({baseUrl:G,credentials:"include"}),realtime:new C(G)}}function MG({bearerToken:G,baseUrl:V=t}){return{api:a({baseUrl:V,headers:{Authorization:`Bearer ${G}`}}),realtime:new C(V)}}export{FG as createSessionClient,MG as createBearerClient,H as ConversationTransportError,q as ConversationSession};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kivox/client",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.39",
|
|
4
4
|
"description": "JavaScript/TypeScript client SDK for Kivox",
|
|
5
5
|
"homepage": "https://github.com/ekisa-team/kivox#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
|
-
"development": "./src/index.ts",
|
|
23
22
|
"import": "./dist/index.mjs",
|
|
24
23
|
"require": "./dist/index.cjs",
|
|
25
24
|
"default": "./dist/index.mjs"
|
|
@@ -38,7 +37,7 @@
|
|
|
38
37
|
"test:watch": "bun test --watch"
|
|
39
38
|
},
|
|
40
39
|
"dependencies": {
|
|
41
|
-
"
|
|
40
|
+
"openapi-fetch": "^0.17.0"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
43
|
"@types/bun": "latest",
|