import"./index-XbihxApF.js";import{c}from"./constants-Cn7R_Bik.js";function u(n){if(!n)return"";const r=n.find(t=>t.name==="COLLECTION_REGISTRY_APP_LIST");if(r)return r.name;const e=n.find(t=>t.name.startsWith("COLLECTION_REGISTRY_APP_")&&t.name.endsWith("_LIST"));return e?e.name:n.find(t=>t.name.endsWith("_LIST"))?.name??""}function m(n){if(!n)return"";const r=n.find(t=>t.name==="COLLECTION_REGISTRY_APP_FILTERS");if(r)return r.name;const e=n.find(t=>t.name.startsWith("COLLECTION_REGISTRY_APP_")&&t.name.endsWith("_FILTERS"));return e?e.name:n.find(t=>t.name.endsWith("_FILTERS"))?.name??""}function T(n,r){if(!n)return"";const e=n.find(i=>i.name===`COLLECTION_REGISTRY_APP${r}`);if(e)return e.name;const a=n.find(i=>i.name.startsWith("COLLECTION_REGISTRY_APP_")&&i.name.endsWith(r));return a?a.name:n.find(i=>i.name.endsWith(r))?.name??""}function l(n){if(!n)return[];const r=[];for(const e of n){let a=[];if(Array.isArray(e))a=e;else if(typeof e=="object"&&e!==null){const t=Object.keys(e).find(i=>Array.isArray(e[i]));t&&(a=e[t])}r.push(...a)}return r}const s={"streamable-http":"HTTP",http:"HTTP",sse:"SSE",stdio:"STDIO",websocket:"Websocket"};function d(n){return n?s[n]??n.toUpperCase():null}function I(n){return n?n.match(/schemas\/([\d-]+)/)?.[1]??null:null}function _(n){if(!n)return[];if(Array.isArray(n))return n;if(typeof n=="object"&&n!==null){const r=Object.keys(n).find(e=>Array.isArray(n[e]));if(r)return n[r]}return[]}async function y(n,r,e,a){const t=await c({connectionId:n,orgId:r});try{const i=await t.callTool({name:e,arguments:a});return i.structuredContent??i}finally{await t.close().catch(console.error)}}export{l as a,m as b,y as c,T as d,_ as e,u as f,d as g,I as h};
