import{b as p}from"./useflows-BpG3C9m1.js";import{s as m,e as n}from"./main-few-lands-burn.js";import{c as u}from"./import-Cn4VUyaV.js";import{h as s,s as E}from"./machine.-BRuqPpdF.js";import"./mutative-C6xjlr6O.js";import"./lodash-YpNkAOPN.js";import"./index-btcdg7gz.js";import"./index-28_Ul1Wv.js";import"./context-Ba3TiTex.js";import"./useclosa-m-cf8k_D.js";import"./index-ubWv-fhI.js";import"./index-CB2KTxNj.js";import"./tabpanel-DvU0ks7q.js";import"./index-BcDJZYeX.js";import"./index-DAhFlZRY.js";import"./usebreak-DJkppNCB.js";import"./index-CTlEl9RP.js";const T=(e,t,l)=>m("mcp-client/tools",{connectionId:t,serverTransport:l,serverUrl:e}),_=(e,t)=>{e.setComponent("selected-tools",l=>{e.util.isSelectComponent(l)&&(l.loading=t)}),e.setComponent("except-selected-tools",l=>{e.util.isSelectComponent(l)&&(l.loading=t)})},a=async e=>{if(e.getComponent("tools-to-include")?.value==="all")return;_(e,!0);const t=e.getComponent("server-url")?.value,l=e.getComponent("connection-id")?.value,r=e.getComponent("server-transport")?.value,{data:i,status:c}=await T(t,l,r);if(c==="error"){e.setComponent("selected-tools",o=>{e.util.isSelectComponent(o)&&(o.status=c,o.loading=!1,o.invalidMessage=i)}),e.setComponent("except-selected-tools",o=>{e.util.isSelectComponent(o)&&(o.status=c,o.loading=!1,o.invalidMessage=i)});return}const d=i.tools.map(o=>({label:o.name,value:o.name}));e.setComponent("selected-tools",o=>{e.util.isSelectComponent(o)&&(o.options=d,o.loading=!1,o.status=void 0)}),e.setComponent("except-selected-tools",o=>{e.util.isSelectComponent(o)&&(o.options=d,o.loading=!1,o.status=void 0)})},U=p(({helpers:e})=>({states:{components:[{allowClear:!0,componentName:e.componentName.connection,connectionsTypes:u,customConnection:!0,fieldType:"config",id:"connection-id",label:n("Connection (optional)"),onConnectionChange:"HANDLE_CONNECTION_CHANGE",render:!0,value:void 0},{componentName:e.componentName.mixInput,fieldType:"config",helperText:n("Enter the URL of your MCP server"),id:"server-url",label:n("MCP Server URL"),onChange:"HANDLE_SERVER_URL",placeholder:n("https://mcp-server.example.com"),render:!0,required:!0,value:void 0},{componentName:e.componentName.select,fieldType:"config",id:"server-transport",label:n("Server Transport"),onChange:"HANDLE_SERVER_TRANSPORT",options:[{label:n("HTTP Streamable"),value:"http"},{label:n("Server-Sent Events (Deprecated)"),value:"sse"}],render:!0,required:!0,value:"http"},{componentName:e.componentName.select,fieldType:"config",id:"tools-to-include",label:n("Tools to include"),onChange:"HANDLE_TOOLS_TO_INCLUDE",optionFilterProp:"label",options:[{label:n("All"),value:"all"},{label:n("Selected"),value:"selected"},{label:n("Except Selected"),value:"except-selected"}],render:"IF_SERVER_URL_SELECTED",required:!1,showSearch:!0,value:["all"]},{componentName:e.componentName.select,fieldType:"config",id:"selected-tools",label:n("Tools to include"),mode:"multiple",onChange:"HANDLE_SELECTED_TOOLS",onRefetch:"REFETCH_TOOLS",optionFilterProp:"label",options:[],render:"IF_TOOLS_TO_INCLUDE_IS_SELECTED",required:!0,showSearch:!0,value:[]},{componentName:e.componentName.select,fieldType:"config",id:"except-selected-tools",label:n("Tools to exclude"),mode:"multiple",onChange:"HANDLE_EXCEPT_SELECTED_TOOLS",onRefetch:"REFETCH_TOOLS",optionFilterProp:"label",options:[],render:"IF_TOOLS_TO_INCLUDE_IS_EXCEPT_SELECTED",required:!0,showSearch:!0,value:[]}]},actions:{IF_SERVER_URL_SELECTED:({$:t})=>t.getComponent("server-url")?.value!==void 0,IF_TOOLS_TO_INCLUDE_IS_SELECTED:({$:t})=>t.getComponent("tools-to-include")?.value==="selected",ON_MACHINE_LOAD:async({$:t})=>{E(t,[{db:"connectionId",id:"connection-id"},{db:"serverUrl",id:"server-url"},{db:"serverTransport",id:"server-transport"},{db:"selectedTools",id:"selected-tools"},{db:"exceptSelectedTools",id:"except-selected-tools"},{db:"toolsToInclude",id:"tools-to-include"}]),await a(t)},IF_TOOLS_TO_INCLUDE_IS_EXCEPT_SELECTED:({$:t})=>t.getComponent("tools-to-include")?.value==="except-selected",HANDLE_CONNECTION_CHANGE:s("connectionId"),HANDLE_EXCEPT_SELECTED_TOOLS:s("exceptSelectedTools"),HANDLE_SELECTED_TOOLS:s("selectedTools"),HANDLE_SERVER_TRANSPORT:s("serverTransport"),HANDLE_SERVER_URL:s("serverUrl"),HANDLE_TOOLS_TO_INCLUDE:async({$:t,e:l})=>{const r=t.getComponent("tools-to-include")?.value;s("toolsToInclude")({$:t,e:l}),r==="all"&&await a(t)},REFETCH_TOOLS:({$:t})=>a(t)}}));export{U as default};
