@tableau/mcp-server 1.17.18 → 1.17.19
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/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -102,7 +102,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
102
102
|
]))`;continue}else if(n[c]==="$"){i+=`($|(?=[\r
|
|
103
103
|
]))`;continue}}if(r.s&&n[c]==="."){i+=o?`${n[c]}\r
|
|
104
104
|
`:`[${n[c]}\r
|
|
105
|
-
]`;continue}i+=n[c],n[c]==="\\"?a=!0:o&&n[c]==="]"?o=!1:!o&&n[c]==="["&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return i}function ff(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===P.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,i)=>({...n,[i]:J(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",i]})??nt(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:J(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===P.ZodString&&t.keyType._def.checks?.length){let{type:n,...i}=df(t.keyType._def,e);return{...r,propertyNames:i}}else{if(t.keyType?._def.typeName===P.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===P.ZodBranded&&t.keyType._def.type._def.typeName===P.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...i}=pf(t.keyType._def,e);return{...r,propertyNames:i}}}return r}function JC(t,e){if(e.mapStrategy==="record")return ff(t,e);let r=J(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||nt(e),n=J(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||nt(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function QC(t){let e=t.values,n=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),i=Array.from(new Set(n.map(a=>typeof a)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:n}}function YC(t){return t.target==="openAi"?void 0:{not:nt({...t,currentPath:[...t.currentPath,"not"]})}}function XC(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Nu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function tP(t,e){if(e.target==="openApi3")return eP(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Nu&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,a)=>{let o=Nu[a._def.typeName];return o&&!i.includes(o)?[...i,o]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,a)=>{let o=typeof a._def.value;switch(o){case"string":case"number":case"boolean":return[...i,o];case"bigint":return[...i,"integer"];case"object":if(a._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(n.length===r.length){let i=n.filter((a,o,s)=>s.indexOf(a)===o);return{type:i.length>1?i:i[0],enum:r.reduce((a,o)=>a.includes(o._def.value)?a:[...a,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(a=>!n.includes(a))],[])};return eP(t,e)}var eP=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,i)=>J(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function rP(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:Nu[t.innerType._def.typeName],nullable:!0}:{type:[Nu[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=J(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=J(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function nP(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",ex(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?be(r,"minimum",n.value,n.message,e):be(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),be(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?be(r,"maximum",n.value,n.message,e):be(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),be(r,"maximum",n.value,n.message,e));break;case"multipleOf":be(r,"multipleOf",n.value,n.message,e);break}return r}function iP(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},i=[],a=t.shape();for(let s in a){let c=a[s];if(c===void 0||c._def===void 0)continue;let u=ZH(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=J(c._def,{...e,currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]});l!==void 0&&(n.properties[s]=l,u||i.push(s))}i.length&&(n.required=i);let o=HH(t,e);return o!==void 0&&(n.additionalProperties=o),n}function HH(t,e){if(t.catchall._def.typeName!=="ZodNever")return J(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function ZH(t){try{return t.isOptional()}catch{return!0}}var aP=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return J(t.innerType._def,e);let r=J(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:nt(e)},r]}:nt(e)};var oP=(t,e)=>{if(e.pipeStrategy==="input")return J(t.in._def,e);if(e.pipeStrategy==="output")return J(t.out._def,e);let r=J(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=J(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(i=>i!==void 0)}};function sP(t,e){return J(t.type._def,e)}function cP(t,e){let n={type:"array",uniqueItems:!0,items:J(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&be(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&be(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function uP(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>J(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:J(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>J(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function lP(t){return{not:nt(t)}}function pP(t){return nt(t)}var dP=(t,e)=>J(t.innerType._def,e);var fP=(t,e,r)=>{switch(e){case P.ZodString:return df(t,r);case P.ZodNumber:return nP(t,r);case P.ZodObject:return iP(t,r);case P.ZodBigInt:return UC(t,r);case P.ZodBoolean:return FC();case P.ZodDate:return tx(t,r);case P.ZodUndefined:return lP(r);case P.ZodNull:return XC(r);case P.ZodArray:return LC(t,r);case P.ZodUnion:case P.ZodDiscriminatedUnion:return tP(t,r);case P.ZodIntersection:return WC(t,r);case P.ZodTuple:return uP(t,r);case P.ZodRecord:return ff(t,r);case P.ZodLiteral:return KC(t,r);case P.ZodEnum:return ZC(t);case P.ZodNativeEnum:return QC(t);case P.ZodNullable:return rP(t,r);case P.ZodOptional:return aP(t,r);case P.ZodMap:return JC(t,r);case P.ZodSet:return cP(t,r);case P.ZodLazy:return()=>t.getter()._def;case P.ZodPromise:return sP(t,r);case P.ZodNaN:case P.ZodNever:return YC(r);case P.ZodEffects:return HC(t,r);case P.ZodAny:return nt(r);case P.ZodUnknown:return pP(r);case P.ZodDefault:return BC(t,r);case P.ZodBranded:return pf(t,r);case P.ZodReadonly:return dP(t,r);case P.ZodCatch:return VC(t,r);case P.ZodPipeline:return oP(t,r);case P.ZodFunction:case P.ZodVoid:case P.ZodSymbol:return;default:return(n=>{})(e)}};function J(t,e,r=!1){let n=e.seen.get(t);if(e.override){let s=e.override?.(t,e,n,r);if(s!==zC)return s}if(n&&!r){let s=WH(n,e);if(s!==void 0)return s}let i={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,i);let a=fP(t,t.typeName,e),o=typeof a=="function"?J(a(),e):a;if(o&&KH(t,e,o),e.postProcess){let s=e.postProcess(o,t,e);return i.jsonSchema=o,s}return i.jsonSchema=o,o}var WH=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:lf(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),nt(e)):e.$refStrategy==="seen"?nt(e):void 0}},KH=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var ix=(t,e)=>{let r=DC(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:J(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??nt(r)}),{}):void 0,i=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=J(t._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??nt(r),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(a.title=o),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=i===void 0?n?{...a,[r.definitionPath]:n}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:a}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in s||"oneOf"in s||"allOf"in s||"type"in s&&Array.isArray(s.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),s};function GH(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function ax(t,e){return Br(t)?gb(t,{target:GH(e?.target),io:e?.pipeStrategy??"input"}):ix(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function ox(t){let r=Hi(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=uf(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function sx(t,e){let r=Bi(t,e);if(!r.success)throw r.error;return r.data}var JH=6e4,mf=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Id,r=>{this._oncancel(r)}),this.setNotificationHandler(Od,r=>{this._onprogress(r)}),this.setRequestHandler(rs,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(jd,async(r,n)=>{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new L(H.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(qd,async(r,n)=>{let i=async()=>{let a=r.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(a,n.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else{let p=c,f=new L(p.error.code,p.error.message,p.error.data);l(f)}else{let p=s.type==="response"?"Response":"Error";this._onerror(new Error(`${p} handler missing for request ${u}`))}continue}await this._transport?.send(s.message,{relatedRequestId:n.requestId})}}let o=await this._taskStore.getTask(a,n.sessionId);if(!o)throw new L(H.InvalidParams,`Task not found: ${a}`);if(!Zi(o.status))return await this._waitForTaskUpdate(a,n.signal),await i();if(Zi(o.status)){let s=await this._taskStore.getTaskResult(a,n.sessionId);return this._clearTaskQueue(a),{...s,_meta:{...s._meta,[ji]:{taskId:a}}}}return await i()};return await i()}),this.setRequestHandler(zd,async(r,n)=>{try{let{tasks:i,nextCursor:a}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:i,nextCursor:a,_meta:{}}}catch(i){throw new L(H.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(Dd,async(r,n)=>{try{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new L(H.InvalidParams,`Task not found: ${r.params.taskId}`);if(Zi(i.status))throw new L(H.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let a=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!a)throw new L(H.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...a}}catch(i){throw i instanceof L?i:new L(H.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,i,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(i,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:a,onTimeout:i})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),L.fromError(H.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=a=>{n?.(a),this._onerror(a)};let i=this._transport?.onmessage;this._transport.onmessage=(a,o)=>{i?.(a,o),ri(a)||ts(a)?this._onresponse(a):Ni(a)?this._onrequest(a,o):Kk(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=L.fromError(H.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,i=this._transport,a=e.params?._meta?.[ji]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:H.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},i?.sessionId).catch(p=>this._onerror(new Error(`Failed to enqueue error response: ${p}`))):i?.send(l).catch(p=>this._onerror(new Error(`Failed to send an error response: ${p}`)));return}let o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);let s=Hk(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,i?.sessionId):void 0,u={signal:o.signal,sessionId:i?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(o.signal.aborted)return;let p={relatedRequestId:e.id};a&&(p.relatedTask={taskId:a}),await this.notification(l,p)},sendRequest:async(l,p,f)=>{if(o.signal.aborted)throw new L(H.ConnectionClosed,"Request was cancelled");let g={...f,relatedRequestId:e.id};a&&!g.relatedTask&&(g.relatedTask={taskId:a});let m=g.relatedTask?.taskId??a;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,p,g)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:a,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(o.signal.aborted)return;let p={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:p,timestamp:Date.now()},i?.sessionId):await i?.send(p)},async l=>{if(o.signal.aborted)return;let p={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:H.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:p,timestamp:Date.now()},i?.sessionId):await i?.send(p)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,i=Number(r),a=this._progressHandlers.get(i);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let o=this._responseHandlers.get(i),s=this._timeoutInfo.get(i);if(s&&o&&s.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(c){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),o(c);return}a(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),ri(e))n(e);else{let o=new L(e.error.code,e.error.message,e.error.data);n(o)}return}let i=this._responseHandlers.get(r);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let a=!1;if(ri(e)&&e.result&&typeof e.result=="object"){let o=e.result;if(o.task&&typeof o.task=="object"){let s=o.task;typeof s.taskId=="string"&&(a=!0,this._taskProgressTokens.set(s.taskId,r))}}if(a||this._progressHandlers.delete(r),ri(e))i(e);else{let o=L.fromError(e.error.code,e.error.message,e.error.data);i(o)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:i}=n??{};if(!i){try{yield{type:"result",result:await this.request(e,r,n)}}catch(o){yield{type:"error",error:o instanceof L?o:new L(H.InternalError,String(o))}}return}let a;try{let o=await this.request(e,ns,n);if(o.task)a=o.task.taskId,yield{type:"taskCreated",task:o.task};else throw new L(H.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:a},n);if(yield{type:"taskStatus",task:s},Zi(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)}:s.status==="failed"?yield{type:"error",error:new L(H.InternalError,`Task ${a} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new L(H.InternalError,`Task ${a} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(o){yield{type:"error",error:o instanceof L?o:new L(H.InternalError,String(o))}}}request(e,r,n){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,task:s,relatedTask:c}=n??{};return new Promise((u,l)=>{let p=x=>{l(x)};if(!this._transport){p(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),s&&this.assertTaskCapability(e.method)}catch(x){p(x);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,g={...e,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),g.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),s&&(g.params={...g.params,task:s}),c&&(g.params={...g.params,_meta:{...g.params?._meta||{},[ji]:c}});let m=x=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(x)}},{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(S=>this._onerror(new Error(`Failed to send cancellation: ${S}`)));let w=x instanceof L?x:new L(H.RequestTimeout,String(x));l(w)};this._responseHandlers.set(f,x=>{if(!n?.signal?.aborted){if(x instanceof Error)return l(x);try{let w=Bi(r,x.result);w.success?u(w.data):l(w.error)}catch(w){l(w)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??JH,v=()=>m(L.fromError(H.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,v,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let x=w=>{let S=this._responseHandlers.get(f);S?S(w):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,x),this._enqueueTaskMessage(y,{type:"request",message:g,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(f),l(w)})}else this._transport.send(g,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(x=>{this._cleanupTimeout(f),l(x)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Nd,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Md,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Jk,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let s={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[ji]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let s={...e,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[ji]:r.relatedTask}}}),this._transport?.send(s,r).catch(c=>this._onerror(c))});return}let o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[ji]:r.relatedTask}}}),await this._transport.send(o,r)}setRequestHandler(e,r){let n=ox(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,a)=>{let o=sx(e,i);return Promise.resolve(r(o,a))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=ox(e);this._notificationHandlers.set(n,i=>{let a=sx(e,i);return Promise.resolve(r(a))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,i)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let i of n)if(i.type==="request"&&Ni(i.message)){let a=i.message.id,o=this._requestResolvers.get(a);o?(o(new L(H.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(e);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,a)=>{if(r.aborted){a(new L(H.InvalidRequest,"Request cancelled"));return}let o=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(o),a(new L(H.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async i=>{if(!e)throw new Error("No request provided");return await n.createTask(i,e.id,{method:e.method,params:e.params},r)},getTask:async i=>{let a=await n.getTask(i,r);if(!a)throw new L(H.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(i,a,o)=>{await n.storeTaskResult(i,a,o,r);let s=await n.getTask(i,r);if(s){let c=Eu.parse({method:"notifications/tasks/status",params:s});await this.notification(c),Zi(s.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>n.getTaskResult(i,r),updateTaskStatus:async(i,a,o)=>{let s=await n.getTask(i,r);if(!s)throw new L(H.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Zi(s.status))throw new L(H.InvalidParams,`Cannot update task "${i}" from terminal status "${s.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(i,a,o,r);let c=await n.getTask(i,r);if(c){let u=Eu.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Zi(c.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>n.listTasks(i,r)}}};function mP(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function hP(t,e){let r={...t};for(let n in e){let i=n,a=e[i];if(a===void 0)continue;let o=r[i];mP(o)&&mP(a)?r[i]={...o,...a}:r[i]=a}return r}var h2=je(UI(),1),g2=je(m2(),1);function qte(){let t=new h2.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,g2.default)(t),t}var Am=class{constructor(e){this._ajv=e??qte()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var km=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function v2(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function y2(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var Cm=class extends mf{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Au.options.map((n,i)=>[n,i])),this.isMessageIgnored=(n,i)=>{let a=this._loggingLevels.get(i);return a?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(a):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Am,this.setRequestHandler($d,n=>this._oninitialize(n)),this.setNotificationHandler(Ib,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(ku,async(n,i)=>{let a=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:o}=n.params,s=Au.safeParse(o);return s.success&&this._loggingLevels.set(a,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new km(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=hP(this._capabilities,e)}setRequestHandler(e,r){let i=Hi(e)?.method;if(!i)throw new Error("Schema is missing a method literal");let a;if(Br(i)){let s=i;a=s._zod?.def?.value??s.value}else{let s=i;a=s._def?.value??s.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");if(a==="tools/call"){let s=async(c,u)=>{let l=Bi(zi,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new L(H.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:p}=l.data,f=await Promise.resolve(r(c,u));if(p.task){let m=Bi(ns,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new L(H.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let g=Bi(Zd,f);if(!g.success){let m=g.error instanceof Error?g.error.message:String(g.error);throw new L(H.InvalidParams,`Invalid tools/call result: ${m}`)}return g.data};return super.setRequestHandler(e,s)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){y2(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&v2(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:vu.includes(r)?r:kb,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Rd)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],a=i.some(u=>u.type==="tool_result"),o=e.messages.length>1?e.messages[e.messages.length-2]:void 0,s=o?Array.isArray(o.content)?o.content:[o.content]:[],c=s.some(u=>u.type==="tool_use");if(a){if(i.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(s.filter(p=>p.type==="tool_use").map(p=>p.id)),l=new Set(i.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==l.size||![...u].every(p=>l.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Db,r):this.request({method:"sampling/createMessage",params:e},Mb,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let i=e;return this.request({method:"elicitation/create",params:i},Wd,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let i=e.mode==="form"?e:{...e,mode:"form"},a=await this.request({method:"elicitation/create",params:i},Wd,r);if(a.action==="accept"&&a.content&&i.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(i.requestedSchema)(a.content);if(!s.valid)throw new L(H.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(o){throw o instanceof L?o:new L(H.InternalError,`Error validating elicitation response: ${o instanceof Error?o.message:String(o)}`)}return a}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},Lb,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var x2=Symbol.for("mcp.completable");function I_(t){return!!t&&typeof t=="object"&&x2 in t}function w2(t){return t[x2]?.complete}var b2;(function(t){t.Completable="McpCompletable"})(b2||(b2={}));var zte=/^[A-Za-z0-9._-]{1,128}$/;function Mte(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!zte.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,i,a)=>a.indexOf(n)===i);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function Dte(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function $_(t){let e=Mte(t);return Dte(t,e.warnings),e.isValid}var Pm=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let i={taskSupport:"required",...r.execution};if(i.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,i,r._meta,n)}};var Rm=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Cm(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Pm(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(ca(Hd)),this.server.assertCanSetRequestHandler(ca(zi)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Hd,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let i=ms(r.inputSchema);return i?ax(i,{strictUnions:!0,pipeStrategy:"input"}):Lte})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let i=ms(r.outputSchema);i&&(n.outputSchema=ax(i,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(zi,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new L(H.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new L(H.InvalidParams,`Tool ${e.params.name} disabled`);let i=!!e.params.task,a=n.execution?.taskSupport,o="createTask"in n.handler;if((a==="required"||a==="optional")&&!o)throw new L(H.InternalError,`Tool ${e.params.name} has taskSupport '${a}' but was not registered with registerToolTask`);if(a==="required"&&!i)throw new L(H.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(a==="optional"&&!i&&o)return await this.handleAutomaticTaskPolling(n,e,r);let s=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,s,r);return i||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof L&&n.code===H.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let a=ms(e.inputSchema)??e.inputSchema,o=await sf(a,r);if(!o.success){let s="error"in o?o.error:"Unknown error",c=cf(s);throw new L(H.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return o.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new L(H.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let i=ms(e.outputSchema),a=await sf(i,r.structuredContent);if(!a.success){let o="error"in a?a.error:"Unknown error",s=cf(o);throw new L(H.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${s}`)}}async executeToolHandler(e,r,n){let i=e.handler;if("createTask"in i){if(!n.taskStore)throw new Error("No task store provided.");let o={...n,taskStore:n.taskStore};if(e.inputSchema){let s=i;return await Promise.resolve(s.createTask(r,o))}else{let s=i;return await Promise.resolve(s.createTask(o))}}if(e.inputSchema){let o=i;return await Promise.resolve(o(r,n))}else{let o=i;return await Promise.resolve(o(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let i=await this.validateToolInput(e,r.params.arguments,r.params.name),a=e.handler,o={...n,taskStore:n.taskStore},s=i?await Promise.resolve(a.createTask(i,o)):await Promise.resolve(a.createTask(o)),c=s.task.taskId,u=s.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(f=>setTimeout(f,l));let p=await n.taskStore.getTask(c);if(!p)throw new L(H.InternalError,`Task ${c} not found during polling`);u=p}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(ca(Kd)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Kd,async e=>{switch(e.params.ref.type){case"ref/prompt":return rC(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return nC(e),this.handleResourceCompletion(e,e.params.ref);default:throw new L(H.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new L(H.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new L(H.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Dl;let a=Hi(n.argsSchema)?.[e.params.argument.name];if(!I_(a))return Dl;let o=w2(a);if(!o)return Dl;let s=await o(e.params.argument.value,e.params.context);return S2(s)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(o=>o.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Dl;throw new L(H.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let i=n.resourceTemplate.completeCallback(e.params.argument.name);if(!i)return Dl;let a=await i(e.params.argument.value,e.params.context);return S2(a)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(ca(Ld)),this.server.assertCanSetRequestHandler(ca(Ud)),this.server.assertCanSetRequestHandler(ca(Fd)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Ld,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([a,o])=>o.enabled).map(([a,o])=>({uri:a,name:o.name,...o.metadata})),i=[];for(let a of Object.values(this._registeredResourceTemplates)){if(!a.resourceTemplate.listCallback)continue;let o=await a.resourceTemplate.listCallback(r);for(let s of o.resources)i.push({...a.metadata,...s})}return{resources:[...n,...i]}}),this.server.setRequestHandler(Ud,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Fd,async(e,r)=>{let n=new URL(e.params.uri),i=this._registeredResources[n.toString()];if(i){if(!i.enabled)throw new L(H.InvalidParams,`Resource ${n} disabled`);return i.readCallback(n,r)}for(let a of Object.values(this._registeredResourceTemplates)){let o=a.resourceTemplate.uriTemplate.match(n.toString());if(o)return a.readCallback(n,o,r)}throw new L(H.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(ca(Vd)),this.server.assertCanSetRequestHandler(ca(Bd)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Vd,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?Fte(r.argsSchema):void 0}))})),this.server.setRequestHandler(Bd,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new L(H.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new L(H.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let i=ms(n.argsSchema),a=await sf(i,e.params.arguments);if(!a.success){let c="error"in a?a.error:"Unknown error",u=cf(c);throw new L(H.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let o=a.data,s=n.callback;return await Promise.resolve(s(o,r))}else{let i=n.callback;return await Promise.resolve(i(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let i;typeof n[0]=="object"&&(i=n.shift());let a=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,void 0,r,i,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,void 0,r,i,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}registerResource(e,r,n,i){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let a=this._createRegisteredResource(e,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let a=this._createRegisteredResourceTemplate(e,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}_createRegisteredResource(e,r,n,i,a){let o={name:e,title:r,metadata:i,readCallback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({uri:null}),update:s=>{typeof s.uri<"u"&&s.uri!==n&&(delete this._registeredResources[n],s.uri&&(this._registeredResources[s.uri]=o)),typeof s.name<"u"&&(o.name=s.name),typeof s.title<"u"&&(o.title=s.title),typeof s.metadata<"u"&&(o.metadata=s.metadata),typeof s.callback<"u"&&(o.readCallback=s.callback),typeof s.enabled<"u"&&(o.enabled=s.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=o,o}_createRegisteredResourceTemplate(e,r,n,i,a){let o={resourceTemplate:n,title:r,metadata:i,readCallback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=o)),typeof u.title<"u"&&(o.title=u.title),typeof u.template<"u"&&(o.resourceTemplate=u.template),typeof u.metadata<"u"&&(o.metadata=u.metadata),typeof u.callback<"u"&&(o.readCallback=u.callback),typeof u.enabled<"u"&&(o.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=o;let s=n.uriTemplate.variableNames;return Array.isArray(s)&&s.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),o}_createRegisteredPrompt(e,r,n,i,a){let o={title:r,description:n,argsSchema:i===void 0?void 0:Xa(i),callback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:s=>{typeof s.name<"u"&&s.name!==e&&(delete this._registeredPrompts[e],s.name&&(this._registeredPrompts[s.name]=o)),typeof s.title<"u"&&(o.title=s.title),typeof s.description<"u"&&(o.description=s.description),typeof s.argsSchema<"u"&&(o.argsSchema=Xa(s.argsSchema)),typeof s.callback<"u"&&(o.callback=s.callback),typeof s.enabled<"u"&&(o.enabled=s.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=o,i&&Object.values(i).some(c=>{let u=c instanceof fr?c._def?.innerType:c;return I_(u)})&&this.setCompletionRequestHandler(),o}_createRegisteredTool(e,r,n,i,a,o,s,c,u){$_(e);let l={title:r,description:n,inputSchema:_2(i),outputSchema:_2(a),annotations:o,execution:s,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:p=>{typeof p.name<"u"&&p.name!==e&&(typeof p.name=="string"&&$_(p.name),delete this._registeredTools[e],p.name&&(this._registeredTools[p.name]=l)),typeof p.title<"u"&&(l.title=p.title),typeof p.description<"u"&&(l.description=p.description),typeof p.paramsSchema<"u"&&(l.inputSchema=Xa(p.paramsSchema)),typeof p.outputSchema<"u"&&(l.outputSchema=Xa(p.outputSchema)),typeof p.callback<"u"&&(l.handler=p.callback),typeof p.annotations<"u"&&(l.annotations=p.annotations),typeof p._meta<"u"&&(l._meta=p._meta),typeof p.enabled<"u"&&(l.enabled=p.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,i,a,o;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];O_(c)?(i=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!O_(r[0])&&(o=r.shift())):typeof c=="object"&&c!==null&&(o=r.shift())}let s=r[0];return this._createRegisteredTool(e,void 0,n,i,a,o,{taskSupport:"forbidden"},void 0,s)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:i,description:a,inputSchema:o,outputSchema:s,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,i,a,o,s,c,{taskSupport:"forbidden"},u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let i;r.length>1&&(i=r.shift());let a=r[0],o=this._createRegisteredPrompt(e,void 0,n,i,a);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:i,description:a,argsSchema:o}=r,s=this._createRegisteredPrompt(e,i,a,o,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var Lte={type:"object",properties:{}};function E2(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Ute(t){return"_def"in t||"_zod"in t||E2(t)}function O_(t){return typeof t!="object"||t===null||Ute(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(E2)}function _2(t){if(t)return O_(t)?Xa(t):t}function Fte(t){let e=Hi(t);return e?Object.entries(e).map(([r,n])=>{let i=jC(n),a=NC(n);return{name:r,description:i,required:!a}}):[]}function ca(t){let r=Hi(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=uf(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function S2(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Dl={completion:{values:[],hasMore:!1}};var T2={name:"@tableau/mcp-server",description:"Helping agents see and understand data.",version:"1.17.18",repository:{type:"git",url:"git+https://github.com/tableau/tableau-mcp.git"},homepage:"https://github.com/tableau/tableau-mcp",bugs:"https://github.com/tableau/tableau-mcp/issues",author:"Tableau",type:"commonjs",license:"Apache-2.0",keywords:["tableau","mcp"],bin:{"tableau-mcp-server":"./build/index.js"},exports:{".":"./build/index.js","./tracing":"./build/telemetry/tracing.js"},scripts:{build:"tsx src/scripts/build.ts","build:dev":"tsx src/scripts/build.ts --dev","build:docker":"docker build -t tableau-mcp .",":build:mcpb":"npx -y @anthropic-ai/mcpb pack . tableau-mcp.mcpb","build:mcpb":"run-s build:manifest :build:mcpb","build:manifest":"tsx src/scripts/createClaudeMcpBundleManifest.ts","start:http":"node build/index.js","start:http:apm":"node -r ./build/telemetry/tracing.js build/index.js","start:http:docker":"docker run -p 3927:3927 -i --rm --env-file env.list tableau-mcp",lint:"npm exec eslint",inspect:"npx @modelcontextprotocol/inspector --config config.json --server tableau",":inspect:http":"npx @modelcontextprotocol/inspector --config config.http.json --server tableau","inspect:http":"run-p start:http :inspect:http","inspect:docker":"npx @modelcontextprotocol/inspector --config config.docker.json --server tableau","inspect:docker:http":"run-p start:http:docker :inspect:http","build:inspect":"run-s build inspect","build:inspect:docker":"run-s build:docker inspect:docker","build:inspect:docker:http":"run-s build:docker inspect:docker:http",test:"vitest --config ./vitest.config.ts","test:e2e":"vitest --config ./vitest.config.e2e.ts","test:eval":"vitest --config ./vitest.config.eval.ts","test:oauth:embedded":"vitest --config ./vitest.config.oauth.embedded.ts",coverage:"vitest run --config ./vitest.config.ts --coverage","version:major":"npm version major --no-git-tag-version","version:minor":"npm version minor --no-git-tag-version","version:patch":"npm version patch --no-git-tag-version","docs:start":"npm run start --prefix docs"},dependencies:{"@modelcontextprotocol/sdk":"^1.26.0","@zodios/core":"^10.9.6","cookie-parser":"^1.4.7",cors:"^2.8.5",dotenv:"^16.5.0",express:"^5.1.0","fast-levenshtein":"^3.0.0",jose:"^6.0.12",ssrfcheck:"^1.2.0","ts-results-es":"^5.0.1",zod:"^3.24.3","zod-validation-error":"^4.0.1"},devDependencies:{"@anthropic-ai/mcpb":"^1.0.0","@eslint/eslintrc":"^3.3.1","@eslint/js":"^9.25.1","@openai/agents":"^0.1.9","@types/cookie-parser":"^1.4.10","@types/cors":"^2.8.19","@types/eslint__js":"^8.42.3","@types/express":"^5.0.3","@types/fast-levenshtein":"^0.0.1","@types/node":"^22.15.3","@types/supertest":"^6.0.3","@typescript-eslint/eslint-plugin":"^8.31.1","@typescript-eslint/parser":"^8.31.1","@vitest/coverage-v8":"^3.1.3",esbuild:"^0.25.5",eslint:"^9.25.1","eslint-config-prettier":"^10.1.2","eslint-plugin-prettier":"^5.2.6","eslint-plugin-simple-import-sort":"^12.1.1","npm-run-all":"^4.1.5",openai:"^5.23.2",prettier:"^3.5.3",supertest:"^7.1.4",tsx:"^4.21.0",typescript:"^5.8.3","typescript-eslint":"^8.31.1",vitest:"^3.1.3"},engines:{node:">=22.7.5"}};function Ll(t,e){return function(){return t.apply(e,arguments)}}var{toString:Bte}=Object.prototype,{getPrototypeOf:N_}=Object,{iterator:$m,toStringTag:k2}=Symbol,Om=(t=>e=>{let r=Bte.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),wn=t=>(t=t.toLowerCase(),e=>Om(e)===t),jm=t=>e=>typeof e===t,{isArray:Ks}=Array,Ws=jm("undefined");function Ul(t){return t!==null&&!Ws(t)&&t.constructor!==null&&!Ws(t.constructor)&&Sr(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var C2=wn("ArrayBuffer");function Hte(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&C2(t.buffer),e}var Zte=jm("string"),Sr=jm("function"),P2=jm("number"),Fl=t=>t!==null&&typeof t=="object",Wte=t=>t===!0||t===!1,Im=t=>{if(Om(t)!=="object")return!1;let e=N_(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(k2 in t)&&!($m in t)},Kte=t=>{if(!Fl(t)||Ul(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Gte=wn("Date"),Jte=wn("File"),Qte=wn("Blob"),Yte=wn("FileList"),Xte=t=>Fl(t)&&Sr(t.pipe),ere=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||Sr(t.append)&&((e=Om(t))==="formdata"||e==="object"&&Sr(t.toString)&&t.toString()==="[object FormData]"))},tre=wn("URLSearchParams"),[rre,nre,ire,are]=["ReadableStream","Request","Response","Headers"].map(wn),ore=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Vl(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),Ks(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{if(Ul(t))return;let a=r?Object.getOwnPropertyNames(t):Object.keys(t),o=a.length,s;for(n=0;n<o;n++)s=a[n],e.call(null,t[s],s,t)}}function R2(t,e){if(Ul(t))return null;e=e.toLowerCase();let r=Object.keys(t),n=r.length,i;for(;n-- >0;)if(i=r[n],e===i.toLowerCase())return i;return null}var wo=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,I2=t=>!Ws(t)&&t!==wo;function j_(){let{caseless:t,skipUndefined:e}=I2(this)&&this||{},r={},n=(i,a)=>{if(a==="__proto__"||a==="constructor"||a==="prototype")return;let o=t&&R2(r,a)||a;Im(r[o])&&Im(i)?r[o]=j_(r[o],i):Im(i)?r[o]=j_({},i):Ks(i)?r[o]=i.slice():(!e||!Ws(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&Vl(arguments[i],n);return r}var sre=(t,e,r,{allOwnKeys:n}={})=>(Vl(e,(i,a)=>{r&&Sr(i)?Object.defineProperty(t,a,{value:Ll(i,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,a,{value:i,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),t),cre=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),ure=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},lre=(t,e,r,n)=>{let i,a,o,s={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),a=i.length;a-- >0;)o=i[a],(!n||n(o,t,e))&&!s[o]&&(e[o]=t[o],s[o]=!0);t=r!==!1&&N_(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},pre=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;let n=t.indexOf(e,r);return n!==-1&&n===r},dre=t=>{if(!t)return null;if(Ks(t))return t;let e=t.length;if(!P2(e))return null;let r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},fre=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&N_(Uint8Array)),mre=(t,e)=>{let n=(t&&t[$m]).call(t),i;for(;(i=n.next())&&!i.done;){let a=i.value;e.call(t,a[0],a[1])}},hre=(t,e)=>{let r,n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},gre=wn("HTMLFormElement"),vre=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),A2=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),yre=wn("RegExp"),$2=(t,e)=>{let r=Object.getOwnPropertyDescriptors(t),n={};Vl(r,(i,a)=>{let o;(o=e(i,a,t))!==!1&&(n[a]=o||i)}),Object.defineProperties(t,n)},bre=t=>{$2(t,(e,r)=>{if(Sr(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=t[r];if(Sr(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},xre=(t,e)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return Ks(t)?n(t):n(String(t).split(e)),r},wre=()=>{},_re=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Sre(t){return!!(t&&Sr(t.append)&&t[k2]==="FormData"&&t[$m])}var Ere=t=>{let e=new Array(10),r=(n,i)=>{if(Fl(n)){if(e.indexOf(n)>=0)return;if(Ul(n))return n;if(!("toJSON"in n)){e[i]=n;let a=Ks(n)?[]:{};return Vl(n,(o,s)=>{let c=r(o,i+1);!Ws(c)&&(a[s]=c)}),e[i]=void 0,a}}return n};return r(t,0)},Tre=wn("AsyncFunction"),Are=t=>t&&(Fl(t)||Sr(t))&&Sr(t.then)&&Sr(t.catch),O2=((t,e)=>t?setImmediate:e?((r,n)=>(wo.addEventListener("message",({source:i,data:a})=>{i===wo&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),wo.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Sr(wo.postMessage)),kre=typeof queueMicrotask<"u"?queueMicrotask.bind(wo):typeof process<"u"&&process.nextTick||O2,Cre=t=>t!=null&&Sr(t[$m]),_={isArray:Ks,isArrayBuffer:C2,isBuffer:Ul,isFormData:ere,isArrayBufferView:Hte,isString:Zte,isNumber:P2,isBoolean:Wte,isObject:Fl,isPlainObject:Im,isEmptyObject:Kte,isReadableStream:rre,isRequest:nre,isResponse:ire,isHeaders:are,isUndefined:Ws,isDate:Gte,isFile:Jte,isBlob:Qte,isRegExp:yre,isFunction:Sr,isStream:Xte,isURLSearchParams:tre,isTypedArray:fre,isFileList:Yte,forEach:Vl,merge:j_,extend:sre,trim:ore,stripBOM:cre,inherits:ure,toFlatObject:lre,kindOf:Om,kindOfTest:wn,endsWith:pre,toArray:dre,forEachEntry:mre,matchAll:hre,isHTMLForm:gre,hasOwnProperty:A2,hasOwnProp:A2,reduceDescriptors:$2,freezeMethods:bre,toObjectSet:xre,toCamelCase:vre,noop:wre,toFiniteNumber:_re,findKey:R2,global:wo,isContextDefined:I2,isSpecCompliantForm:Sre,toJSONObject:Ere,isAsyncFn:Tre,isThenable:Are,setImmediate:O2,asap:kre,isIterable:Cre};var ur=class t extends Error{static from(e,r,n,i,a,o){let s=new t(e.message,r||e.code,n,i,a);return s.cause=e,s.name=e.name,o&&Object.assign(s,o),s}constructor(e,r,n,i,a){super(e),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),i&&(this.request=i),a&&(this.response=a,this.status=a.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:_.toJSONObject(this.config),code:this.code,status:this.status}}};ur.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ur.ERR_BAD_OPTION="ERR_BAD_OPTION";ur.ECONNABORTED="ECONNABORTED";ur.ETIMEDOUT="ETIMEDOUT";ur.ERR_NETWORK="ERR_NETWORK";ur.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ur.ERR_DEPRECATED="ERR_DEPRECATED";ur.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ur.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ur.ERR_CANCELED="ERR_CANCELED";ur.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ur.ERR_INVALID_URL="ERR_INVALID_URL";var $=ur;var NN=je(jN(),1),Bm=NN.default;function rS(t){return _.isPlainObject(t)||_.isArray(t)}function zN(t){return _.endsWith(t,"[]")?t.slice(0,-2):t}function qN(t,e,r){return t?t.concat(e).map(function(i,a){return i=zN(i),!r&&a?"["+i+"]":i}).join(r?".":""):e}function fie(t){return _.isArray(t)&&!t.some(rS)}var mie=_.toFlatObject(_,{},null,function(e){return/^is[A-Z]/.test(e)});function hie(t,e,r){if(!_.isObject(t))throw new TypeError("target must be an object");e=e||new(Bm||FormData),r=_.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,v){return!_.isUndefined(v[h])});let n=r.metaTokens,i=r.visitor||l,a=r.dots,o=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(e);if(!_.isFunction(i))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(_.isDate(m))return m.toISOString();if(_.isBoolean(m))return m.toString();if(!c&&_.isBlob(m))throw new $("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(m)||_.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function l(m,h,v){let y=m;if(m&&!v&&typeof m=="object"){if(_.endsWith(h,"{}"))h=n?h:h.slice(0,-2),m=JSON.stringify(m);else if(_.isArray(m)&&fie(m)||(_.isFileList(m)||_.endsWith(h,"[]"))&&(y=_.toArray(m)))return h=zN(h),y.forEach(function(w,S){!(_.isUndefined(w)||w===null)&&e.append(o===!0?qN([h],S,a):o===null?h:h+"[]",u(w))}),!1}return rS(m)?!0:(e.append(qN(v,h,a),u(m)),!1)}let p=[],f=Object.assign(mie,{defaultVisitor:l,convertValue:u,isVisitable:rS});function g(m,h){if(!_.isUndefined(m)){if(p.indexOf(m)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(m),_.forEach(m,function(y,x){(!(_.isUndefined(y)||y===null)&&i.call(e,y,_.isString(x)?x.trim():x,h,f))===!0&&g(y,h?h.concat(x):[x])}),p.pop()}}if(!_.isObject(t))throw new TypeError("data must be an object");return g(t),e}var pa=hie;function MN(t){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function DN(t,e){this._pairs=[],t&&pa(t,this,e)}var LN=DN.prototype;LN.append=function(e,r){this._pairs.push([e,r])};LN.toString=function(e){let r=e?function(n){return e.call(this,n,MN)}:MN;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var UN=DN;function gie(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function So(t,e,r){if(!e)return t;let n=r&&r.encode||gie,i=_.isFunction(r)?{serialize:r}:r,a=i&&i.serialize,o;if(a?o=a(e,i):o=_.isURLSearchParams(e)?e.toString():new UN(e,i).toString(n),o){let s=t.indexOf("#");s!==-1&&(t=t.slice(0,s)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}var nS=class{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){_.forEach(this.handlers,function(n){n!==null&&e(n)})}},iS=nS;var da={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0};var HN=je(require("crypto"),1);var FN=je(require("url"),1),VN=FN.default.URLSearchParams;var aS="abcdefghijklmnopqrstuvwxyz",BN="0123456789",ZN={DIGIT:BN,ALPHA:aS,ALPHA_DIGIT:aS+aS.toUpperCase()+BN},vie=(t=16,e=ZN.ALPHA_DIGIT)=>{let r="",{length:n}=e,i=new Uint32Array(t);HN.default.randomFillSync(i);for(let a=0;a<t;a++)r+=e[i[a]%n];return r},WN={isNode:!0,classes:{URLSearchParams:VN,FormData:Bm,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:ZN,generateString:vie,protocols:["http","https","file","data"]};var cS={};od(cS,{hasBrowserEnv:()=>sS,hasStandardBrowserEnv:()=>yie,hasStandardBrowserWebWorkerEnv:()=>bie,navigator:()=>oS,origin:()=>xie});var sS=typeof window<"u"&&typeof document<"u",oS=typeof navigator=="object"&&navigator||void 0,yie=sS&&(!oS||["ReactNative","NativeScript","NS"].indexOf(oS.product)<0),bie=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",xie=sS&&window.location.href||"http://localhost";var Oe={...cS,...WN};function uS(t,e){return pa(t,new Oe.classes.URLSearchParams,{visitor:function(r,n,i,a){return Oe.isNode&&_.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...e})}function wie(t){return _.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function _ie(t){let e={},r=Object.keys(t),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],e[a]=t[a];return e}function Sie(t){function e(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let s=Number.isFinite(+o),c=a>=r.length;return o=!o&&_.isArray(i)?i.length:o,c?(_.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!s):((!i[o]||!_.isObject(i[o]))&&(i[o]=[]),e(r,n,i[o],a)&&_.isArray(i[o])&&(i[o]=_ie(i[o])),!s)}if(_.isFormData(t)&&_.isFunction(t.entries)){let r={};return _.forEachEntry(t,(n,i)=>{e(wie(n),i,r,0)}),r}return null}var Hm=Sie;function Eie(t,e,r){if(_.isString(t))try{return(e||JSON.parse)(t),_.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var lS={transitional:da,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=_.isObject(e);if(a&&_.isHTMLForm(e)&&(e=new FormData(e)),_.isFormData(e))return i?JSON.stringify(Hm(e)):e;if(_.isArrayBuffer(e)||_.isBuffer(e)||_.isStream(e)||_.isFile(e)||_.isBlob(e)||_.isReadableStream(e))return e;if(_.isArrayBufferView(e))return e.buffer;if(_.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return uS(e,this.formSerializer).toString();if((s=_.isFileList(e))||n.indexOf("multipart/form-data")>-1){let c=this.env&&this.env.FormData;return pa(s?{"files[]":e}:e,c&&new c,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),Eie(e)):e}],transformResponse:[function(e){let r=this.transitional||lS.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(_.isResponse(e)||_.isReadableStream(e))return e;if(e&&_.isString(e)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(s){if(o)throw s.name==="SyntaxError"?$.from(s,$.ERR_BAD_RESPONSE,this,null,this.response):s}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Oe.classes.FormData,Blob:Oe.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],t=>{lS.headers[t]={}});var Xs=lS;var Tie=_.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"]),KN=t=>{let e={},r,n,i;return t&&t.split(`
|
|
105
|
+
]`;continue}i+=n[c],n[c]==="\\"?a=!0:o&&n[c]==="]"?o=!1:!o&&n[c]==="["&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return i}function ff(t,e){if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&t.keyType?._def.typeName===P.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,i)=>({...n,[i]:J(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",i]})??nt(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:J(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===P.ZodString&&t.keyType._def.checks?.length){let{type:n,...i}=df(t.keyType._def,e);return{...r,propertyNames:i}}else{if(t.keyType?._def.typeName===P.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===P.ZodBranded&&t.keyType._def.type._def.typeName===P.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...i}=pf(t.keyType._def,e);return{...r,propertyNames:i}}}return r}function JC(t,e){if(e.mapStrategy==="record")return ff(t,e);let r=J(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||nt(e),n=J(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||nt(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function QC(t){let e=t.values,n=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),i=Array.from(new Set(n.map(a=>typeof a)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:n}}function YC(t){return t.target==="openAi"?void 0:{not:nt({...t,currentPath:[...t.currentPath,"not"]})}}function XC(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Nu={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function tP(t,e){if(e.target==="openApi3")return eP(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Nu&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,a)=>{let o=Nu[a._def.typeName];return o&&!i.includes(o)?[...i,o]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,a)=>{let o=typeof a._def.value;switch(o){case"string":case"number":case"boolean":return[...i,o];case"bigint":return[...i,"integer"];case"object":if(a._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(n.length===r.length){let i=n.filter((a,o,s)=>s.indexOf(a)===o);return{type:i.length>1?i:i[0],enum:r.reduce((a,o)=>a.includes(o._def.value)?a:[...a,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(a=>!n.includes(a))],[])};return eP(t,e)}var eP=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,i)=>J(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function rP(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:Nu[t.innerType._def.typeName],nullable:!0}:{type:[Nu[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=J(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=J(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function nP(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",ex(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?be(r,"minimum",n.value,n.message,e):be(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),be(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?be(r,"maximum",n.value,n.message,e):be(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),be(r,"maximum",n.value,n.message,e));break;case"multipleOf":be(r,"multipleOf",n.value,n.message,e);break}return r}function iP(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},i=[],a=t.shape();for(let s in a){let c=a[s];if(c===void 0||c._def===void 0)continue;let u=ZH(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=J(c._def,{...e,currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]});l!==void 0&&(n.properties[s]=l,u||i.push(s))}i.length&&(n.required=i);let o=HH(t,e);return o!==void 0&&(n.additionalProperties=o),n}function HH(t,e){if(t.catchall._def.typeName!=="ZodNever")return J(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]});switch(t.unknownKeys){case"passthrough":return e.allowedAdditionalProperties;case"strict":return e.rejectedAdditionalProperties;case"strip":return e.removeAdditionalStrategy==="strict"?e.allowedAdditionalProperties:e.rejectedAdditionalProperties}}function ZH(t){try{return t.isOptional()}catch{return!0}}var aP=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return J(t.innerType._def,e);let r=J(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:nt(e)},r]}:nt(e)};var oP=(t,e)=>{if(e.pipeStrategy==="input")return J(t.in._def,e);if(e.pipeStrategy==="output")return J(t.out._def,e);let r=J(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=J(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(i=>i!==void 0)}};function sP(t,e){return J(t.type._def,e)}function cP(t,e){let n={type:"array",uniqueItems:!0,items:J(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&be(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&be(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function uP(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>J(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:J(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>J(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function lP(t){return{not:nt(t)}}function pP(t){return nt(t)}var dP=(t,e)=>J(t.innerType._def,e);var fP=(t,e,r)=>{switch(e){case P.ZodString:return df(t,r);case P.ZodNumber:return nP(t,r);case P.ZodObject:return iP(t,r);case P.ZodBigInt:return UC(t,r);case P.ZodBoolean:return FC();case P.ZodDate:return tx(t,r);case P.ZodUndefined:return lP(r);case P.ZodNull:return XC(r);case P.ZodArray:return LC(t,r);case P.ZodUnion:case P.ZodDiscriminatedUnion:return tP(t,r);case P.ZodIntersection:return WC(t,r);case P.ZodTuple:return uP(t,r);case P.ZodRecord:return ff(t,r);case P.ZodLiteral:return KC(t,r);case P.ZodEnum:return ZC(t);case P.ZodNativeEnum:return QC(t);case P.ZodNullable:return rP(t,r);case P.ZodOptional:return aP(t,r);case P.ZodMap:return JC(t,r);case P.ZodSet:return cP(t,r);case P.ZodLazy:return()=>t.getter()._def;case P.ZodPromise:return sP(t,r);case P.ZodNaN:case P.ZodNever:return YC(r);case P.ZodEffects:return HC(t,r);case P.ZodAny:return nt(r);case P.ZodUnknown:return pP(r);case P.ZodDefault:return BC(t,r);case P.ZodBranded:return pf(t,r);case P.ZodReadonly:return dP(t,r);case P.ZodCatch:return VC(t,r);case P.ZodPipeline:return oP(t,r);case P.ZodFunction:case P.ZodVoid:case P.ZodSymbol:return;default:return(n=>{})(e)}};function J(t,e,r=!1){let n=e.seen.get(t);if(e.override){let s=e.override?.(t,e,n,r);if(s!==zC)return s}if(n&&!r){let s=WH(n,e);if(s!==void 0)return s}let i={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,i);let a=fP(t,t.typeName,e),o=typeof a=="function"?J(a(),e):a;if(o&&KH(t,e,o),e.postProcess){let s=e.postProcess(o,t,e);return i.jsonSchema=o,s}return i.jsonSchema=o,o}var WH=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:lf(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),nt(e)):e.$refStrategy==="seen"?nt(e):void 0}},KH=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var ix=(t,e)=>{let r=DC(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:J(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??nt(r)}),{}):void 0,i=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=J(t._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??nt(r),o=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;o!==void 0&&(a.title=o),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=i===void 0?n?{...a,[r.definitionPath]:n}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:a}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in s||"oneOf"in s||"allOf"in s||"type"in s&&Array.isArray(s.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),s};function GH(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function ax(t,e){return Br(t)?gb(t,{target:GH(e?.target),io:e?.pipeStrategy??"input"}):ix(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function ox(t){let r=Hi(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=uf(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function sx(t,e){let r=Bi(t,e);if(!r.success)throw r.error;return r.data}var JH=6e4,mf=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Id,r=>{this._oncancel(r)}),this.setNotificationHandler(Od,r=>{this._onprogress(r)}),this.setRequestHandler(rs,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(jd,async(r,n)=>{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new L(H.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(qd,async(r,n)=>{let i=async()=>{let a=r.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(a,n.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else{let p=c,f=new L(p.error.code,p.error.message,p.error.data);l(f)}else{let p=s.type==="response"?"Response":"Error";this._onerror(new Error(`${p} handler missing for request ${u}`))}continue}await this._transport?.send(s.message,{relatedRequestId:n.requestId})}}let o=await this._taskStore.getTask(a,n.sessionId);if(!o)throw new L(H.InvalidParams,`Task not found: ${a}`);if(!Zi(o.status))return await this._waitForTaskUpdate(a,n.signal),await i();if(Zi(o.status)){let s=await this._taskStore.getTaskResult(a,n.sessionId);return this._clearTaskQueue(a),{...s,_meta:{...s._meta,[ji]:{taskId:a}}}}return await i()};return await i()}),this.setRequestHandler(zd,async(r,n)=>{try{let{tasks:i,nextCursor:a}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:i,nextCursor:a,_meta:{}}}catch(i){throw new L(H.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(Dd,async(r,n)=>{try{let i=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!i)throw new L(H.InvalidParams,`Task not found: ${r.params.taskId}`);if(Zi(i.status))throw new L(H.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let a=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!a)throw new L(H.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...a}}catch(i){throw i instanceof L?i:new L(H.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,i,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(i,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:a,onTimeout:i})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),L.fromError(H.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=a=>{n?.(a),this._onerror(a)};let i=this._transport?.onmessage;this._transport.onmessage=(a,o)=>{i?.(a,o),ri(a)||ts(a)?this._onresponse(a):Ni(a)?this._onrequest(a,o):Kk(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=L.fromError(H.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,i=this._transport,a=e.params?._meta?.[ji]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:H.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},i?.sessionId).catch(p=>this._onerror(new Error(`Failed to enqueue error response: ${p}`))):i?.send(l).catch(p=>this._onerror(new Error(`Failed to send an error response: ${p}`)));return}let o=new AbortController;this._requestHandlerAbortControllers.set(e.id,o);let s=Hk(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,i?.sessionId):void 0,u={signal:o.signal,sessionId:i?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(o.signal.aborted)return;let p={relatedRequestId:e.id};a&&(p.relatedTask={taskId:a}),await this.notification(l,p)},sendRequest:async(l,p,f)=>{if(o.signal.aborted)throw new L(H.ConnectionClosed,"Request was cancelled");let g={...f,relatedRequestId:e.id};a&&!g.relatedTask&&(g.relatedTask={taskId:a});let m=g.relatedTask?.taskId??a;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,p,g)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:a,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(o.signal.aborted)return;let p={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:p,timestamp:Date.now()},i?.sessionId):await i?.send(p)},async l=>{if(o.signal.aborted)return;let p={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:H.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:p,timestamp:Date.now()},i?.sessionId):await i?.send(p)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,i=Number(r),a=this._progressHandlers.get(i);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let o=this._responseHandlers.get(i),s=this._timeoutInfo.get(i);if(s&&o&&s.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(c){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),o(c);return}a(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),ri(e))n(e);else{let o=new L(e.error.code,e.error.message,e.error.data);n(o)}return}let i=this._responseHandlers.get(r);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let a=!1;if(ri(e)&&e.result&&typeof e.result=="object"){let o=e.result;if(o.task&&typeof o.task=="object"){let s=o.task;typeof s.taskId=="string"&&(a=!0,this._taskProgressTokens.set(s.taskId,r))}}if(a||this._progressHandlers.delete(r),ri(e))i(e);else{let o=L.fromError(e.error.code,e.error.message,e.error.data);i(o)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:i}=n??{};if(!i){try{yield{type:"result",result:await this.request(e,r,n)}}catch(o){yield{type:"error",error:o instanceof L?o:new L(H.InternalError,String(o))}}return}let a;try{let o=await this.request(e,ns,n);if(o.task)a=o.task.taskId,yield{type:"taskCreated",task:o.task};else throw new L(H.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:a},n);if(yield{type:"taskStatus",task:s},Zi(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)}:s.status==="failed"?yield{type:"error",error:new L(H.InternalError,`Task ${a} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new L(H.InternalError,`Task ${a} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(o){yield{type:"error",error:o instanceof L?o:new L(H.InternalError,String(o))}}}request(e,r,n){let{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o,task:s,relatedTask:c}=n??{};return new Promise((u,l)=>{let p=x=>{l(x)};if(!this._transport){p(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),s&&this.assertTaskCapability(e.method)}catch(x){p(x);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,g={...e,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),g.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),s&&(g.params={...g.params,task:s}),c&&(g.params={...g.params,_meta:{...g.params?._meta||{},[ji]:c}});let m=x=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(x)}},{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(S=>this._onerror(new Error(`Failed to send cancellation: ${S}`)));let w=x instanceof L?x:new L(H.RequestTimeout,String(x));l(w)};this._responseHandlers.set(f,x=>{if(!n?.signal?.aborted){if(x instanceof Error)return l(x);try{let w=Bi(r,x.result);w.success?u(w.data):l(w.error)}catch(w){l(w)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??JH,v=()=>m(L.fromError(H.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,v,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let x=w=>{let S=this._responseHandlers.get(f);S?S(w):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,x),this._enqueueTaskMessage(y,{type:"request",message:g,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(f),l(w)})}else this._transport.send(g,{relatedRequestId:i,resumptionToken:a,onresumptiontoken:o}).catch(x=>{this._cleanupTimeout(f),l(x)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Nd,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Md,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Jk,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let s={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[ji]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let s={...e,jsonrpc:"2.0"};r?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[ji]:r.relatedTask}}}),this._transport?.send(s,r).catch(c=>this._onerror(c))});return}let o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[ji]:r.relatedTask}}}),await this._transport.send(o,r)}setRequestHandler(e,r){let n=ox(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,a)=>{let o=sx(e,i);return Promise.resolve(r(o,a))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=ox(e);this._notificationHandlers.set(n,i=>{let a=sx(e,i);return Promise.resolve(r(a))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,i)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let i of n)if(i.type==="request"&&Ni(i.message)){let a=i.message.id,o=this._requestResolvers.get(a);o?(o(new L(H.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let i=await this._taskStore?.getTask(e);i?.pollInterval&&(n=i.pollInterval)}catch{}return new Promise((i,a)=>{if(r.aborted){a(new L(H.InvalidRequest,"Request cancelled"));return}let o=setTimeout(i,n);r.addEventListener("abort",()=>{clearTimeout(o),a(new L(H.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async i=>{if(!e)throw new Error("No request provided");return await n.createTask(i,e.id,{method:e.method,params:e.params},r)},getTask:async i=>{let a=await n.getTask(i,r);if(!a)throw new L(H.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(i,a,o)=>{await n.storeTaskResult(i,a,o,r);let s=await n.getTask(i,r);if(s){let c=Eu.parse({method:"notifications/tasks/status",params:s});await this.notification(c),Zi(s.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>n.getTaskResult(i,r),updateTaskStatus:async(i,a,o)=>{let s=await n.getTask(i,r);if(!s)throw new L(H.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Zi(s.status))throw new L(H.InvalidParams,`Cannot update task "${i}" from terminal status "${s.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(i,a,o,r);let c=await n.getTask(i,r);if(c){let u=Eu.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Zi(c.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>n.listTasks(i,r)}}};function mP(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function hP(t,e){let r={...t};for(let n in e){let i=n,a=e[i];if(a===void 0)continue;let o=r[i];mP(o)&&mP(a)?r[i]={...o,...a}:r[i]=a}return r}var h2=je(UI(),1),g2=je(m2(),1);function qte(){let t=new h2.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,g2.default)(t),t}var Am=class{constructor(e){this._ajv=e??qte()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var km=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function v2(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function y2(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var Cm=class extends mf{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Au.options.map((n,i)=>[n,i])),this.isMessageIgnored=(n,i)=>{let a=this._loggingLevels.get(i);return a?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(a):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Am,this.setRequestHandler($d,n=>this._oninitialize(n)),this.setNotificationHandler(Ib,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(ku,async(n,i)=>{let a=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:o}=n.params,s=Au.safeParse(o);return s.success&&this._loggingLevels.set(a,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new km(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=hP(this._capabilities,e)}setRequestHandler(e,r){let i=Hi(e)?.method;if(!i)throw new Error("Schema is missing a method literal");let a;if(Br(i)){let s=i;a=s._zod?.def?.value??s.value}else{let s=i;a=s._def?.value??s.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");if(a==="tools/call"){let s=async(c,u)=>{let l=Bi(zi,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new L(H.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:p}=l.data,f=await Promise.resolve(r(c,u));if(p.task){let m=Bi(ns,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new L(H.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let g=Bi(Zd,f);if(!g.success){let m=g.error instanceof Error?g.error.message:String(g.error);throw new L(H.InvalidParams,`Invalid tools/call result: ${m}`)}return g.data};return super.setRequestHandler(e,s)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){y2(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&v2(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:vu.includes(r)?r:kb,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Rd)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],i=Array.isArray(n.content)?n.content:[n.content],a=i.some(u=>u.type==="tool_result"),o=e.messages.length>1?e.messages[e.messages.length-2]:void 0,s=o?Array.isArray(o.content)?o.content:[o.content]:[],c=s.some(u=>u.type==="tool_use");if(a){if(i.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(s.filter(p=>p.type==="tool_use").map(p=>p.id)),l=new Set(i.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==l.size||![...u].every(p=>l.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Db,r):this.request({method:"sampling/createMessage",params:e},Mb,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let i=e;return this.request({method:"elicitation/create",params:i},Wd,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let i=e.mode==="form"?e:{...e,mode:"form"},a=await this.request({method:"elicitation/create",params:i},Wd,r);if(a.action==="accept"&&a.content&&i.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(i.requestedSchema)(a.content);if(!s.valid)throw new L(H.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(o){throw o instanceof L?o:new L(H.InternalError,`Error validating elicitation response: ${o instanceof Error?o.message:String(o)}`)}return a}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},Lb,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var x2=Symbol.for("mcp.completable");function I_(t){return!!t&&typeof t=="object"&&x2 in t}function w2(t){return t[x2]?.complete}var b2;(function(t){t.Completable="McpCompletable"})(b2||(b2={}));var zte=/^[A-Za-z0-9._-]{1,128}$/;function Mte(t){let e=[];if(t.length===0)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(t.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${t.length})`]};if(t.includes(" ")&&e.push("Tool name contains spaces, which may cause parsing issues"),t.includes(",")&&e.push("Tool name contains commas, which may cause parsing issues"),(t.startsWith("-")||t.endsWith("-"))&&e.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(t.startsWith(".")||t.endsWith("."))&&e.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!zte.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,i,a)=>a.indexOf(n)===i);return e.push(`Tool name contains invalid characters: ${r.map(n=>`"${n}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:e}}return{isValid:!0,warnings:e}}function Dte(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let r of e)console.warn(` - ${r}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}function $_(t){let e=Mte(t);return Dte(t,e.warnings),e.isValid}var Pm=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let i={taskSupport:"required",...r.execution};if(i.taskSupport==="forbidden")throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,r.title,r.description,r.inputSchema,r.outputSchema,r.annotations,i,r._meta,n)}};var Rm=class{constructor(e,r){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new Cm(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Pm(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(ca(Hd)),this.server.assertCanSetRequestHandler(ca(zi)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Hd,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let i=ms(r.inputSchema);return i?ax(i,{strictUnions:!0,pipeStrategy:"input"}):Lte})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let i=ms(r.outputSchema);i&&(n.outputSchema=ax(i,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(zi,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new L(H.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new L(H.InvalidParams,`Tool ${e.params.name} disabled`);let i=!!e.params.task,a=n.execution?.taskSupport,o="createTask"in n.handler;if((a==="required"||a==="optional")&&!o)throw new L(H.InternalError,`Tool ${e.params.name} has taskSupport '${a}' but was not registered with registerToolTask`);if(a==="required"&&!i)throw new L(H.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(a==="optional"&&!i&&o)return await this.handleAutomaticTaskPolling(n,e,r);let s=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,s,r);return i||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof L&&n.code===H.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;let a=ms(e.inputSchema)??e.inputSchema,o=await sf(a,r);if(!o.success){let s="error"in o?o.error:"Unknown error",c=cf(s);throw new L(H.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return o.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new L(H.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let i=ms(e.outputSchema),a=await sf(i,r.structuredContent);if(!a.success){let o="error"in a?a.error:"Unknown error",s=cf(o);throw new L(H.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${s}`)}}async executeToolHandler(e,r,n){let i=e.handler;if("createTask"in i){if(!n.taskStore)throw new Error("No task store provided.");let o={...n,taskStore:n.taskStore};if(e.inputSchema){let s=i;return await Promise.resolve(s.createTask(r,o))}else{let s=i;return await Promise.resolve(s.createTask(o))}}if(e.inputSchema){let o=i;return await Promise.resolve(o(r,n))}else{let o=i;return await Promise.resolve(o(n))}}async handleAutomaticTaskPolling(e,r,n){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");let i=await this.validateToolInput(e,r.params.arguments,r.params.name),a=e.handler,o={...n,taskStore:n.taskStore},s=i?await Promise.resolve(a.createTask(i,o)):await Promise.resolve(a.createTask(o)),c=s.task.taskId,u=s.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(f=>setTimeout(f,l));let p=await n.taskStore.getTask(c);if(!p)throw new L(H.InternalError,`Task ${c} not found during polling`);u=p}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(ca(Kd)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Kd,async e=>{switch(e.params.ref.type){case"ref/prompt":return rC(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return nC(e),this.handleResourceCompletion(e,e.params.ref);default:throw new L(H.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new L(H.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new L(H.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Dl;let a=Hi(n.argsSchema)?.[e.params.argument.name];if(!I_(a))return Dl;let o=w2(a);if(!o)return Dl;let s=await o(e.params.argument.value,e.params.context);return S2(s)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(o=>o.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Dl;throw new L(H.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let i=n.resourceTemplate.completeCallback(e.params.argument.name);if(!i)return Dl;let a=await i(e.params.argument.value,e.params.context);return S2(a)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(ca(Ld)),this.server.assertCanSetRequestHandler(ca(Ud)),this.server.assertCanSetRequestHandler(ca(Fd)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Ld,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([a,o])=>o.enabled).map(([a,o])=>({uri:a,name:o.name,...o.metadata})),i=[];for(let a of Object.values(this._registeredResourceTemplates)){if(!a.resourceTemplate.listCallback)continue;let o=await a.resourceTemplate.listCallback(r);for(let s of o.resources)i.push({...a.metadata,...s})}return{resources:[...n,...i]}}),this.server.setRequestHandler(Ud,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Fd,async(e,r)=>{let n=new URL(e.params.uri),i=this._registeredResources[n.toString()];if(i){if(!i.enabled)throw new L(H.InvalidParams,`Resource ${n} disabled`);return i.readCallback(n,r)}for(let a of Object.values(this._registeredResourceTemplates)){let o=a.resourceTemplate.uriTemplate.match(n.toString());if(o)return a.readCallback(n,o,r)}throw new L(H.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(ca(Vd)),this.server.assertCanSetRequestHandler(ca(Bd)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Vd,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?Fte(r.argsSchema):void 0}))})),this.server.setRequestHandler(Bd,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new L(H.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new L(H.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let i=ms(n.argsSchema),a=await sf(i,e.params.arguments);if(!a.success){let c="error"in a?a.error:"Unknown error",u=cf(c);throw new L(H.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let o=a.data,s=n.callback;return await Promise.resolve(s(o,r))}else{let i=n.callback;return await Promise.resolve(i(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let i;typeof n[0]=="object"&&(i=n.shift());let a=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let o=this._createRegisteredResource(e,void 0,r,i,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let o=this._createRegisteredResourceTemplate(e,void 0,r,i,a);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),o}}registerResource(e,r,n,i){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let a=this._createRegisteredResource(e,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let a=this._createRegisteredResourceTemplate(e,n.title,r,n,i);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),a}}_createRegisteredResource(e,r,n,i,a){let o={name:e,title:r,metadata:i,readCallback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({uri:null}),update:s=>{typeof s.uri<"u"&&s.uri!==n&&(delete this._registeredResources[n],s.uri&&(this._registeredResources[s.uri]=o)),typeof s.name<"u"&&(o.name=s.name),typeof s.title<"u"&&(o.title=s.title),typeof s.metadata<"u"&&(o.metadata=s.metadata),typeof s.callback<"u"&&(o.readCallback=s.callback),typeof s.enabled<"u"&&(o.enabled=s.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=o,o}_createRegisteredResourceTemplate(e,r,n,i,a){let o={resourceTemplate:n,title:r,metadata:i,readCallback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=o)),typeof u.title<"u"&&(o.title=u.title),typeof u.template<"u"&&(o.resourceTemplate=u.template),typeof u.metadata<"u"&&(o.metadata=u.metadata),typeof u.callback<"u"&&(o.readCallback=u.callback),typeof u.enabled<"u"&&(o.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=o;let s=n.uriTemplate.variableNames;return Array.isArray(s)&&s.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),o}_createRegisteredPrompt(e,r,n,i,a){let o={title:r,description:n,argsSchema:i===void 0?void 0:Xa(i),callback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:s=>{typeof s.name<"u"&&s.name!==e&&(delete this._registeredPrompts[e],s.name&&(this._registeredPrompts[s.name]=o)),typeof s.title<"u"&&(o.title=s.title),typeof s.description<"u"&&(o.description=s.description),typeof s.argsSchema<"u"&&(o.argsSchema=Xa(s.argsSchema)),typeof s.callback<"u"&&(o.callback=s.callback),typeof s.enabled<"u"&&(o.enabled=s.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=o,i&&Object.values(i).some(c=>{let u=c instanceof fr?c._def?.innerType:c;return I_(u)})&&this.setCompletionRequestHandler(),o}_createRegisteredTool(e,r,n,i,a,o,s,c,u){$_(e);let l={title:r,description:n,inputSchema:_2(i),outputSchema:_2(a),annotations:o,execution:s,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:p=>{typeof p.name<"u"&&p.name!==e&&(typeof p.name=="string"&&$_(p.name),delete this._registeredTools[e],p.name&&(this._registeredTools[p.name]=l)),typeof p.title<"u"&&(l.title=p.title),typeof p.description<"u"&&(l.description=p.description),typeof p.paramsSchema<"u"&&(l.inputSchema=Xa(p.paramsSchema)),typeof p.outputSchema<"u"&&(l.outputSchema=Xa(p.outputSchema)),typeof p.callback<"u"&&(l.handler=p.callback),typeof p.annotations<"u"&&(l.annotations=p.annotations),typeof p._meta<"u"&&(l._meta=p._meta),typeof p.enabled<"u"&&(l.enabled=p.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}tool(e,...r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let n,i,a,o;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];O_(c)?(i=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!O_(r[0])&&(o=r.shift())):typeof c=="object"&&c!==null&&(o=r.shift())}let s=r[0];return this._createRegisteredTool(e,void 0,n,i,a,o,{taskSupport:"forbidden"},void 0,s)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:i,description:a,inputSchema:o,outputSchema:s,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,i,a,o,s,c,{taskSupport:"forbidden"},u,n)}prompt(e,...r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let n;typeof r[0]=="string"&&(n=r.shift());let i;r.length>1&&(i=r.shift());let a=r[0],o=this._createRegisteredPrompt(e,void 0,n,i,a);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:i,description:a,argsSchema:o}=r,s=this._createRegisteredPrompt(e,i,a,o,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),s}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var Lte={type:"object",properties:{}};function E2(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Ute(t){return"_def"in t||"_zod"in t||E2(t)}function O_(t){return typeof t!="object"||t===null||Ute(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(E2)}function _2(t){if(t)return O_(t)?Xa(t):t}function Fte(t){let e=Hi(t);return e?Object.entries(e).map(([r,n])=>{let i=jC(n),a=NC(n);return{name:r,description:i,required:!a}}):[]}function ca(t){let r=Hi(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=uf(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function S2(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Dl={completion:{values:[],hasMore:!1}};var T2={name:"@tableau/mcp-server",description:"Helping agents see and understand data.",version:"1.17.19",repository:{type:"git",url:"git+https://github.com/tableau/tableau-mcp.git"},homepage:"https://github.com/tableau/tableau-mcp",bugs:"https://github.com/tableau/tableau-mcp/issues",author:"Tableau",type:"commonjs",license:"Apache-2.0",keywords:["tableau","mcp"],bin:{"tableau-mcp-server":"./build/index.js"},exports:{".":"./build/index.js","./tracing":"./build/telemetry/tracing.js"},scripts:{build:"tsx src/scripts/build.ts","build:dev":"tsx src/scripts/build.ts --dev","build:docker":"docker build -t tableau-mcp .",":build:mcpb":"npx -y @anthropic-ai/mcpb pack . tableau-mcp.mcpb","build:mcpb":"run-s build:manifest :build:mcpb","build:manifest":"tsx src/scripts/createClaudeMcpBundleManifest.ts","start:http":"node build/index.js","start:http:apm":"node -r ./build/telemetry/tracing.js build/index.js","start:http:docker":"docker run -p 3927:3927 -i --rm --env-file env.list tableau-mcp",lint:"npm exec eslint",inspect:"npx @modelcontextprotocol/inspector --config config.json --server tableau",":inspect:http":"npx @modelcontextprotocol/inspector --config config.http.json --server tableau","inspect:http":"run-p start:http :inspect:http","inspect:docker":"npx @modelcontextprotocol/inspector --config config.docker.json --server tableau","inspect:docker:http":"run-p start:http:docker :inspect:http","build:inspect":"run-s build inspect","build:inspect:docker":"run-s build:docker inspect:docker","build:inspect:docker:http":"run-s build:docker inspect:docker:http",test:"vitest --config ./vitest.config.ts","test:e2e":"vitest --config ./vitest.config.e2e.ts","test:eval":"vitest --config ./vitest.config.eval.ts","test:oauth:embedded":"vitest --config ./vitest.config.oauth.embedded.ts",coverage:"vitest run --config ./vitest.config.ts --coverage","version:major":"npm version major --no-git-tag-version","version:minor":"npm version minor --no-git-tag-version","version:patch":"npm version patch --no-git-tag-version","docs:start":"npm run start --prefix docs"},dependencies:{"@modelcontextprotocol/sdk":"^1.26.0","@zodios/core":"^10.9.6","cookie-parser":"^1.4.7",cors:"^2.8.5",dotenv:"^16.5.0",express:"^5.1.0","fast-levenshtein":"^3.0.0",jose:"^6.0.12",ssrfcheck:"^1.2.0","ts-results-es":"^5.0.1",zod:"^3.24.3","zod-validation-error":"^4.0.1"},devDependencies:{"@anthropic-ai/mcpb":"^1.0.0","@eslint/eslintrc":"^3.3.1","@eslint/js":"^9.25.1","@openai/agents":"^0.1.9","@types/cookie-parser":"^1.4.10","@types/cors":"^2.8.19","@types/eslint__js":"^8.42.3","@types/express":"^5.0.3","@types/fast-levenshtein":"^0.0.1","@types/node":"^22.15.3","@types/supertest":"^6.0.3","@typescript-eslint/eslint-plugin":"^8.31.1","@typescript-eslint/parser":"^8.31.1","@vitest/coverage-v8":"^3.1.3",esbuild:"^0.25.5",eslint:"^9.25.1","eslint-config-prettier":"^10.1.2","eslint-plugin-prettier":"^5.2.6","eslint-plugin-simple-import-sort":"^12.1.1","npm-run-all":"^4.1.5",openai:"^5.23.2",prettier:"^3.5.3",supertest:"^7.1.4",tsx:"^4.21.0",typescript:"^5.8.3","typescript-eslint":"^8.31.1",vitest:"^3.1.3"},engines:{node:">=22.7.5"}};function Ll(t,e){return function(){return t.apply(e,arguments)}}var{toString:Bte}=Object.prototype,{getPrototypeOf:N_}=Object,{iterator:$m,toStringTag:k2}=Symbol,Om=(t=>e=>{let r=Bte.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),wn=t=>(t=t.toLowerCase(),e=>Om(e)===t),jm=t=>e=>typeof e===t,{isArray:Ks}=Array,Ws=jm("undefined");function Ul(t){return t!==null&&!Ws(t)&&t.constructor!==null&&!Ws(t.constructor)&&Sr(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}var C2=wn("ArrayBuffer");function Hte(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&C2(t.buffer),e}var Zte=jm("string"),Sr=jm("function"),P2=jm("number"),Fl=t=>t!==null&&typeof t=="object",Wte=t=>t===!0||t===!1,Im=t=>{if(Om(t)!=="object")return!1;let e=N_(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(k2 in t)&&!($m in t)},Kte=t=>{if(!Fl(t)||Ul(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},Gte=wn("Date"),Jte=wn("File"),Qte=wn("Blob"),Yte=wn("FileList"),Xte=t=>Fl(t)&&Sr(t.pipe),ere=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||Sr(t.append)&&((e=Om(t))==="formdata"||e==="object"&&Sr(t.toString)&&t.toString()==="[object FormData]"))},tre=wn("URLSearchParams"),[rre,nre,ire,are]=["ReadableStream","Request","Response","Headers"].map(wn),ore=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Vl(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),Ks(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{if(Ul(t))return;let a=r?Object.getOwnPropertyNames(t):Object.keys(t),o=a.length,s;for(n=0;n<o;n++)s=a[n],e.call(null,t[s],s,t)}}function R2(t,e){if(Ul(t))return null;e=e.toLowerCase();let r=Object.keys(t),n=r.length,i;for(;n-- >0;)if(i=r[n],e===i.toLowerCase())return i;return null}var wo=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,I2=t=>!Ws(t)&&t!==wo;function j_(){let{caseless:t,skipUndefined:e}=I2(this)&&this||{},r={},n=(i,a)=>{if(a==="__proto__"||a==="constructor"||a==="prototype")return;let o=t&&R2(r,a)||a;Im(r[o])&&Im(i)?r[o]=j_(r[o],i):Im(i)?r[o]=j_({},i):Ks(i)?r[o]=i.slice():(!e||!Ws(i))&&(r[o]=i)};for(let i=0,a=arguments.length;i<a;i++)arguments[i]&&Vl(arguments[i],n);return r}var sre=(t,e,r,{allOwnKeys:n}={})=>(Vl(e,(i,a)=>{r&&Sr(i)?Object.defineProperty(t,a,{value:Ll(i,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,a,{value:i,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),t),cre=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),ure=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},lre=(t,e,r,n)=>{let i,a,o,s={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),a=i.length;a-- >0;)o=i[a],(!n||n(o,t,e))&&!s[o]&&(e[o]=t[o],s[o]=!0);t=r!==!1&&N_(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},pre=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;let n=t.indexOf(e,r);return n!==-1&&n===r},dre=t=>{if(!t)return null;if(Ks(t))return t;let e=t.length;if(!P2(e))return null;let r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},fre=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&N_(Uint8Array)),mre=(t,e)=>{let n=(t&&t[$m]).call(t),i;for(;(i=n.next())&&!i.done;){let a=i.value;e.call(t,a[0],a[1])}},hre=(t,e)=>{let r,n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},gre=wn("HTMLFormElement"),vre=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),A2=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),yre=wn("RegExp"),$2=(t,e)=>{let r=Object.getOwnPropertyDescriptors(t),n={};Vl(r,(i,a)=>{let o;(o=e(i,a,t))!==!1&&(n[a]=o||i)}),Object.defineProperties(t,n)},bre=t=>{$2(t,(e,r)=>{if(Sr(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=t[r];if(Sr(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},xre=(t,e)=>{let r={},n=i=>{i.forEach(a=>{r[a]=!0})};return Ks(t)?n(t):n(String(t).split(e)),r},wre=()=>{},_re=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Sre(t){return!!(t&&Sr(t.append)&&t[k2]==="FormData"&&t[$m])}var Ere=t=>{let e=new Array(10),r=(n,i)=>{if(Fl(n)){if(e.indexOf(n)>=0)return;if(Ul(n))return n;if(!("toJSON"in n)){e[i]=n;let a=Ks(n)?[]:{};return Vl(n,(o,s)=>{let c=r(o,i+1);!Ws(c)&&(a[s]=c)}),e[i]=void 0,a}}return n};return r(t,0)},Tre=wn("AsyncFunction"),Are=t=>t&&(Fl(t)||Sr(t))&&Sr(t.then)&&Sr(t.catch),O2=((t,e)=>t?setImmediate:e?((r,n)=>(wo.addEventListener("message",({source:i,data:a})=>{i===wo&&a===r&&n.length&&n.shift()()},!1),i=>{n.push(i),wo.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Sr(wo.postMessage)),kre=typeof queueMicrotask<"u"?queueMicrotask.bind(wo):typeof process<"u"&&process.nextTick||O2,Cre=t=>t!=null&&Sr(t[$m]),_={isArray:Ks,isArrayBuffer:C2,isBuffer:Ul,isFormData:ere,isArrayBufferView:Hte,isString:Zte,isNumber:P2,isBoolean:Wte,isObject:Fl,isPlainObject:Im,isEmptyObject:Kte,isReadableStream:rre,isRequest:nre,isResponse:ire,isHeaders:are,isUndefined:Ws,isDate:Gte,isFile:Jte,isBlob:Qte,isRegExp:yre,isFunction:Sr,isStream:Xte,isURLSearchParams:tre,isTypedArray:fre,isFileList:Yte,forEach:Vl,merge:j_,extend:sre,trim:ore,stripBOM:cre,inherits:ure,toFlatObject:lre,kindOf:Om,kindOfTest:wn,endsWith:pre,toArray:dre,forEachEntry:mre,matchAll:hre,isHTMLForm:gre,hasOwnProperty:A2,hasOwnProp:A2,reduceDescriptors:$2,freezeMethods:bre,toObjectSet:xre,toCamelCase:vre,noop:wre,toFiniteNumber:_re,findKey:R2,global:wo,isContextDefined:I2,isSpecCompliantForm:Sre,toJSONObject:Ere,isAsyncFn:Tre,isThenable:Are,setImmediate:O2,asap:kre,isIterable:Cre};var ur=class t extends Error{static from(e,r,n,i,a,o){let s=new t(e.message,r||e.code,n,i,a);return s.cause=e,s.name=e.name,o&&Object.assign(s,o),s}constructor(e,r,n,i,a){super(e),this.name="AxiosError",this.isAxiosError=!0,r&&(this.code=r),n&&(this.config=n),i&&(this.request=i),a&&(this.response=a,this.status=a.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:_.toJSONObject(this.config),code:this.code,status:this.status}}};ur.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";ur.ERR_BAD_OPTION="ERR_BAD_OPTION";ur.ECONNABORTED="ECONNABORTED";ur.ETIMEDOUT="ETIMEDOUT";ur.ERR_NETWORK="ERR_NETWORK";ur.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";ur.ERR_DEPRECATED="ERR_DEPRECATED";ur.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";ur.ERR_BAD_REQUEST="ERR_BAD_REQUEST";ur.ERR_CANCELED="ERR_CANCELED";ur.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";ur.ERR_INVALID_URL="ERR_INVALID_URL";var $=ur;var NN=je(jN(),1),Bm=NN.default;function rS(t){return _.isPlainObject(t)||_.isArray(t)}function zN(t){return _.endsWith(t,"[]")?t.slice(0,-2):t}function qN(t,e,r){return t?t.concat(e).map(function(i,a){return i=zN(i),!r&&a?"["+i+"]":i}).join(r?".":""):e}function fie(t){return _.isArray(t)&&!t.some(rS)}var mie=_.toFlatObject(_,{},null,function(e){return/^is[A-Z]/.test(e)});function hie(t,e,r){if(!_.isObject(t))throw new TypeError("target must be an object");e=e||new(Bm||FormData),r=_.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,v){return!_.isUndefined(v[h])});let n=r.metaTokens,i=r.visitor||l,a=r.dots,o=r.indexes,c=(r.Blob||typeof Blob<"u"&&Blob)&&_.isSpecCompliantForm(e);if(!_.isFunction(i))throw new TypeError("visitor must be a function");function u(m){if(m===null)return"";if(_.isDate(m))return m.toISOString();if(_.isBoolean(m))return m.toString();if(!c&&_.isBlob(m))throw new $("Blob is not supported. Use a Buffer instead.");return _.isArrayBuffer(m)||_.isTypedArray(m)?c&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function l(m,h,v){let y=m;if(m&&!v&&typeof m=="object"){if(_.endsWith(h,"{}"))h=n?h:h.slice(0,-2),m=JSON.stringify(m);else if(_.isArray(m)&&fie(m)||(_.isFileList(m)||_.endsWith(h,"[]"))&&(y=_.toArray(m)))return h=zN(h),y.forEach(function(w,S){!(_.isUndefined(w)||w===null)&&e.append(o===!0?qN([h],S,a):o===null?h:h+"[]",u(w))}),!1}return rS(m)?!0:(e.append(qN(v,h,a),u(m)),!1)}let p=[],f=Object.assign(mie,{defaultVisitor:l,convertValue:u,isVisitable:rS});function g(m,h){if(!_.isUndefined(m)){if(p.indexOf(m)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(m),_.forEach(m,function(y,x){(!(_.isUndefined(y)||y===null)&&i.call(e,y,_.isString(x)?x.trim():x,h,f))===!0&&g(y,h?h.concat(x):[x])}),p.pop()}}if(!_.isObject(t))throw new TypeError("data must be an object");return g(t),e}var pa=hie;function MN(t){let e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function DN(t,e){this._pairs=[],t&&pa(t,this,e)}var LN=DN.prototype;LN.append=function(e,r){this._pairs.push([e,r])};LN.toString=function(e){let r=e?function(n){return e.call(this,n,MN)}:MN;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};var UN=DN;function gie(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function So(t,e,r){if(!e)return t;let n=r&&r.encode||gie,i=_.isFunction(r)?{serialize:r}:r,a=i&&i.serialize,o;if(a?o=a(e,i):o=_.isURLSearchParams(e)?e.toString():new UN(e,i).toString(n),o){let s=t.indexOf("#");s!==-1&&(t=t.slice(0,s)),t+=(t.indexOf("?")===-1?"?":"&")+o}return t}var nS=class{constructor(){this.handlers=[]}use(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){_.forEach(this.handlers,function(n){n!==null&&e(n)})}},iS=nS;var da={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0};var HN=je(require("crypto"),1);var FN=je(require("url"),1),VN=FN.default.URLSearchParams;var aS="abcdefghijklmnopqrstuvwxyz",BN="0123456789",ZN={DIGIT:BN,ALPHA:aS,ALPHA_DIGIT:aS+aS.toUpperCase()+BN},vie=(t=16,e=ZN.ALPHA_DIGIT)=>{let r="",{length:n}=e,i=new Uint32Array(t);HN.default.randomFillSync(i);for(let a=0;a<t;a++)r+=e[i[a]%n];return r},WN={isNode:!0,classes:{URLSearchParams:VN,FormData:Bm,Blob:typeof Blob<"u"&&Blob||null},ALPHABET:ZN,generateString:vie,protocols:["http","https","file","data"]};var cS={};od(cS,{hasBrowserEnv:()=>sS,hasStandardBrowserEnv:()=>yie,hasStandardBrowserWebWorkerEnv:()=>bie,navigator:()=>oS,origin:()=>xie});var sS=typeof window<"u"&&typeof document<"u",oS=typeof navigator=="object"&&navigator||void 0,yie=sS&&(!oS||["ReactNative","NativeScript","NS"].indexOf(oS.product)<0),bie=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",xie=sS&&window.location.href||"http://localhost";var Oe={...cS,...WN};function uS(t,e){return pa(t,new Oe.classes.URLSearchParams,{visitor:function(r,n,i,a){return Oe.isNode&&_.isBuffer(r)?(this.append(n,r.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...e})}function wie(t){return _.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function _ie(t){let e={},r=Object.keys(t),n,i=r.length,a;for(n=0;n<i;n++)a=r[n],e[a]=t[a];return e}function Sie(t){function e(r,n,i,a){let o=r[a++];if(o==="__proto__")return!0;let s=Number.isFinite(+o),c=a>=r.length;return o=!o&&_.isArray(i)?i.length:o,c?(_.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!s):((!i[o]||!_.isObject(i[o]))&&(i[o]=[]),e(r,n,i[o],a)&&_.isArray(i[o])&&(i[o]=_ie(i[o])),!s)}if(_.isFormData(t)&&_.isFunction(t.entries)){let r={};return _.forEachEntry(t,(n,i)=>{e(wie(n),i,r,0)}),r}return null}var Hm=Sie;function Eie(t,e,r){if(_.isString(t))try{return(e||JSON.parse)(t),_.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var lS={transitional:da,adapter:["xhr","http","fetch"],transformRequest:[function(e,r){let n=r.getContentType()||"",i=n.indexOf("application/json")>-1,a=_.isObject(e);if(a&&_.isHTMLForm(e)&&(e=new FormData(e)),_.isFormData(e))return i?JSON.stringify(Hm(e)):e;if(_.isArrayBuffer(e)||_.isBuffer(e)||_.isStream(e)||_.isFile(e)||_.isBlob(e)||_.isReadableStream(e))return e;if(_.isArrayBufferView(e))return e.buffer;if(_.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return uS(e,this.formSerializer).toString();if((s=_.isFileList(e))||n.indexOf("multipart/form-data")>-1){let c=this.env&&this.env.FormData;return pa(s?{"files[]":e}:e,c&&new c,this.formSerializer)}}return a||i?(r.setContentType("application/json",!1),Eie(e)):e}],transformResponse:[function(e){let r=this.transitional||lS.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(_.isResponse(e)||_.isReadableStream(e))return e;if(e&&_.isString(e)&&(n&&!this.responseType||i)){let o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(s){if(o)throw s.name==="SyntaxError"?$.from(s,$.ERR_BAD_RESPONSE,this,null,this.response):s}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Oe.classes.FormData,Blob:Oe.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};_.forEach(["delete","get","head","post","put","patch"],t=>{lS.headers[t]={}});var Xs=lS;var Tie=_.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"]),KN=t=>{let e={},r,n,i;return t&&t.split(`
|
|
106
106
|
`).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||e[r]&&Tie[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e};var GN=Symbol("internals");function Gl(t){return t&&String(t).trim().toLowerCase()}function Zm(t){return t===!1||t==null?t:_.isArray(t)?t.map(Zm):String(t)}function Aie(t){let e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}var kie=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function pS(t,e,r,n,i){if(_.isFunction(n))return n.call(this,e,r);if(i&&(e=r),!!_.isString(e)){if(_.isString(n))return e.indexOf(n)!==-1;if(_.isRegExp(n))return n.test(e)}}function Cie(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,n)=>r.toUpperCase()+n)}function Pie(t,e){let r=_.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(i,a,o){return this[n].call(this,e,i,a,o)},configurable:!0})})}var ec=class{constructor(e){e&&this.set(e)}set(e,r,n){let i=this;function a(s,c,u){let l=Gl(c);if(!l)throw new Error("header name must be a non-empty string");let p=_.findKey(i,l);(!p||i[p]===void 0||u===!0||u===void 0&&i[p]!==!1)&&(i[p||c]=Zm(s))}let o=(s,c)=>_.forEach(s,(u,l)=>a(u,l,c));if(_.isPlainObject(e)||e instanceof this.constructor)o(e,r);else if(_.isString(e)&&(e=e.trim())&&!kie(e))o(KN(e),r);else if(_.isObject(e)&&_.isIterable(e)){let s={},c,u;for(let l of e){if(!_.isArray(l))throw TypeError("Object iterator must return a key-value pair");s[u=l[0]]=(c=s[u])?_.isArray(c)?[...c,l[1]]:[c,l[1]]:l[1]}o(s,r)}else e!=null&&a(r,e,n);return this}get(e,r){if(e=Gl(e),e){let n=_.findKey(this,e);if(n){let i=this[n];if(!r)return i;if(r===!0)return Aie(i);if(_.isFunction(r))return r.call(this,i,n);if(_.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=Gl(e),e){let n=_.findKey(this,e);return!!(n&&this[n]!==void 0&&(!r||pS(this,this[n],n,r)))}return!1}delete(e,r){let n=this,i=!1;function a(o){if(o=Gl(o),o){let s=_.findKey(n,o);s&&(!r||pS(n,n[s],s,r))&&(delete n[s],i=!0)}}return _.isArray(e)?e.forEach(a):a(e),i}clear(e){let r=Object.keys(this),n=r.length,i=!1;for(;n--;){let a=r[n];(!e||pS(this,this[a],a,e,!0))&&(delete this[a],i=!0)}return i}normalize(e){let r=this,n={};return _.forEach(this,(i,a)=>{let o=_.findKey(n,a);if(o){r[o]=Zm(i),delete r[a];return}let s=e?Cie(a):String(a).trim();s!==a&&delete r[a],r[s]=Zm(i),n[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let r=Object.create(null);return _.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=e&&_.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(`
|
|
107
107
|
`)}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,...r){let n=new this(e);return r.forEach(i=>n.set(i)),n}static accessor(e){let n=(this[GN]=this[GN]={accessors:{}}).accessors,i=this.prototype;function a(o){let s=Gl(o);n[s]||(Pie(i,o),n[s]=!0)}return _.isArray(e)?e.forEach(a):a(e),this}};ec.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);_.reduceDescriptors(ec.prototype,({value:t},e)=>{let r=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(n){this[r]=n}}});_.freezeMethods(ec);var ct=ec;function Jl(t,e){let r=this||Xs,n=e||r,i=ct.from(n.headers),a=n.data;return _.forEach(t,function(s){a=s.call(r,a,i.normalize(),e?e.status:void 0)}),i.normalize(),a}function Ql(t){return!!(t&&t.__CANCEL__)}var dS=class extends ${constructor(e,r,n){super(e??"canceled",$.ERR_CANCELED,r,n),this.name="CanceledError",this.__CANCEL__=!0}},jr=dS;function Un(t,e,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new $("Request failed with status code "+r.status,[$.ERR_BAD_REQUEST,$.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function fS(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function mS(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function Eo(t,e,r){let n=!fS(e);return t&&(n||r==!1)?mS(t,e):e}var T4=je(QN(),1),A4=je(require("http"),1),k4=je(require("https"),1),MS=je(require("http2"),1),DS=je(require("util"),1),C4=je(u4(),1),bi=je(require("zlib"),1);var Co="1.13.5";function rp(t){let e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}var dae=/^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;function RS(t,e,r){let n=r&&r.Blob||Oe.classes.Blob,i=rp(t);if(e===void 0&&n&&(e=!0),i==="data"){t=i.length?t.slice(i.length+1):t;let a=dae.exec(t);if(!a)throw new $("Invalid URL",$.ERR_INVALID_URL);let o=a[1],s=a[2],c=a[3],u=Buffer.from(decodeURIComponent(c),s?"base64":"utf8");if(e){if(!n)throw new $("Blob is not supported",$.ERR_NOT_SUPPORT);return new n([u],{type:o})}return u}throw new $("Unsupported protocol "+i,$.ERR_NOT_SUPPORT)}var yi=je(require("stream"),1);var l4=je(require("stream"),1);var IS=Symbol("internals"),$S=class extends l4.default.Transform{constructor(e){e=_.toFlatObject(e,{maxRate:0,chunkSize:64*1024,minChunkSize:100,timeWindow:500,ticksRate:2,samplesCount:15},null,(n,i)=>!_.isUndefined(i[n])),super({readableHighWaterMark:e.chunkSize});let r=this[IS]={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",n=>{n==="progress"&&(r.isCaptured||(r.isCaptured=!0))})}_read(e){let r=this[IS];return r.onReadCallback&&r.onReadCallback(),super._read(e)}_transform(e,r,n){let i=this[IS],a=i.maxRate,o=this.readableHighWaterMark,s=i.timeWindow,c=1e3/s,u=a/c,l=i.minChunkSize!==!1?Math.max(i.minChunkSize,u*.01):0,p=(g,m)=>{let h=Buffer.byteLength(g);i.bytesSeen+=h,i.bytes+=h,i.isCaptured&&this.emit("progress",i.bytesSeen),this.push(g)?process.nextTick(m):i.onReadCallback=()=>{i.onReadCallback=null,process.nextTick(m)}},f=(g,m)=>{let h=Buffer.byteLength(g),v=null,y=o,x,w=0;if(a){let S=Date.now();(!i.ts||(w=S-i.ts)>=s)&&(i.ts=S,x=u-i.bytes,i.bytes=x<0?-x:0,w=0),x=u-i.bytes}if(a){if(x<=0)return setTimeout(()=>{m(null,g)},s-w);x<y&&(y=x)}y&&h>y&&h-y>l&&(v=g.subarray(y),g=g.subarray(0,y)),p(g,v?()=>{process.nextTick(m,null,v)}:m)};f(e,function g(m,h){if(m)return n(m);h?f(h,g):n(null)})}},OS=$S;var P4=require("events");var d4=je(require("util"),1),f4=require("stream");var{asyncIterator:p4}=Symbol,fae=async function*(t){t.stream?yield*t.stream():t.arrayBuffer?yield await t.arrayBuffer():t[p4]?yield*t[p4]():yield t},Qm=fae;var mae=Oe.ALPHABET.ALPHA_DIGIT+"-_",np=typeof TextEncoder=="function"?new TextEncoder:new d4.default.TextEncoder,Po=`\r
|
|
108
108
|
`,hae=np.encode(Po),gae=2,jS=class{constructor(e,r){let{escapeName:n}=this.constructor,i=_.isString(r),a=`Content-Disposition: form-data; name="${n(e)}"${!i&&r.name?`; filename="${n(r.name)}"`:""}${Po}`;i?r=np.encode(String(r).replace(/\r?\n|\r\n?/g,Po)):a+=`Content-Type: ${r.type||"application/octet-stream"}${Po}`,this.headers=np.encode(a+Po),this.contentLength=i?r.byteLength:r.size,this.size=this.headers.byteLength+this.contentLength+gae,this.name=e,this.value=r}async*encode(){yield this.headers;let{value:e}=this;_.isTypedArray(e)?yield e:yield*Qm(e),yield hae}static escapeName(e){return String(e).replace(/[\r\n"]/g,r=>({"\r":"%0D","\n":"%0A",'"':"%22"})[r])}},vae=(t,e,r)=>{let{tag:n="form-data-boundary",size:i=25,boundary:a=n+"-"+Oe.generateString(i,mae)}=r||{};if(!_.isFormData(t))throw TypeError("FormData instance required");if(a.length<1||a.length>70)throw Error("boundary must be 10-70 characters long");let o=np.encode("--"+a+Po),s=np.encode("--"+a+"--"+Po),c=s.byteLength,u=Array.from(t.entries()).map(([p,f])=>{let g=new jS(p,f);return c+=g.size,g});c+=o.byteLength*u.length,c=_.toFiniteNumber(c);let l={"Content-Type":`multipart/form-data; boundary=${a}`};return Number.isFinite(c)&&(l["Content-Length"]=c),e&&e(l),f4.Readable.from(async function*(){for(let p of u)yield o,yield*p.encode();yield s}())},m4=vae;var h4=je(require("stream"),1),NS=class extends h4.default.Transform{__transform(e,r,n){this.push(e),n()}_transform(e,r,n){if(e.length!==0&&(this._transform=this.__transform,e[0]!==120)){let i=Buffer.alloc(2);i[0]=120,i[1]=156,this.push(i,r)}this.__transform(e,r,n)}},g4=NS;var yae=(t,e)=>_.isAsyncFn(t)?function(...r){let n=r.pop();t.apply(this,r).then(i=>{try{e?n(null,...e(i)):n(null,i)}catch(a){n(a)}},n)}:t,v4=yae;function bae(t,e){t=t||10;let r=new Array(t),n=new Array(t),i=0,a=0,o;return e=e!==void 0?e:1e3,function(c){let u=Date.now(),l=n[a];o||(o=u),r[i]=c,n[i]=u;let p=a,f=0;for(;p!==i;)f+=r[p++],p=p%t;if(i=(i+1)%t,i===a&&(a=(a+1)%t),u-o<e)return;let g=l&&u-l;return g?Math.round(f*1e3/g):void 0}}var y4=bae;function xae(t,e){let r=0,n=1e3/e,i,a,o=(u,l=Date.now())=>{r=l,i=null,a&&(clearTimeout(a),a=null),t(...u)};return[(...u)=>{let l=Date.now(),p=l-r;p>=n?o(u,l):(i=u,a||(a=setTimeout(()=>{a=null,o(i)},n-p)))},()=>i&&o(i)]}var b4=xae;var vi=(t,e,r=3)=>{let n=0,i=y4(50,250);return b4(a=>{let o=a.loaded,s=a.lengthComputable?a.total:void 0,c=o-n,u=i(c),l=o<=s;n=o;let p={loaded:o,total:s,progress:s?o/s:void 0,bytes:c,rate:u||void 0,estimated:u&&s&&l?(s-o)/u:void 0,event:a,lengthComputable:s!=null,[e?"download":"upload"]:!0};t(p)},r)},ac=(t,e)=>{let r=t!=null;return[n=>e[0]({lengthComputable:r,total:t,loaded:n}),e[1]]},oc=t=>(...e)=>_.asap(()=>t(...e));function qS(t){if(!t||typeof t!="string"||!t.startsWith("data:"))return 0;let e=t.indexOf(",");if(e<0)return 0;let r=t.slice(5,e),n=t.slice(e+1);if(/;base64/i.test(r)){let a=n.length,o=n.length;for(let f=0;f<o;f++)if(n.charCodeAt(f)===37&&f+2<o){let g=n.charCodeAt(f+1),m=n.charCodeAt(f+2);(g>=48&&g<=57||g>=65&&g<=70||g>=97&&g<=102)&&(m>=48&&m<=57||m>=65&&m<=70||m>=97&&m<=102)&&(a-=2,f+=2)}let s=0,c=o-1,u=f=>f>=2&&n.charCodeAt(f-2)===37&&n.charCodeAt(f-1)===51&&(n.charCodeAt(f)===68||n.charCodeAt(f)===100);c>=0&&(n.charCodeAt(c)===61?(s++,c--):u(c)&&(s++,c-=3)),s===1&&c>=0&&(n.charCodeAt(c)===61||u(c))&&s++;let p=Math.floor(a/4)*3-(s||0);return p>0?p:0}return Buffer.byteLength(n,"utf8")}var x4={flush:bi.default.constants.Z_SYNC_FLUSH,finishFlush:bi.default.constants.Z_SYNC_FLUSH},wae={flush:bi.default.constants.BROTLI_OPERATION_FLUSH,finishFlush:bi.default.constants.BROTLI_OPERATION_FLUSH},w4=_.isFunction(bi.default.createBrotliDecompress),{http:_ae,https:Sae}=C4.default,Eae=/https:?/,_4=Oe.protocols.map(t=>t+":"),S4=(t,[e,r])=>(t.on("end",r).on("error",r),e),zS=class{constructor(){this.sessions=Object.create(null)}getSession(e,r){r=Object.assign({sessionTimeout:1e3},r);let n=this.sessions[e];if(n){let l=n.length;for(let p=0;p<l;p++){let[f,g]=n[p];if(!f.destroyed&&!f.closed&&DS.default.isDeepStrictEqual(g,r))return f}}let i=MS.default.connect(e,r),a,o=()=>{if(a)return;a=!0;let l=n,p=l.length,f=p;for(;f--;)if(l[f][0]===i){p===1?delete this.sessions[e]:l.splice(f,1);return}},s=i.request,{sessionTimeout:c}=r;if(c!=null){let l,p=0;i.request=function(){let f=s.apply(this,arguments);return p++,l&&(clearTimeout(l),l=null),f.once("close",()=>{--p||(l=setTimeout(()=>{l=null,o()},c))}),f}}i.once("close",o);let u=[i,r];return n?n.push(u):n=this.sessions[e]=[u],i}},Tae=new zS;function Aae(t,e){t.beforeRedirects.proxy&&t.beforeRedirects.proxy(t),t.beforeRedirects.config&&t.beforeRedirects.config(t,e)}function R4(t,e,r){let n=e;if(!n&&n!==!1){let i=T4.default.getProxyForUrl(r);i&&(n=new URL(i))}if(n){if(n.username&&(n.auth=(n.username||"")+":"+(n.password||"")),n.auth){if(!!(n.auth.username||n.auth.password))n.auth=(n.auth.username||"")+":"+(n.auth.password||"");else if(typeof n.auth=="object")throw new $("Invalid proxy authorization",$.ERR_BAD_OPTION,{proxy:n});let o=Buffer.from(n.auth,"utf8").toString("base64");t.headers["Proxy-Authorization"]="Basic "+o}t.headers.host=t.hostname+(t.port?":"+t.port:"");let i=n.hostname||n.host;t.hostname=i,t.host=i,t.port=n.port,t.path=r,n.protocol&&(t.protocol=n.protocol.includes(":")?n.protocol:`${n.protocol}:`)}t.beforeRedirects.proxy=function(a){R4(a,e,a.href)}}var kae=typeof process<"u"&&_.kindOf(process)==="process",Cae=t=>new Promise((e,r)=>{let n,i,a=(c,u)=>{i||(i=!0,n&&n(c,u))},o=c=>{a(c),e(c)},s=c=>{a(c,!0),r(c)};t(o,s,c=>n=c).catch(s)}),Pae=({address:t,family:e})=>{if(!_.isString(t))throw TypeError("address must be a string");return{address:t,family:e||(t.indexOf(".")<0?6:4)}},E4=(t,e)=>Pae(_.isObject(t)?t:{address:t,family:e}),Rae={request(t,e){let r=t.protocol+"//"+t.hostname+":"+(t.port||(t.protocol==="https:"?443:80)),{http2Options:n,headers:i}=t,a=Tae.getSession(r,n),{HTTP2_HEADER_SCHEME:o,HTTP2_HEADER_METHOD:s,HTTP2_HEADER_PATH:c,HTTP2_HEADER_STATUS:u}=MS.default.constants,l={[o]:t.protocol.replace(":",""),[s]:t.method,[c]:t.path};_.forEach(i,(f,g)=>{g.charAt(0)!==":"&&(l[g]=f)});let p=a.request(l);return p.once("response",f=>{let g=p;f=Object.assign({},f);let m=f[u];delete f[u],g.headers=f,g.statusCode=+m,e(g)}),p}},I4=kae&&function(e){return Cae(async function(n,i,a){let{data:o,lookup:s,family:c,httpVersion:u=1,http2Options:l}=e,{responseType:p,responseEncoding:f}=e,g=e.method.toUpperCase(),m,h=!1,v;if(u=+u,Number.isNaN(u))throw TypeError(`Invalid protocol version: '${e.httpVersion}' is not a number`);if(u!==1&&u!==2)throw TypeError(`Unsupported protocol version '${u}'`);let y=u===2;if(s){let G=v4(s,U=>_.isArray(U)?U:[U]);s=(U,Re,tr)=>{G(U,Re,(at,Pr,kn)=>{if(at)return tr(at);let Ht=_.isArray(Pr)?Pr.map(Jo=>E4(Jo)):[E4(Pr,kn)];Re.all?tr(at,Ht):tr(at,Ht[0].address,Ht[0].family)})}}let x=new P4.EventEmitter;function w(G){try{x.emit("abort",!G||G.type?new jr(null,e,v):G)}catch(U){console.warn("emit error",U)}}x.once("abort",i);let S=()=>{e.cancelToken&&e.cancelToken.unsubscribe(w),e.signal&&e.signal.removeEventListener("abort",w),x.removeAllListeners()};(e.cancelToken||e.signal)&&(e.cancelToken&&e.cancelToken.subscribe(w),e.signal&&(e.signal.aborted?w():e.signal.addEventListener("abort",w))),a((G,U)=>{if(m=!0,U){h=!0,S();return}let{data:Re}=G;if(Re instanceof yi.default.Readable||Re instanceof yi.default.Duplex){let tr=yi.default.finished(Re,()=>{tr(),S()})}else S()});let E=Eo(e.baseURL,e.url,e.allowAbsoluteUrls),k=new URL(E,Oe.hasBrowserEnv?Oe.origin:void 0),I=k.protocol||_4[0];if(I==="data:"){if(e.maxContentLength>-1){let U=String(e.url||E||"");if(qS(U)>e.maxContentLength)return i(new $("maxContentLength size of "+e.maxContentLength+" exceeded",$.ERR_BAD_RESPONSE,e))}let G;if(g!=="GET")return Un(n,i,{status:405,statusText:"method not allowed",headers:{},config:e});try{G=RS(e.url,p==="blob",{Blob:e.env&&e.env.Blob})}catch(U){throw $.from(U,$.ERR_BAD_REQUEST,e)}return p==="text"?(G=G.toString(f),(!f||f==="utf8")&&(G=_.stripBOM(G))):p==="stream"&&(G=yi.default.Readable.from(G)),Un(n,i,{data:G,status:200,statusText:"OK",headers:new ct,config:e})}if(_4.indexOf(I)===-1)return i(new $("Unsupported protocol "+I,$.ERR_BAD_REQUEST,e));let M=ct.from(e.headers).normalize();M.set("User-Agent","axios/"+Co,!1);let{onUploadProgress:Z,onDownloadProgress:re}=e,Ke=e.maxRate,pe,Se;if(_.isSpecCompliantForm(o)){let G=M.getContentType(/boundary=([-_\w\d]{10,70})/i);o=m4(o,U=>{M.set(U)},{tag:`axios-${Co}-boundary`,boundary:G&&G[1]||void 0})}else if(_.isFormData(o)&&_.isFunction(o.getHeaders)){if(M.set(o.getHeaders()),!M.hasContentLength())try{let G=await DS.default.promisify(o.getLength).call(o);Number.isFinite(G)&&G>=0&&M.setContentLength(G)}catch{}}else if(_.isBlob(o)||_.isFile(o))o.size&&M.setContentType(o.type||"application/octet-stream"),M.setContentLength(o.size||0),o=yi.default.Readable.from(Qm(o));else if(o&&!_.isStream(o)){if(!Buffer.isBuffer(o))if(_.isArrayBuffer(o))o=Buffer.from(new Uint8Array(o));else if(_.isString(o))o=Buffer.from(o,"utf-8");else return i(new $("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream",$.ERR_BAD_REQUEST,e));if(M.setContentLength(o.length,!1),e.maxBodyLength>-1&&o.length>e.maxBodyLength)return i(new $("Request body larger than maxBodyLength limit",$.ERR_BAD_REQUEST,e))}let qe=_.toFiniteNumber(M.getContentLength());_.isArray(Ke)?(pe=Ke[0],Se=Ke[1]):pe=Se=Ke,o&&(Z||pe)&&(_.isStream(o)||(o=yi.default.Readable.from(o,{objectMode:!1})),o=yi.default.pipeline([o,new OS({maxRate:_.toFiniteNumber(pe)})],_.noop),Z&&o.on("progress",S4(o,ac(qe,vi(oc(Z),!1,3)))));let it;if(e.auth){let G=e.auth.username||"",U=e.auth.password||"";it=G+":"+U}if(!it&&k.username){let G=k.username,U=k.password;it=G+":"+U}it&&M.delete("authorization");let ze;try{ze=So(k.pathname+k.search,e.params,e.paramsSerializer).replace(/^\?/,"")}catch(G){let U=new Error(G.message);return U.config=e,U.url=e.url,U.exists=!0,i(U)}M.set("Accept-Encoding","gzip, compress, deflate"+(w4?", br":""),!1);let Ge={path:ze,method:g,headers:M.toJSON(),agents:{http:e.httpAgent,https:e.httpsAgent},auth:it,protocol:I,family:c,beforeRedirect:Aae,beforeRedirects:{},http2Options:l};!_.isUndefined(s)&&(Ge.lookup=s),e.socketPath?Ge.socketPath=e.socketPath:(Ge.hostname=k.hostname.startsWith("[")?k.hostname.slice(1,-1):k.hostname,Ge.port=k.port,R4(Ge,e.proxy,I+"//"+k.hostname+(k.port?":"+k.port:"")+Ge.path));let bt,sn=Eae.test(Ge.protocol);if(Ge.agent=sn?e.httpsAgent:e.httpAgent,y?bt=Rae:e.transport?bt=e.transport:e.maxRedirects===0?bt=sn?k4.default:A4.default:(e.maxRedirects&&(Ge.maxRedirects=e.maxRedirects),e.beforeRedirect&&(Ge.beforeRedirects.config=e.beforeRedirect),bt=sn?Sae:_ae),e.maxBodyLength>-1?Ge.maxBodyLength=e.maxBodyLength:Ge.maxBodyLength=1/0,e.insecureHTTPParser&&(Ge.insecureHTTPParser=e.insecureHTTPParser),v=bt.request(Ge,function(U){if(v.destroyed)return;let Re=[U],tr=_.toFiniteNumber(U.headers["content-length"]);if(re||Se){let Ht=new OS({maxRate:_.toFiniteNumber(Se)});re&&Ht.on("progress",S4(Ht,ac(tr,vi(oc(re),!0,3)))),Re.push(Ht)}let at=U,Pr=U.req||v;if(e.decompress!==!1&&U.headers["content-encoding"])switch((g==="HEAD"||U.statusCode===204)&&delete U.headers["content-encoding"],(U.headers["content-encoding"]||"").toLowerCase()){case"gzip":case"x-gzip":case"compress":case"x-compress":Re.push(bi.default.createUnzip(x4)),delete U.headers["content-encoding"];break;case"deflate":Re.push(new g4),Re.push(bi.default.createUnzip(x4)),delete U.headers["content-encoding"];break;case"br":w4&&(Re.push(bi.default.createBrotliDecompress(wae)),delete U.headers["content-encoding"])}at=Re.length>1?yi.default.pipeline(Re,_.noop):Re[0];let kn={status:U.statusCode,statusText:U.statusMessage,headers:new ct(U.headers),config:e,request:Pr};if(p==="stream")kn.data=at,Un(n,i,kn);else{let Ht=[],Jo=0;at.on("data",function(Tt){Ht.push(Tt),Jo+=Tt.length,e.maxContentLength>-1&&Jo>e.maxContentLength&&(h=!0,at.destroy(),w(new $("maxContentLength size of "+e.maxContentLength+" exceeded",$.ERR_BAD_RESPONSE,e,Pr)))}),at.on("aborted",function(){if(h)return;let Tt=new $("stream has been aborted",$.ERR_BAD_RESPONSE,e,Pr);at.destroy(Tt),i(Tt)}),at.on("error",function(Tt){v.destroyed||i($.from(Tt,null,e,Pr))}),at.on("end",function(){try{let Tt=Ht.length===1?Ht[0]:Buffer.concat(Ht);p!=="arraybuffer"&&(Tt=Tt.toString(f),(!f||f==="utf8")&&(Tt=_.stripBOM(Tt))),kn.data=Tt}catch(Tt){return i($.from(Tt,null,e,kn.request,kn))}Un(n,i,kn)})}x.once("abort",Ht=>{at.destroyed||(at.emit("error",Ht),at.destroy())})}),x.once("abort",G=>{v.close?v.close():v.destroy(G)}),v.on("error",function(U){i($.from(U,null,e,v))}),v.on("socket",function(U){U.setKeepAlive(!0,1e3*60)}),e.timeout){let G=parseInt(e.timeout,10);if(Number.isNaN(G)){w(new $("error trying to parse `config.timeout` to int",$.ERR_BAD_OPTION_VALUE,e,v));return}v.setTimeout(G,function(){if(m)return;let Re=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",tr=e.transitional||da;e.timeoutErrorMessage&&(Re=e.timeoutErrorMessage),w(new $(Re,tr.clarifyTimeoutError?$.ETIMEDOUT:$.ECONNABORTED,e,v))})}else v.setTimeout(0);if(_.isStream(o)){let G=!1,U=!1;o.on("end",()=>{G=!0}),o.once("error",Re=>{U=!0,v.destroy(Re)}),o.on("close",()=>{!G&&!U&&w(new jr("Request stream has been aborted",e,v))}),o.pipe(v)}else o&&v.write(o),v.end()})};var $4=Oe.hasStandardBrowserEnv?((t,e)=>r=>(r=new URL(r,Oe.origin),t.protocol===r.protocol&&t.host===r.host&&(e||t.port===r.port)))(new URL(Oe.origin),Oe.navigator&&/(msie|trident)/i.test(Oe.navigator.userAgent)):()=>!0;var O4=Oe.hasStandardBrowserEnv?{write(t,e,r,n,i,a,o){if(typeof document>"u")return;let s=[`${t}=${encodeURIComponent(e)}`];_.isNumber(r)&&s.push(`expires=${new Date(r).toUTCString()}`),_.isString(n)&&s.push(`path=${n}`),_.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push("secure"),_.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join("; ")},read(t){if(typeof document>"u")return null;let e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};var j4=t=>t instanceof ct?{...t}:t;function Sn(t,e){e=e||{};let r={};function n(u,l,p,f){return _.isPlainObject(u)&&_.isPlainObject(l)?_.merge.call({caseless:f},u,l):_.isPlainObject(l)?_.merge({},l):_.isArray(l)?l.slice():l}function i(u,l,p,f){if(_.isUndefined(l)){if(!_.isUndefined(u))return n(void 0,u,p,f)}else return n(u,l,p,f)}function a(u,l){if(!_.isUndefined(l))return n(void 0,l)}function o(u,l){if(_.isUndefined(l)){if(!_.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function s(u,l,p){if(p in e)return n(u,l);if(p in t)return n(void 0,u)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(u,l,p)=>i(j4(u),j4(l),p,!0)};return _.forEach(Object.keys({...t,...e}),function(l){if(l==="__proto__"||l==="constructor"||l==="prototype")return;let p=_.hasOwnProp(c,l)?c[l]:i,f=p(t[l],e[l],l);_.isUndefined(f)&&p!==s||(r[l]=f)}),r}var Ym=t=>{let e=Sn({},t),{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=e;if(e.headers=o=ct.from(o),e.url=So(Eo(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),s&&o.set("Authorization","Basic "+btoa((s.username||"")+":"+(s.password?unescape(encodeURIComponent(s.password)):""))),_.isFormData(r)){if(Oe.hasStandardBrowserEnv||Oe.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(_.isFunction(r.getHeaders)){let c=r.getHeaders(),u=["content-type","content-length"];Object.entries(c).forEach(([l,p])=>{u.includes(l.toLowerCase())&&o.set(l,p)})}}if(Oe.hasStandardBrowserEnv&&(n&&_.isFunction(n)&&(n=n(e)),n||n!==!1&&$4(e.url))){let c=i&&a&&O4.read(a);c&&o.set(i,c)}return e};var Iae=typeof XMLHttpRequest<"u",N4=Iae&&function(t){return new Promise(function(r,n){let i=Ym(t),a=i.data,o=ct.from(i.headers).normalize(),{responseType:s,onUploadProgress:c,onDownloadProgress:u}=i,l,p,f,g,m;function h(){g&&g(),m&&m(),i.cancelToken&&i.cancelToken.unsubscribe(l),i.signal&&i.signal.removeEventListener("abort",l)}let v=new XMLHttpRequest;v.open(i.method.toUpperCase(),i.url,!0),v.timeout=i.timeout;function y(){if(!v)return;let w=ct.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders()),E={data:!s||s==="text"||s==="json"?v.responseText:v.response,status:v.status,statusText:v.statusText,headers:w,config:t,request:v};Un(function(I){r(I),h()},function(I){n(I),h()},E),v=null}"onloadend"in v?v.onloadend=y:v.onreadystatechange=function(){!v||v.readyState!==4||v.status===0&&!(v.responseURL&&v.responseURL.indexOf("file:")===0)||setTimeout(y)},v.onabort=function(){v&&(n(new $("Request aborted",$.ECONNABORTED,t,v)),v=null)},v.onerror=function(S){let E=S&&S.message?S.message:"Network Error",k=new $(E,$.ERR_NETWORK,t,v);k.event=S||null,n(k),v=null},v.ontimeout=function(){let S=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded",E=i.transitional||da;i.timeoutErrorMessage&&(S=i.timeoutErrorMessage),n(new $(S,E.clarifyTimeoutError?$.ETIMEDOUT:$.ECONNABORTED,t,v)),v=null},a===void 0&&o.setContentType(null),"setRequestHeader"in v&&_.forEach(o.toJSON(),function(S,E){v.setRequestHeader(E,S)}),_.isUndefined(i.withCredentials)||(v.withCredentials=!!i.withCredentials),s&&s!=="json"&&(v.responseType=i.responseType),u&&([f,m]=vi(u,!0),v.addEventListener("progress",f)),c&&v.upload&&([p,g]=vi(c),v.upload.addEventListener("progress",p),v.upload.addEventListener("loadend",g)),(i.cancelToken||i.signal)&&(l=w=>{v&&(n(!w||w.type?new jr(null,t,v):w),v.abort(),v=null)},i.cancelToken&&i.cancelToken.subscribe(l),i.signal&&(i.signal.aborted?l():i.signal.addEventListener("abort",l)));let x=rp(i.url);if(x&&Oe.protocols.indexOf(x)===-1){n(new $("Unsupported protocol "+x+":",$.ERR_BAD_REQUEST,t));return}v.send(a||null)})};var $ae=(t,e)=>{let{length:r}=t=t?t.filter(Boolean):[];if(e||r){let n=new AbortController,i,a=function(u){if(!i){i=!0,s();let l=u instanceof Error?u:this.reason;n.abort(l instanceof $?l:new jr(l instanceof Error?l.message:l))}},o=e&&setTimeout(()=>{o=null,a(new $(`timeout of ${e}ms exceeded`,$.ETIMEDOUT))},e),s=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(a):u.removeEventListener("abort",a)}),t=null)};t.forEach(u=>u.addEventListener("abort",a));let{signal:c}=n;return c.unsubscribe=()=>_.asap(s),c}},q4=$ae;var Oae=function*(t,e){let r=t.byteLength;if(!e||r<e){yield t;return}let n=0,i;for(;n<r;)i=n+e,yield t.slice(n,i),n=i},jae=async function*(t,e){for await(let r of Nae(t))yield*Oae(r,e)},Nae=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}let e=t.getReader();try{for(;;){let{done:r,value:n}=await e.read();if(r)break;yield n}}finally{await e.cancel()}},LS=(t,e,r,n)=>{let i=jae(t,e),a=0,o,s=c=>{o||(o=!0,n&&n(c))};return new ReadableStream({async pull(c){try{let{done:u,value:l}=await i.next();if(u){s(),c.close();return}let p=l.byteLength;if(r){let f=a+=p;r(f)}c.enqueue(new Uint8Array(l))}catch(u){throw s(u),u}},cancel(c){return s(c),i.return()}},{highWaterMark:2})};var z4=64*1024,{isFunction:Xm}=_,qae=(({Request:t,Response:e})=>({Request:t,Response:e}))(_.global),{ReadableStream:M4,TextEncoder:D4}=_.global,L4=(t,...e)=>{try{return!!t(...e)}catch{return!1}},zae=t=>{t=_.merge.call({skipUndefined:!0},qae,t);let{fetch:e,Request:r,Response:n}=t,i=e?Xm(e):typeof fetch=="function",a=Xm(r),o=Xm(n);if(!i)return!1;let s=i&&Xm(M4),c=i&&(typeof D4=="function"?(m=>h=>m.encode(h))(new D4):async m=>new Uint8Array(await new r(m).arrayBuffer())),u=a&&s&&L4(()=>{let m=!1,h=new r(Oe.origin,{body:new M4,method:"POST",get duplex(){return m=!0,"half"}}).headers.has("Content-Type");return m&&!h}),l=o&&s&&L4(()=>_.isReadableStream(new n("").body)),p={stream:l&&(m=>m.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!p[m]&&(p[m]=(h,v)=>{let y=h&&h[m];if(y)return y.call(h);throw new $(`Response type '${m}' is not supported`,$.ERR_NOT_SUPPORT,v)})});let f=async m=>{if(m==null)return 0;if(_.isBlob(m))return m.size;if(_.isSpecCompliantForm(m))return(await new r(Oe.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(_.isArrayBufferView(m)||_.isArrayBuffer(m))return m.byteLength;if(_.isURLSearchParams(m)&&(m=m+""),_.isString(m))return(await c(m)).byteLength},g=async(m,h)=>{let v=_.toFiniteNumber(m.getContentLength());return v??f(h)};return async m=>{let{url:h,method:v,data:y,signal:x,cancelToken:w,timeout:S,onDownloadProgress:E,onUploadProgress:k,responseType:I,headers:M,withCredentials:Z="same-origin",fetchOptions:re}=Ym(m),Ke=e||fetch;I=I?(I+"").toLowerCase():"text";let pe=q4([x,w&&w.toAbortSignal()],S),Se=null,qe=pe&&pe.unsubscribe&&(()=>{pe.unsubscribe()}),it;try{if(k&&u&&v!=="get"&&v!=="head"&&(it=await g(M,y))!==0){let U=new r(h,{method:"POST",body:y,duplex:"half"}),Re;if(_.isFormData(y)&&(Re=U.headers.get("content-type"))&&M.setContentType(Re),U.body){let[tr,at]=ac(it,vi(oc(k)));y=LS(U.body,z4,tr,at)}}_.isString(Z)||(Z=Z?"include":"omit");let ze=a&&"credentials"in r.prototype,Ge={...re,signal:pe,method:v.toUpperCase(),headers:M.normalize().toJSON(),body:y,duplex:"half",credentials:ze?Z:void 0};Se=a&&new r(h,Ge);let bt=await(a?Ke(Se,re):Ke(h,Ge)),sn=l&&(I==="stream"||I==="response");if(l&&(E||sn&&qe)){let U={};["status","statusText","headers"].forEach(Pr=>{U[Pr]=bt[Pr]});let Re=_.toFiniteNumber(bt.headers.get("content-length")),[tr,at]=E&&ac(Re,vi(oc(E),!0))||[];bt=new n(LS(bt.body,z4,tr,()=>{at&&at(),qe&&qe()}),U)}I=I||"text";let G=await p[_.findKey(p,I)||"text"](bt,m);return!sn&&qe&&qe(),await new Promise((U,Re)=>{Un(U,Re,{data:G,headers:ct.from(bt.headers),status:bt.status,statusText:bt.statusText,config:m,request:Se})})}catch(ze){throw qe&&qe(),ze&&ze.name==="TypeError"&&/Load failed|fetch/i.test(ze.message)?Object.assign(new $("Network Error",$.ERR_NETWORK,m,Se,ze&&ze.response),{cause:ze.cause||ze}):$.from(ze,ze&&ze.code,m,Se,ze&&ze.response)}}},Mae=new Map,US=t=>{let e=t&&t.env||{},{fetch:r,Request:n,Response:i}=e,a=[n,i,r],o=a.length,s=o,c,u,l=Mae;for(;s--;)c=a[s],u=l.get(c),u===void 0&&l.set(c,u=s?new Map:zae(e)),l=u;return u},WCe=US();var FS={http:I4,xhr:N4,fetch:{get:US}};_.forEach(FS,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});var U4=t=>`- ${t}`,Lae=t=>_.isFunction(t)||t===null||t===!1;function Uae(t,e){t=_.isArray(t)?t:[t];let{length:r}=t,n,i,a={};for(let o=0;o<r;o++){n=t[o];let s;if(i=n,!Lae(n)&&(i=FS[(s=String(n)).toLowerCase()],i===void 0))throw new $(`Unknown adapter '${s}'`);if(i&&(_.isFunction(i)||(i=i.get(e))))break;a[s||"#"+o]=i}if(!i){let o=Object.entries(a).map(([c,u])=>`adapter ${c} `+(u===!1?"is not supported by the environment":"is not available in the build")),s=r?o.length>1?`since :
|