import{r as F,e as V,j as s,q as W,f as X,g as Z,d as ee,b as te,K as ne,n as se,O as ie,l as oe,B as le}from"./index-DjCrtoJM.js";import{u as re}from"./use-connection-C7K5Qf-S.js";import{j as ae}from"./use-mcp-client-Wf5qUXFF.js";import{u as ce}from"./studio-tools-C1zamUp1.js";import{a as ue}from"./Settings02-B_z2JeIq.js";import{P as B}from"./index-D7vPwljU.js";const de=F.createContext(null);function K(i){const e=V.c(3),{value:C,children:m}=i,t=C;let o;return e[0]!==m||e[1]!==t?(o=s.jsx(de.Provider,{value:t,children:m}),e[0]=m,e[1]=t,e[2]=o):o=e[2],o}F.createContext(null);function me(i){return{id:i.id,title:i.title,icon:i.icon,description:i.description,app_name:i.app_name,app_id:i.app_id,tools:i.tools,metadata:i.metadata}}function Pe(i){const e=V.c(57),{bindingName:C,renderEmptyState:m}=i,{org:t,project:o}=W(),M=X();let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={strict:!1},e[0]=j):j=e[0];const{org:T,taskId:k,pluginId:f}=Z(j);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={strict:!1},e[1]=v):v=e[1];const w=ee(v).virtualmcpid;let P;e[2]!==C?(P={binding:C},e[2]=C,e[3]=P):P=e[3];const R=re(P),{data:g}=te.useSession(),G=ce();let x;e[4]!==f||e[5]!==o.id?(x=ne.projectPluginConfig(o.id??"",f),e[4]=f,e[5]=o.id,e[6]=x):x=e[6];let p;e[7]!==f||e[8]!==o.id||e[9]!==G?(p=async()=>await G.call("VIRTUAL_MCP_PLUGIN_CONFIG_GET",{virtualMcpId:o.id,pluginId:f}),e[7]=f,e[8]=o.id,e[9]=G,e[10]=p):p=e[10];const O=!!o.id&&!!f;let _;e[11]!==x||e[12]!==p||e[13]!==O?(_={queryKey:x,queryFn:p,enabled:O},e[11]=x,e[12]=p,e[13]=O,e[14]=_):_=e[14];const{data:A,isLoading:D}=se(_),z=A?.config?.connectionId,h=z?R.find(n=>n.id===z):null,I=ae({connectionId:h?.id,orgId:t.id,orgSlug:t.slug});let y;e[15]!==g?(y=g?.user?{user:{id:g.user.id,name:g.user.name,email:g.user.email,image:g.user.image}}:null,e[15]=g,e[16]=y):y=e[16];const a=y;let b;e[17]!==t.id||e[18]!==t.name||e[19]!==t.slug?(b={id:t.id,slug:t.slug,name:t.name},e[17]=t.id,e[18]=t.name,e[19]=t.slug,e[20]=b):b=e[20];const c=b;if(D){let n;return e[21]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[s.jsx(oe,{size:32,className:"animate-spin text-muted-foreground mb-4"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})]}),e[21]=n):n=e[21],n}if(R.length===0){let n;e[22]!==c||e[23]!==a?(n={connectionId:null,connection:null,toolCaller:null,org:c,session:a},e[22]=c,e[23]=a,e[24]=n):n=e[24];const u=n;let r;e[25]!==m?(r=m(),e[25]=m,e[26]=r):r=e[26];let l;e[27]!==r?(l=s.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:r}),e[27]=r,e[28]=l):l=e[28];let d;return e[29]!==u||e[30]!==l?(d=s.jsx(K,{value:u,children:l}),e[29]=u,e[30]=l,e[31]=d):d=e[31],d}if(!h){let n;e[32]!==c||e[33]!==a?(n={connectionId:null,connection:null,toolCaller:null,org:c,session:a},e[32]=c,e[33]=a,e[34]=n):n=e[34];const u=n;let r;e[35]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsxs("div",{className:"flex flex-col items-center gap-2 text-center max-w-md",children:[s.jsx(ue,{size:48,className:"text-muted-foreground mb-2"}),s.jsx("h2",{className:"text-lg font-semibold",children:"Plugin Not Configured"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"This plugin requires a connection to be configured. Go to project settings to select which integration to use."})]}),e[35]=r):r=e[35];let l;e[36]!==M||e[37]!==t.slug||e[38]!==T||e[39]!==o.id||e[40]!==k||e[41]!==w?(l=s.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-4 p-8",children:[r,s.jsx(le,{onClick:()=>{const Y=T??t.slug,H=w??o.id??"",J=k??crypto.randomUUID();M({to:"/$org/$taskId",params:{org:Y,taskId:J},search:{virtualmcpid:H,main:"settings"}})},children:"Go to Project Settings"})]}),e[36]=M,e[37]=t.slug,e[38]=T,e[39]=o.id,e[40]=k,e[41]=w,e[42]=l):l=e[42];let d;return e[43]!==u||e[44]!==l?(d=s.jsx(K,{value:u,children:l}),e[43]=u,e[44]=l,e[45]=d):d=e[45],d}const Q=h.id,q=me(h);let N;e[46]!==I?(N=(n,u)=>I?I.callTool({name:n,arguments:u}).then(fe):Promise.reject(new Error("MCP client is not available")),e[46]=I,e[47]=N):N=e[47];const U=N;let S;e[48]!==h||e[49]!==c||e[50]!==a||e[51]!==q||e[52]!==U?(S={connectionId:Q,connection:q,toolCaller:U,org:c,session:a},e[48]=h,e[49]=c,e[50]=a,e[51]=q,e[52]=U,e[53]=S):S=e[53];const $=S;let E;e[54]===Symbol.for("react.memo_cache_sentinel")?(E=s.jsx(B,{children:s.jsx(B.Content,{children:s.jsx(ie,{})})}),e[54]=E):E=e[54];let L;return e[55]!==$?(L=s.jsx(K,{value:$,children:E}),e[55]=$,e[56]=L):L=e[56],L}function fe(i){return i.structuredContent??i}export{Pe as P};
