@mcp-use/inspector 20.0.0-beta.0 → 20.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/{ChatTab-5ya_YTFV.js → ChatTab-D8uwCHAf.js} +2 -2
- package/dist/cdn/{ConnectionSettingsForm-iwNW86ZU.js → ConnectionSettingsForm-BNS6bOMD.js} +1 -1
- package/dist/cdn/{ConnectionSettingsTab-CeK83dxn.js → ConnectionSettingsTab-B97gPPJW.js} +1 -1
- package/dist/cdn/{OAuthCallback-BxuOVgdb.js → OAuthCallback-k3oeLtIC.js} +1 -1
- package/dist/cdn/{ResourcesTab-BczUMFil.js → ResourcesTab-KfamsM6-.js} +3 -3
- package/dist/cdn/{SamplingTab-6u5s845G.js → SamplingTab-vcufuK24.js} +1 -1
- package/dist/cdn/{ToolsTab-CUhwP4rZ.js → ToolsTab-DRjcZnpu.js} +3 -3
- package/dist/cdn/{ViewPreview-CxJc1Kht.js → ViewPreview-B_onhcUB.js} +2 -2
- package/dist/cdn/{WidgetWrapper-BJJtLqMb.js → WidgetWrapper-D29YDxIu.js} +1 -1
- package/dist/cdn/inspector.js +116 -109
- package/dist/cdn/{react-yUi9mVK4.js → react-BxO-uEDZ.js} +32 -26
- package/dist/cdn/{useViewHostProps-C7vjco2m.js → useViewHostProps-Dr6W2ooF.js} +1 -1
- package/dist/cli.js +116 -14
- package/dist/server/asset-urls.d.ts +14 -0
- package/dist/server/asset-urls.d.ts.map +1 -0
- package/dist/server/asset-urls.js +13 -0
- package/dist/server/cdn-shell.d.ts +3 -3
- package/dist/server/cdn-shell.d.ts.map +1 -1
- package/dist/server/cdn-shell.js +5 -3
- package/dist/server/{chunk-J67FVPHF.js → chunk-IXYK6ZOY.js} +1 -1
- package/dist/server/{chunk-ESODOPDD.js → chunk-J4FNYLBF.js} +4 -0
- package/dist/server/chunk-KBVKS4J5.js +53 -0
- package/dist/server/chunk-M5TZA42I.js +54 -0
- package/dist/server/{chunk-TPHRVELX.js → chunk-VDUV6LR6.js} +16 -9
- package/dist/server/{chunk-THQ67TSE.js → chunk-Y2GBQOQW.js} +1 -1
- package/dist/server/cli.js +6 -4
- package/dist/server/favicon-static.d.ts.map +1 -1
- package/dist/server/favicon-static.js +1 -1
- package/dist/server/index.js +7 -5
- package/dist/server/middleware.js +7 -5
- package/dist/server/static-assets.d.ts +5 -0
- package/dist/server/static-assets.d.ts.map +1 -0
- package/dist/server/static-assets.js +9 -0
- package/dist/server/version.js +1 -1
- package/dist/web/assets/{ChatTab-CiAqtqhj.js → ChatTab-Cy8eyFYI.js} +3 -3
- package/dist/web/assets/{ConnectionSettingsTab-CTh6MFKE.js → ConnectionSettingsTab-sDZGaUJn.js} +1 -1
- package/dist/web/assets/{ElicitationTab-B3Eg0_Jm.js → ElicitationTab-wDKgU1qL.js} +1 -1
- package/dist/web/assets/{ManufactOAuthCallback-B-tdkUA2.js → ManufactOAuthCallback-DCLbW-mz.js} +1 -1
- package/dist/web/assets/{NotificationsTab-BgLjxuos.js → NotificationsTab-JevzvJTg.js} +1 -1
- package/dist/web/assets/{OAuthCallback-Bp-jLoQs.js → OAuthCallback-BjcRxLh5.js} +1 -1
- package/dist/web/assets/{PromptsTab-CA-SZs43.js → PromptsTab-DsQVOjKH.js} +1 -1
- package/dist/web/assets/{ResourcesTab-DdMIW_af.js → ResourcesTab-Bw8_p6M1.js} +1 -1
- package/dist/web/assets/{SamplingTab-DjyDG01W.js → SamplingTab-BrcF1zJF.js} +1 -1
- package/dist/web/assets/{ServerMetadataTab-Q4PlqP_B.js → ServerMetadataTab-Bydeh1Po.js} +1 -1
- package/dist/web/assets/{ToolsTab-BHk8GCmd.js → ToolsTab-DJWF7Q_x.js} +1 -1
- package/dist/web/assets/{ViewPreview-DWtmwzCb.js → ViewPreview-jgeU7bY9.js} +1 -1
- package/dist/web/assets/{WidgetWrapper-B43lqbld.js → WidgetWrapper-B_vJU9uF.js} +1 -1
- package/dist/web/assets/{checkbox-_GzEPQic.js → checkbox-BA-XURSj.js} +1 -1
- package/dist/web/assets/{chunk-BO2N2NFS-BdIeB5Lr.js → chunk-BO2N2NFS-CGbd3eLY.js} +4 -4
- package/dist/web/assets/{dist-DQjEDTKs.js → dist-BcAQZluc.js} +3 -3
- package/dist/web/assets/{highlighted-body-OFNGDK62-Dp3e1QHL.js → highlighted-body-OFNGDK62-BBJFbIMp.js} +1 -1
- package/dist/web/assets/{index-Bbn-6QR2.js → index-D2UxaT9v.js} +3 -3
- package/dist/web/assets/mermaid-GHXKKRXX-B4MKVODA.js +1 -0
- package/dist/web/assets/{pdf-C3cfS_Ha.js → pdf-CuwKm9zO.js} +1 -1
- package/dist/web/assets/{shared-Dfwy7nyg.js → shared-DQE60Op-.js} +1 -1
- package/dist/web/assets/{sheet-CRPrEqAa.js → sheet-7TIkLdpr.js} +1 -1
- package/dist/web/assets/{tabs-subtle-Dxgism9f.js → tabs-subtle-AkJZvdxS.js} +1 -1
- package/dist/web/assets/{useConfig-b1f_iVFH.js → useConfig-Qglo4xs1.js} +1 -1
- package/dist/web/assets/{useMCPPrompts-CPskz9af.js → useMCPPrompts-USLYc1I4.js} +1 -1
- package/dist/web/assets/{useViewHostProps-BgsQ2yYl.js → useViewHostProps-DXAD1g7g.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +5 -5
- package/dist/web/assets/mermaid-GHXKKRXX-yq1lkD3x.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatTab-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatTab-Cy8eyFYI.js","assets/react-CU_d2d5K.js","assets/input-CjmxOFr6.js","assets/bundle-mjs-8puS6ou7.js","assets/createLucideIcon-B3b8EU0b.js","assets/jsx-runtime-Cjj9sGSy.js","assets/FormContext-Cqc_A12u.js","assets/select-C0xlfLAa.js","assets/AnimatePresence-CthXziG2.js","assets/label-B5Q_Zr8M.js","assets/tabs-subtle-AkJZvdxS.js","assets/chunk-BO2N2NFS-CGbd3eLY.js","assets/refresh-cw-C9wQl8_d.js","assets/dist-BcAQZluc.js","assets/useConfig-Qglo4xs1.js","assets/schemaHelpers-DLNTQr_6.js","assets/checkbox-BA-XURSj.js","assets/sheet-7TIkLdpr.js","assets/textarea-Ci09-en6.js","assets/useViewHostProps-DXAD1g7g.js","assets/useMCPPrompts-USLYc1I4.js","assets/ToolsTab-DJWF7Q_x.js","assets/WidgetWrapper-B_vJU9uF.js","assets/maximize-2-BTT9QQU9.js","assets/sparkles-2OAsc1aP.js","assets/zap-Du2Uc5pa.js","assets/code-tME-5H6D.js","assets/shared-DQE60Op-.js","assets/ListTabHeader-G-nQX18m.js","assets/maximize-_O55kFcr.js","assets/save-B-MsgxX9.js","assets/PromptsTab-DsQVOjKH.js","assets/ResourcesTab-Bw8_p6M1.js","assets/brush--0LobUi4.js","assets/SamplingTab-BrcF1zJF.js","assets/ElicitationTab-wDKgU1qL.js","assets/NotificationsTab-JevzvJTg.js","assets/ServerMetadataTab-Bydeh1Po.js","assets/inspector-settings-layout-yjKRJDai.js","assets/ConnectionSettingsTab-sDZGaUJn.js","assets/OAuthCallback-BjcRxLh5.js","assets/ManufactOAuthCallback-DCLbW-mz.js","assets/ViewPreview-jgeU7bY9.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{a as e,i as t,n,s as r,t as i}from"./react-CU_d2d5K.js";import{r as a}from"./bundle-mjs-8puS6ou7.js";import{t as o}from"./jsx-runtime-Cjj9sGSy.js";import{$ as s,$n as c,A as l,Ar as u,At as d,B as f,Bn as p,Cr as m,Ct as h,D as g,Dn as _,Dr as v,Dt as y,E as b,En as x,Er as S,F as C,Fr as w,G as T,Gt as ee,I as E,Ir as D,It as te,J as ne,K as O,Kn as re,Kt as k,L as ie,Lr as A,Lt as j,M,Mn as ae,Mt as oe,N as se,Nn as N,Nr as P,Nt as ce,O as le,Ot as ue,P as de,Pn as fe,Pr as pe,Pt as me,Q as he,R as ge,Rn as _e,Rt as ve,S as ye,Sr as be,St as F,T as xe,Tn as Se,Tt as Ce,U as we,Un as Te,Ut as Ee,Wn as De,X as Oe,Y as ke,Yn as Ae,Z as je,Zn as Me,_ as Ne,_r as Pe,_t as Fe,a as Ie,an as Le,ar as Re,at as ze,b as Be,br as Ve,c as He,ct as Ue,dr as We,dt as Ge,et as Ke,f as qe,fr as Je,ft as Ye,g as Xe,gr as Ze,gt as Qe,h as $e,hn as et,ht as tt,i as nt,in as rt,ir as it,it as at,j as ot,jt as st,k as ct,kn as lt,kr as ut,kt as dt,lt as ft,m as I,mn as pt,mr as mt,mt as ht,n as gt,nr as _t,o as vt,on as yt,or as bt,ot as xt,pr as St,pt as Ct,q as wt,qt as Tt,r as Et,rn as Dt,rr as Ot,rt as kt,s as At,sr as jt,st as Mt,t as Nt,tt as Pt,ut as Ft,v as It,vt as Lt,w as Rt,wn as zt,wr as Bt,wt as Vt,x as Ht,xr as Ut,y as Wt,yr as Gt,yt as Kt,z as qt,zn as Jt}from"./input-CjmxOFr6.js";import{n as Yt,t as Xt}from"./label-B5Q_Zr8M.js";import{b as Zt,l as Qt,r as $t,t as en}from"./AnimatePresence-CthXziG2.js";import{C as tn,S as nn,T as rn,_ as an,a as on,b as sn,c as cn,d as ln,f as un,g as dn,h as fn,i as pn,l as mn,m as hn,n as gn,p as _n,r as vn,t as yn,u as bn,v as xn,w as Sn,x as Cn,y as wn}from"./select-C0xlfLAa.js";import{c as Tn,i as En,l as Dn,o as On,r as kn,t as An}from"./FormContext-Cqc_A12u.js";import{t as L}from"./createLucideIcon-B3b8EU0b.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var jn=n((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,D());else{var t=n(l);t!==null&&O(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function ee(){return g?!0:!(e.unstable_now()-T<w)}function E(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ee());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&O(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?D():S=!1}}}var D;if(typeof y==`function`)D=function(){y(E)};else if(typeof MessageChannel<`u`){var te=new MessageChannel,ne=te.port2;te.port1.onmessage=E,D=function(){ne.postMessage(null)}}else D=function(){_(E,0)};function O(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,O(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,D()))),r},e.unstable_shouldYield=ee,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Mn=n(((e,t)=>{t.exports=jn()})),Nn=n((e=>{var t=Mn(),n=i(),r=a();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(o(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return d(i),e;if(a===r)return d(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,l=i.child;l;){if(l===n){s=!0,n=i,r=a;break}if(l===r){s=!0,r=i,n=a;break}l=l.sibling}if(!s){for(l=a.child;l;){if(l===n){s=!0,n=a,r=i;break}if(l===r){s=!0,r=a,n=i;break}l=l.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function O(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var re=Symbol.for(`react.client.reference`);function k(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===re?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ee:return t=e.displayName||null,t===null?k(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return k(e(t))}catch{}}return null}var ie=Array.isArray,A=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M={pending:!1,data:null,method:null,action:null},ae=[],oe=-1;function se(e){return{current:e}}function N(e){0>oe||(e.current=ae[oe],ae[oe]=null,oe--)}function P(e,t){oe++,ae[oe]=e.current,e.current=t}var ce=se(null),le=se(null),ue=se(null),de=se(null);function fe(e,t){switch(P(ue,t),P(le,e),P(ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?ef(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=ef(t),e=tf(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}N(ce),P(ce,e)}function pe(){N(ce),N(le),N(ue)}function me(e){e.memoizedState!==null&&P(de,e);var t=ce.current,n=tf(t,e.type);t!==n&&(P(le,e),P(ce,n))}function he(e){le.current===e&&(N(ce),N(le)),de.current===e&&(N(de),up._currentValue=M)}var ge,_e;function ve(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ge+e+_e}var ye=!1;function be(e,t){if(!e||ye)return``;ye=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -193,7 +193,7 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
193
193
|
- omitted: host decides border`)});var AO=K({method:X(`ui/request-display-mode`),params:K({mode:fO.describe(`The display mode being requested.`)})}),jO=K({mode:fO.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),MO=J([X(`model`),X(`app`)]).describe(`Tool visibility scope - who can access the tool.`);K({resourceUri:V().optional(),visibility:G(MO).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
194
194
|
- "model": Tool visible to and callable by the agent
|
|
195
195
|
- "app": Tool callable by the app from this server only`),csp:Sp().optional(),permissions:Sp().optional()}),K({mimeTypes:G(V()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var NO=K({method:X(`ui/download-file`),params:K({contents:G(J([aD,oD])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),PO=K({method:X(`ui/message`),params:K({role:X(`user`).describe(`Message role, currently only "user" is supported.`),content:G(sD).describe(`Message content blocks (text, image, etc.).`)})});K({method:X(`ui/notifications/sandbox-resource-ready`),params:K({html:V().describe(`HTML content to load into the inner iframe.`),sandbox:V().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:yO.optional().describe(`CSP configuration from resource metadata.`),permissions:bO.optional().describe(`Sandbox permissions from resource metadata.`)})}),K({method:X(`ui/notifications/tool-result`),params:gD.describe(`Standard MCP tool execution result.`)});var FO=K({toolInfo:K({id:UT.optional().describe(`JSON-RPC id of the tools/call request.`),tool:pD.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:dO.optional().describe(`Current color theme preference.`),styles:CO.optional().describe(`Style configuration for theming the app.`),displayMode:fO.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:G(fO).optional().describe(`Display modes the host supports.`),containerDimensions:J([K({height:H().describe(`Fixed container height in pixels.`)}),K({maxHeight:J([H(),hp()]).optional().describe(`Maximum container height in pixels.`)})]).and(J([K({width:H().describe(`Fixed container width in pixels.`)}),K({maxWidth:J([H(),hp()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
196
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:V().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:V().optional().describe(`User's timezone in IANA format.`),userAgent:V().optional().describe(`Host application identifier.`),platform:J([X(`web`),X(`desktop`),X(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:K({touch:U().optional().describe(`Whether the device supports touch input.`),hover:U().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:K({top:H().describe(`Top safe area inset in pixels.`),right:H().describe(`Right safe area inset in pixels.`),bottom:H().describe(`Bottom safe area inset in pixels.`),left:H().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();K({method:X(`ui/notifications/host-context-changed`),params:FO.describe(`Partial context update containing only changed fields.`)});var IO=K({method:X(`ui/update-model-context`),params:K({content:G(sD).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:Y(V(),W().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),LO=K({method:X(`ui/initialize`),params:K({appInfo:eE.describe(`App identification (name and version).`),appCapabilities:OO.describe(`Features and capabilities this app provides.`),protocolVersion:V().describe(`Protocol version this app supports.`)})}),RO=K({protocolVersion:V().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:eE.describe(`Host application identification and version.`),hostCapabilities:DO.describe(`Features and capabilities provided by the host.`),hostContext:FO.describe(`Rich context about the host environment.`)}).passthrough(),zO=class{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=e=>{if(t&&e.source!==this.eventSource){console.debug(`Ignoring message from unknown source`,e);return}let n=JT.safeParse(e.data);n.success?(console.debug(`Parsed message`,n.data),this.onmessage?.(n.data)):e.data?.jsonrpc===`2.0`?(console.error(`Failed to parse message`,n.error.message,e),this.onerror?.(Error(`Invalid JSON-RPC message received: `+n.error.message))):console.debug(`Ignoring non-JSON-RPC message`,n.error.message,e)}}async start(){window.addEventListener(`message`,this.messageListener)}async send(e,t){e.method!==`ui/notifications/tool-input-partial`&&console.debug(`Sending message`,e),this.eventTarget.postMessage(e,`*`)}async close(){window.removeEventListener(`message`,this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion},BO=`text/html;profile=mcp-app`;function VO(e){if(!e)return``;let t=[];return e.camera&&t.push(`camera`),e.microphone&&t.push(`microphone`),e.geolocation&&t.push(`geolocation`),e.clipboardWrite&&t.push(`clipboard-write`),t.join(`; `)}var HO=[uO],UO=class extends Bb{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new lO;_wrapHandler(e,t){let n=super._wrapHandler(e,t);return e===`ui/initialize`||e===`ping`?n:async(t,r)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${e}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(t,r))}eventSchemas={sizechange:xO,sandboxready:vO,initialized:kO,requestteardown:EO,loggingmessage:wD};setEventHandler(e,t){this._ensureEventSlot(e),this._events.setHandler(e,t)}getEventHandler(e){return this._events.getHandler(e)}addEventListener(e,t){this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);let n=t=>{e===`initialized`&&(this._initializedReceived=!0),this._events.dispatch(e,t)};e===`loggingmessage`?this.setNotificationHandler(`notifications/message`,e=>{n(e.params)}):this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},e=>n(e)),this._registeredEvents.add(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._hostCapabilities=n,this._ensureEventSlot(`initialized`),this._hostContext=r?.hostContext||{},this.setRequestHandler(`ui/initialize`,{params:LO.shape.params,result:RO},e=>this._onAppsInitialize(e)),this.setRequestHandler(`ping`,(e,t)=>(this.onping?.(e.params,t),{})),this.setRequestHandler(`ui/request-display-mode`,{params:AO.shape.params,result:jO},()=>({mode:this._hostContext.displayMode??`inline`}))}buildContext(e){return e}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler(`sizechange`)}set onsizechange(e){this.setEventHandler(`sizechange`,e)}get onsandboxready(){return this.getEventHandler(`sandboxready`)}set onsandboxready(e){this.setEventHandler(`sandboxready`,e)}get oninitialized(){return this.getEventHandler(`initialized`)}set oninitialized(e){this.setEventHandler(`initialized`,e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced(`onmessage`,this._onmessage,e),this._onmessage=e,this.setRequestHandler(`ui/message`,{params:PO.shape.params,result:_O},async(e,t)=>{if(!this._onmessage)throw Error(`No onmessage handler set`);return this._onmessage(e,t)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced(`onopenlink`,this._onopenlink,e),this._onopenlink=e,this.setRequestHandler(`ui/open-link`,{params:mO.shape.params,result:hO},async(e,t)=>{if(!this._onopenlink)throw Error(`No onopenlink handler set`);return this._onopenlink(e,t)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced(`ondownloadfile`,this._ondownloadfile,e),this._ondownloadfile=e,this.setRequestHandler(`ui/download-file`,{params:NO.shape.params,result:gO},async(e,t)=>{if(!this._ondownloadfile)throw Error(`No ondownloadfile handler set`);return this._ondownloadfile(e,t)})}get onrequestteardown(){return this.getEventHandler(`requestteardown`)}set onrequestteardown(e){this.setEventHandler(`requestteardown`,e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced(`onrequestdisplaymode`,this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.setRequestHandler(`ui/request-display-mode`,{params:AO.shape.params,result:jO},async(e,t)=>{if(!this._onrequestdisplaymode)throw Error(`No onrequestdisplaymode handler set`);return this._onrequestdisplaymode(e,t)})}get onloggingmessage(){return this.getEventHandler(`loggingmessage`)}set onloggingmessage(e){this.setEventHandler(`loggingmessage`,e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced(`onupdatemodelcontext`,this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.setRequestHandler(`ui/update-model-context`,{params:IO.shape.params,result:YT},async(e,t)=>{if(!this._onupdatemodelcontext)throw Error(`No onupdatemodelcontext handler set`);return this._onupdatemodelcontext(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.setRequestHandler(`tools/call`,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(`sampling/createMessage`,async(t,n)=>e(t.params,n))}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced(`onlistresources`,this._onlistresources,e),this._onlistresources=e,this.setRequestHandler(`resources/list`,async(e,t)=>{if(!this._onlistresources)throw Error(`No onlistresources handler set`);return this._onlistresources(e.params,t)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced(`onlistresourcetemplates`,this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.setRequestHandler(`resources/templates/list`,async(e,t)=>{if(!this._onlistresourcetemplates)throw Error(`No onlistresourcetemplates handler set`);return this._onlistresourcetemplates(e.params,t)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced(`onreadresource`,this._onreadresource,e),this._onreadresource=e,this.setRequestHandler(`resources/read`,async(e,t)=>{if(!this._onreadresource)throw Error(`No onreadresource handler set`);return this._onreadresource(e.params,t)})}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced(`onlistprompts`,this._onlistprompts,e),this._onlistprompts=e,this.setRequestHandler(`prompts/list`,async(e,t)=>{if(!this._onlistprompts)throw Error(`No onlistprompts handler set`);return this._onlistprompts(e.params,t)})}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(e){let t=e.protocolVersion;return this._appInfo!==void 0&&console.warn(`[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.`),this._appCapabilities=e.appCapabilities,this._appInfo=e.appInfo,{protocolVersion:HO.includes(t)?t:uO,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];WO(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},wO,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},t)}listTools(e,t){return this.request({method:`tools/list`,params:e},t)}async connect(e){if(this.transport)throw Error(`AppBridge is already connected. Call close() before connecting again.`);if(this._initializedReceived=!1,this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},{signal:t.mcpReq.signal}),e.tools.listChanged&&this._client.setNotificationHandler(`notifications/tools/list_changed`,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},{signal:t.mcpReq.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},{signal:t.mcpReq.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},{signal:t.mcpReq.signal}),e.resources.listChanged&&this._client.setNotificationHandler(`notifications/resources/list_changed`,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},{signal:t.mcpReq.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(`notifications/prompts/list_changed`,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function WO(e,t){return JSON.stringify(e)===JSON.stringify(t)}var GO=Object.defineProperty,KO=Object.getOwnPropertyNames,qO=(e,t)=>function(){return e&&(t=(0,e[KO(e)[0]])(e=0)),t},JO=(e,t)=>{for(var n in t)GO(e,n,{get:t[n],enumerable:!0})};function YO(){let e;try{e=typeof process<`u`?{}.MCP_USE_LOG_LEVEL??{}.DEBUG:void 0}catch{}let t=e?.trim().toLowerCase();return t===`2`?`debug`:t&&XO.includes(t)?t:`info`}var XO,ZO,QO,$O,$,ek=qO({"src/utils/logging.ts"(){XO=[`silent`,`error`,`warn`,`info`,`http`,`verbose`,`debug`,`silly`],ZO={silent:``,error:`❌`,warn:`⚠️`,info:`ℹ️`,http:`🌐`,verbose:`📝`,debug:`🔍`,silly:`🤪`},QO=class{constructor(e=`mcp-use`,t=`info`,n=`minimal`){this.name=e,this.level=t,this.format=n}write(e,t,n){if(this.level===`silent`||XO.indexOf(e)>XO.indexOf(this.level))return;let r=n.map(e=>{if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `),i=r?`${t} ${r}`:t,a=new Date().toLocaleTimeString(`en-US`,{hour12:!1}),o=this.format===`minimal`?e:e.toUpperCase(),s=this.format===`emoji`?` ${ZO[e]}`:``,c=`${a} [${this.name}]${s} ${o}: ${i}`;(e===`error`?console.error:e===`warn`?console.warn:e===`info`?console.info:e===`debug`?console.debug:console.log)(c)}error=(e,...t)=>this.write(`error`,e,t);warn=(e,...t)=>this.write(`warn`,e,t);info=(e,...t)=>this.write(`info`,e,t);debug=(e,...t)=>this.write(`debug`,e,t);http=(e,...t)=>this.write(`http`,e,t);verbose=(e,...t)=>this.write(`verbose`,e,t);silly=(e,...t)=>this.write(`silly`,e,t);setFormat(e){this.format=e}},$O=class{static instances={};static currentFormat=`minimal`;static currentLevel;static get(e=`mcp-use`){return this.instances[e]??=new QO(e,this.currentLevel??YO(),this.currentFormat)}static configure({level:e=YO(),format:t=`minimal`}={}){this.currentLevel=e,this.currentFormat=t;for(let n of Object.values(this.instances))n.level=e,n.format=t}static setDebug(e){let t=e===2||e===!0?`debug`:`info`;this.currentLevel=t;for(let e of Object.values(this.instances))e.level=t;try{typeof process<`u`&&({}.MCP_USE_LOG_LEVEL=t)}catch{}}static setFormat(e){this.configure({format:e})}},$=$O.get()}}),tk={};JO(tk,{clearRpcLogs:()=>ak,getAllRpcLogs:()=>rk,getRpcLogs:()=>nk,subscribeToRpcLogs:()=>ik,wrapTransportForLogging:()=>ok});function nk(e){return lk.getLogsForServer(e)}function rk(){return lk.getAllLogs()}function ik(e){return lk.subscribe(e)}function ak(e){lk.clear(e)}function ok(e,t){class n{constructor(e){this.inner=e,this.inner.onmessage=(e,n)=>{lk.publish({serverId:t,direction:`receive`,timestamp:new Date().toISOString(),message:e}),this.onmessage?.(e,n)},this.inner.onclose=()=>{this.onclose?.()},this.inner.onerror=e=>{this.onerror?.(e)}}onclose;onerror;onmessage;async start(){typeof this.inner.start==`function`&&await this.inner.start()}async send(e,n){lk.publish({serverId:t,direction:`send`,timestamp:new Date().toISOString(),message:e}),await this.inner.send(e,n)}async close(){await this.inner.close()}get sessionId(){return this.inner.sessionId}setProtocolVersion(e){typeof this.inner.setProtocolVersion==`function`&&this.inner.setProtocolVersion(e)}}return new n(e)}var sk,ck,lk,uk=qO({"src/react/rpc-logger.ts"(){ek(),sk=$O.get(`RpcLogger`),ck=class{logs=[];listeners=new Set;maxLogs=1e3;publish(e){sk.debug(`[RPC Logger] Publishing log:`,e.direction,e.serverId,e.message?.method),this.logs.push(e),this.logs.length>this.maxLogs&&(this.logs=this.logs.slice(-this.maxLogs)),sk.debug(`[RPC Logger] Total logs:`,this.logs.length,`Listeners:`,this.listeners.size),this.listeners.forEach(t=>{try{t(e)}catch(e){sk.error(`[RPC Logger] Listener error:`,e)}})}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}getLogsForServer(e){return this.logs.filter(t=>t.serverId===e)}getAllLogs(){return[...this.logs]}clear(e){e?this.logs=this.logs.filter(t=>t.serverId!==e):this.logs=[]}},lk=new ck}}),dk=`mcp_auth_callback`,fk=`mcp_auth_callback`;function pk(e){try{return typeof localStorage<`u`&&!!localStorage.getItem(e)}catch{return!1}}function mk({popup:e,state:t,tokensKey:n,timeoutMs:r=5*6e4,closePollMs:i=1e3,closeGraceMs:a=2e4,expectedOrigin:o=typeof window<`u`?window.location.origin:``}){return new Promise(s=>{let c=!1,l=null,u=null,d=null,f=null,p=()=>{if(l&&=(clearInterval(l),null),u&&=(clearTimeout(u),null),d&&=(clearTimeout(d),null),typeof window<`u`&&(window.removeEventListener(`message`,g),window.removeEventListener(`storage`,v)),f){try{f.removeEventListener(`message`,_),f.close()}catch{}f=null}},m=e=>{c||(c=!0,p(),s(e))},h=e=>{!e||e.type!==fk||e.state&&t&&e.state!==t||(e.success?m({kind:`success`}):m({kind:`error`,error:e.error??`Authentication failed in callback.`}))},g=e=>{o&&e.origin!==o||h(e.data)},_=e=>{h(e.data)},v=e=>{e.key===n&&e.newValue&&m({kind:`success`})};if(typeof window<`u`&&(window.addEventListener(`message`,g),window.addEventListener(`storage`,v)),typeof BroadcastChannel<`u`)try{f=new BroadcastChannel(dk),f.addEventListener(`message`,_)}catch{f=null}e&&(l=setInterval(()=>{if(c)return;let t=!1;try{t=e.closed}catch{t=!1}if(t){if(l&&=(clearInterval(l),null),pk(n)){m({kind:`success`});return}d=setTimeout(()=>{m(pk(n)?{kind:`success`}:{kind:`cancelled`})},a)}},i)),u=setTimeout(()=>{m(pk(n)?{kind:`success`}:{kind:`timeout`})},r)})}ek();var hk=`http://json-schema.org/draft-04/schema`,gk=new Set([`http://json-schema.org/draft-07/schema`,`https://json-schema.org/draft-07/schema`]),_k=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),vk=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]);function yk(e){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let t=e.$schema.replace(/#$/,``);if(t===hk)return`4`;if(gk.has(t))return`7`;if(_k.has(t))return`2019-09`;if(vk.has(t))return`2020-12`}var bk=class{getValidator(e){let t=yk(e);return(t===void 0?new Bx:new Bx({draft:t})).getValidator(e)}};ek();var xk;function Sk(e){xk?.(e)}var Ck={"~standard":{version:1,vendor:`mcp-use`,validate:e=>({value:e})}},wk=class{client=null;connectionManager=null;toolsCache=null;capabilitiesCache=null;serverInfoCache=null;connected=!1;opts;notificationHandlers=[];rootsCache=[];activeProgressHandlers=new Set;constructor(e={}){this.opts=e,e.roots&&(this.rootsCache=[...e.roots]),e.onNotification&&this.notificationHandlers.push(e.onNotification)}trackConnectorInit(e){let t=this.constructor.name;Sk({connectorType:t,...e})}onNotification(e){this.notificationHandlers.push(e),this.client&&this.setupNotificationHandler()}async forwardNotification(e){for(let t of this.notificationHandlers)try{await t(e)}catch(e){$.error(`Error in notification handler:`,e)}}async handleListChanged(e,t,n){if(t){$.warn(`[Auto] ${e} refresh failed:`,t);return}e===`notifications/tools/list_changed`&&n&&(this.toolsCache=[...n]),await this.forwardNotification({method:e})}setupNotificationHandler(){if(!this.client)return;this.client.fallbackNotificationHandler=async e=>{switch(e.method){case`notifications/tools/list_changed`:await this.refreshToolsCache();break;case`notifications/resources/list_changed`:await this.onResourcesListChanged();break;case`notifications/prompts/list_changed`:await this.onPromptsListChanged();break;default:break}await this.forwardNotification(e)};let e=this.client._notificationHandlers;for(let t of[`notifications/progress`,`notifications/cancelled`]){let n=e.get(t);n&&e.set(t,async e=>{await n(e),await this.forwardNotification(e)})}}setupRoundProgressForwarding(){if(!this.client)return;let e=this.client,t=e._onnotification.bind(this.client);e._onnotification=async e=>{e&&typeof e==`object`&&e.method===`notifications/progress`&&this.forwardRoundProgress(e.params),await t?.(e)}}forwardRoundProgress(e){if(this.activeProgressHandlers.size===1){let[t]=this.activeProgressHandlers;t?.(e)}}async refreshToolsCache(){if(this.client)try{$.debug(`[Auto] Refreshing tools cache due to list_changed notification`);let e=await this.client.listTools();this.toolsCache=e.tools??[],$.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(e){$.warn(`[Auto] Failed to refresh tools cache:`,e)}}async onResourcesListChanged(){$.debug(`[Auto] Resources list changed - clients should re-fetch if needed`)}async onPromptsListChanged(){$.debug(`[Auto] Prompts list changed - clients should re-fetch if needed`)}async setRoots(e){this.rootsCache=[...e],this.client&&($.debug(`Sending roots/list_changed notification with ${e.length} root(s)`),await this.client.sendRootsListChanged())}getRoots(){return[...this.rootsCache]}setupRootsHandler(){this.client&&this.client.setRequestHandler(`roots/list`,async()=>($.debug(`Server requested roots list, returning ${this.rootsCache.length} root(s)`),{roots:this.rootsCache}))}setupSamplingHandler(){if(!this.client){$.debug(`setupSamplingHandler: No client available`);return}let e=this.opts.onSampling;if(!e){$.debug(`setupSamplingHandler: No sampling callback provided`);return}$.debug(`setupSamplingHandler: Setting up sampling request handler`),this.client.setRequestHandler(`sampling/createMessage`,async t=>($.debug(`Server requested sampling, forwarding to callback`),await e(t.params))),$.debug(`setupSamplingHandler: Sampling handler registered successfully`)}setupElicitationHandler(){if(!this.client){$.debug(`setupElicitationHandler: No client available`);return}let e=this.opts.onElicitation;if(!e){$.debug(`setupElicitationHandler: No elicitation callback provided`);return}$.debug(`setupElicitationHandler: Setting up elicitation request handler`),this.client.setRequestHandler(`elicitation/create`,async t=>($.debug(`Server requested elicitation, forwarding to callback`),await e(t.params))),$.debug(`setupElicitationHandler: Elicitation handler registered successfully`)}async disconnect(){if(!this.connected){$.debug(`Not connected to MCP implementation`);return}$.debug(`Disconnecting from MCP implementation`),await this.cleanupResources(),this.connected=!1,$.debug(`Disconnected from MCP implementation`)}get isClientConnected(){return this.client!=null}async initialize(e=this.opts.defaultRequestOptions??{}){if(!this.client)throw Error(`MCP client is not connected`);$.debug(`Caching server capabilities & tools`);let t=this.client.getServerCapabilities();this.capabilitiesCache=t||null;let n=this.client.getServerVersion();this.serverInfoCache=n?{name:n.name,version:n.version,title:n.title,description:n.description,websiteUrl:n.websiteUrl,icons:n.icons}:null;try{let t=await this.client.listTools(void 0,e);this.toolsCache=t.tools??[],$.debug(`Fetched ${this.toolsCache.length} tools from server`)}catch(e){let t=e;t.code===-32601?$.debug(`Server does not implement tools/list, assuming no tools`):$.debug(`Failed to list tools, assuming empty:`,t.message),this.toolsCache=[]}return $.debug(`Server capabilities:`,t),$.debug(`Server info:`,n),t}get tools(){if(!this.toolsCache)throw Error(`MCP client is not initialized; call initialize() first`);return this.toolsCache}get serverCapabilities(){return this.capabilitiesCache||{}}get serverInfo(){return this.serverInfoCache}get instructions(){return this.client?.getInstructions?.()}get protocolEra(){return this.client?.getProtocolEra?.()}get negotiatedProtocolVersion(){return this.client?.getNegotiatedProtocolVersion?.()}async callTool(e,t,n){if(!this.client)throw Error(`MCP client is not connected`);let r=n?{...n}:void 0;r?.resetTimeoutOnProgress&&!r.onprogress&&(r.onprogress=()=>{},$.debug(`[BaseConnector] Added onprogress callback for tool '${e}' to enable progressToken`)),$.debug(`Calling tool '${e}' with args`,t);let i=r?.onprogress;i&&this.activeProgressHandlers.add(i);try{let n=await this.client.callTool({name:e,arguments:t},r);return $.debug(`Tool '${e}' returned`,n),n}finally{i&&this.activeProgressHandlers.delete(i)}}async listTools(e){if(!this.client)throw Error(`MCP client is not connected`);$.debug(`[listTools] Fetching fresh tools from server...`);let t=await this.client.listTools(void 0,e),n=t.tools?[...t.tools]:[];return $.debug(`[listTools] Returned ${n.length} tools:`,n.map(e=>e.name)),n}async listResources(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Listing resources`,e?`with cursor: ${e}`:``),await this.client.listResources({cursor:e},t)}async listAllResources(e){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.resources)return $.debug(`Server does not advertise resources capability, skipping`),{resources:[]};try{$.debug(`Listing all resources (with auto-pagination)`);let t=[],n;do{let r=await this.client.listResources({cursor:n},e);t.push(...r.resources||[]),n=r.nextCursor}while(n);return{resources:t}}catch(e){if(e.code===-32601)return $.debug(`Server advertised resources but method not found`),{resources:[]};throw e}}async listResourceTemplates(e){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Listing resource templates`),await this.client.listResourceTemplates(void 0,e)}async complete(e,t){if(!this.client)throw Error(`MCP client is not connected`);$.debug(`[complete] Requesting completions for:`,e.ref);let n=await this.client.complete(e,t);return $.debug(`[complete] Received ${n.completion.values.length} suggestions`),n}async readResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Reading resource ${e}`),await this.client.readResource({uri:e},t)}async subscribeToResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Subscribing to resource: ${e}`),await this.client.subscribeResource({uri:e},t)}async unsubscribeFromResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Unsubscribing from resource: ${e}`),await this.client.unsubscribeResource({uri:e},t)}async listPrompts(){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.prompts)return $.debug(`Server does not advertise prompts capability, skipping`),{prompts:[]};try{return $.debug(`Listing prompts`),await this.client.listPrompts()}catch(e){if(e.code===-32601)return $.debug(`Server advertised prompts but method not found`),{prompts:[]};throw e}}async getPrompt(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Getting prompt ${e}`),await this.client.getPrompt({name:e,arguments:t})}async request(e,t=null,n){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Sending raw request '${e}' with params`,t),await this.client.request({method:e,params:t??{}},Ck,n)}async cleanupResources(){let e=[];if(this.client)try{typeof this.client.close==`function`&&await this.client.close()}catch(t){let n=`Error closing client: ${t}`;$.warn(n),e.push(n)}finally{this.client=null}if(this.connectionManager)try{await this.connectionManager.stop()}catch(t){let n=`Error stopping connection manager: ${t}`;$.warn(n),e.push(n)}finally{this.connectionManager=null}this.toolsCache=null,e.length&&$.warn(`Resource cleanup finished with ${e.length} issue(s)`)}};function Tk(e,t=0){if(!e||t>5)return!1;if(e instanceof pS||e instanceof U_&&e.status===401)return!0;if(e instanceof Error){if(e.cause&&Tk(e.cause,t+1))return!0;let n=e instanceof H_?e.data:void 0;if(n?.cause&&Tk(n.cause,t+1))return!0}return!1}function Ek(e,t,n,r){let i=new URL(e),a=t.replace(/\/$/,``);return async(e,t)=>{let o=new Request(e,t),s=new URL(o.url);if(!(s.origin===i.origin&&s.pathname===i.pathname))return n(o);let c=new Headers(o.headers);c.set(`X-Target-URL`,o.url),r&&c.set(`X-Server-Id`,r);let l=o.method===`GET`||o.method===`HEAD`?void 0:await o.clone().arrayBuffer();return n(new Request(a,{method:o.method,headers:c,body:l,signal:o.signal,redirect:`manual`}))}}var Dk=class extends wk{baseUrl;headers;timeout;customFetch;clientInfo;protocolNegotiation;gatewayUrl;serverId;reconnectionOptions;transportType=null;streamableTransport=null;constructor(e,t={}){super(t);let n=e.replace(/\/$/,``);this.baseUrl=n,this.headers={...t.headers??{}},this.gatewayUrl=t.gatewayUrl,this.serverId=t.serverId,t.authToken&&(this.headers.Authorization=`Bearer ${t.authToken}`),this.timeout=t.timeout??1e4;let r=t.fetch??globalThis.fetch.bind(globalThis);this.customFetch=this.gatewayUrl?Ek(n,this.gatewayUrl,r,this.serverId):t.fetch,this.clientInfo=t.clientInfo??{name:`http-connector`,version:`1.0.0`},this.protocolNegotiation=t.protocolNegotiation??`auto`,this.reconnectionOptions=t.reconnectionOptions}buildClientOptions(){return{...this.opts.clientOptions||{},jsonSchemaValidator:this.opts.clientOptions?.jsonSchemaValidator??new bk,versionNegotiation:{mode:this.protocolNegotiation,...this.opts.clientOptions?.versionNegotiation??{}},listChanged:{tools:{autoRefresh:!0,onChanged:(e,t)=>void this.handleListChanged(`notifications/tools/list_changed`,e,t)},resources:{autoRefresh:!1,onChanged:e=>void this.handleListChanged(`notifications/resources/list_changed`,e)},prompts:{autoRefresh:!1,onChanged:e=>void this.handleListChanged(`notifications/prompts/list_changed`,e)},...this.opts.clientOptions?.listChanged??{}},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.onSampling?{sampling:{}}:{},...this.opts.onElicitation?{elicitation:{form:{},url:{}}}:{}}}}unwrapStreamableError(e){return e instanceof U_?e:e instanceof Error&&e.cause instanceof U_?e.cause:null}classifyStreamableHttpFailure(e){let t=`Unknown error`,n=!1,r,i=this.unwrapStreamableError(e);if(i){let e=i.status;return n=e===401,r=e,e===400&&i.message.includes(`Missing session ID`)?(t=`Server requires session ID (FastMCP compatibility)`,$.warn(`\u26A0\uFE0F ${t}`)):e===404||e===405?(t=`Server returned ${e} - server likely doesn't support streamable HTTP`,$.debug(t)):(t=`Server returned ${e}: ${i.message}`,$.debug(t)),{fallbackReason:t,is401Error:n,httpStatusCode:r}}if(e instanceof Error){let r=e.toString(),i=e.message||``;n=Tk(e)||r.includes(`401`)||i.includes(`Unauthorized`),r.includes(`Missing session ID`)||r.includes(`Bad Request: Missing session ID`)||i.includes(`FastMCP session ID error`)?(t=`Server requires session ID (FastMCP compatibility)`,$.warn(`\u26A0\uFE0F ${t}`)):r.includes(`405 Method Not Allowed`)||r.includes(`404 Not Found`)?(t=`Server doesn't support streamable HTTP (405/404)`,$.debug(t)):(t=`Streamable HTTP failed: ${e.message}`,$.debug(t))}return{fallbackReason:t,is401Error:n,httpStatusCode:r}}async connect(){if(this.connected){$.debug(`Already connected to MCP implementation`);return}let e=this.baseUrl;$.debug(`Connecting to MCP implementation via HTTP: ${e}`);try{await this.connectWithStreamableHttp(e),$.debug(`✅ Successfully connected via streamable HTTP`)}catch(e){$.debug(`Streamable HTTP connect failed`,e);let{fallbackReason:t,is401Error:n,httpStatusCode:r}=this.classifyStreamableHttpFailure(e);if(await this.cleanupResources(),n){$.info(`Authentication required`);let e=Error(`Authentication required`);throw e.code=401,e}let i=Error(`Could not connect via streamable HTTP: ${t}`);throw r!==void 0&&Object.defineProperty(i,"code",{value:r,writable:!1,enumerable:!0,configurable:!0}),i}}observeSseProgress(e){if(!e.body||!e.headers.get(`content-type`)?.includes(`text/event-stream`))return e;let[t,n]=e.body.tee();return(async()=>{let e=n.getReader(),t=new TextDecoder,r=``;try{for(;;){let{done:n,value:i}=await e.read();if(n)break;r+=t.decode(i,{stream:!0});let a=r.split(/\r?\n\r?\n/);r=a.pop()??``;for(let e of a)for(let t of e.split(/\r?\n/))if(t.startsWith(`data:`))try{let e=JSON.parse(t.slice(5).trim());e.method===`notifications/progress`&&this.forwardRoundProgress(e.params)}catch{}}}catch(e){e instanceof DOMException&&e.name===`AbortError`||$.debug(`Progress observer stream ended:`,e)}finally{e.releaseLock()}})(),new Response(t,{status:e.status,statusText:e.statusText,headers:e.headers})}async connectWithStreamableHttp(e){try{$.debug(`[HttpConnector] Connecting with Streamable HTTP`,{baseUrl:e,originalUrl:this.baseUrl,gatewayUrl:this.gatewayUrl||`none`,authProviderUrl:this.opts.authProvider&&`serverUrl`in this.opts.authProvider&&typeof this.opts.authProvider.serverUrl==`string`?this.opts.authProvider.serverUrl:`none`,headers:this.headers});let t,n=new Promise(e=>{t=e}),r=this.customFetch??globalThis.fetch.bind(globalThis),i=new LC(new URL(e),{authProvider:this.opts.authProvider,fetch:async(e,n)=>{let i=await r(e,n),a=n?.method??(e instanceof Request?e.method:`GET`),o=new Headers(e instanceof Request?e.headers:void 0);return new Headers(n?.headers).forEach((e,t)=>{o.set(t,e)}),a.toUpperCase()===`GET`&&i.ok&&i.headers.get(`content-type`)?.includes(`text/event-stream`)&&t?.(),o.get(`mcp-method`)===`subscriptions/listen`?i:this.observeSseProgress(i)},requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2,...this.reconnectionOptions}}),a=i;if(this.opts.wrapTransport){let e=this.baseUrl;a=this.opts.wrapTransport(a,e)}let o=this.buildClientOptions();$.debug(`Creating Client with capabilities:`,JSON.stringify(o.capabilities,null,2)),this.client=new MC(this.clientInfo,o),this.setupRootsHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$.debug(`Roots/sampling/elicitation handlers registered before connect`);try{let e;if(await Promise.race([this.client.connect(a),new Promise((t,n)=>{e=setTimeout(()=>n(Error(`MCP connection timed out after ${this.timeout}ms`)),this.timeout)})]).finally(()=>{e!==void 0&&clearTimeout(e)}),(this.client.getProtocolEra?.()??`legacy`)===`legacy`&&i.sessionId){let e,t=await Promise.race([n.then(()=>!0),new Promise(t=>e=setTimeout(()=>t(!1),Math.min(this.timeout,5e3)))]);e&&clearTimeout(e),t||$.warn(`Legacy server push stream did not attach before connect completed`)}let t=i.sessionId;t&&$.debug(`Session ID obtained: ${t}`)}catch(e){if(e instanceof Error){let t=e.message||e.toString();if(t.includes(`Missing session ID`)||t.includes(`Bad Request: Missing session ID`)||t.includes(`Mcp-Session-Id header is required`)){let n=Error(`Session ID error: ${t}. The SDK should automatically extract session ID from initialize response.`);throw n.cause=e,n}}throw e}this.streamableTransport=i,this.connectionManager={stop:async()=>{if(this.streamableTransport)try{await this.streamableTransport.close()}catch(e){$.warn(`Error closing Streamable HTTP transport: ${e}`)}finally{this.streamableTransport=null}}},this.connected=!0,this.transportType=`streamable-http`,this.setupNotificationHandler(),$.debug(`Successfully connected to MCP implementation via streamable HTTP: ${e}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (streamable-http)`})}catch(e){throw await this.cleanupResources(),e}}get publicIdentifier(){return{type:`http`,url:this.baseUrl,transport:this.transportType||`unknown`,protocolEra:this.protocolEra??`unknown`}}getTransportType(){return this.transportType}async cleanupResources(){if(this.streamableTransport&&this.protocolEra!==`modern`){let e;try{await Promise.race([this.streamableTransport.terminateSession().then(()=>!0),new Promise(t=>e=setTimeout(()=>t(!1),Math.min(this.timeout,5e3)))])||$.debug(`Timed out terminating legacy HTTP session; closing transport`)}catch(e){$.debug(`Error terminating Streamable HTTP session: ${e}`)}finally{e&&clearTimeout(e)}}await super.cleanupResources()}},Ok=`2.0.0-beta.0`;function kk(){return Ok}function Ak(e,t){return{onSampling:e?.onSampling??t?.onSampling,onElicitation:e?.onElicitation??t?.onElicitation,onNotification:e?.onNotification??t?.onNotification}}function jk(e){if(!(`url`in e)||typeof e.url!=`string`||e.authProvider||e.authToken||e.oauth===!1)return!1;let t=e.headers;if(t){for(let e of Object.keys(t))if(e.toLowerCase()===`authorization`)return!1}return!0}function Mk(){return{name:`mcp-use`,title:`mcp-use`,version:kk(),description:`mcp-use is a complete TypeScript framework for building and using MCP`,icons:[{src:`https://mcp-use.com/logo.png`}],websiteUrl:`https://mcp-use.com`}}function Nk(e){let t=Mk();if(!e||typeof e!=`object`)return t;let n=e;return!n.name||!n.version?t:{...t,...n}}function Pk(e){let t=e?.capabilities;if(!t||t.views!==!0)return e;let{views:n,...r}=t,i=r.extensions&&typeof r.extensions==`object`&&!Array.isArray(r.extensions)?{...r.extensions}:{};return{...e,capabilities:{...r,extensions:{...i,"io.modelcontextprotocol/ui":{mimeTypes:[`text/html;profile=mcp-app`]}}}}}function Fk(e){let t=()=>{throw Error(`Invalid url to pass to open(): ${e}`)},n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&=encodeURIComponent(n.username),n.password&&=encodeURIComponent(n.password),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(Ik).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}function Ik([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}var Lk=class{get(e){return localStorage.getItem(e)}set(e,t){localStorage.setItem(e,t)}remove(e){localStorage.removeItem(e)}keys(){let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&e.push(n)}return e}},Rk=class e{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;clientMetadataUrl;scope;store;allowClientSecret;constructor(t,n,r){FS(n.clientMetadataUrl),this.serverUrl=t,this.storageKeyPrefix=n.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=e.hashString(t),this.clientName=n.clientName||`mcp-use`,this.clientUri=n.clientUri||(typeof window<`u`?window.location.origin:`https://mcp-use.com`),this.logoUri=n.logoUri||`https://mcp-use.com/logo.png`,this.callbackUrl=Fk(n.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.clientMetadataUrl=n.clientMetadataUrl,this.scope=n.scope,this.store=r,this.allowClientSecret=n.allowClientSecret??!0}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}static hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}get redirectUrl(){return this.callbackUrl}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri,logo_uri:this.logoUri,...this.scope?{scope:this.scope}:{}}}credentialKey(e,t){return t?this.getKey(`${e}_${encodeURIComponent(t.issuer)}`):this.getKey(e)}async readCredential(e,t){let n=this.credentialKey(e,t),r=await this.store.get(n);if(!r&&t){let r=this.credentialKey(e),i=await this.store.get(r);if(i)try{let e=JSON.parse(i);if(!e.issuer||e.issuer===t.issuer){let i={...e,issuer:t.issuer},a=JSON.stringify(i);return await this.store.set(n,a),await this.store.set(r,a),{key:n,value:i}}}catch{await this.store.remove(r)}return}if(r)try{return{key:n,value:JSON.parse(r)}}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse ${e.replace(`_`,` `)}:`,t),await this.store.remove(n);return}}async tokens(e){return(await this.readCredential(`tokens`,e))?.value}async saveTokens(e,t){let n=JSON.stringify(e);await this.store.set(this.credentialKey(`tokens`,t),n),t&&await this.store.set(this.credentialKey(`tokens`),n),await this.store.remove(this.getKey(`code_verifier`)),await this.store.remove(this.getKey(`last_auth_url`))}async clientInformation(e){let t=await this.readCredential(`client_info`,e);if(!t)return;let{key:n,value:r}=t;try{if(!this.allowClientSecret&&r.client_secret){await this.store.remove(n),e&&await this.store.remove(this.credentialKey(`client_info`)),console.warn(`[${this.storageKeyPrefix}] Removed OAuth client information containing a browser client_secret.`);return}let t=Array.isArray(r.redirect_uris)?r.redirect_uris:[];if(!(t.length===0||t.includes(this.redirectUrl))){console.info(`[${this.storageKeyPrefix}] Invalidating cached OAuth client info due to redirect URI mismatch.`),await this.store.remove(n),await this.store.remove(this.credentialKey(`tokens`,e)),await this.store.remove(this.getKey(`last_auth_url`));return}return r}catch{await this.store.remove(n);return}}async saveClientInformation(e,t){let n=e;if(!this.allowClientSecret&&n.client_secret)throw await this.store.remove(this.credentialKey(`client_info`,t)),t&&await this.store.remove(this.credentialKey(`client_info`)),Error(`Browser OAuth clients must be public clients; client_secret persistence is not allowed.`);let r=JSON.stringify(e);await this.store.set(this.credentialKey(`client_info`,t),r),t&&await this.store.set(this.credentialKey(`client_info`),r)}async saveCodeVerifier(e){await this.store.set(this.getKey(`code_verifier`),e)}async codeVerifier(){let e=this.getKey(`code_verifier`),t=await this.store.get(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async invalidateCredentials(e){let t=async e=>{let t=`${this.getKey(e)}_`;for(let n of await this.store.keys())(n===this.getKey(e)||n.startsWith(t))&&await this.store.remove(n)};switch(e){case`all`:await t(`tokens`),await t(`client_info`),await this.store.remove(this.getKey(`code_verifier`)),await this.store.remove(this.getKey(`last_auth_url`)),await this.store.remove(this.getKey(`discovery_state`)),await this.store.remove(this.getKey(`token_endpoint`));break;case`client`:await t(`client_info`);break;case`tokens`:await t(`tokens`);break;case`verifier`:await this.store.remove(this.getKey(`code_verifier`));break;case`discovery`:await this.store.remove(this.getKey(`discovery_state`));break;default:break}}async saveDiscoveryState(e){await this.store.set(this.getKey(`discovery_state`),JSON.stringify(e))}async discoveryState(){let e=await this.store.get(this.getKey(`discovery_state`));if(e)try{return JSON.parse(e)}catch{await this.store.remove(this.getKey(`discovery_state`));return}}async storeAuthorizationState(e,t={}){let n=globalThis.crypto.randomUUID(),r=`${this.storageKeyPrefix}:state_${n}`,i={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl,...this.clientMetadataUrl?{clientMetadataUrl:this.clientMetadataUrl}:{},...t.extraProviderOptions??{}},flowType:t.flowType,returnUrl:t.returnUrl};e.searchParams.set(`state`,n);let a=Fk(e.toString());return await this.store.set(r,JSON.stringify(i)),await this.store.set(this.getKey(`last_auth_url`),a),a}async getTokenEndpoint(){return(await this.discoveryState())?.authorizationServerMetadata?.token_endpoint??null}};async function zk(e){return typeof e==`string`?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}var Bk=class{serverUrl;staticClientInfo;session;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;proxyOAuthRequests;onPopupWindow;constructor(e,t={}){if(t.staticClientInfo?.client_secret)throw Error(`Browser OAuth clients must be public clients; staticClientInfo.client_secret is not allowed.`);this.serverUrl=e,this.session=new Rk(e,{...t,allowClientSecret:!1},new Lk),this.preventAutoAuth=t.preventAutoAuth,this.useRedirectFlow=t.useRedirectFlow,this.oauthProxyUrl=t.oauthProxyUrl,this.connectionUrl=t.connectionUrl,this.proxyOAuthRequests=t.proxyOAuthRequests??!0,this.staticClientInfo=t.staticClientInfo,this.onPopupWindow=t.onPopupWindow}get storageKeyPrefix(){return this.session.storageKeyPrefix}get serverUrlHash(){return this.session.serverUrlHash}get clientName(){return this.session.clientName}get clientUri(){return this.session.clientUri}get logoUri(){return this.session.logoUri}get callbackUrl(){return this.session.callbackUrl}get scope(){return this.session.scope}get clientMetadataUrl(){return this.session.clientMetadataUrl}getKey(e){return this.session.getKey(e)}reanchorWellKnownUrl(e){if(!this.connectionUrl)return e;try{let t=new URL(e),n=new URL(this.connectionUrl);if(t.origin!==n.origin||!t.pathname.startsWith(`/.well-known/`))return e;let r=new URL(this.serverUrl),[i,...a]=t.pathname.slice(13).split(`/`);if(!i)return e;let o=a.length?`/${a.join(`/`)}`:``,s=n.pathname.replace(/\/+$/,``),c=r.pathname.replace(/\/+$/,``),l=o&&o===s?c:o;return`${r.origin}/.well-known/${i}${l}${t.search}`}catch{return e}}getProxyFetch(e){if(!this.proxyOAuthRequests||!this.oauthProxyUrl)return e;let t=e??globalThis.fetch.bind(globalThis),n=this.oauthProxyUrl,r=new Set,i=!1;return async(e,a)=>{let o=typeof e==`string`?e:e instanceof URL?e.toString():e.url,s=this.reanchorWellKnownUrl(o),c;try{c=new URL(s).pathname}catch{return await t(e,a)}let l=c.includes(`/.well-known/`);if(!i){i=!0;let e=(await this.discoveryState())?.authorizationServerMetadata;for(let t of[`registration_endpoint`,`token_endpoint`,`revocation_endpoint`,`introspection_endpoint`])typeof e?.[t]==`string`&&r.add(e[t])}let u=r.has(s)||/\/(?:register|registration|token|revoke|revocation|introspect|introspection)\/?$/.test(c);if(!l&&!u)return await t(e,a);try{let r=new URL(s),i=new URL(n);if(r.origin===i.origin&&(r.pathname.startsWith(i.pathname)||s.includes(`/inspector/api/oauth`)))return await t(e,a)}catch{}let d=l?`${n}/metadata?serverUrl=${encodeURIComponent(this.serverUrl)}&url=${encodeURIComponent(s)}`:`${n}/proxy`;if(l){let e=await t(d,{...a,method:`GET`});try{let t=await e.clone().json();for(let e of[`registration_endpoint`,`token_endpoint`,`revocation_endpoint`,`introspection_endpoint`])typeof t[e]==`string`&&r.add(t[e])}catch{}return e}let f=a?.body?await zk(a.body):void 0,p=await(await t(d,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({serverUrl:this.serverUrl,url:s,method:a?.method||`POST`,headers:a?.headers?Object.fromEntries(new Headers(a.headers)):{},body:f})})).json();return new Response(JSON.stringify(p.body),{status:p.status,statusText:p.statusText,headers:new Headers(p.headers)})}}get redirectUrl(){return this.session.redirectUrl}get clientMetadata(){return this.session.clientMetadata}tokens(e){return this.session.tokens(e)}saveTokens(e,t){return this.session.saveTokens(e,t)}async clientInformation(e){return this.staticClientInfo?this.staticClientInfo:this.session.clientInformation(e)}async saveClientInformation(e,t){if(!this.staticClientInfo)return this.session.saveClientInformation(e,t)}codeVerifier(){return this.session.codeVerifier()}saveCodeVerifier(e){return this.session.saveCodeVerifier(e)}invalidateCredentials(e){return this.session.invalidateCredentials(e)}saveDiscoveryState(e){return this.session.saveDiscoveryState(e)}discoveryState(){return this.session.discoveryState()}getTokenEndpoint(){return this.session.getTokenEndpoint()}async getClientCredentials(){let e=await this.clientInformation();return e?.client_id?{client_id:e.client_id}:null}async prepareAuthorizationUrl(e){return this.session.storeAuthorizationState(e,{extraProviderOptions:{oauthProxyUrl:this.oauthProxyUrl,...this.clientMetadataUrl?{clientMetadataUrl:this.clientMetadataUrl}:{},...this.staticClientInfo?{staticClientInfo:this.staticClientInfo}:{},...this.scope?{scope:this.scope}:{}},flowType:this.useRedirectFlow?`redirect`:`popup`,returnUrl:typeof window<`u`?window.location.href:void 0})}async redirectToAuthorization(e){let t=await this.prepareAuthorizationUrl(e);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=t;return}let n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?Fk(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}};async function Vk(e,t={}){return new Bk(e,t)}ek(),ek();var Hk=class{},Uk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`mcp_agent_execution`}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}},Wk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`mcpclient_init`}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},Gk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`connector_init`}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},Kk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`client_add_server`}get properties(){let{serverName:e,serverConfig:t}=this.data,n=t.url;return{server_name:e,server_url_domain:n?this._extractHostname(n):null,transport:t.transport??null,has_auth:!!(t.authToken||t.authProvider)}}_extractHostname(e){try{return new URL(e).hostname}catch{return null}}},qk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`client_remove_server`}get properties(){return{server_name:this.data.serverName}}};async function Jk(e,t){try{await fetch(e,t)}catch{}}var Yk=`https://eu.i.posthog.com`,Xk=`phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI`,Zk=`https://mcpuse.gateway.scarf.sh/events-ts`,Qk=`https://mcpuse.gateway.scarf.sh/simple/`,$k=1800,eA=new Set([`query`,`response`,`messages`]);function tA(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function nA(e,t=Qk){let n=new URLSearchParams;for(let[t,r]of Object.entries(e)){let e=tA(r);eA.has(t)&&e.length>120&&(e=`${e.slice(0,117)}...`),e!==``&&n.set(t,e)}let r=`${t}${t.includes(`?`)?`&`:`?`}${n.toString()}`;if(r.length<=$k)return r;let i=[...n.keys()].sort((e,t)=>(n.get(t)?.length??0)-(n.get(e)?.length??0));for(let e of i){if(r.length<=$k)break;e===`event`||e===`user_id`||(n.delete(e),r=`${t}${t.includes(`?`)?`&`:`?`}${n.toString()}`)}return r.slice(0,$k)}function rA(e,t){return Jk(t,{method:`POST`,headers:{"Content-Type":`application/json`},keepalive:!0,body:JSON.stringify(e)})}function iA(e,t){try{let n=nA(e,t),r=new Image;r.referrerPolicy=`no-referrer-when-downgrade`,r.src=n}catch{}return Promise.resolve()}function aA(e){let t=e.host??Yk,n=e.apiKey??Xk;return Jk(`${t}/i/v0/e/`,{method:`POST`,headers:{"Content-Type":`application/json`},keepalive:!0,body:JSON.stringify({api_key:n,event:e.event,distinct_id:e.distinctId,properties:e.properties,timestamp:new Date().toISOString()})})}function oA(e,t=Zk){return typeof window<`u`?iA(e,t===Zk?Qk:t):rA(e,t)}function sA(){return globalThis.crypto.randomUUID()}function cA(){let e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function lA(e,t){let n=e=>e.split(`-`)[0].split(`.`).map(e=>parseInt(e,10)||0),r=n(e),i=n(t),a=Math.max(r.length,i.length);for(let e=0;e<a;e++){let t=r[e]??0,n=i[e]??0;if(t!==n)return t>n}return!1}var uA=`mcp_use_user_id`,dA=`phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI`,fA=`https://eu.i.posthog.com`,pA=null;function mA(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`&&typeof localStorage.removeItem==`function`}function hA(){if(!mA())return null;try{localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`)}catch{return null}return{getUserId(){try{return localStorage.getItem(uA)}catch{return null}},setUserId(e){try{localStorage.setItem(uA,e)}catch{}},getDownloadedVersion:()=>null,setDownloadedVersion:()=>void 0}}function gA(){try{return globalThis.Bun===void 0?globalThis.Deno===void 0?typeof navigator<`u`&&navigator.userAgent?.includes(`Cloudflare-Workers`)?`cloudflare-workers`:globalThis.EdgeRuntime===void 0?typeof window<`u`&&typeof document<`u`?`browser`:typeof process<`u`&&process.versions?.node!==void 0?`node`:`unknown`:`edge`:`deno`:`bun`}catch{return`unknown`}}function _A(){if(typeof process<`u`&&{}.MCP_USE_TELEMETRY_SOURCE)return{}.MCP_USE_TELEMETRY_SOURCE;try{if(mA())return localStorage.getItem(`MCP_USE_TELEMETRY_SOURCE`)??void 0}catch{}}function vA(){if(typeof window<`u`&&window.__MCP_USE_ANONYMIZED_TELEMETRY__===!1||typeof process<`u`&&{}.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase()===`false`)return!0;try{if(mA()&&localStorage.getItem(`MCP_USE_ANONYMIZED_TELEMETRY`)===`false`)return!0}catch{}return!1}function yA(){try{return`session-${sA()}`}catch{return`session-${Date.now()}-${cA()}`}}var bA=class e{static instance=null;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_telemetryEnabled=!1;_pending=new Set;_scarfEnabled=!1;_runtimeEnvironment;_storageCapability;_storage;_fsBacked;_source;_productVersion;constructor(){this._runtimeEnvironment=gA(),this._fsBacked=pA!==null,this._storage=pA??hA()??null,this._storageCapability=this._storage?`persistent`:`session-only`,this._source=_A()||this._runtimeEnvironment;let e=vA(),t=this._runtimeEnvironment!==`unknown`;e?(this._telemetryEnabled=!1,$.debug(`Telemetry disabled via opt-out`)):t?($.debug(`Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable.`),this._telemetryEnabled=!0,this._scarfEnabled=!0,this._fsBacked&&setTimeout(()=>{this.trackPackageDownload({triggered_by:`initialization`}).catch(e=>$.debug(`Failed to track package download: ${e}`))},0)):(this._telemetryEnabled=!1,$.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e;try{mA()&&localStorage.setItem(`MCP_USE_TELEMETRY_SOURCE`,e)}catch{}$.debug(`Telemetry source set to: ${e}`)}getSource(){return this._source}setProductVersion(e){this._productVersion=e}get isEnabled(){return this._telemetryEnabled||this._scarfEnabled}get userId(){if(this._currUserId)return this._currUserId;try{if(this._storage){let e=this._storage.getUserId();if(e)return this._currUserId=e,e;let t=sA();return this._storage.setUserId(t),this._currUserId=t,t}this._currUserId=yA()}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}async capture(e){if(!this._telemetryEnabled&&!this._scarfEnabled)return;let t=this.userId,n={...e.properties,mcp_use_version:this._productVersion??kk(),language:`typescript`,source:this._source,runtime:this._runtimeEnvironment};if(this._telemetryEnabled){let r=aA({host:fA,apiKey:dA,event:e.name,distinctId:t,properties:n});this._pending.add(r),r.finally(()=>this._pending.delete(r))}if(this._scarfEnabled){let r=oA({...n,user_id:t,event:e.name});this._pending.add(r),r.finally(()=>this._pending.delete(r))}}async trackPackageDownload(e){if(!this._scarfEnabled||!this._fsBacked||!this._storage)return;let t=kk(),n=this._storage.getDownloadedVersion(),r=!1,i=!1;n?lA(t,n)&&(i=!0,this._storage.setDownloadedVersion(t)):(i=!0,r=!0,this._storage.setDownloadedVersion(t)),i&&await oA({...e||{},mcp_use_version:t,user_id:this.userId,event:`package_download`,first_download:r,language:`typescript`,source:this._source,runtime:this._runtimeEnvironment})}async trackAgentExecution(e){this.isEnabled&&await this.capture(new Uk(e))}async trackMCPClientInit(e){this.isEnabled&&await this.capture(new Wk(e))}async trackConnectorInit(e){this.isEnabled&&await this.capture(new Gk(e))}async trackClientAddServer(e,t){this.isEnabled&&await this.capture(new Kk({serverName:e,serverConfig:t}))}async trackClientRemoveServer(e){this.isEnabled&&await this.capture(new qk({serverName:e}))}async trackUseMcpConnection(e){this.isEnabled&&await this.capture({name:`usemcp_connection`,properties:{url_domain:new URL(e.url).hostname,transport_type:e.transportType,success:e.success,error_type:e.errorType??null,connection_time_ms:e.connectionTimeMs??null,has_oauth:e.hasOAuth,has_sampling:e.hasSampling,has_elicitation:e.hasElicitation}})}async trackUseMcpToolCall(e){this.isEnabled&&await this.capture({name:`usemcp_tool_call`,properties:{tool_name:e.toolName,success:e.success,error_type:e.errorType??null,execution_time_ms:e.executionTimeMs??null}})}async trackUseMcpResourceRead(e){this.isEnabled&&await this.capture({name:`usemcp_resource_read`,properties:{resource_uri_scheme:e.resourceUri.split(`:`)[0],success:e.success,error_type:e.errorType??null}})}identify(e,t){this._currUserId=e,this._storage?.setUserId(e),this._telemetryEnabled&&aA({host:fA,apiKey:dA,event:`$identify`,distinctId:e,properties:{$set:t??{}}})}reset(){this._currUserId=null}flush(){Promise.allSettled([...this._pending])}async shutdown(){try{await Promise.allSettled([...this._pending]),$.debug(`Telemetry fetch captures flushed`)}catch(e){$.debug(`Error flushing telemetry captures: ${e}`)}}},xA=5*6e4;function SA(e,t=0){if(!e||t>5)return!1;if(e instanceof pS)return!0;if(e instanceof Error){if(e.code===401||e.name===`UnauthorizedError`)return!0;let n=e.message??``;if(n.includes(`401`)||n.includes(`Unauthorized`)||e.cause&&SA(e.cause,t+1))return!0;let r=e.data;if(r?.cause&&SA(r.cause,t+1))return!0}return!1}async function CA(e,t,n={}){let r=e,i=n.timeoutMs??xA,a=n.fetchFn??r.getProxyFetch?.()??void 0;if(!r.hasPendingFlow){let n=await MS(e,{serverUrl:t,fetchFn:a});if(n===`AUTHORIZED`)return;if(n!==`REDIRECT`)throw Error(`Unexpected OAuth auth() result: ${n}`)}if(typeof r.getAuthorizationCode==`function`){await MS(e,{serverUrl:t,authorizationCode:await r.getAuthorizationCode(),fetchFn:a});return}await wA(r,i)}async function wA(e,t){if(typeof window>`u`)throw Error(`OAuth redirect requires a browser environment or a provider with getAuthorizationCode()`);if(e.useRedirectFlow)return;let n=e.getKey?.(`tokens`);if(!n)throw Error(`Browser OAuth provider must expose getKey() for token storage`);let r=null,i=e.getLastAttemptedAuthUrl?.();if(i)try{r=new URL(i).searchParams.get(`state`)}catch{}let a=await mk({popup:null,state:r,tokensKey:n,timeoutMs:t});switch(a.kind){case`success`:return;case`cancelled`:throw Error(`OAuth authentication was cancelled.`);case`timeout`:throw Error(`OAuth callback not received within ${t}ms. Ensure /oauth/callback calls onMcpAuthorization().`);case`error`:throw Error(a.error);default:throw Error(`Unexpected OAuth popup result`)}}ek();var TA=class{connector;autoConnect;constructor(e,t=!0){this.connector=e,this.autoConnect=t}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(e,t){e===`notification`&&this.connector.onNotification(t)}async setRoots(e){return this.connector.setRoots(e)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(e){return this.connector.listTools(e)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}get protocolEra(){return this.connector.protocolEra}get negotiatedProtocolVersion(){return this.connector.negotiatedProtocolVersion}get info(){let e=this.protocolEra,t=this.negotiatedProtocolVersion,n=this.serverInfo;if(!e||!t||!n)throw Error(`MCP connection is not initialized`);let r=this.serverCapabilities,i=r.extensions&&typeof r.extensions==`object`&&!Array.isArray(r.extensions)?r.extensions:{};return{protocolEra:e,protocolVersion:t,server:n,capabilities:r,instructions:this.connector.instructions,extensions:i}}supports(e){return e in this.serverCapabilities}async callTool(e,t={},n){return this.connector.callTool(e,t,n)}async listResources(e,t){return this.connector.listResources(e,t)}async listAllResources(e){return this.connector.listAllResources(e)}async listResourceTemplates(e){return this.connector.listResourceTemplates(e)}async complete(e,t){return this.connector.complete(e,t)}async readResource(e,t){return this.connector.readResource(e,t)}async subscribeToResource(e,t){return this.connector.subscribeToResource(e,t)}async unsubscribeFromResource(e,t){return this.connector.unsubscribeFromResource(e,t)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(e,t){return this.connector.getPrompt(e,t)}async request(e,t=null,n){return this.connector.request(e,t,n)}},EA;function DA(e,t){EA?.addServer(e,t)}function OA(e){EA?.removeServer(e)}function kA(e){return!!e&&typeof e==`object`&&`redirectUrl`in e&&`clientMetadata`in e}var AA=class{config={};sessions={};activeSessions=[];constructor(e){e&&(this.config=e)}static fromDict(e){throw Error(`fromDict must be implemented by concrete class`)}addServer(e,t){this.config.mcpServers=this.config.mcpServers||{},this.config.mcpServers[e]=t,DA(e,t)}async removeServer(e){this.config.mcpServers?.[e]&&(await this.closeSession(e),delete this.config.mcpServers[e],OA(e))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(e){return this.config.mcpServers?.[e]}getConfig(){return this.config??{}}async createSession(e,t=!0){let n=this.config.mcpServers??{};if(Object.keys(n).length===0&&$.warn(`No MCP servers defined in config`),!n[e])throw Error(`Server '${e}' not found in config`);let r={...n[e]},i;if(jk(r)){let e=r.oauth===!1?void 0:r.oauth??{};i=await this.createDefaultOAuthProvider(r.url,e),r={...r,authProvider:i}}else `authProvider`in r&&r.authProvider&&kA(r.authProvider)&&(i=r.authProvider);let a=async()=>{let e=new TA(await Promise.resolve(this.createConnectorFromConfig(r)));return t&&await e.initialize(),e},o;try{o=await a()}catch(n){let s=r;if(!t||!i||!(`url`in s)||!SA(n)||i.preventAutoAuth)throw n;$.info(`[MCPClient] Unauthorized connecting to '${e}'; completing OAuth\u2026`),await CA(i,s.url),o=await a()}return this.sessions[e]=o,this.activeSessions.includes(e)||this.activeSessions.push(e),o}async connect(e){return this.createSession(e)}async createAllSessions(e=!0){let t=this.config.mcpServers??{};Object.keys(t).length===0&&$.warn(`No MCP servers defined in config`);for(let n of Object.keys(t))await this.createSession(n,e);return this.sessions}async connectAll(){return this.createAllSessions()}getSession(e){return this.sessions[e]||null}requireSession(e){let t=this.sessions[e];if(!t)throw Error(`Session '${e}' not found. Available sessions: ${this.activeSessions.join(`, `)||`none`}`);return t}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(e=>[e,this.sessions[e]]))}async closeSession(e){let t=this.sessions[e];if(!t){$.warn(`No session exists for server ${e}, nothing to close`);return}try{$.debug(`Closing session for server ${e}`),await t.disconnect()}catch(t){$.error(`Error closing session for server '${e}': ${t}`)}finally{this.sessions[e]===t&&(delete this.sessions[e],this.activeSessions=this.activeSessions.filter(t=>t!==e))}}async closeAllSessions(){let e=Object.keys(this.sessions),t=[];for(let n of e)try{$.debug(`Closing session for server ${n}`),await this.closeSession(n)}catch(e){let r=`Failed to close session for server '${n}': ${e}`;$.error(r),t.push(r)}t.length?$.error(`Encountered ${t.length} errors while closing sessions`):$.debug(`All sessions closed successfully`)}async close(){await this.closeAllSessions()}};function jA(e){let t=Object.keys(e.mcpServers??{});bA.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(e=>$.debug(`Failed to track BrowserMCPClient init: ${e}`))}var MA=class e extends AA{static getPackageVersion(){return kk()}constructor(e){super(e),jA(this.config)}static fromDict(t){return new e(t)}async createDefaultOAuthProvider(e,t={}){return Vk(e,t)}createConnectorFromConfig(e){let{url:t,headers:n,fetch:r,authToken:i,authProvider:a,wrapTransport:o,clientOptions:s,protocolNegotiation:c,timeout:l,gatewayUrl:u,serverId:d,reconnectionOptions:f}=e;if(!t)throw Error(`Server URL is required`);let p=this.config,m=Ak(e,p),h=Nk(e.clientInfo??this.config.clientInfo),g={headers:n,fetch:r??globalThis.fetch.bind(globalThis),authToken:i,authProvider:a,wrapTransport:o,clientOptions:s,onSampling:m.onSampling,onElicitation:m.onElicitation,onNotification:m.onNotification,protocolNegotiation:c,timeout:l,clientInfo:h,gatewayUrl:u,serverId:d,reconnectionOptions:f};return $.debug(`[BrowserMCPClient] Connector options prepared (clientOptions: ${s?`provided`:`none`})`),new Dk(t,g)}};ek();var NA=`https://favicon.tools.mcp-use.com`,PA=/^\d{1,3}(\.\d{1,3}){3}$/;function FA(e){try{let t=e.includes(`://`)?e:`https://${e}`;return new URL(t).hostname}catch{return null}}function IA(e){let t=e.toLowerCase();if(t===`localhost`||t.endsWith(`.localhost`)||t===`host.docker.internal`||t===`0.0.0.0`)return!0;if(!PA.test(t))return!1;if(t===`127.0.0.1`||t.startsWith(`127.`)||t.startsWith(`10.`)||t.startsWith(`192.168.`))return!0;let n=/^172\.(\d+)\./.exec(t);if(n){let e=Number.parseInt(n[1],10);if(e>=16&&e<=31)return!0}return!1}function LA(e){let t=e.split(`.`);return Array.from({length:t.length-1},(e,n)=>t.slice(n).join(`.`))}function RA(e){return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}async function zA(e){try{let t=FA(e);if(!t||IA(t))return null;for(let e of LA(t))try{let t=await fetch(`${NA}/${e}?response=json`,{signal:AbortSignal.timeout(2e3)});if(!t.ok)continue;let n=await t.json();if(n.source==="default")continue;let r=n.url.replace(/^http:\/\//,`https://`),i=await fetch(r,{signal:AbortSignal.timeout(2e3)});if(!i.ok)continue;return await RA(await i.blob())}catch{continue}return null}catch(e){return console.warn(`[favicon] Error detecting favicon:`,e),null}}var BA=`inspector-server`;function VA(e,t){if(!e)throw Error(t)}async function HA(e){try{let t=e.serverInfo.icons?.[0]?.src;if(t){e.addLog(`info`,`Server provided icon:`,t);let n=await(await fetch(t)).blob(),r=await new Promise((e,t)=>{let r=new FileReader;r.onloadend=()=>e(r.result),r.onerror=t,r.readAsDataURL(n)});return e.isMounted()&&(e.setServerInfo(e=>e?{...e,icon:r}:void 0),e.addLog(`debug`,`Server icon converted to base64`)),r}if(e.url){let t=await zA(e.url);if(!e.isMounted())return e.addLog(`debug`,`Connection aborted after favicon detection - component unmounted`),null;if(t)return e.setServerInfo(e=>e?{...e,icon:t}:void 0),e.addLog(`debug`,`Favicon detected and added to serverInfo`),t}return null}catch(t){return e.addLog(`debug`,`Icon loading failed (non-critical):`,t),null}}function UA(e,t){return t?`state=${e}`:`client disconnected (state=${e})`}function WA(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}function GA(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`oauth discovery failed`)||t.includes(`oauth-authorization-server`)||t.includes(`not valid json`)||t.includes(`404`)&&(t.includes(`openid-configuration`)||t.includes(`oauth-protected-resources`)||t.includes(`oauth-authorization-url`)||t.includes(`register`))||t.includes(`invalid oauth error response`)&&t.includes(`not found`)}function KA(e,t){if(t)return t;if(e)try{let t=new URL(e);return t.pathname=t.pathname.replace(/\/proxy\/?$/,`/oauth`),t.toString()}catch{return}}function qA(e){let t=KA(e.gatewayUrl,e.oauthProxyUrl);return{provider:new Bk(e.effectiveOAuthUrl,{storageKeyPrefix:e.storageKeyPrefix,clientName:e.oauthClientConfig.name,clientUri:e.oauthClientConfig.uri,logoUri:e.oauthClientConfig.logo_uri||`https://mcp-use.com/logo.png`,callbackUrl:e.callbackUrl,preventAutoAuth:e.preventAutoAuth,useRedirectFlow:e.useRedirectFlow,oauthProxyUrl:t,connectionUrl:e.gatewayUrl,onPopupWindow:e.onPopupWindow,proxyOAuthRequests:e.proxyOAuthRequests,staticClientInfo:e.staticClientInfo,clientMetadataUrl:e.clientMetadataUrl,scope:e.scope}),oauthProxyUrl:t}}function JA(e){let t=null,n=Date.now(),r=e.healthCheckIntervalMs??1e4,i=e.healthCheckTimeoutMs??3e4;return t=setInterval(async()=>{if(!e.isMountedRef.current||e.stateRef.current!==`ready`){t&&=(clearInterval(t),null);return}try{let t=e.gatewayUrl||e.url;if(!t)return;let r=e.getAuthHeaders?await e.getAuthHeaders():{},i=await fetch(t,{method:`HEAD`,headers:{...e.allHeaders,...r},signal:AbortSignal.timeout(5e3)});if(i.ok||i.status<500)n=Date.now();else throw Error(`Server returned ${i.status}`)}catch{let r=Date.now()-n;r>i&&(e.addLog(`warn`,`Connection appears to be broken (no response for ${Math.round(r/1e3)}s), attempting to reconnect...`),t&&=(clearInterval(t),null),e.autoReconnectRef.current&&e.isMountedRef.current&&(e.setState(`discovering`),e.addLog(`info`,`Auto-reconnecting to MCP server...`),setTimeout(()=>{e.isMountedRef.current&&e.stateRef.current===`discovering`&&e.connect()},typeof e.autoReconnectRef.current==`number`?e.autoReconnectRef.current:e.defaultReconnectDelay)))}},r),()=>{t&&=(clearInterval(t),null)}}function YA(e,t){let n=e.connectionRef.current;if(e.stateRef.current!==`ready`||!e.hasClient()||!n)throw Error(`MCP client is not ready (${UA(e.stateRef.current,e.hasClient())}). Cannot ${t}.`);return n}function XA(e){let t=(0,z.useCallback)(async(t,n,r)=>{let i=YA(e,`call tool "${t}"`);e.addLog(`info`,`Calling tool: ${t}`,n);let a=Date.now();try{let o=await i.callTool(t,n||{},r);return e.addLog(`info`,`Tool "${t}" call successful:`,o),bA.getInstance().trackUseMcpToolCall({toolName:t,success:!0,executionTimeMs:Date.now()-a}).catch(()=>{}),o}catch(n){throw e.addLog(`error`,`Tool "${t}" call failed:`,n),bA.getInstance().trackUseMcpToolCall({toolName:t,success:!1,errorType:n instanceof Error?n.name:`UnknownError`,executionTimeMs:Date.now()-a}).catch(()=>{}),n}},[e.addLog]),n=(0,z.useCallback)(async()=>{let t=YA(e,`list resources`);e.addLog(`info`,`Listing resources`);let n=await t.listAllResources();e.setResources(n.resources||[])},[e.addLog]),r=(0,z.useCallback)(async t=>{let n=YA(e,`read resource`);e.addLog(`info`,`Reading resource: ${t}`);try{let e=await n.readResource(t);return bA.getInstance().trackUseMcpResourceRead({resourceUri:t,success:!0}).catch(()=>{}),e}catch(e){throw bA.getInstance().trackUseMcpResourceRead({resourceUri:t,success:!1,errorType:e instanceof Error?e.name:`UnknownError`}).catch(()=>{}),e}},[e.addLog]),i=(0,z.useCallback)(async()=>{let t=YA(e,`list prompts`);e.addLog(`info`,`Listing prompts`);let n=await t.listPrompts();e.setPrompts(n.prompts||[])},[e.addLog]),a=(0,z.useCallback)(async()=>{if(!(e.stateRef.current!==`ready`||!e.connectionRef.current))try{e.setTools(await e.connectionRef.current.listTools()||[])}catch(t){e.addLog(`error`,`Failed to refresh tools:`,t)}},[e.addLog]),o=(0,z.useCallback)(async()=>{if(!(e.stateRef.current!==`ready`||!e.connectionRef.current))try{let t=await e.connectionRef.current.listAllResources();e.setResources(t.resources||[])}catch(t){e.addLog(`warn`,`Failed to refresh resources:`,t)}},[e.addLog]),s=(0,z.useCallback)(async()=>{if(!(e.stateRef.current!==`ready`||!e.connectionRef.current))try{let t=await e.connectionRef.current.listPrompts();e.setPrompts(t.prompts||[])}catch(t){e.addLog(`warn`,`Failed to refresh prompts:`,t)}},[e.addLog]),c=(0,z.useCallback)(async()=>{let t=await YA(e,`refresh resource templates`).listResourceTemplates();e.isMounted()&&e.setResourceTemplates(t.resourceTemplates||[])},[e.addLog]);return{callTool:t,listResources:n,readResource:r,listPrompts:i,refreshTools:a,refreshResources:o,refreshPrompts:s,refreshResourceTemplates:c,refreshAll:(0,z.useCallback)(()=>Promise.all([a(),o(),c(),s()]).then(()=>void 0),[a,o,c,s]),getPrompt:(0,z.useCallback)(async(t,n)=>YA(e,`get prompt`).getPrompt(t,n||{}),[e.addLog]),complete:(0,z.useCallback)(async t=>YA(e,`request completion`).complete(t),[e.addLog])}}var ZA=3e3,QA=5e3;function $A(e){let{url:t,enabled:n=!0,callbackUrl:r=typeof window<`u`?Fk(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:i=`mcp:auth`,authProvider:a,headers:o,proxyConfig:s,oauthProxyUrl:c,autoProxyFallback:l=!1,logLevel:u=`silent`,autoRetry:d=!1,autoReconnect:f=!0,reconnectionOptions:p,preventAutoAuth:m=!0,useRedirectFlow:h=!1,onPopupWindow:g,timeout:_=3e4,wrapTransport:v,serverId:y,fetch:b,clientOptions:x,protocolNegotiation:S,onNotification:C,onSampling:w,onElicitation:T,oauth:ee}=e,E=`http`,D=ee?.clientId?.trim()||void 0,te=ee?.clientMetadataUrl?.trim()||void 0,ne=ee?.scope?.trim()||void 0,O=(0,z.useMemo)(()=>D?{client_id:D}:void 0,[D]),re=(0,z.useMemo)(()=>{let e=`useMcp:${t||`no-url`}`,n=$O.get(e);return u&&(n.level=u),n},[t,u]),k=o??{},ie=(0,z.useMemo)(()=>Pk(x),[x]),A=w,j=T,M=(0,z.useMemo)(()=>({name:`mcp-use`,title:`mcp-use`,version:kk(),description:`mcp-use is a complete TypeScript framework for building and using MCP`,icons:[{src:`https://mcp-use.com/logo.png`}],websiteUrl:`https://mcp-use.com`}),[]),ae=(0,z.useMemo)(()=>e.clientInfo?{...M,...e.clientInfo}:M,[e.clientInfo,M]),oe=(0,z.useMemo)(()=>WA(ae),[ae]),se=(0,z.useMemo)(()=>{if(!l)return{enabled:!1,proxyAddress:void 0};if(typeof l==`boolean`){let e=s?.proxyAddress;return{enabled:l&&!!e,proxyAddress:e}}let e=l.proxyAddress??s?.proxyAddress;return{enabled:l.enabled!==!1&&!!e,proxyAddress:e}},[l,s]),N=(0,z.useMemo)(()=>f===!1?{enabled:!1,initialDelay:0,healthCheckInterval:!1,healthCheckTimeout:3e4}:f===!0?{enabled:!0,initialDelay:ZA,healthCheckInterval:1e4,healthCheckTimeout:3e4}:typeof f==`number`?{enabled:!0,initialDelay:f,healthCheckInterval:1e4,healthCheckTimeout:3e4}:{enabled:f.enabled!==!1,initialDelay:f.initialDelay??ZA,healthCheckInterval:f.healthCheckInterval??1e4,healthCheckTimeout:f.healthCheckTimeout??3e4},[f]),[P,ce]=(0,z.useState)(void 0);(0,z.useEffect)(()=>{ce(void 0)},[t,s]);let le=(0,z.useMemo)(()=>{if(!P?.proxyAddress)return s;let e=s?.headers??{};return{...P,headers:{...e,...P.headers??{}}}},[P,s]),ue=le?.proxyAddress,de=le?.headers??{},fe=(0,z.useMemo)(()=>t||``,[t]),pe=(0,z.useMemo)(()=>({...de,...k}),[de,k]),[me,he]=(0,z.useState)(`discovering`),[ge,_e]=(0,z.useState)([]),[ve,ye]=(0,z.useState)([]),[be,F]=(0,z.useState)([]),[xe,Se]=(0,z.useState)([]),[Ce,we]=(0,z.useState)(e._initialServerInfo?.name?e._initialServerInfo:void 0),[Te,Ee]=(0,z.useState)(),[De,Oe]=(0,z.useState)(void 0),[ke,Ae]=(0,z.useState)(void 0),[je,Me]=(0,z.useState)(),[Ne,Pe]=(0,z.useState)({}),[Fe,Ie]=(0,z.useState)(void 0),[Le,Re]=(0,z.useState)([]),[ze,Be]=(0,z.useState)(void 0),[Ve,He]=(0,z.useState)(void 0),Ue=(0,z.useRef)(null),We=(0,z.useRef)(null),Ge=(0,z.useRef)(a??null),Ke=(0,z.useRef)(null),qe=(0,z.useRef)(!1),Je=(0,z.useRef)(!0),Ye=(0,z.useRef)(0),Xe=(0,z.useRef)(0),Ze=(0,z.useRef)(null),Qe=(0,z.useRef)(!1),$e=(0,z.useRef)(!1),et=(0,z.useRef)(me),tt=(0,z.useRef)(f),nt=(0,z.useRef)(null),rt=(0,z.useRef)(null),it=(0,z.useRef)(null),at=(0,z.useRef)(A),ot=(0,z.useRef)(j),st=(0,z.useRef)(A!==void 0),ct=(0,z.useRef)(j!==void 0),lt=(0,z.useRef)(C);A!==void 0&&(at.current=A),j!==void 0&&(ot.current=j),st.current=A!==void 0,ct.current=j!==void 0,lt.current=C;let ut=(0,z.useCallback)(async e=>at.current(e),[]),dt=(0,z.useCallback)(async e=>ot.current(e),[]),ft=(0,z.useCallback)(e=>{lt.current?.(e)},[]);(0,z.useEffect)(()=>{et.current=me,tt.current=f},[me,f]),(0,z.useEffect)(()=>{Ge.current=a??null},[a]);let I=(0,z.useCallback)((e,t,...n)=>{let r=n.length>0?`${t} ${n.map(e=>JSON.stringify(e)).join(` `)}`:t,i=`[useMcp] ${r}`;switch(e){case`error`:re.error(i);break;case`warn`:re.warn(i);break;case`info`:re.info(i);break;case`debug`:re.debug(i);break;default:re.info(i)}Je.current&&Re(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[re]),pt=XA({stateRef:et,connectionRef:We,hasClient:()=>Ue.current!==null,isMounted:()=>Je.current,setTools:_e,setResources:ye,setResourceTemplates:F,setPrompts:Se,addLog:I}),mt=(0,z.useCallback)(async(e=!1)=>{e||I(`info`,`Disconnecting...`),qe.current=!1,Ze.current&&clearTimeout(Ze.current),Ze.current=null;let t=Xe.current,n=Ue.current;if(n)try{let e=BA,t=n===Ue.current?We.current:null;t&&t._healthCheckCleanup&&(t._healthCheckCleanup(),t._healthCheckCleanup=null),t&&await n.closeSession(e)}catch(t){e||I(`warn`,`Error closing connection:`,t)}let r=Xe.current!==t;Ue.current===n&&!r&&(Ue.current=null,We.current=null),Je.current&&!e&&!r&&(he(`discovering`),_e([]),ye([]),F([]),Se([]),Ie(void 0),Be(void 0),He(void 0),we(void 0),Ee(void 0),Oe(void 0),Ae(void 0),Me(void 0),Pe({}))},[I]),ht=(0,z.useCallback)((e,n)=>{I(`error`,e,n??``);let r=n&&`code`in n?n.code:void 0,i=se.enabled&&!le?.proxyAddress,o=e.includes(`CORS`)||e.includes(`blocked by CORS policy`)||e.includes(`Failed to fetch`),s=r===400;if(i&&(o||s||typeof r==`number`&&r>=404&&r<500)&&!(r===401||r===403))return I(`info`,`Direct connection failed with ${o?`CORS error`:s?`HTTP 400 (Bad Request)`:`HTTP 4xx error`}. Trying with proxy...`),Ue.current=null,a||(Ge.current=null),I(`debug`,`Cleared client and auth provider for proxy fallback`),ce({proxyAddress:se.proxyAddress}),Je.current&&he(`discovering`),setTimeout(()=>{Je.current&&rt.current?.()},1e3),!0;if(Je.current){I(`info`,`Setting state to FAILED:`,e),he(`failed`),Ie(e);let t=Ge.current?.getLastAttemptedAuthUrl?.();t&&(Be(t),I(`info`,`Manual authentication URL may be available.`,t))}return qe.current=!1,t&&bA.getInstance().trackUseMcpConnection({url:t,transportType:E,success:!1,errorType:n?.name||`UnknownError`,hasOAuth:!!Ge.current,hasSampling:st.current,hasElicitation:ct.current}).catch(()=>{}),!1},[I,t,E,se,le,a]),gt=(0,z.useCallback)(async()=>{if(!n||!t){I(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`);return}if(qe.current){I(`debug`,`Connection attempt already in progress.`);return}if(!Je.current){I(`debug`,`Connect called after unmount, aborting.`);return}if(qe.current=!0,Xe.current+=1,Ye.current+=1,Ie(void 0),Be(void 0),nt.current=null,he(`discovering`),_e([]),ye([]),F([]),Se([]),we(void 0),Ee(void 0),Oe(void 0),Ae(void 0),Me(void 0),Pe({}),I(`info`,`Connecting attempt #${Ye.current} to ${t}...`),!Ge.current){let{provider:e,oauthProxyUrl:t}=qA({effectiveOAuthUrl:fe,storageKeyPrefix:i,oauthClientConfig:oe,callbackUrl:r,preventAutoAuth:m,useRedirectFlow:h,gatewayUrl:ue,oauthProxyUrl:c,onPopupWindow:g,proxyOAuthRequests:!0,staticClientInfo:O,clientMetadataUrl:te,scope:ne});Ge.current=e,t&&I(`debug`,`OAuth BFF enabled: ${t}`),I(`debug`,`BrowserOAuthClientProvider initialized with URL: ${fe}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ue?`enabled`:`disabled`}`)}Ue.current?I(`debug`,`BrowserMCPClient already exists, reusing.`):(Ue.current=new MA,I(`debug`,`BrowserMCPClient initialized in connect.`));let e=async n=>{if(!Je.current)return I(`debug`,`Connection attempt aborted - component unmounted`),`failed`;I(`info`,`Attempting connection with transport: ${n}`),I(`debug`,`Client ref status at start of tryConnectWithTransport: ${Ue.current?`initialized`:`NULL`}`);try{let e=BA,r={url:t,timeout:_,clientInfo:ae,...(()=>{let e=Ge.current?.getProxyFetch?.(b)??b;return e?{fetch:e}:{}})(),...ie&&{clientOptions:ie},...S!==void 0&&{protocolNegotiation:S},...p?{reconnectionOptions:p}:f===!1?{reconnectionOptions:{maxRetries:0}}:{}};if(ue&&(r.gatewayUrl=ue,I(`debug`,`Using proxy gateway: ${ue} for target: ${t}`)),pe&&Object.keys(pe).length>0&&(r.headers=pe),!Ue.current){if(!Je.current)return I(`debug`,`Connection aborted - component unmounted, client cleaned up`),`failed`;let e=Error(`Client not initialized - this is a bug in the connection flow`);throw I(`error`,`Client ref is null in tryConnectWithTransport but component is still mounted`),e}Ue.current.addServer(e,{...r,authProvider:Ge.current,onSampling:st.current?ut:void 0,onElicitation:ct.current?dt:void 0,onNotification:e=>{I(`debug`,`Notification received:`,e.method,e),ft(e),e.method===`notifications/tools/list_changed`?(I(`info`,`Tools list changed, auto-refreshing...`),pt.refreshTools().catch(e=>I(`warn`,`Auto-refresh tools failed:`,e))):e.method===`notifications/resources/list_changed`?(I(`info`,`Resources list changed, auto-refreshing...`),pt.refreshResources().catch(e=>I(`warn`,`Auto-refresh resources failed:`,e))):e.method===`notifications/prompts/list_changed`&&(I(`info`,`Prompts list changed, auto-refreshing...`),pt.refreshPrompts().catch(e=>I(`warn`,`Auto-refresh prompts failed:`,e)))},wrapTransport:v?n=>(I(`debug`,`Applying transport wrapper for server:`,e,`url:`,t),v(n,y??t)):void 0});let i=await Ue.current.connect(e);if(We.current=i,!Je.current)return I(`debug`,`Connection aborted after connection creation - component unmounted`),`failed`;I(`info`,`✅ Successfully connected to MCP server`),I(`info`,`Server info:`,i.info.server),I(`info`,`Server capabilities:`,i.info.capabilities),N.enabled&&N.healthCheckInterval!==!1&&(i._healthCheckCleanup=JA({gatewayUrl:ue,url:t,allHeaders:pe,getAuthHeaders:async()=>{try{let e=await Ge.current?.tokens?.();if(e?.access_token){let t=e.token_type||`bearer`;return{Authorization:`${t.charAt(0).toUpperCase()+t.slice(1)} ${e.access_token}`}}}catch{}return{}},isMountedRef:Je,stateRef:et,autoReconnectRef:tt,setState:he,addLog:I,connect:gt,defaultReconnectDelay:N.initialDelay,healthCheckIntervalMs:N.healthCheckInterval,healthCheckTimeoutMs:N.healthCheckTimeout})),bA.getInstance().trackUseMcpConnection({url:t,transportType:n,success:!0,hasOAuth:!!Ge.current,hasSampling:st.current,hasElicitation:ct.current}).catch(()=>{}),_e(i.tools||[]);let[a,o,s]=await Promise.all([i.listAllResources(),i.listPrompts(),i.supports(`resources`)?i.listResourceTemplates():Promise.resolve({resourceTemplates:[]})]);if(!Je.current)return I(`debug`,`Connection aborted after discovery - component unmounted`),`failed`;ye(a.resources||[]),Se(o.prompts||[]),F(s.resourceTemplates||[]);let{server:c,capabilities:l,protocolEra:u,protocolVersion:d,instructions:m,extensions:h}=i.info;if(Je.current&&(Oe(u),Ae(d),Me(m),Pe(h)),c){if(I(`debug`,`Server info:`,c),!Je.current)return I(`debug`,`Skipping state update - component unmounted`),`failed`;we(c),Ke.current=HA({serverInfo:c,url:t,isMounted:()=>Je.current,setServerInfo:we,addLog:I})}if(l){if(I(`debug`,`Server capabilities:`,l),!Je.current)return I(`debug`,`Skipping state update - component unmounted`),`failed`;Ee(l)}if(Ge.current){let e=await Ge.current.tokens?.();if(!Je.current)return I(`debug`,`Connection aborted after token fetch for auth tokens - component unmounted`),`failed`;if(e?.access_token){let t=e.expires_in?Date.now()+e.expires_in*1e3:void 0,n=null,r=null;try{n=await Ge.current.getTokenEndpoint?.()??null}catch{n=null}try{r=await Ge.current.getClientCredentials?.()??null}catch{r=null}if(!Je.current)return I(`debug`,`Skipping state update - component unmounted`),`failed`;He({access_token:e.access_token,token_type:e.token_type||`Bearer`,expires_at:t,refresh_token:e.refresh_token,scope:e.scope,...n?{token_endpoint:n}:{},...r?.client_id?{client_id:r.client_id}:{},...r?.client_secret?{client_secret:r.client_secret}:{}})}}return nt.current=n,he(`ready`),`success`}catch(r){let i=r,a=i?.message||String(r),o=Ge.current?.getLastAttemptedAuthUrl?.();if(o&&Ge.current&&m)return I(`info`,`OAuth already discovered (stored auth URL present); awaiting manual authentication.`),Je.current&&(he(`pending_auth`),Be(o)),qe.current=!1,`auth_redirect`;let s=GA(r),c=SA(r);if(s&&k&&Object.keys(k).length>0)return ht(`Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct.`),`failed`;if(s&&(!k||Object.keys(k).length===0))return ht(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(c){if(s)return ht(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(Ge.current)if(I(`info`,`Authentication required. OAuth provider available.`),m){if(I(`info`,`Waiting for user to initiate authentication flow...`),Je.current){he(`pending_auth`);let e=Ge.current?.getLastAttemptedAuthUrl?.();e&&(Be(e),I(`info`,`Retrieved stored auth URL for manual authentication`))}return qe.current=!1,`auth_redirect`}else{I(`info`,`Triggering automatic OAuth authentication flow...`);try{if(await MS(Ge.current,{serverUrl:t,fetchFn:Ge.current.getProxyFetch?.()})===`REDIRECT`){let e=await Ge.current.getAuthorizationCode?.();if(!e)throw Error(`Authorization code not captured by headless provider`);await MS(Ge.current,{serverUrl:t,authorizationCode:e,fetchFn:Ge.current.getProxyFetch?.()})}return I(`info`,`OAuth flow completed, reconnecting...`),await e(n)}catch(e){return ht(`Automatic OAuth authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:Error(String(e))),`failed`}}return k&&Object.keys(k).length>0?(ht(`Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct.`),`failed`):(ht(`Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`)}return ht(a,i instanceof Error?i:Error(String(i)))?`auth_redirect`:`failed`}},a=`failed`;I(`debug`,`Connecting via streamable HTTP`),a=await e(`http`),(a===`success`||a===`failed`||a===`auth_redirect`)&&(qe.current=!1),I(`debug`,`Connection sequence finished with status: ${a}`)},[I,ht,mt,t,i,r,oe.name,oe.version,oe.uri,oe.logo_uri,O,te,ne,k,E,m,h,g,n,_,ae,ie,S,ue,c,pe,fe,ut,dt,ft]);(0,z.useEffect)(()=>{rt.current=gt,it.current=ht},[gt,ht]);let _t=(0,z.useCallback)(()=>{et.current===`failed`?(I(`info`,`Retry requested...`),rt.current?.()):I(`warn`,`Retry called but state is not 'failed' (state: ${et.current}). Ignoring.`)},[I]),vt=(0,z.useCallback)(async()=>{I(`info`,`Manual authentication requested...`);let e=et.current;if(e===`failed`)I(`info`,`Attempting to reconnect and authenticate via retry...`),_t();else if(e===`pending_auth`){I(`info`,`Proceeding with authentication from pending state...`);try{if(VA(Ge.current,`Auth Provider not available for manual auth`),VA(t,`Server URL is required for authentication`),a){I(`info`,`Using provided authProvider for manual authentication`);let e=new URL(t),n=e.origin+e.pathname.replace(/\/+$/,``);await MS(Ge.current,{serverUrl:n,fetchFn:Ge.current.getProxyFetch?.()}),rt.current?.();return}I(`info`,`Cleared ${Ge.current.clearStorage?.()??0} OAuth storage item(s) for fresh authentication`),he(`authenticating`);let e=null,n=null,{provider:o,oauthProxyUrl:s}=qA({effectiveOAuthUrl:fe,storageKeyPrefix:i,oauthClientConfig:oe,callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:h,gatewayUrl:ue,oauthProxyUrl:c,onPopupWindow:(t,r,i)=>{e=i;try{n=new URL(t).searchParams.get(`state`)}catch{}g?.(t,r,i)},proxyOAuthRequests:!0,staticClientInfo:O,clientMetadataUrl:te,scope:ne});s&&I(`info`,`Scoped OAuth proxy fetch enabled for manual auth`),Ge.current=o,I(`info`,`Triggering fresh OAuth authorization...`);let l=new URL(t),u=l.origin+l.pathname.replace(/\/+$/,``);try{await MS(o,{serverUrl:u,fetchFn:o.getProxyFetch?.()}),I(`info`,`OAuth flow completed (tokens obtained)`)}catch(e){I(`info`,`OAuth flow initiated (popup/redirect):`,e instanceof Error?e.message:`Redirecting...`)}let d=o.getLastAttemptedAuthUrl?.();if(d&&(Be(d),I(`info`,`Updated auth URL for fallback:`,d),!n))try{n=new URL(d).searchParams.get(`state`)}catch{}if(h)return;let f=o.getKey?.(`tokens`);if(!f){I(`warn`,`Could not derive tokens storage key; relying on callback listener.`);return}$e.current=!0;let p;try{p=await mk({popup:e,state:n,tokensKey:f})}finally{$e.current=!1}if(!Je.current)return;switch(p.kind){case`success`:I(`info`,`Authentication succeeded; reconnecting to MCP server...`),qe.current=!1,rt.current?.();break;case`cancelled`:I(`warn`,`Authentication popup was closed before completing. Returning to pending_auth.`),he(`pending_auth`);break;case`timeout`:I(`warn`,`Authentication timed out waiting for the popup. Returning to pending_auth.`),he(`pending_auth`);break;case`error`:ht(`Authentication failed: ${p.error}`);break;default:break}}catch(e){if(!Je.current)return;he(`pending_auth`),I(`error`,`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`)}}else if(e===`authenticating`){I(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=Ge.current?.getLastAttemptedAuthUrl?.();e&&!ze&&(Be(e),I(`info`,`Manual authentication URL retrieved:`,e))}else I(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[I,_t,ht,ze,t,h,g,i,oe.name,oe.uri,oe.logo_uri,O,te,ne,r,ae,a]),yt=(0,z.useCallback)(()=>{Ge.current?.clearStorage?(I(`info`,`Cleared ${Ge.current.clearStorage()} item(s) from localStorage for ${t}.`),Be(void 0),mt()):I(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,I,mt]);(0,z.useEffect)(()=>{if(typeof window>`u`)return;let e=(e,t)=>{if($e.current){I(`debug`,`Ignoring auth callback via ${t}; manual popup flow owns this result.`);return}let n=Ge.current?.serverUrlHash;if(e?.serverUrlHash&&n&&e.serverUrlHash!==n){I(`debug`,`Ignoring auth callback via ${t} for a different server.`);return}if(I(`info`,`Received auth callback via ${t}.`,e),Ze.current&&clearTimeout(Ze.current),Ze.current=null,e?.success)I(`info`,`Authentication successful via popup. Reconnecting client...`),qe.current&&I(`debug`,`Connection attempt already in progress, resetting flag to allow reconnection.`),qe.current=!1,setTimeout(()=>{Je.current&&(I(`debug`,`Initiating reconnection after successful auth callback.`),rt.current?.())},100);else{if(et.current!==`authenticating`&&et.current!==`pending_auth`){I(`debug`,`Ignoring stale auth failure callback (state=${et.current}).`);return}it.current?.(`Authentication failed in callback: ${e?.error||`Unknown reason.`}`)}},t=t=>{t.origin===window.location.origin&&t.data?.type===fk&&e(t.data,`postMessage`)};window.addEventListener(`message`,t),I(`debug`,`Auth callback message listener added.`);let n=null,r=t=>{t.data?.type===fk&&e(t.data,`BroadcastChannel`)};if(typeof BroadcastChannel<`u`)try{n=new BroadcastChannel(dk),n.addEventListener(`message`,r),I(`debug`,`Auth callback BroadcastChannel listener added.`)}catch(e){I(`warn`,`Failed to open auth callback BroadcastChannel; lost-opener popups will not reach this client.`,e),n=null}return()=>{if(window.removeEventListener(`message`,t),I(`debug`,`Auth callback message listener removed.`),n){try{n.removeEventListener(`message`,r),n.close()}catch{}I(`debug`,`Auth callback BroadcastChannel listener removed.`)}Ze.current&&clearTimeout(Ze.current)}},[I]),(0,z.useEffect)(()=>{if(Je.current=!0,!n||!t)return I(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`),he(`discovering`),()=>{Je.current=!1};if(I(`debug`,`useMcp mounted, initiating connection.`),Ye.current=0,a)Ge.current=a,I(`debug`,`Using externally provided authProvider`);else if(!Ge.current||Ge.current.serverUrl!==fe){let{provider:e,oauthProxyUrl:t}=qA({effectiveOAuthUrl:fe,storageKeyPrefix:i,oauthClientConfig:oe,callbackUrl:r,preventAutoAuth:m,useRedirectFlow:h,gatewayUrl:ue,oauthProxyUrl:c,onPopupWindow:g,proxyOAuthRequests:!0,staticClientInfo:O,clientMetadataUrl:te,scope:ne});Ge.current=e,t&&I(`debug`,`OAuth proxy URL in effect: ${t}`),I(`debug`,`BrowserOAuthClientProvider initialized/updated with URL: ${fe}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ue?`enabled`:`disabled`}`)}return gt(),()=>{Je.current=!1,I(`debug`,`useMcp unmounting, disconnecting.`),mt(!0)}},[t,n,i,r,oe.name,oe.version,oe.uri,oe.logo_uri,O,te,ne,h,ae,fe,s,a]);let bt=(0,z.useRef)(_t),xt=(0,z.useRef)(I);(0,z.useEffect)(()=>{bt.current=_t,xt.current=I},[_t,I]),(0,z.useEffect)(()=>{let e=null;if(me===`failed`&&d&&Ye.current>0){if(!Qe.current){Qe.current=!0;let t=typeof d==`number`?d:QA;xt.current(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{Qe.current=!1,Je.current&&et.current===`failed`&&bt.current()},t)}}else me!==`failed`&&(Qe.current=!1);return()=>{e&&(clearTimeout(e),Qe.current=!1)}},[me,d]);let St=(0,z.useCallback)(async()=>et.current===`ready`?Ce?.icon?Ce.icon:Ke.current?(I(`debug`,`Waiting for icon to finish loading...`),await Ke.current):(I(`debug`,`No icon available and no loading in progress`),null):(I(`warn`,`Cannot ensure icon loaded - not connected`),null),[Ce,I]);return{state:me,name:Ce?.name||t||``,tools:ge,resources:ve,resourceTemplates:be,prompts:xe,serverInfo:Ce,capabilities:Te,protocolEra:De,protocolVersion:ke,instructions:je,extensions:Ne,error:Fe,log:Le,authUrl:ze,authTokens:Ve,client:Ue.current,...pt,retry:_t,disconnect:mt,authenticate:vt,clearStorage:yt,ensureIconLoaded:St}}var ej=null;function tj(){return typeof window<`u`&&window.name.startsWith(`mcp_auth_`)}function nj(e,t,n){return{type:fk,success:e,...e?{}:{error:t??`Unknown error`},...n.state?{state:n.state}:{},...n.serverUrlHash?{serverUrlHash:n.serverUrlHash}:{}}}function rj(e){if(typeof BroadcastChannel>`u`)return;let t;try{t=new BroadcastChannel(dk),t.postMessage(e)}catch(e){console.warn(`[mcp-callback] Failed to broadcast callback result:`,e)}finally{t&&setTimeout(()=>{try{t?.close()}catch{}},0)}}function ij(e,t,n,r){if(typeof document>`u`)return;document.body.innerHTML=``;let i=document.createElement(`div`);i.style.fontFamily=`sans-serif`,i.style.padding=`20px`;let a=document.createElement(`h1`);a.textContent=e,i.appendChild(a);let o=document.createElement(`p`);o.textContent=t,n&&(o.style.color=`red`,o.style.backgroundColor=`#ffebeb`,o.style.border=`1px solid red`,o.style.padding=`10px`,o.style.borderRadius=`4px`),i.appendChild(o);let s=document.createElement(`a`);if(s.href=`#`,s.textContent=`Close this window`,s.onclick=e=>(e.preventDefault(),window.close(),!1),i.appendChild(s),r){let e=document.createTextNode(` or `),t=document.createElement(`a`);t.href=r,t.textContent=`return to the app`,i.append(e,t)}document.body.appendChild(i)}function aj(e){let t=`mcp:auth:state_${e}`,n=localStorage.getItem(t)?t:null;if(!n){let t=`:state_${e}`;for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.endsWith(t)){n=r;break}}}let r=n?localStorage.getItem(n):null;if(!n||!r)throw Error(`Invalid or expired OAuth state "${e}".`);let i;try{i=JSON.parse(r)}catch{throw localStorage.removeItem(n),Error(`Failed to parse stored OAuth state.`)}return{key:n,value:i}}function oj(e,t){let n=new URL(e);n.searchParams.set(`auth_error`,`oauth_callback_failed`),n.searchParams.set(`auth_error_description`,t),window.location.href=n.toString()}function sj(e,t,n,r){let i=nj(e,t,r),a=n?.returnUrl,o=n?.flowType===`popup`||tj();if(n?.flowType===`redirect`&&a){e?window.location.href=a:oj(a,t??`Authentication failed.`);return}if(window.opener&&!window.opener.closed){window.opener.postMessage(i,window.location.origin),window.close();return}if(o){rj(i),ij(e?`Authentication Successful!`:`Authentication Error`,e?`You're authenticated. You can close this window and return to the app.`:t??`Authentication failed.`,!e,a);try{window.close()}catch{}return}if(a){e?window.location.href=a:oj(a,t??`Authentication failed.`);return}if(!e){ij(`Authentication Error`,t??`Authentication failed.`,!0);return}window.location.href=`/`}function cj(){return ej||=lj(),ej}async function lj(){let e=new URLSearchParams(window.location.search),t=e.get(`state`),n=null,r=null,i=null;try{if(!t)throw Error(`OAuth callback is missing the state parameter.`);let a=aj(t);if(n=a.key,r=a.value,!r.expiry||r.expiry<Date.now())throw localStorage.removeItem(n),Error(`OAuth state has expired. Please start authentication again.`);if(!r.providerOptions)throw Error(`Stored OAuth state is missing provider options.`);let{serverUrl:o,...s}=r.providerOptions;i=new Bk(o,s),await new LC(new URL(o),{authProvider:i,fetch:i.getProxyFetch()}).finishAuth(e),localStorage.removeItem(n),sj(!0,void 0,r,{state:t,serverUrlHash:r.serverUrlHash})}catch(e){let a=e instanceof Error?e.message:String(e);console.error(`[mcp-callback] OAuth callback failed:`,e),n&&localStorage.removeItem(n),i&&localStorage.removeItem(i.getKey(`last_auth_url`)),sj(!1,a,r,{state:t,serverUrlHash:r?.serverUrlHash})}}ek();var uj=[`url`,`displayName`,`enabled`,`proxyConfig`,`oauthProxyUrl`,`connectionMode`,`autoProxyFallback`,`callbackUrl`,`storageKeyPrefix`,`headers`,`logLevel`,`autoRetry`,`autoReconnect`,`reconnectionOptions`,`popupFeatures`,`preventAutoAuth`,`useRedirectFlow`,`clientOptions`,`protocolNegotiation`,`timeout`,`clientInfo`,`oauth`];function dj(e){let t={};for(let n of uj){let r=e[n];r!==void 0&&(t[n]=r)}return t}function fj(e){return dj(e)}var pj=500,mj=5*6e4;function hj(e){let[t,n]=(0,z.useState)([]),[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)([]),s=(0,z.useRef)(0),c=(0,z.useRef)(0),l=(0,z.useRef)(new Map),u=(0,z.useRef)(new Map),d=(0,z.useCallback)(e=>{for(let t of l.current.values())clearTimeout(t.timeout),t.reject(Error(e));l.current.clear();for(let t of u.current.values())clearTimeout(t.timeout),t.reject(Error(e));u.current.clear(),i([]),o([])},[]);(0,z.useEffect)(()=>()=>d(`MCP server connection was removed`),[d]);let f=(0,z.useCallback)(t=>{let r={id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,method:t.method,params:t.params,timestamp:Date.now(),read:!1};n(e=>[r,...e].slice(0,pj)),e.onNotificationReceived?.(r)},[e.onNotificationReceived]),p=(0,z.useCallback)((e,t)=>{let n=l.current.get(e);n&&(clearTimeout(n.timeout),l.current.delete(e),i(t=>t.filter(t=>t.id!==e)),n.resolve(t))},[]),m=(0,z.useCallback)((e,t)=>{let n=l.current.get(e);n&&(clearTimeout(n.timeout),l.current.delete(e),i(t=>t.filter(t=>t.id!==e)),n.reject(Error(t??`User rejected sampling request`)))},[]),h=(0,z.useCallback)(t=>new Promise((n,r)=>{let a=`sampling-${s.current++}`,o={id:a,request:{method:`sampling/createMessage`,params:t},timestamp:Date.now(),serverName:e.serverName},c=setTimeout(()=>m(a,`Sampling request timed out`),mj);l.current.set(a,{resolve:n,reject:r,timeout:c}),i(e=>[...e,o]),e.onSamplingRequest?.(o),e.onGlobalSamplingRequest?.(o,e.serverId,e.serverName,p,m)}),[p,e,m]),g=(0,z.useCallback)((e,t)=>{let n=u.current.get(e);n&&(clearTimeout(n.timeout),u.current.delete(e),o(t=>t.filter(t=>t.id!==e)),n.resolve(t))},[]),_=(0,z.useCallback)((e,t)=>{let n=u.current.get(e);n&&(clearTimeout(n.timeout),u.current.delete(e),o(t=>t.filter(t=>t.id!==e)),n.reject(Error(t??`User rejected elicitation request`)))},[]),v=(0,z.useCallback)(t=>new Promise((n,r)=>{let i=`elicitation-${c.current++}`,a={id:i,request:t,timestamp:Date.now(),serverName:e.serverName},s=setTimeout(()=>_(i,`Elicitation request timed out`),mj);u.current.set(i,{resolve:n,reject:r,timeout:s}),o(e=>[...e,a]),e.onElicitationRequest?.(a),e.onGlobalElicitationRequest?.(a,e.serverId,e.serverName,g,_)}),[g,e,_]),y=(0,z.useCallback)(e=>{n(t=>t.map(t=>t.id===e?{...t,read:!0}:t))},[]),b=(0,z.useCallback)(()=>n(e=>e.map(e=>({...e,read:!0}))),[]),x=(0,z.useCallback)(()=>n([]),[]);return{notifications:t,pendingSamplingRequests:r,pendingElicitationRequests:a,unreadNotificationCount:t.filter(e=>!e.read).length,markNotificationRead:y,markAllNotificationsRead:b,clearNotifications:x,approveSampling:p,rejectSampling:m,approveElicitation:g,rejectElicitation:_,onNotification:f,onSampling:h,onElicitation:v,rejectAll:d}}var gj=$O.get(`McpClientProvider`),_j=(0,z.createContext)(null);function vj(e,t){return JSON.stringify(e)===JSON.stringify(t)}function yj(e,t){return e.id===t.id&&vj(dj(e),dj(t))&&e.name===t.name&&e.state===t.state&&e.error===t.error&&e.authUrl===t.authUrl&&vj(e.authTokens,t.authTokens)&&e.protocolEra===t.protocolEra&&e.protocolVersion===t.protocolVersion&&vj(e.serverInfo,t.serverInfo)&&vj(e.capabilities,t.capabilities)&&e.instructions===t.instructions&&vj(e.extensions,t.extensions)&&vj(e.tools,t.tools)&&vj(e.resources,t.resources)&&vj(e.resourceTemplates,t.resourceTemplates)&&vj(e.prompts,t.prompts)&&vj(e.notifications,t.notifications)&&e.unreadNotificationCount===t.unreadNotificationCount&&vj(e.pendingSamplingRequests,t.pendingSamplingRequests)&&vj(e.pendingElicitationRequests,t.pendingElicitationRequests)&&e.client===t.client}function bj({id:e,options:t,defaultCallbackUrl:n,defaultOAuthProxyUrl:r,defaultProxyConfig:i,defaultAutoProxyFallback:a,clientInfo:o,cachedMetadata:s,onUpdate:c,onUpdateConfig:l,onUpdateDisplayName:u,onReconnect:d,rpcWrapTransport:f,onGlobalSamplingRequest:p,onGlobalElicitationRequest:m}){let{displayName:h,onSamplingRequest:g,onElicitationRequest:_,onNotificationReceived:v,wrapTransport:y}=t,b=(0,z.useMemo)(()=>{let{displayName:c,onSamplingRequest:l,onElicitationRequest:u,onNotificationReceived:d,wrapTransport:f,...p}=t;return{...p,callbackUrl:p.callbackUrl||n,oauthProxyUrl:p.oauthProxyUrl||r,proxyConfig:p.proxyConfig||i,autoProxyFallback:p.autoProxyFallback===void 0?a:p.autoProxyFallback,clientInfo:p.clientInfo?o?{...o,...p.clientInfo}:p.clientInfo:o,_initialServerInfo:s,serverId:e}},[t,n,r,i,a,o,s]),x=(0,z.useMemo)(()=>{if(!(!f&&!y))return t=>{let n=t;return f&&(n=f(n,e)),y&&(n=y(n,e)),n}},[f,y,e]),S=hj({serverId:e,serverName:h||e,onNotificationReceived:v,onSamplingRequest:g,onElicitationRequest:_,onGlobalSamplingRequest:p,onGlobalElicitationRequest:m}),C=$A({...b,onNotification:S.onNotification,onSampling:S.onSampling,onElicitation:S.onElicitation,wrapTransport:x});(0,z.useEffect)(()=>{C.state!==`ready`&&S.rejectAll(`MCP server connection is no longer active`)},[C.state,S.rejectAll]);let w=(0,z.useCallback)(t=>l(e,t),[e,l]),T=(0,z.useCallback)(n=>{let r=t.proxyConfig?.proxyAddress?.trim();return t.connectionMode===`proxy`&&r?l(e,{proxyConfig:{...t.proxyConfig,proxyAddress:r,...n?{headers:n}:{}},headers:void 0}):l(e,{headers:n})},[e,t.connectionMode,t.proxyConfig,l]),ee=(0,z.useCallback)(t=>u(e,t),[e,u]),E=(0,z.useCallback)(()=>d(e),[e,d]),D=(0,z.useRef)(c),te=(0,z.useRef)(null);return(0,z.useEffect)(()=>{D.current=c},[c]),(0,z.useEffect)(()=>{let n={...fj(t),...C,id:e,displayName:h||t.displayName||e,notifications:S.notifications,unreadNotificationCount:S.unreadNotificationCount,markNotificationRead:S.markNotificationRead,markAllNotificationsRead:S.markAllNotificationsRead,clearNotifications:S.clearNotifications,pendingSamplingRequests:S.pendingSamplingRequests,approveSampling:S.approveSampling,rejectSampling:S.rejectSampling,pendingElicitationRequests:S.pendingElicitationRequests,approveElicitation:S.approveElicitation,rejectElicitation:S.rejectElicitation,updateConfig:w,setHeaders:T,setDisplayName:ee,reconnect:E},r=te.current;!r||!yj(r,n)?(te.current=n,D.current(n)):gj.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`)},[e,h,t,t.url,C.state,C.error,C.authUrl,C.tools,C.resources,C.resourceTemplates,C.prompts,C.serverInfo,C.capabilities,C.protocolEra,C.protocolVersion,C.instructions,C.extensions,C.authTokens,S,w,T,ee,E]),null}function xj({children:e,mcpServers:t,defaultCallbackUrl:n,defaultOAuthProxyUrl:r,defaultProxyConfig:i,defaultAutoProxyFallback:a=!1,defaultServerConfig:o,clientInfo:s,storageProvider:c,enableRpcLogging:l=!1,onServerAdded:u,onServerRemoved:d,onServerStateChange:f,onSamplingRequest:p,onElicitationRequest:m}){let[h,g]=(0,z.useState)([]),[_,v]=(0,z.useState)([]),[y,b]=(0,z.useState)({}),[x,S]=(0,z.useState)(!1),C=(0,z.useRef)(!1),w=(0,z.useRef)([]);(0,z.useEffect)(()=>{w.current=_},[_]);let T=(0,z.useRef)({}),[ee,E]=(0,z.useState)(void 0),[D,te]=(0,z.useState)(!1);(0,z.useEffect)(()=>{if(!l||typeof window>`u`){E(void 0),te(!0);return}Promise.resolve().then(()=>(uk(),tk)).then(e=>{gj.debug(`[McpClientProvider] RPC logger loaded`),E(()=>e.wrapTransportForLogging),te(!0)}).catch(e=>{gj.error(`[McpClientProvider] Failed to load RPC logger:`,e),E(void 0),te(!0)})},[l]),(0,z.useEffect)(()=>{if(!D){gj.debug(`[McpClientProvider] Waiting for RPC logging to be ready before loading servers`);return}C.current||(C.current=!0,(async()=>{if(gj.debug(`[McpClientProvider] Loading servers, storageProvider:`,!!c,`mcpServers:`,t),!c){if(t){let e=Object.entries(t).map(([e,t])=>({id:e,options:t}));gj.debug(`[McpClientProvider] Loaded from mcpServers prop:`,e.length),g(e)}S(!0);return}try{let e=await Promise.resolve(c.getServers());if(gj.debug(`[McpClientProvider] Loaded from storage:`,Object.keys(e).length),c.getServerMetadata)try{let t=Object.keys(e).map(async e=>[e,await Promise.resolve(c.getServerMetadata(e))]),n=await Promise.all(t);T.current=Object.fromEntries(n.filter(e=>e[1]!==void 0)),gj.debug(`[McpClientProvider] Loaded cached metadata for`,Object.keys(T.current).length,`servers`)}catch(e){gj.warn(`[McpClientProvider] Failed to load cached metadata:`,e)}let n={...e,...t},r=Object.entries(n).map(([e,t])=>({id:e,options:t}));gj.debug(`[McpClientProvider] Total servers after merge:`,r.length),g(r),S(!0)}catch(e){gj.error(`[McpClientProvider] Failed to load from storage:`,e),t&&g(Object.entries(t).map(([e,t])=>({id:e,options:t}))),S(!0)}})())},[c,t,D]),(0,z.useEffect)(()=>{!c||!x||(async()=>{try{let e=h.reduce((e,t)=>(e[t.id]=fj(t.options),e),{});await Promise.resolve(c.setServers(e))}catch(e){gj.error(`[McpClientProvider] Failed to save to storage:`,e)}})()},[h,c,x]);let ne=(0,z.useCallback)(e=>{gj.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`,{toolCount:e.tools.length,state:e.state});let t=[];v(n=>{let r=n.findIndex(t=>t.id===e.id);if(r===-1)return gj.debug(`[McpClientProvider] Adding new server ${e.id} to state`),t.push(()=>u?.(e.id,e)),[...n,e];let i=n[r],a=i.state!==e.state,o=i.serverInfo!==e.serverInfo;if(gj.debug(`[McpClientProvider] Comparing server ${e.id}:`,{toolsChanged:i.tools!==e.tools,currentToolCount:i.tools.length,updatedToolCount:e.tools.length,stateChanged:a}),yj(i,e))return gj.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`),n;if(gj.debug(`[McpClientProvider] Updating server ${e.id} in state`),a&&t.push(()=>f?.(e.id,e.state)),o&&e.serverInfo&&c?.setServerMetadata){let t={name:e.serverInfo.name,version:e.serverInfo.version,title:e.serverInfo.title,websiteUrl:e.serverInfo.websiteUrl,icons:e.serverInfo.icons,icon:e.serverInfo.icon};T.current[e.id]=t,Promise.resolve(c.setServerMetadata(e.id,t)).catch(e=>{gj.error(`[McpClientProvider] Failed to save server metadata:`,e)})}let s=[...n];return s[r]=e,s}),t.length>0&&queueMicrotask(()=>{t.forEach(e=>e())})},[u,f,c]),O=(0,z.useCallback)((e,t)=>{g(n=>n.find(t=>t.id===e)?n:(gj.debug(`[McpClientProvider] Adding new server to configs:`,e),[...n,{id:e,options:t}]))},[]),re=(0,z.useCallback)(async(e,t)=>{let n=w.current.find(t=>t.id===e);if(v(t=>t.filter(t=>t.id!==e)),g(t=>t.filter(t=>t.id!==e)),b(t=>{let{[e]:n,...r}=t;return r}),n?.disconnect&&await n.disconnect(),t?.clearCredentials&&n?.clearStorage&&await n.clearStorage(),l){let{clearRpcLogs:t}=await Promise.resolve().then(()=>(uk(),tk));t(e)}d?.(e)},[l,d]),k=(0,z.useCallback)(async(e,t)=>{let n=h.find(t=>t.id===e);if(!n){gj.warn(`[McpClientProvider] Cannot update server "${e}" - not found`);return}let r={...n.options,...t};vj(dj(n.options),dj(r))||(await w.current.find(t=>t.id===e)?.disconnect(),v(t=>t.filter(t=>t.id!==e)),g(t=>t.map(t=>t.id===e?{id:e,options:r}:t)),b(t=>({...t,[e]:(t[e]??0)+1})))},[h]),ie=(0,z.useCallback)(async e=>{if(!h.find(t=>t.id===e)){gj.warn(`[McpClientProvider] Cannot reconnect server "${e}" - not found`);return}await w.current.find(t=>t.id===e)?.disconnect(),v(t=>t.filter(t=>t.id!==e)),b(t=>({...t,[e]:(t[e]??0)+1}))},[h]),A=(0,z.useCallback)(async(e,t)=>new Promise(n=>{let r=h.find(t=>t.id===e);if(!r){gj.warn(`[McpClientProvider] Cannot update server metadata for "${e}" - not found`),n();return}let i={...r.options,displayName:t.name};v(n=>n.map(n=>n.id===e?{...n,displayName:t.name}:n)),g(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r})}),[h]),j=(0,z.useCallback)(e=>_.find(t=>t.id===e),[_]),M=(0,z.useMemo)(()=>({servers:_,addServer:O,removeServer:re,updateServerMetadata:A,updateServer:k,getServer:j,storageLoaded:x}),[_,O,re,A,k,j,x]),{capabilities:ae,...oe}=s||{},se=(0,z.useMemo)(()=>Object.keys(oe).length?oe:void 0,[s]),N=(0,z.useMemo)(()=>h.map(e=>{let t=o?{...o,...e.options}:e.options;return ae&&(t={...t,clientOptions:{...t.clientOptions,capabilities:{...ae,...t.clientOptions?.capabilities}}}),{id:e.id,options:t}}),[h,ae,o]);return z.createElement(_j.Provider,{value:M},e,N.map(e=>z.createElement(bj,{key:`${e.id}-v${y[e.id]??0}`,id:e.id,options:e.options,defaultCallbackUrl:n,defaultOAuthProxyUrl:r,defaultProxyConfig:i,defaultAutoProxyFallback:a,clientInfo:se,cachedMetadata:T.current[e.id],onUpdate:ne,onUpdateConfig:k,onUpdateDisplayName:(e,t)=>A(e,{name:t}),onReconnect:ie,rpcWrapTransport:ee,onGlobalSamplingRequest:p,onGlobalElicitationRequest:m})))}function Sj(){let e=(0,z.useContext)(_j);if(!e)throw Error(`useMcpClient must be used within a McpClientProvider`);return e}var Cj=class{constructor(e=`mcp-client-servers`){this.storageKey=e,this.metadataKey=`${e}-metadata`}metadataKey;getServers(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load servers:`,e),{}}}setServers(e){try{localStorage.setItem(this.storageKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save servers:`,e)}}setServer(e,t){let n=this.getServers();n[e]=t,this.setServers(n)}removeServer(e){let t=this.getServers();delete t[e],this.setServers(t),this.removeServerMetadata(e)}clear(){try{localStorage.removeItem(this.storageKey),localStorage.removeItem(this.metadataKey)}catch(e){console.error(`[LocalStorageProvider] Failed to clear:`,e)}}getAllMetadata(){try{let e=localStorage.getItem(this.metadataKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load metadata:`,e),{}}}setAllMetadata(e){try{localStorage.setItem(this.metadataKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save metadata:`,e)}}getServerMetadata(e){return this.getAllMetadata()[e]}setServerMetadata(e,t){let n=this.getAllMetadata();n[e]={...t,cachedAt:Date.now()},this.setAllMetadata(n)}removeServerMetadata(e){let t=this.getAllMetadata();delete t[e],this.setAllMetadata(t)}};uk();function wj(e){let t={};if(!e)return t;for(let[n,r]of Object.entries(e))if(typeof r==`string`&&(r.trim().startsWith(`[`)||r.trim().startsWith(`{`)))try{t[n]=JSON.parse(r)}catch{t[n]=r}else t[n]=r;return t}function Tj(e){let{resourceResult:t,listingResource:n,cspMode:r,resourceUri:i}=e,a=(Array.isArray(t?.contents)?t.contents:[])[0],o=``,s;if(a&&(s=a.mimeType,typeof a.text==`string`?o=a.text:typeof a.blob==`string`&&(o=atob(a.blob))),!o)throw Error(`No HTML content in resource`);let c=n?._meta?.ui,l=a?._meta?.ui,u=c||l?{...c,...l}:void 0,d=u?.csp,f=u?.permissions,p=u?.prefersBorder??!1,m=s===BO,h=m?null:s?`Invalid MIME type "${s}" - SEP-1865 requires "${BO}"`:`Missing MIME type - SEP-1865 requires "${BO}"`;return h&&console.warn(`[ViewRenderer] MIME type validation:`,h,{resourceUri:i}),{html:o,declaredCsp:d,csp:r===`permissive`?void 0:d,permissions:f,prefersBorder:p,mimeType:s,mimeTypeValid:m,mimeTypeWarning:h}}function Ej(e,t){let{cspMode:n,permissions:r,widgetCsp:i}=t;e.searchParams.set(`v`,JSON.stringify({cspMode:n,permissions:r,widgetCsp:i})),e.searchParams.set(`csp_mode`,n),r&&Object.keys(r).length>0&&e.searchParams.set(`permissions`,JSON.stringify(r)),i&&Object.keys(i).length>0&&e.searchParams.set(`widget_csp`,JSON.stringify(i))}function Dj(e){let t=new URL(`https://sandbox.invalid/`);Ej(t,e);let n=kj(t.search);return new URL(URL.createObjectURL(new Blob([n],{type:`text/html`})))}var Oj=`<!doctype html>
|
|
196
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:V().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:V().optional().describe(`User's timezone in IANA format.`),userAgent:V().optional().describe(`Host application identifier.`),platform:J([X(`web`),X(`desktop`),X(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:K({touch:U().optional().describe(`Whether the device supports touch input.`),hover:U().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:K({top:H().describe(`Top safe area inset in pixels.`),right:H().describe(`Right safe area inset in pixels.`),bottom:H().describe(`Bottom safe area inset in pixels.`),left:H().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough();K({method:X(`ui/notifications/host-context-changed`),params:FO.describe(`Partial context update containing only changed fields.`)});var IO=K({method:X(`ui/update-model-context`),params:K({content:G(sD).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:Y(V(),W().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),LO=K({method:X(`ui/initialize`),params:K({appInfo:eE.describe(`App identification (name and version).`),appCapabilities:OO.describe(`Features and capabilities this app provides.`),protocolVersion:V().describe(`Protocol version this app supports.`)})}),RO=K({protocolVersion:V().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:eE.describe(`Host application identification and version.`),hostCapabilities:DO.describe(`Features and capabilities provided by the host.`),hostContext:FO.describe(`Rich context about the host environment.`)}).passthrough(),zO=class{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=e=>{if(t&&e.source!==this.eventSource){console.debug(`Ignoring message from unknown source`,e);return}let n=JT.safeParse(e.data);n.success?(console.debug(`Parsed message`,n.data),this.onmessage?.(n.data)):e.data?.jsonrpc===`2.0`?(console.error(`Failed to parse message`,n.error.message,e),this.onerror?.(Error(`Invalid JSON-RPC message received: `+n.error.message))):console.debug(`Ignoring non-JSON-RPC message`,n.error.message,e)}}async start(){window.addEventListener(`message`,this.messageListener)}async send(e,t){e.method!==`ui/notifications/tool-input-partial`&&console.debug(`Sending message`,e),this.eventTarget.postMessage(e,`*`)}async close(){window.removeEventListener(`message`,this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion},BO=`text/html;profile=mcp-app`;function VO(e){if(!e)return``;let t=[];return e.camera&&t.push(`camera`),e.microphone&&t.push(`microphone`),e.geolocation&&t.push(`geolocation`),e.clipboardWrite&&t.push(`clipboard-write`),t.join(`; `)}var HO=[uO],UO=class extends Bb{_client;_hostInfo;_hostCapabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_registeredEvents=new Set;_events=new lO;_wrapHandler(e,t){let n=super._wrapHandler(e,t);return e===`ui/initialize`||e===`ping`?n:async(t,r)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${e}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(t,r))}eventSchemas={sizechange:xO,sandboxready:vO,initialized:kO,requestteardown:EO,loggingmessage:wD};setEventHandler(e,t){this._ensureEventSlot(e),this._events.setHandler(e,t)}getEventHandler(e){return this._events.getHandler(e)}addEventListener(e,t){this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);let n=t=>{e===`initialized`&&(this._initializedReceived=!0),this._events.dispatch(e,t)};e===`loggingmessage`?this.setNotificationHandler(`notifications/message`,e=>{n(e.params)}):this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},e=>n(e)),this._registeredEvents.add(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t,n,r){super(r),this._client=e,this._hostInfo=t,this._hostCapabilities=n,this._ensureEventSlot(`initialized`),this._hostContext=r?.hostContext||{},this.setRequestHandler(`ui/initialize`,{params:LO.shape.params,result:RO},e=>this._onAppsInitialize(e)),this.setRequestHandler(`ping`,(e,t)=>(this.onping?.(e.params,t),{})),this.setRequestHandler(`ui/request-display-mode`,{params:AO.shape.params,result:jO},()=>({mode:this._hostContext.displayMode??`inline`}))}buildContext(e){return e}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){}assertNotificationCapability(e){}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler(`sizechange`)}set onsizechange(e){this.setEventHandler(`sizechange`,e)}get onsandboxready(){return this.getEventHandler(`sandboxready`)}set onsandboxready(e){this.setEventHandler(`sandboxready`,e)}get oninitialized(){return this.getEventHandler(`initialized`)}set oninitialized(e){this.setEventHandler(`initialized`,e)}_onmessage;get onmessage(){return this._onmessage}set onmessage(e){this.warnIfRequestHandlerReplaced(`onmessage`,this._onmessage,e),this._onmessage=e,this.setRequestHandler(`ui/message`,{params:PO.shape.params,result:_O},async(e,t)=>{if(!this._onmessage)throw Error(`No onmessage handler set`);return this._onmessage(e,t)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(e){this.warnIfRequestHandlerReplaced(`onopenlink`,this._onopenlink,e),this._onopenlink=e,this.setRequestHandler(`ui/open-link`,{params:mO.shape.params,result:hO},async(e,t)=>{if(!this._onopenlink)throw Error(`No onopenlink handler set`);return this._onopenlink(e,t)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(e){this.warnIfRequestHandlerReplaced(`ondownloadfile`,this._ondownloadfile,e),this._ondownloadfile=e,this.setRequestHandler(`ui/download-file`,{params:NO.shape.params,result:gO},async(e,t)=>{if(!this._ondownloadfile)throw Error(`No ondownloadfile handler set`);return this._ondownloadfile(e,t)})}get onrequestteardown(){return this.getEventHandler(`requestteardown`)}set onrequestteardown(e){this.setEventHandler(`requestteardown`,e)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(e){this.warnIfRequestHandlerReplaced(`onrequestdisplaymode`,this._onrequestdisplaymode,e),this._onrequestdisplaymode=e,this.setRequestHandler(`ui/request-display-mode`,{params:AO.shape.params,result:jO},async(e,t)=>{if(!this._onrequestdisplaymode)throw Error(`No onrequestdisplaymode handler set`);return this._onrequestdisplaymode(e,t)})}get onloggingmessage(){return this.getEventHandler(`loggingmessage`)}set onloggingmessage(e){this.setEventHandler(`loggingmessage`,e)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(e){this.warnIfRequestHandlerReplaced(`onupdatemodelcontext`,this._onupdatemodelcontext,e),this._onupdatemodelcontext=e,this.setRequestHandler(`ui/update-model-context`,{params:IO.shape.params,result:YT},async(e,t)=>{if(!this._onupdatemodelcontext)throw Error(`No onupdatemodelcontext handler set`);return this._onupdatemodelcontext(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.setRequestHandler(`tools/call`,async(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}set oncreatesamplingmessage(e){this.setRequestHandler(`sampling/createMessage`,async(t,n)=>e(t.params,n))}sendToolListChanged(e={}){return this.notification({method:`notifications/tools/list_changed`,params:e})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(e){this.warnIfRequestHandlerReplaced(`onlistresources`,this._onlistresources,e),this._onlistresources=e,this.setRequestHandler(`resources/list`,async(e,t)=>{if(!this._onlistresources)throw Error(`No onlistresources handler set`);return this._onlistresources(e.params,t)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(e){this.warnIfRequestHandlerReplaced(`onlistresourcetemplates`,this._onlistresourcetemplates,e),this._onlistresourcetemplates=e,this.setRequestHandler(`resources/templates/list`,async(e,t)=>{if(!this._onlistresourcetemplates)throw Error(`No onlistresourcetemplates handler set`);return this._onlistresourcetemplates(e.params,t)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(e){this.warnIfRequestHandlerReplaced(`onreadresource`,this._onreadresource,e),this._onreadresource=e,this.setRequestHandler(`resources/read`,async(e,t)=>{if(!this._onreadresource)throw Error(`No onreadresource handler set`);return this._onreadresource(e.params,t)})}sendResourceListChanged(e={}){return this.notification({method:`notifications/resources/list_changed`,params:e})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(e){this.warnIfRequestHandlerReplaced(`onlistprompts`,this._onlistprompts,e),this._onlistprompts=e,this.setRequestHandler(`prompts/list`,async(e,t)=>{if(!this._onlistprompts)throw Error(`No onlistprompts handler set`);return this._onlistprompts(e.params,t)})}sendPromptListChanged(e={}){return this.notification({method:`notifications/prompts/list_changed`,params:e})}getCapabilities(){return this._hostCapabilities}async _onAppsInitialize(e){let t=e.protocolVersion;return this._appInfo!==void 0&&console.warn(`[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values.`),this._appCapabilities=e.appCapabilities,this._appInfo=e.appInfo,{protocolVersion:HO.includes(t)?t:uO,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(e){let t={},n=!1;for(let r of Object.keys(e)){let i=this._hostContext[r],a=e[r];WO(i,a)||(t[r]=a,n=!0)}n&&(this._hostContext=e,this.sendHostContextChange(t))}sendHostContextChange(e){return this.notification({method:`ui/notifications/host-context-changed`,params:e})}sendToolInput(e){return this.notification({method:`ui/notifications/tool-input`,params:e})}sendToolInputPartial(e){return this.notification({method:`ui/notifications/tool-input-partial`,params:e})}sendToolResult(e){return this.notification({method:`ui/notifications/tool-result`,params:e})}sendToolCancelled(e){return this.notification({method:`ui/notifications/tool-cancelled`,params:e})}sendSandboxResourceReady(e){return this.notification({method:`ui/notifications/sandbox-resource-ready`,params:e})}teardownResource(e,t){return this.request({method:`ui/resource-teardown`,params:e},wO,t)}sendResourceTeardown=this.teardownResource;callTool(e,t){return this.request({method:`tools/call`,params:e},t)}listTools(e,t){return this.request({method:`tools/list`,params:e},t)}async connect(e){if(this.transport)throw Error(`AppBridge is already connected. Call close() before connecting again.`);if(this._initializedReceived=!1,this._client){let e=this._client.getServerCapabilities();if(!e)throw Error(`Client server capabilities not available`);e.tools&&(this.oncalltool=async(e,t)=>this._client.request({method:`tools/call`,params:e},{signal:t.mcpReq.signal}),e.tools.listChanged&&this._client.setNotificationHandler(`notifications/tools/list_changed`,e=>this.sendToolListChanged(e.params))),e.resources&&(this.onlistresources=async(e,t)=>this._client.request({method:`resources/list`,params:e},{signal:t.mcpReq.signal}),this.onlistresourcetemplates=async(e,t)=>this._client.request({method:`resources/templates/list`,params:e},{signal:t.mcpReq.signal}),this.onreadresource=async(e,t)=>this._client.request({method:`resources/read`,params:e},{signal:t.mcpReq.signal}),e.resources.listChanged&&this._client.setNotificationHandler(`notifications/resources/list_changed`,e=>this.sendResourceListChanged(e.params))),e.prompts&&(this.onlistprompts=async(e,t)=>this._client.request({method:`prompts/list`,params:e},{signal:t.mcpReq.signal}),e.prompts.listChanged&&this._client.setNotificationHandler(`notifications/prompts/list_changed`,e=>this.sendPromptListChanged(e.params)))}return super.connect(e)}};function WO(e,t){return JSON.stringify(e)===JSON.stringify(t)}var GO=Object.defineProperty,KO=Object.getOwnPropertyNames,qO=(e,t)=>function(){return e&&(t=(0,e[KO(e)[0]])(e=0)),t},JO=(e,t)=>{for(var n in t)GO(e,n,{get:t[n],enumerable:!0})};function YO(){let e;try{e=typeof process<`u`?{}.MCP_USE_LOG_LEVEL??{}.DEBUG:void 0}catch{}let t=e?.trim().toLowerCase();return t===`2`?`debug`:t&&XO.includes(t)?t:`info`}var XO,ZO,QO,$O,$,ek=qO({"src/utils/logging.ts"(){XO=[`silent`,`error`,`warn`,`info`,`http`,`verbose`,`debug`,`silly`],ZO={silent:``,error:`❌`,warn:`⚠️`,info:`ℹ️`,http:`🌐`,verbose:`📝`,debug:`🔍`,silly:`🤪`},QO=class{constructor(e=`mcp-use`,t=`info`,n=`minimal`){this.name=e,this.level=t,this.format=n}write(e,t,n){if(this.level===`silent`||XO.indexOf(e)>XO.indexOf(this.level))return;let r=n.map(e=>{if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `),i=r?`${t} ${r}`:t,a=new Date().toLocaleTimeString(`en-US`,{hour12:!1}),o=this.format===`minimal`?e:e.toUpperCase(),s=this.format===`emoji`?` ${ZO[e]}`:``,c=`${a} [${this.name}]${s} ${o}: ${i}`;(e===`error`?console.error:e===`warn`?console.warn:e===`info`?console.info:e===`debug`?console.debug:console.log)(c)}error=(e,...t)=>this.write(`error`,e,t);warn=(e,...t)=>this.write(`warn`,e,t);info=(e,...t)=>this.write(`info`,e,t);debug=(e,...t)=>this.write(`debug`,e,t);http=(e,...t)=>this.write(`http`,e,t);verbose=(e,...t)=>this.write(`verbose`,e,t);silly=(e,...t)=>this.write(`silly`,e,t);setFormat(e){this.format=e}},$O=class{static instances={};static currentFormat=`minimal`;static currentLevel;static get(e=`mcp-use`){return this.instances[e]??=new QO(e,this.currentLevel??YO(),this.currentFormat)}static configure({level:e=YO(),format:t=`minimal`}={}){this.currentLevel=e,this.currentFormat=t;for(let n of Object.values(this.instances))n.level=e,n.format=t}static setDebug(e){let t=e===2||e===!0?`debug`:`info`;this.currentLevel=t;for(let e of Object.values(this.instances))e.level=t;try{typeof process<`u`&&({}.MCP_USE_LOG_LEVEL=t)}catch{}}static setFormat(e){this.configure({format:e})}},$=$O.get()}}),tk={};JO(tk,{clearRpcLogs:()=>ak,getAllRpcLogs:()=>rk,getRpcLogs:()=>nk,subscribeToRpcLogs:()=>ik,wrapTransportForLogging:()=>ok});function nk(e){return lk.getLogsForServer(e)}function rk(){return lk.getAllLogs()}function ik(e){return lk.subscribe(e)}function ak(e){lk.clear(e)}function ok(e,t){class n{constructor(e){this.inner=e,this.inner.onmessage=(e,n)=>{lk.publish({serverId:t,direction:`receive`,timestamp:new Date().toISOString(),message:e}),this.onmessage?.(e,n)},this.inner.onclose=()=>{this.onclose?.()},this.inner.onerror=e=>{this.onerror?.(e)}}onclose;onerror;onmessage;async start(){typeof this.inner.start==`function`&&await this.inner.start()}async send(e,n){lk.publish({serverId:t,direction:`send`,timestamp:new Date().toISOString(),message:e}),await this.inner.send(e,n)}async close(){await this.inner.close()}get sessionId(){return this.inner.sessionId}setProtocolVersion(e){typeof this.inner.setProtocolVersion==`function`&&this.inner.setProtocolVersion(e)}}return new n(e)}var sk,ck,lk,uk=qO({"src/react/rpc-logger.ts"(){ek(),sk=$O.get(`RpcLogger`),ck=class{logs=[];listeners=new Set;maxLogs=1e3;publish(e){sk.debug(`[RPC Logger] Publishing log:`,e.direction,e.serverId,e.message?.method),this.logs.push(e),this.logs.length>this.maxLogs&&(this.logs=this.logs.slice(-this.maxLogs)),sk.debug(`[RPC Logger] Total logs:`,this.logs.length,`Listeners:`,this.listeners.size),this.listeners.forEach(t=>{try{t(e)}catch(e){sk.error(`[RPC Logger] Listener error:`,e)}})}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}getLogsForServer(e){return this.logs.filter(t=>t.serverId===e)}getAllLogs(){return[...this.logs]}clear(e){e?this.logs=this.logs.filter(t=>t.serverId!==e):this.logs=[]}},lk=new ck}}),dk=`mcp_auth_callback`,fk=`mcp_auth_callback`;function pk(e){try{return typeof localStorage<`u`&&!!localStorage.getItem(e)}catch{return!1}}function mk({popup:e,state:t,tokensKey:n,timeoutMs:r=5*6e4,closePollMs:i=1e3,closeGraceMs:a=2e4,expectedOrigin:o=typeof window<`u`?window.location.origin:``}){return new Promise(s=>{let c=!1,l=null,u=null,d=null,f=null,p=()=>{if(l&&=(clearInterval(l),null),u&&=(clearTimeout(u),null),d&&=(clearTimeout(d),null),typeof window<`u`&&(window.removeEventListener(`message`,g),window.removeEventListener(`storage`,v)),f){try{f.removeEventListener(`message`,_),f.close()}catch{}f=null}},m=e=>{c||(c=!0,p(),s(e))},h=e=>{!e||e.type!==fk||e.state&&t&&e.state!==t||(e.success?m({kind:`success`}):m({kind:`error`,error:e.error??`Authentication failed in callback.`}))},g=e=>{o&&e.origin!==o||h(e.data)},_=e=>{h(e.data)},v=e=>{e.key===n&&e.newValue&&m({kind:`success`})};if(typeof window<`u`&&(window.addEventListener(`message`,g),window.addEventListener(`storage`,v)),typeof BroadcastChannel<`u`)try{f=new BroadcastChannel(dk),f.addEventListener(`message`,_)}catch{f=null}e&&(l=setInterval(()=>{if(c)return;let t=!1;try{t=e.closed}catch{t=!1}if(t){if(l&&=(clearInterval(l),null),pk(n)){m({kind:`success`});return}d=setTimeout(()=>{m(pk(n)?{kind:`success`}:{kind:`cancelled`})},a)}},i)),u=setTimeout(()=>{m(pk(n)?{kind:`success`}:{kind:`timeout`})},r)})}ek();var hk=`http://json-schema.org/draft-04/schema`,gk=new Set([`http://json-schema.org/draft-07/schema`,`https://json-schema.org/draft-07/schema`]),_k=new Set([`https://json-schema.org/draft/2019-09/schema`,`http://json-schema.org/draft/2019-09/schema`]),vk=new Set([`https://json-schema.org/draft/2020-12/schema`,`http://json-schema.org/draft/2020-12/schema`]);function yk(e){if(!(`$schema`in e)||typeof e.$schema!=`string`)return`2020-12`;let t=e.$schema.replace(/#$/,``);if(t===hk)return`4`;if(gk.has(t))return`7`;if(_k.has(t))return`2019-09`;if(vk.has(t))return`2020-12`}var bk=class{getValidator(e){let t=yk(e);return(t===void 0?new Bx:new Bx({draft:t})).getValidator(e)}};ek();var xk;function Sk(e){xk?.(e)}var Ck={"~standard":{version:1,vendor:`mcp-use`,validate:e=>({value:e})}},wk=class{client=null;connectionManager=null;toolsCache=null;capabilitiesCache=null;serverInfoCache=null;connected=!1;opts;notificationHandlers=[];rootsCache=[];activeProgressHandlers=new Set;constructor(e={}){this.opts=e,e.roots&&(this.rootsCache=[...e.roots]),e.onNotification&&this.notificationHandlers.push(e.onNotification)}trackConnectorInit(e){let t=this.constructor.name;Sk({connectorType:t,...e})}onNotification(e){this.notificationHandlers.push(e),this.client&&this.setupNotificationHandler()}async forwardNotification(e){for(let t of this.notificationHandlers)try{await t(e)}catch(e){$.error(`Error in notification handler:`,e)}}async handleListChanged(e,t,n){if(t){$.warn(`[Auto] ${e} refresh failed:`,t);return}e===`notifications/tools/list_changed`&&n&&(this.toolsCache=[...n]),await this.forwardNotification({method:e})}setupNotificationHandler(){if(!this.client)return;this.client.fallbackNotificationHandler=async e=>{switch(e.method){case`notifications/tools/list_changed`:await this.refreshToolsCache();break;case`notifications/resources/list_changed`:await this.onResourcesListChanged();break;case`notifications/prompts/list_changed`:await this.onPromptsListChanged();break;default:break}await this.forwardNotification(e)};let e=this.client._notificationHandlers;for(let t of[`notifications/progress`,`notifications/cancelled`]){let n=e.get(t);n&&e.set(t,async e=>{await n(e),await this.forwardNotification(e)})}}setupRoundProgressForwarding(){if(!this.client)return;let e=this.client,t=e._onnotification.bind(this.client);e._onnotification=async e=>{e&&typeof e==`object`&&e.method===`notifications/progress`&&this.forwardRoundProgress(e.params),await t?.(e)}}forwardRoundProgress(e){if(this.activeProgressHandlers.size===1){let[t]=this.activeProgressHandlers;t?.(e)}}async refreshToolsCache(){if(this.client)try{$.debug(`[Auto] Refreshing tools cache due to list_changed notification`);let e=await this.client.listTools();this.toolsCache=e.tools??[],$.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(e){$.warn(`[Auto] Failed to refresh tools cache:`,e)}}async onResourcesListChanged(){$.debug(`[Auto] Resources list changed - clients should re-fetch if needed`)}async onPromptsListChanged(){$.debug(`[Auto] Prompts list changed - clients should re-fetch if needed`)}async setRoots(e){this.rootsCache=[...e],this.client&&($.debug(`Sending roots/list_changed notification with ${e.length} root(s)`),await this.client.sendRootsListChanged())}getRoots(){return[...this.rootsCache]}setupRootsHandler(){this.client&&this.client.setRequestHandler(`roots/list`,async()=>($.debug(`Server requested roots list, returning ${this.rootsCache.length} root(s)`),{roots:this.rootsCache}))}setupSamplingHandler(){if(!this.client){$.debug(`setupSamplingHandler: No client available`);return}let e=this.opts.onSampling;if(!e){$.debug(`setupSamplingHandler: No sampling callback provided`);return}$.debug(`setupSamplingHandler: Setting up sampling request handler`),this.client.setRequestHandler(`sampling/createMessage`,async t=>($.debug(`Server requested sampling, forwarding to callback`),await e(t.params))),$.debug(`setupSamplingHandler: Sampling handler registered successfully`)}setupElicitationHandler(){if(!this.client){$.debug(`setupElicitationHandler: No client available`);return}let e=this.opts.onElicitation;if(!e){$.debug(`setupElicitationHandler: No elicitation callback provided`);return}$.debug(`setupElicitationHandler: Setting up elicitation request handler`),this.client.setRequestHandler(`elicitation/create`,async t=>($.debug(`Server requested elicitation, forwarding to callback`),await e(t.params))),$.debug(`setupElicitationHandler: Elicitation handler registered successfully`)}async disconnect(){if(!this.connected){$.debug(`Not connected to MCP implementation`);return}$.debug(`Disconnecting from MCP implementation`),await this.cleanupResources(),this.connected=!1,$.debug(`Disconnected from MCP implementation`)}get isClientConnected(){return this.client!=null}async initialize(e=this.opts.defaultRequestOptions??{}){if(!this.client)throw Error(`MCP client is not connected`);$.debug(`Caching server capabilities & tools`);let t=this.client.getServerCapabilities();this.capabilitiesCache=t||null;let n=this.client.getServerVersion();this.serverInfoCache=n?{name:n.name,version:n.version,title:n.title,description:n.description,websiteUrl:n.websiteUrl,icons:n.icons}:null;try{let t=await this.client.listTools(void 0,e);this.toolsCache=t.tools??[],$.debug(`Fetched ${this.toolsCache.length} tools from server`)}catch(e){let t=e;t.code===-32601?$.debug(`Server does not implement tools/list, assuming no tools`):$.debug(`Failed to list tools, assuming empty:`,t.message),this.toolsCache=[]}return $.debug(`Server capabilities:`,t),$.debug(`Server info:`,n),t}get tools(){if(!this.toolsCache)throw Error(`MCP client is not initialized; call initialize() first`);return this.toolsCache}get serverCapabilities(){return this.capabilitiesCache||{}}get serverInfo(){return this.serverInfoCache}get instructions(){return this.client?.getInstructions?.()}get protocolEra(){return this.client?.getProtocolEra?.()}get negotiatedProtocolVersion(){return this.client?.getNegotiatedProtocolVersion?.()}async callTool(e,t,n){if(!this.client)throw Error(`MCP client is not connected`);let r=n?{...n}:void 0;r?.resetTimeoutOnProgress&&!r.onprogress&&(r.onprogress=()=>{},$.debug(`[BaseConnector] Added onprogress callback for tool '${e}' to enable progressToken`)),$.debug(`Calling tool '${e}' with args`,t);let i=r?.onprogress;i&&this.activeProgressHandlers.add(i);try{let n=await this.client.callTool({name:e,arguments:t},r);return $.debug(`Tool '${e}' returned`,n),n}finally{i&&this.activeProgressHandlers.delete(i)}}async listTools(e){if(!this.client)throw Error(`MCP client is not connected`);$.debug(`[listTools] Fetching fresh tools from server...`);let t=await this.client.listTools(void 0,e),n=t.tools?[...t.tools]:[];return $.debug(`[listTools] Returned ${n.length} tools:`,n.map(e=>e.name)),n}async listResources(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Listing resources`,e?`with cursor: ${e}`:``),await this.client.listResources({cursor:e},t)}async listAllResources(e){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.resources)return $.debug(`Server does not advertise resources capability, skipping`),{resources:[]};try{$.debug(`Listing all resources (with auto-pagination)`);let t=[],n;do{let r=await this.client.listResources({cursor:n},e);t.push(...r.resources||[]),n=r.nextCursor}while(n);return{resources:t}}catch(e){if(e.code===-32601)return $.debug(`Server advertised resources but method not found`),{resources:[]};throw e}}async listResourceTemplates(e){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Listing resource templates`),await this.client.listResourceTemplates(void 0,e)}async complete(e,t){if(!this.client)throw Error(`MCP client is not connected`);$.debug(`[complete] Requesting completions for:`,e.ref);let n=await this.client.complete(e,t);return $.debug(`[complete] Received ${n.completion.values.length} suggestions`),n}async readResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Reading resource ${e}`),await this.client.readResource({uri:e},t)}async subscribeToResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Subscribing to resource: ${e}`),await this.client.subscribeResource({uri:e},t)}async unsubscribeFromResource(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Unsubscribing from resource: ${e}`),await this.client.unsubscribeResource({uri:e},t)}async listPrompts(){if(!this.client)throw Error(`MCP client is not connected`);if(!this.capabilitiesCache?.prompts)return $.debug(`Server does not advertise prompts capability, skipping`),{prompts:[]};try{return $.debug(`Listing prompts`),await this.client.listPrompts()}catch(e){if(e.code===-32601)return $.debug(`Server advertised prompts but method not found`),{prompts:[]};throw e}}async getPrompt(e,t){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Getting prompt ${e}`),await this.client.getPrompt({name:e,arguments:t})}async request(e,t=null,n){if(!this.client)throw Error(`MCP client is not connected`);return $.debug(`Sending raw request '${e}' with params`,t),await this.client.request({method:e,params:t??{}},Ck,n)}async cleanupResources(){let e=[];if(this.client)try{typeof this.client.close==`function`&&await this.client.close()}catch(t){let n=`Error closing client: ${t}`;$.warn(n),e.push(n)}finally{this.client=null}if(this.connectionManager)try{await this.connectionManager.stop()}catch(t){let n=`Error stopping connection manager: ${t}`;$.warn(n),e.push(n)}finally{this.connectionManager=null}this.toolsCache=null,e.length&&$.warn(`Resource cleanup finished with ${e.length} issue(s)`)}};function Tk(e,t=0){if(!e||t>5)return!1;if(e instanceof pS||e instanceof U_&&e.status===401)return!0;if(e instanceof Error){if(e.cause&&Tk(e.cause,t+1))return!0;let n=e instanceof H_?e.data:void 0;if(n?.cause&&Tk(n.cause,t+1))return!0}return!1}function Ek(e,t,n,r){let i=new URL(e),a=t.replace(/\/$/,``);return async(e,t)=>{let o=new Request(e,t),s=new URL(o.url);if(!(s.origin===i.origin&&s.pathname===i.pathname))return n(o);let c=new Headers(o.headers);c.set(`X-Target-URL`,o.url),r&&c.set(`X-Server-Id`,r);let l=o.method===`GET`||o.method===`HEAD`?void 0:await o.clone().arrayBuffer();return n(new Request(a,{method:o.method,headers:c,body:l,signal:o.signal,redirect:`manual`}))}}var Dk=class extends wk{baseUrl;headers;timeout;customFetch;clientInfo;protocolNegotiation;gatewayUrl;serverId;reconnectionOptions;transportType=null;streamableTransport=null;constructor(e,t={}){super(t);let n=e.replace(/\/$/,``);this.baseUrl=n,this.headers={...t.headers??{}},this.gatewayUrl=t.gatewayUrl,this.serverId=t.serverId,t.authToken&&(this.headers.Authorization=`Bearer ${t.authToken}`),this.timeout=t.timeout??1e4;let r=t.fetch??globalThis.fetch.bind(globalThis);this.customFetch=this.gatewayUrl?Ek(n,this.gatewayUrl,r,this.serverId):t.fetch,this.clientInfo=t.clientInfo??{name:`http-connector`,version:`1.0.0`},this.protocolNegotiation=t.protocolNegotiation??`auto`,this.reconnectionOptions=t.reconnectionOptions}buildClientOptions(){return{...this.opts.clientOptions||{},jsonSchemaValidator:this.opts.clientOptions?.jsonSchemaValidator??new bk,versionNegotiation:{mode:this.protocolNegotiation,...this.opts.clientOptions?.versionNegotiation??{}},listChanged:{tools:{autoRefresh:!0,onChanged:(e,t)=>void this.handleListChanged(`notifications/tools/list_changed`,e,t)},resources:{autoRefresh:!1,onChanged:e=>void this.handleListChanged(`notifications/resources/list_changed`,e)},prompts:{autoRefresh:!1,onChanged:e=>void this.handleListChanged(`notifications/prompts/list_changed`,e)},...this.opts.clientOptions?.listChanged??{}},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.onSampling?{sampling:{}}:{},...this.opts.onElicitation?{elicitation:{form:{},url:{}}}:{}}}}unwrapStreamableError(e){return e instanceof U_?e:e instanceof Error&&e.cause instanceof U_?e.cause:null}classifyStreamableHttpFailure(e){let t=`Unknown error`,n=!1,r,i=this.unwrapStreamableError(e);if(i){let e=i.status;return n=e===401,r=e,e===400&&i.message.includes(`Missing session ID`)?(t=`Server requires session ID (FastMCP compatibility)`,$.warn(`\u26A0\uFE0F ${t}`)):e===404||e===405?(t=`Server returned ${e} - server likely doesn't support streamable HTTP`,$.debug(t)):(t=`Server returned ${e}: ${i.message}`,$.debug(t)),{fallbackReason:t,is401Error:n,httpStatusCode:r}}if(e instanceof Error){let r=e.toString(),i=e.message||``;n=Tk(e)||r.includes(`401`)||i.includes(`Unauthorized`),r.includes(`Missing session ID`)||r.includes(`Bad Request: Missing session ID`)||i.includes(`FastMCP session ID error`)?(t=`Server requires session ID (FastMCP compatibility)`,$.warn(`\u26A0\uFE0F ${t}`)):r.includes(`405 Method Not Allowed`)||r.includes(`404 Not Found`)?(t=`Server doesn't support streamable HTTP (405/404)`,$.debug(t)):(t=`Streamable HTTP failed: ${e.message}`,$.debug(t))}return{fallbackReason:t,is401Error:n,httpStatusCode:r}}async connect(){if(this.connected){$.debug(`Already connected to MCP implementation`);return}let e=this.baseUrl;$.debug(`Connecting to MCP implementation via HTTP: ${e}`);try{await this.connectWithStreamableHttp(e),$.debug(`✅ Successfully connected via streamable HTTP`)}catch(e){$.debug(`Streamable HTTP connect failed`,e);let{fallbackReason:t,is401Error:n,httpStatusCode:r}=this.classifyStreamableHttpFailure(e);if(await this.cleanupResources(),n){$.info(`Authentication required`);let e=Error(`Authentication required`);throw e.code=401,e}let i=Error(`Could not connect via streamable HTTP: ${t}`);throw r!==void 0&&Object.defineProperty(i,"code",{value:r,writable:!1,enumerable:!0,configurable:!0}),i}}observeSseProgress(e){if(!e.body||!e.headers.get(`content-type`)?.includes(`text/event-stream`))return e;let[t,n]=e.body.tee();return(async()=>{let e=n.getReader(),t=new TextDecoder,r=``;try{for(;;){let{done:n,value:i}=await e.read();if(n)break;r+=t.decode(i,{stream:!0});let a=r.split(/\r?\n\r?\n/);r=a.pop()??``;for(let e of a)for(let t of e.split(/\r?\n/))if(t.startsWith(`data:`))try{let e=JSON.parse(t.slice(5).trim());e.method===`notifications/progress`&&this.forwardRoundProgress(e.params)}catch{}}}catch(e){e instanceof DOMException&&e.name===`AbortError`||$.debug(`Progress observer stream ended:`,e)}finally{e.releaseLock()}})(),new Response(t,{status:e.status,statusText:e.statusText,headers:e.headers})}async connectWithStreamableHttp(e){try{$.debug(`[HttpConnector] Connecting with Streamable HTTP`,{baseUrl:e,originalUrl:this.baseUrl,gatewayUrl:this.gatewayUrl||`none`,authProviderUrl:this.opts.authProvider&&`serverUrl`in this.opts.authProvider&&typeof this.opts.authProvider.serverUrl==`string`?this.opts.authProvider.serverUrl:`none`,headers:this.headers});let t,n=new Promise(e=>{t=e}),r=this.customFetch??globalThis.fetch.bind(globalThis),i=new LC(new URL(e),{authProvider:this.opts.authProvider,fetch:async(e,n)=>{let i=await r(e,n),a=n?.method??(e instanceof Request?e.method:`GET`),o=new Headers(e instanceof Request?e.headers:void 0);return new Headers(n?.headers).forEach((e,t)=>{o.set(t,e)}),a.toUpperCase()===`GET`&&i.ok&&i.headers.get(`content-type`)?.includes(`text/event-stream`)&&t?.(),o.get(`mcp-method`)===`subscriptions/listen`?i:this.observeSseProgress(i)},requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2,...this.reconnectionOptions}}),a=i;if(this.opts.wrapTransport){let e=this.baseUrl;a=this.opts.wrapTransport(a,e)}let o=this.buildClientOptions();$.debug(`Creating Client with capabilities:`,JSON.stringify(o.capabilities,null,2)),this.client=new MC(this.clientInfo,o),this.setupRootsHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$.debug(`Roots/sampling/elicitation handlers registered before connect`);try{let e;if(await Promise.race([this.client.connect(a),new Promise((t,n)=>{e=setTimeout(()=>n(Error(`MCP connection timed out after ${this.timeout}ms`)),this.timeout)})]).finally(()=>{e!==void 0&&clearTimeout(e)}),(this.client.getProtocolEra?.()??`legacy`)===`legacy`&&i.sessionId){let e,t=await Promise.race([n.then(()=>!0),new Promise(t=>e=setTimeout(()=>t(!1),Math.min(this.timeout,5e3)))]);e&&clearTimeout(e),t||$.warn(`Legacy server push stream did not attach before connect completed`)}let t=i.sessionId;t&&$.debug(`Session ID obtained: ${t}`)}catch(e){if(e instanceof Error){let t=e.message||e.toString();if(t.includes(`Missing session ID`)||t.includes(`Bad Request: Missing session ID`)||t.includes(`Mcp-Session-Id header is required`)){let n=Error(`Session ID error: ${t}. The SDK should automatically extract session ID from initialize response.`);throw n.cause=e,n}}throw e}this.streamableTransport=i,this.connectionManager={stop:async()=>{if(this.streamableTransport)try{await this.streamableTransport.close()}catch(e){$.warn(`Error closing Streamable HTTP transport: ${e}`)}finally{this.streamableTransport=null}}},this.connected=!0,this.transportType=`streamable-http`,this.setupNotificationHandler(),$.debug(`Successfully connected to MCP implementation via streamable HTTP: ${e}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (streamable-http)`})}catch(e){throw await this.cleanupResources(),e}}get publicIdentifier(){return{type:`http`,url:this.baseUrl,transport:this.transportType||`unknown`,protocolEra:this.protocolEra??`unknown`}}getTransportType(){return this.transportType}async cleanupResources(){if(this.streamableTransport&&this.protocolEra!==`modern`){let e;try{await Promise.race([this.streamableTransport.terminateSession().then(()=>!0),new Promise(t=>e=setTimeout(()=>t(!1),Math.min(this.timeout,5e3)))])||$.debug(`Timed out terminating legacy HTTP session; closing transport`)}catch(e){$.debug(`Error terminating Streamable HTTP session: ${e}`)}finally{e&&clearTimeout(e)}}await super.cleanupResources()}},Ok=`2.0.0-beta.0`;function kk(){return Ok}function Ak(e,t){return{onSampling:e?.onSampling??t?.onSampling,onElicitation:e?.onElicitation??t?.onElicitation,onNotification:e?.onNotification??t?.onNotification}}function jk(e){if(!(`url`in e)||typeof e.url!=`string`||e.authProvider||e.authToken||e.oauth===!1)return!1;let t=e.headers;if(t){for(let e of Object.keys(t))if(e.toLowerCase()===`authorization`)return!1}return!0}function Mk(){return{name:`mcp-use`,title:`mcp-use`,version:kk(),description:`mcp-use is a complete TypeScript framework for building and using MCP`,icons:[{src:`https://mcp-use.com/logo.png`}],websiteUrl:`https://mcp-use.com`}}function Nk(e){let t=Mk();if(!e||typeof e!=`object`)return t;let n=e;return!n.name||!n.version?t:{...t,...n}}function Pk(e){let t=e?.capabilities;if(!t||t.views!==!0)return e;let{views:n,...r}=t,i=r.extensions&&typeof r.extensions==`object`&&!Array.isArray(r.extensions)?{...r.extensions}:{};return{...e,capabilities:{...r,extensions:{...i,"io.modelcontextprotocol/ui":{mimeTypes:[`text/html;profile=mcp-app`]}}}}}function Fk(e){let t=()=>{throw Error(`Invalid url to pass to open(): ${e}`)},n;try{n=new URL(e)}catch{t()}return n.protocol!==`https:`&&n.protocol!==`http:`&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&=encodeURIComponent(n.username),n.password&&=encodeURIComponent(n.password),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,`/`),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(Ik).join(`&`),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}function Ik([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:``}`}var Lk=class{get(e){return localStorage.getItem(e)}set(e,t){localStorage.setItem(e,t)}remove(e){localStorage.removeItem(e)}keys(){let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&e.push(n)}return e}},Rk=class e{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;clientMetadataUrl;scope;store;allowClientSecret;constructor(t,n,r){FS(n.clientMetadataUrl),this.serverUrl=t,this.storageKeyPrefix=n.storageKeyPrefix||`mcp:auth`,this.serverUrlHash=e.hashString(t),this.clientName=n.clientName||`mcp-use`,this.clientUri=n.clientUri||(typeof window<`u`?window.location.origin:`https://mcp-use.com`),this.logoUri=n.logoUri||`https://mcp-use.com/logo.png`,this.callbackUrl=Fk(n.callbackUrl||(typeof window<`u`?new URL(`/oauth/callback`,window.location.origin).toString():`/oauth/callback`)),this.clientMetadataUrl=n.clientMetadataUrl,this.scope=n.scope,this.store=r,this.allowClientSecret=n.allowClientSecret??!0}getKey(e){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`}static hashString(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t).toString(16)}get redirectUrl(){return this.callbackUrl}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:`none`,grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],client_name:this.clientName,client_uri:this.clientUri,logo_uri:this.logoUri,...this.scope?{scope:this.scope}:{}}}credentialKey(e,t){return t?this.getKey(`${e}_${encodeURIComponent(t.issuer)}`):this.getKey(e)}async readCredential(e,t){let n=this.credentialKey(e,t),r=await this.store.get(n);if(!r&&t){let r=this.credentialKey(e),i=await this.store.get(r);if(i)try{let e=JSON.parse(i);if(!e.issuer||e.issuer===t.issuer){let i={...e,issuer:t.issuer},a=JSON.stringify(i);return await this.store.set(n,a),await this.store.set(r,a),{key:n,value:i}}}catch{await this.store.remove(r)}return}if(r)try{return{key:n,value:JSON.parse(r)}}catch(t){console.warn(`[${this.storageKeyPrefix}] Failed to parse ${e.replace(`_`,` `)}:`,t),await this.store.remove(n);return}}async tokens(e){return(await this.readCredential(`tokens`,e))?.value}async saveTokens(e,t){let n=JSON.stringify(e);await this.store.set(this.credentialKey(`tokens`,t),n),t&&await this.store.set(this.credentialKey(`tokens`),n),await this.store.remove(this.getKey(`code_verifier`)),await this.store.remove(this.getKey(`last_auth_url`))}async clientInformation(e){let t=await this.readCredential(`client_info`,e);if(!t)return;let{key:n,value:r}=t;try{if(!this.allowClientSecret&&r.client_secret){await this.store.remove(n),e&&await this.store.remove(this.credentialKey(`client_info`)),console.warn(`[${this.storageKeyPrefix}] Removed OAuth client information containing a browser client_secret.`);return}let t=Array.isArray(r.redirect_uris)?r.redirect_uris:[];if(!(t.length===0||t.includes(this.redirectUrl))){console.info(`[${this.storageKeyPrefix}] Invalidating cached OAuth client info due to redirect URI mismatch.`),await this.store.remove(n),await this.store.remove(this.credentialKey(`tokens`,e)),await this.store.remove(this.getKey(`last_auth_url`));return}return r}catch{await this.store.remove(n);return}}async saveClientInformation(e,t){let n=e;if(!this.allowClientSecret&&n.client_secret)throw await this.store.remove(this.credentialKey(`client_info`,t)),t&&await this.store.remove(this.credentialKey(`client_info`)),Error(`Browser OAuth clients must be public clients; client_secret persistence is not allowed.`);let r=JSON.stringify(e);await this.store.set(this.credentialKey(`client_info`,t),r),t&&await this.store.set(this.credentialKey(`client_info`),r)}async saveCodeVerifier(e){await this.store.set(this.getKey(`code_verifier`),e)}async codeVerifier(){let e=this.getKey(`code_verifier`),t=await this.store.get(e);if(!t)throw Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${e}. Auth flow likely corrupted or timed out.`);return t}async invalidateCredentials(e){let t=async e=>{let t=`${this.getKey(e)}_`;for(let n of await this.store.keys())(n===this.getKey(e)||n.startsWith(t))&&await this.store.remove(n)};switch(e){case`all`:await t(`tokens`),await t(`client_info`),await this.store.remove(this.getKey(`code_verifier`)),await this.store.remove(this.getKey(`last_auth_url`)),await this.store.remove(this.getKey(`discovery_state`)),await this.store.remove(this.getKey(`token_endpoint`));break;case`client`:await t(`client_info`);break;case`tokens`:await t(`tokens`);break;case`verifier`:await this.store.remove(this.getKey(`code_verifier`));break;case`discovery`:await this.store.remove(this.getKey(`discovery_state`));break;default:break}}async saveDiscoveryState(e){await this.store.set(this.getKey(`discovery_state`),JSON.stringify(e))}async discoveryState(){let e=await this.store.get(this.getKey(`discovery_state`));if(e)try{return JSON.parse(e)}catch{await this.store.remove(this.getKey(`discovery_state`));return}}async storeAuthorizationState(e,t={}){let n=globalThis.crypto.randomUUID(),r=`${this.storageKeyPrefix}:state_${n}`,i={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl,...this.clientMetadataUrl?{clientMetadataUrl:this.clientMetadataUrl}:{},...t.extraProviderOptions??{}},flowType:t.flowType,returnUrl:t.returnUrl};e.searchParams.set(`state`,n);let a=Fk(e.toString());return await this.store.set(r,JSON.stringify(i)),await this.store.set(this.getKey(`last_auth_url`),a),a}async getTokenEndpoint(){return(await this.discoveryState())?.authorizationServerMetadata?.token_endpoint??null}};async function zk(e){return typeof e==`string`?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}var Bk=class{serverUrl;staticClientInfo;session;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;proxyOAuthRequests;onPopupWindow;constructor(e,t={}){if(t.staticClientInfo?.client_secret)throw Error(`Browser OAuth clients must be public clients; staticClientInfo.client_secret is not allowed.`);this.serverUrl=e,this.session=new Rk(e,{...t,allowClientSecret:!1},new Lk),this.preventAutoAuth=t.preventAutoAuth,this.useRedirectFlow=t.useRedirectFlow,this.oauthProxyUrl=t.oauthProxyUrl,this.connectionUrl=t.connectionUrl,this.proxyOAuthRequests=t.proxyOAuthRequests??!0,this.staticClientInfo=t.staticClientInfo,this.onPopupWindow=t.onPopupWindow}get storageKeyPrefix(){return this.session.storageKeyPrefix}get serverUrlHash(){return this.session.serverUrlHash}get clientName(){return this.session.clientName}get clientUri(){return this.session.clientUri}get logoUri(){return this.session.logoUri}get callbackUrl(){return this.session.callbackUrl}get scope(){return this.session.scope}get clientMetadataUrl(){return this.session.clientMetadataUrl}getKey(e){return this.session.getKey(e)}reanchorWellKnownUrl(e){if(!this.connectionUrl)return e;try{let t=new URL(e),n=new URL(this.connectionUrl);if(t.origin!==n.origin||!t.pathname.startsWith(`/.well-known/`))return e;let r=new URL(this.serverUrl),[i,...a]=t.pathname.slice(13).split(`/`);if(!i)return e;let o=a.length?`/${a.join(`/`)}`:``,s=n.pathname.replace(/\/+$/,``),c=r.pathname.replace(/\/+$/,``),l=o&&o===s?c:o;return`${r.origin}/.well-known/${i}${l}${t.search}`}catch{return e}}getProxyFetch(e){if(!this.proxyOAuthRequests||!this.oauthProxyUrl)return e;let t=e??globalThis.fetch.bind(globalThis),n=this.oauthProxyUrl,r=new Set,i=!1;return async(e,a)=>{let o=typeof e==`string`?e:e instanceof URL?e.toString():e.url,s=this.reanchorWellKnownUrl(o),c;try{c=new URL(s).pathname}catch{return await t(e,a)}let l=c.includes(`/.well-known/`);if(!i){i=!0;let e=(await this.discoveryState())?.authorizationServerMetadata;for(let t of[`registration_endpoint`,`token_endpoint`,`revocation_endpoint`,`introspection_endpoint`])typeof e?.[t]==`string`&&r.add(e[t])}let u=r.has(s)||/\/(?:register|registration|token|revoke|revocation|introspect|introspection)\/?$/.test(c);if(!l&&!u)return await t(e,a);try{let r=new URL(s),i=new URL(n);if(r.origin===i.origin&&(r.pathname.startsWith(i.pathname)||s.includes(`/inspector/api/oauth`)))return await t(e,a)}catch{}let d=l?`${n}/metadata?serverUrl=${encodeURIComponent(this.serverUrl)}&url=${encodeURIComponent(s)}`:`${n}/proxy`;if(l){let e=await t(d,{...a,method:`GET`});try{let t=await e.clone().json();for(let e of[`registration_endpoint`,`token_endpoint`,`revocation_endpoint`,`introspection_endpoint`])typeof t[e]==`string`&&r.add(t[e])}catch{}return e}let f=a?.body?await zk(a.body):void 0,p=await(await t(d,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({serverUrl:this.serverUrl,url:s,method:a?.method||`POST`,headers:a?.headers?Object.fromEntries(new Headers(a.headers)):{},body:f})})).json();return new Response(JSON.stringify(p.body),{status:p.status,statusText:p.statusText,headers:new Headers(p.headers)})}}get redirectUrl(){return this.session.redirectUrl}get clientMetadata(){return this.session.clientMetadata}tokens(e){return this.session.tokens(e)}saveTokens(e,t){return this.session.saveTokens(e,t)}async clientInformation(e){return this.staticClientInfo?this.staticClientInfo:this.session.clientInformation(e)}async saveClientInformation(e,t){if(!this.staticClientInfo)return this.session.saveClientInformation(e,t)}codeVerifier(){return this.session.codeVerifier()}saveCodeVerifier(e){return this.session.saveCodeVerifier(e)}invalidateCredentials(e){return this.session.invalidateCredentials(e)}saveDiscoveryState(e){return this.session.saveDiscoveryState(e)}discoveryState(){return this.session.discoveryState()}getTokenEndpoint(){return this.session.getTokenEndpoint()}async getClientCredentials(){let e=await this.clientInformation();return e?.client_id?{client_id:e.client_id}:null}async prepareAuthorizationUrl(e){return this.session.storeAuthorizationState(e,{extraProviderOptions:{oauthProxyUrl:this.oauthProxyUrl,...this.clientMetadataUrl?{clientMetadataUrl:this.clientMetadataUrl}:{},...this.staticClientInfo?{staticClientInfo:this.staticClientInfo}:{},...this.scope?{scope:this.scope}:{}},flowType:this.useRedirectFlow?`redirect`:`popup`,returnUrl:typeof window<`u`?window.location.href:void 0})}async redirectToAuthorization(e){let t=await this.prepareAuthorizationUrl(e);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=t;return}let n=`width=600,height=700,resizable=yes,scrollbars=yes,status=yes`;try{let e=window.open(t,`mcp_auth_${this.serverUrlHash}`,n);this.onPopupWindow&&this.onPopupWindow(t,n,e),!e||e.closed||e.closed===void 0?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(e.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(e){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,e)}}getLastAttemptedAuthUrl(){let e=localStorage.getItem(this.getKey(`last_auth_url`));return e?Fk(e):null}clearStorage(){let e=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,t=`${this.storageKeyPrefix}:state_`,n=[],r=0;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i){if(i.startsWith(e))n.push(i);else if(i.startsWith(t))try{let e=localStorage.getItem(i);e&&JSON.parse(e).serverUrlHash===this.serverUrlHash&&n.push(i)}catch(e){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${i} during clearStorage:`,e)}}}return[...new Set(n)].forEach(e=>{localStorage.removeItem(e),r++}),r}};async function Vk(e,t={}){return new Bk(e,t)}ek(),ek();var Hk=class{},Uk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`mcp_agent_execution`}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}},Wk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`mcpclient_init`}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},Gk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`connector_init`}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},Kk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`client_add_server`}get properties(){let{serverName:e,serverConfig:t}=this.data,n=t.url;return{server_name:e,server_url_domain:n?this._extractHostname(n):null,transport:t.transport??null,has_auth:!!(t.authToken||t.authProvider)}}_extractHostname(e){try{return new URL(e).hostname}catch{return null}}},qk=class extends Hk{constructor(e){super(),this.data=e}get name(){return`client_remove_server`}get properties(){return{server_name:this.data.serverName}}};async function Jk(e,t){try{await fetch(e,t)}catch{}}var Yk=`https://eu.i.posthog.com`,Xk=`phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI`,Zk=`https://mcpuse.gateway.scarf.sh/events-ts`,Qk=`https://mcpuse.gateway.scarf.sh/simple/`,$k=1800,eA=new Set([`query`,`response`,`messages`]);function tA(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function nA(e,t=Qk){let n=new URLSearchParams;for(let[t,r]of Object.entries(e)){let e=tA(r);eA.has(t)&&e.length>120&&(e=`${e.slice(0,117)}...`),e!==``&&n.set(t,e)}let r=`${t}${t.includes(`?`)?`&`:`?`}${n.toString()}`;if(r.length<=$k)return r;let i=[...n.keys()].sort((e,t)=>(n.get(t)?.length??0)-(n.get(e)?.length??0));for(let e of i){if(r.length<=$k)break;e===`event`||e===`user_id`||(n.delete(e),r=`${t}${t.includes(`?`)?`&`:`?`}${n.toString()}`)}return r.slice(0,$k)}function rA(e,t){return Jk(t,{method:`POST`,headers:{"Content-Type":`application/json`},keepalive:!0,body:JSON.stringify(e)})}function iA(e,t){try{let n=nA(e,t),r=new Image;r.referrerPolicy=`no-referrer-when-downgrade`,r.src=n}catch{}return Promise.resolve()}function aA(e){let t=e.host??Yk,n=e.apiKey??Xk;return Jk(`${t}/i/v0/e/`,{method:`POST`,headers:{"Content-Type":`application/json`},keepalive:!0,body:JSON.stringify({api_key:n,event:e.event,distinct_id:e.distinctId,properties:e.properties,timestamp:new Date().toISOString()})})}function oA(e,t=Zk){return typeof window<`u`?iA(e,t===Zk?Qk:t):rA(e,t)}function sA(){return globalThis.crypto.randomUUID()}function cA(){let e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}function lA(e,t){let n=e=>e.split(`-`)[0].split(`.`).map(e=>parseInt(e,10)||0),r=n(e),i=n(t),a=Math.max(r.length,i.length);for(let e=0;e<a;e++){let t=r[e]??0,n=i[e]??0;if(t!==n)return t>n}return!1}var uA=`mcp_use_user_id`,dA=`phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI`,fA=`https://eu.i.posthog.com`,pA=null;function mA(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`&&typeof localStorage.removeItem==`function`}function hA(){if(!mA())return null;try{localStorage.setItem(`__mcp_use_test__`,`1`),localStorage.removeItem(`__mcp_use_test__`)}catch{return null}return{getUserId(){try{return localStorage.getItem(uA)}catch{return null}},setUserId(e){try{localStorage.setItem(uA,e)}catch{}},getDownloadedVersion:()=>null,setDownloadedVersion:()=>void 0}}function gA(){try{return globalThis.Bun===void 0?globalThis.Deno===void 0?typeof navigator<`u`&&navigator.userAgent?.includes(`Cloudflare-Workers`)?`cloudflare-workers`:globalThis.EdgeRuntime===void 0?typeof window<`u`&&typeof document<`u`?`browser`:typeof process<`u`&&process.versions?.node!==void 0?`node`:`unknown`:`edge`:`deno`:`bun`}catch{return`unknown`}}function _A(){if(typeof process<`u`&&{}.MCP_USE_TELEMETRY_SOURCE)return{}.MCP_USE_TELEMETRY_SOURCE;try{if(mA())return localStorage.getItem(`MCP_USE_TELEMETRY_SOURCE`)??void 0}catch{}}function vA(){if(typeof window<`u`&&window.__MCP_USE_ANONYMIZED_TELEMETRY__===!1||typeof process<`u`&&{}.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase()===`false`)return!0;try{if(mA()&&localStorage.getItem(`MCP_USE_ANONYMIZED_TELEMETRY`)===`false`)return!0}catch{}return!1}function yA(){try{return`session-${sA()}`}catch{return`session-${Date.now()}-${cA()}`}}var bA=class e{static instance=null;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_telemetryEnabled=!1;_pending=new Set;_scarfEnabled=!1;_runtimeEnvironment;_storageCapability;_storage;_fsBacked;_source;_productVersion;constructor(){this._runtimeEnvironment=gA(),this._fsBacked=pA!==null,this._storage=pA??hA()??null,this._storageCapability=this._storage?`persistent`:`session-only`,this._source=_A()||this._runtimeEnvironment;let e=vA(),t=this._runtimeEnvironment!==`unknown`;e?(this._telemetryEnabled=!1,$.debug(`Telemetry disabled via opt-out`)):t?($.debug(`Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable.`),this._telemetryEnabled=!0,this._scarfEnabled=!0,this._fsBacked&&setTimeout(()=>{this.trackPackageDownload({triggered_by:`initialization`}).catch(e=>$.debug(`Failed to track package download: ${e}`))},0)):(this._telemetryEnabled=!1,$.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e;try{mA()&&localStorage.setItem(`MCP_USE_TELEMETRY_SOURCE`,e)}catch{}$.debug(`Telemetry source set to: ${e}`)}getSource(){return this._source}setProductVersion(e){this._productVersion=e}get isEnabled(){return this._telemetryEnabled||this._scarfEnabled}get userId(){if(this._currUserId)return this._currUserId;try{if(this._storage){let e=this._storage.getUserId();if(e)return this._currUserId=e,e;let t=sA();return this._storage.setUserId(t),this._currUserId=t,t}this._currUserId=yA()}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}async capture(e){if(!this._telemetryEnabled&&!this._scarfEnabled)return;let t=this.userId,n={...e.properties,mcp_use_version:this._productVersion??kk(),language:`typescript`,source:this._source,runtime:this._runtimeEnvironment};if(this._telemetryEnabled){let r=aA({host:fA,apiKey:dA,event:e.name,distinctId:t,properties:n});this._pending.add(r),r.finally(()=>this._pending.delete(r))}if(this._scarfEnabled){let r=oA({...n,user_id:t,event:e.name});this._pending.add(r),r.finally(()=>this._pending.delete(r))}}async trackPackageDownload(e){if(!this._scarfEnabled||!this._fsBacked||!this._storage)return;let t=kk(),n=this._storage.getDownloadedVersion(),r=!1,i=!1;n?lA(t,n)&&(i=!0,this._storage.setDownloadedVersion(t)):(i=!0,r=!0,this._storage.setDownloadedVersion(t)),i&&await oA({...e||{},mcp_use_version:t,user_id:this.userId,event:`package_download`,first_download:r,language:`typescript`,source:this._source,runtime:this._runtimeEnvironment})}async trackAgentExecution(e){this.isEnabled&&await this.capture(new Uk(e))}async trackMCPClientInit(e){this.isEnabled&&await this.capture(new Wk(e))}async trackConnectorInit(e){this.isEnabled&&await this.capture(new Gk(e))}async trackClientAddServer(e,t){this.isEnabled&&await this.capture(new Kk({serverName:e,serverConfig:t}))}async trackClientRemoveServer(e){this.isEnabled&&await this.capture(new qk({serverName:e}))}async trackUseMcpConnection(e){this.isEnabled&&await this.capture({name:`usemcp_connection`,properties:{url_domain:new URL(e.url).hostname,transport_type:e.transportType,success:e.success,error_type:e.errorType??null,connection_time_ms:e.connectionTimeMs??null,has_oauth:e.hasOAuth,has_sampling:e.hasSampling,has_elicitation:e.hasElicitation}})}async trackUseMcpToolCall(e){this.isEnabled&&await this.capture({name:`usemcp_tool_call`,properties:{tool_name:e.toolName,success:e.success,error_type:e.errorType??null,execution_time_ms:e.executionTimeMs??null}})}async trackUseMcpResourceRead(e){this.isEnabled&&await this.capture({name:`usemcp_resource_read`,properties:{resource_uri_scheme:e.resourceUri.split(`:`)[0],success:e.success,error_type:e.errorType??null}})}identify(e,t){this._currUserId=e,this._storage?.setUserId(e),this._telemetryEnabled&&aA({host:fA,apiKey:dA,event:`$identify`,distinctId:e,properties:{$set:t??{}}})}reset(){this._currUserId=null}flush(){Promise.allSettled([...this._pending])}async shutdown(){try{await Promise.allSettled([...this._pending]),$.debug(`Telemetry fetch captures flushed`)}catch(e){$.debug(`Error flushing telemetry captures: ${e}`)}}},xA=5*6e4;function SA(e,t=0){if(!e||t>5)return!1;if(e instanceof pS)return!0;if(e instanceof Error){if(e.code===401||e.name===`UnauthorizedError`)return!0;let n=e.message??``;if(n.includes(`401`)||n.includes(`Unauthorized`)||e.cause&&SA(e.cause,t+1))return!0;let r=e.data;if(r?.cause&&SA(r.cause,t+1))return!0}return!1}async function CA(e,t,n={}){let r=e,i=n.timeoutMs??xA,a=n.fetchFn??r.getProxyFetch?.()??void 0;if(!r.hasPendingFlow){let n=await MS(e,{serverUrl:t,fetchFn:a});if(n===`AUTHORIZED`)return;if(n!==`REDIRECT`)throw Error(`Unexpected OAuth auth() result: ${n}`)}if(typeof r.getAuthorizationCode==`function`){await MS(e,{serverUrl:t,authorizationCode:await r.getAuthorizationCode(),fetchFn:a});return}await wA(r,i)}async function wA(e,t){if(typeof window>`u`)throw Error(`OAuth redirect requires a browser environment or a provider with getAuthorizationCode()`);if(e.useRedirectFlow)return;let n=e.getKey?.(`tokens`);if(!n)throw Error(`Browser OAuth provider must expose getKey() for token storage`);let r=null,i=e.getLastAttemptedAuthUrl?.();if(i)try{r=new URL(i).searchParams.get(`state`)}catch{}let a=await mk({popup:null,state:r,tokensKey:n,timeoutMs:t});switch(a.kind){case`success`:return;case`cancelled`:throw Error(`OAuth authentication was cancelled.`);case`timeout`:throw Error(`OAuth callback not received within ${t}ms. Ensure /oauth/callback calls onMcpAuthorization().`);case`error`:throw Error(a.error);default:throw Error(`Unexpected OAuth popup result`)}}ek();var TA=class{connector;autoConnect;constructor(e,t=!0){this.connector=e,this.autoConnect=t}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(e,t){e===`notification`&&this.connector.onNotification(t)}async setRoots(e){return this.connector.setRoots(e)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(e){return this.connector.listTools(e)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}get protocolEra(){return this.connector.protocolEra}get negotiatedProtocolVersion(){return this.connector.negotiatedProtocolVersion}get info(){let e=this.protocolEra,t=this.negotiatedProtocolVersion,n=this.serverInfo;if(!e||!t||!n)throw Error(`MCP connection is not initialized`);let r=this.serverCapabilities,i=r.extensions&&typeof r.extensions==`object`&&!Array.isArray(r.extensions)?r.extensions:{};return{protocolEra:e,protocolVersion:t,server:n,capabilities:r,instructions:this.connector.instructions,extensions:i}}supports(e){return e in this.serverCapabilities}async callTool(e,t={},n){return this.connector.callTool(e,t,n)}async listResources(e,t){return this.connector.listResources(e,t)}async listAllResources(e){return this.connector.listAllResources(e)}async listResourceTemplates(e){return this.connector.listResourceTemplates(e)}async complete(e,t){return this.connector.complete(e,t)}async readResource(e,t){return this.connector.readResource(e,t)}async subscribeToResource(e,t){return this.connector.subscribeToResource(e,t)}async unsubscribeFromResource(e,t){return this.connector.unsubscribeFromResource(e,t)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(e,t){return this.connector.getPrompt(e,t)}async request(e,t=null,n){return this.connector.request(e,t,n)}},EA;function DA(e,t){EA?.addServer(e,t)}function OA(e){EA?.removeServer(e)}function kA(e){return!!e&&typeof e==`object`&&`redirectUrl`in e&&`clientMetadata`in e}var AA=class{config={};sessions={};activeSessions=[];constructor(e){e&&(this.config=e)}static fromDict(e){throw Error(`fromDict must be implemented by concrete class`)}addServer(e,t){this.config.mcpServers=this.config.mcpServers||{},this.config.mcpServers[e]=t,DA(e,t)}async removeServer(e){this.config.mcpServers?.[e]&&(await this.closeSession(e),delete this.config.mcpServers[e],OA(e))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(e){return this.config.mcpServers?.[e]}getConfig(){return this.config??{}}async createSession(e,t=!0){let n=this.config.mcpServers??{};if(Object.keys(n).length===0&&$.warn(`No MCP servers defined in config`),!n[e])throw Error(`Server '${e}' not found in config`);let r={...n[e]},i;if(jk(r)){let e=r.oauth===!1?void 0:r.oauth??{};i=await this.createDefaultOAuthProvider(r.url,e),r={...r,authProvider:i}}else `authProvider`in r&&r.authProvider&&kA(r.authProvider)&&(i=r.authProvider);let a=async()=>{let e=new TA(await Promise.resolve(this.createConnectorFromConfig(r)));return t&&await e.initialize(),e},o;try{o=await a()}catch(n){let s=r;if(!t||!i||!(`url`in s)||!SA(n)||i.preventAutoAuth)throw n;$.info(`[MCPClient] Unauthorized connecting to '${e}'; completing OAuth\u2026`),await CA(i,s.url),o=await a()}return this.sessions[e]=o,this.activeSessions.includes(e)||this.activeSessions.push(e),o}async connect(e){return this.createSession(e)}async createAllSessions(e=!0){let t=this.config.mcpServers??{};Object.keys(t).length===0&&$.warn(`No MCP servers defined in config`);for(let n of Object.keys(t))await this.createSession(n,e);return this.sessions}async connectAll(){return this.createAllSessions()}getSession(e){return this.sessions[e]||null}requireSession(e){let t=this.sessions[e];if(!t)throw Error(`Session '${e}' not found. Available sessions: ${this.activeSessions.join(`, `)||`none`}`);return t}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(e=>[e,this.sessions[e]]))}async closeSession(e){let t=this.sessions[e];if(!t){$.warn(`No session exists for server ${e}, nothing to close`);return}try{$.debug(`Closing session for server ${e}`),await t.disconnect()}catch(t){$.error(`Error closing session for server '${e}': ${t}`)}finally{this.sessions[e]===t&&(delete this.sessions[e],this.activeSessions=this.activeSessions.filter(t=>t!==e))}}async closeAllSessions(){let e=Object.keys(this.sessions),t=[];for(let n of e)try{$.debug(`Closing session for server ${n}`),await this.closeSession(n)}catch(e){let r=`Failed to close session for server '${n}': ${e}`;$.error(r),t.push(r)}t.length?$.error(`Encountered ${t.length} errors while closing sessions`):$.debug(`All sessions closed successfully`)}async close(){await this.closeAllSessions()}};function jA(e){let t=Object.keys(e.mcpServers??{});bA.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(e=>$.debug(`Failed to track BrowserMCPClient init: ${e}`))}var MA=class e extends AA{static getPackageVersion(){return kk()}constructor(e){super(e),jA(this.config)}static fromDict(t){return new e(t)}async createDefaultOAuthProvider(e,t={}){return Vk(e,t)}createConnectorFromConfig(e){let{url:t,headers:n,fetch:r,authToken:i,authProvider:a,wrapTransport:o,clientOptions:s,protocolNegotiation:c,timeout:l,gatewayUrl:u,serverId:d,reconnectionOptions:f}=e;if(!t)throw Error(`Server URL is required`);let p=this.config,m=Ak(e,p),h=Nk(e.clientInfo??this.config.clientInfo),g={headers:n,fetch:r??globalThis.fetch.bind(globalThis),authToken:i,authProvider:a,wrapTransport:o,clientOptions:s,onSampling:m.onSampling,onElicitation:m.onElicitation,onNotification:m.onNotification,protocolNegotiation:c,timeout:l,clientInfo:h,gatewayUrl:u,serverId:d,reconnectionOptions:f};return $.debug(`[BrowserMCPClient] Connector options prepared (clientOptions: ${s?`provided`:`none`})`),new Dk(t,g)}};ek();var NA=`https://favicon.tools.mcp-use.com`,PA=/^\d{1,3}(\.\d{1,3}){3}$/;function FA(e){try{let t=e.includes(`://`)?e:`https://${e}`;return new URL(t).hostname}catch{return null}}function IA(e){let t=e.toLowerCase();if(t===`localhost`||t.endsWith(`.localhost`)||t===`host.docker.internal`||t===`0.0.0.0`)return!0;if(!PA.test(t))return!1;if(t===`127.0.0.1`||t.startsWith(`127.`)||t.startsWith(`10.`)||t.startsWith(`192.168.`))return!0;let n=/^172\.(\d+)\./.exec(t);if(n){let e=Number.parseInt(n[1],10);if(e>=16&&e<=31)return!0}return!1}function LA(e){let t=e.split(`.`);return Array.from({length:t.length-1},(e,n)=>t.slice(n).join(`.`))}function RA(e){return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}async function zA(e){try{let t=FA(e);if(!t||IA(t))return null;for(let e of LA(t))try{let t=await fetch(`${NA}/${e}?response=json`,{signal:AbortSignal.timeout(2e3)});if(!t.ok)continue;let n=await t.json();if(n.source==="default")continue;let r=n.url.replace(/^http:\/\//,`https://`),i=await fetch(r,{signal:AbortSignal.timeout(2e3)});if(!i.ok)continue;return await RA(await i.blob())}catch{continue}return null}catch(e){return console.warn(`[favicon] Error detecting favicon:`,e),null}}var BA=`inspector-server`;function VA(e,t){if(!e)throw Error(t)}async function HA(e){try{let t=e.serverInfo.icons?.[0]?.src;if(t){e.addLog(`info`,`Server provided icon:`,t);let n=await(await fetch(t)).blob(),r=await new Promise((e,t)=>{let r=new FileReader;r.onloadend=()=>e(r.result),r.onerror=t,r.readAsDataURL(n)});return e.isMounted()&&(e.setServerInfo(e=>e?{...e,icon:r}:void 0),e.addLog(`debug`,`Server icon converted to base64`)),r}if(e.url){let t=await zA(e.url);if(!e.isMounted())return e.addLog(`debug`,`Connection aborted after favicon detection - component unmounted`),null;if(t)return e.setServerInfo(e=>e?{...e,icon:t}:void 0),e.addLog(`debug`,`Favicon detected and added to serverInfo`),t}return null}catch(t){return e.addLog(`debug`,`Icon loading failed (non-critical):`,t),null}}function UA(e,t){return t?`state=${e}`:`client disconnected (state=${e})`}function WA(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}function GA(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`oauth discovery failed`)||t.includes(`oauth-authorization-server`)||t.includes(`not valid json`)||t.includes(`404`)&&(t.includes(`openid-configuration`)||t.includes(`oauth-protected-resources`)||t.includes(`oauth-authorization-url`)||t.includes(`register`))||t.includes(`invalid oauth error response`)&&t.includes(`not found`)}function KA(e,t){if(t)return t;if(e)try{let t=new URL(e);return t.pathname=t.pathname.replace(/\/proxy\/?$/,`/oauth`),t.toString()}catch{return}}function qA(e){let t=KA(e.gatewayUrl,e.oauthProxyUrl);return{provider:new Bk(e.effectiveOAuthUrl,{storageKeyPrefix:e.storageKeyPrefix,clientName:e.oauthClientConfig.name,clientUri:e.oauthClientConfig.uri,logoUri:e.oauthClientConfig.logo_uri||`https://mcp-use.com/logo.png`,callbackUrl:e.callbackUrl,preventAutoAuth:e.preventAutoAuth,useRedirectFlow:e.useRedirectFlow,oauthProxyUrl:t,connectionUrl:e.gatewayUrl,onPopupWindow:e.onPopupWindow,proxyOAuthRequests:e.proxyOAuthRequests,staticClientInfo:e.staticClientInfo,clientMetadataUrl:e.clientMetadataUrl,scope:e.scope}),oauthProxyUrl:t}}function JA(e){let t=null,n=Date.now(),r=!1,i=e.healthCheckIntervalMs??1e4,a=e.healthCheckTimeoutMs??3e4;return t=setInterval(async()=>{if(!r){if(!e.isMountedRef.current||e.stateRef.current!==`ready`){t&&=(clearInterval(t),null);return}try{let i=e.gatewayUrl||e.url;if(!i)return;let a=e.getAuthHeaders?await e.getAuthHeaders():{},o=await fetch(i,{method:`HEAD`,headers:{...e.allHeaders,...a},signal:AbortSignal.timeout(5e3)});if(o.status===405||o.status===404){r=!0,n=Date.now(),t&&=(clearInterval(t),null);return}if(o.ok||o.status<500)n=Date.now();else throw Error(`Server returned ${o.status}`)}catch{let r=Date.now()-n;r>a&&(e.addLog(`warn`,`Connection appears to be broken (no response for ${Math.round(r/1e3)}s), attempting to reconnect...`),t&&=(clearInterval(t),null),e.autoReconnectRef.current&&e.isMountedRef.current&&(e.setState(`discovering`),e.addLog(`info`,`Auto-reconnecting to MCP server...`),setTimeout(()=>{e.isMountedRef.current&&e.stateRef.current===`discovering`&&e.connect()},typeof e.autoReconnectRef.current==`number`?e.autoReconnectRef.current:e.defaultReconnectDelay)))}}},i),()=>{t&&=(clearInterval(t),null)}}function YA(e,t){let n=e.connectionRef.current;if(e.stateRef.current!==`ready`||!e.hasClient()||!n)throw Error(`MCP client is not ready (${UA(e.stateRef.current,e.hasClient())}). Cannot ${t}.`);return n}function XA(e){let t=(0,z.useCallback)(async(t,n,r)=>{let i=YA(e,`call tool "${t}"`);e.addLog(`info`,`Calling tool: ${t}`,n);let a=Date.now();try{let o=await i.callTool(t,n||{},r);return e.addLog(`info`,`Tool "${t}" call successful:`,o),bA.getInstance().trackUseMcpToolCall({toolName:t,success:!0,executionTimeMs:Date.now()-a}).catch(()=>{}),o}catch(n){throw e.addLog(`error`,`Tool "${t}" call failed:`,n),bA.getInstance().trackUseMcpToolCall({toolName:t,success:!1,errorType:n instanceof Error?n.name:`UnknownError`,executionTimeMs:Date.now()-a}).catch(()=>{}),n}},[e.addLog]),n=(0,z.useCallback)(async()=>{let t=YA(e,`list resources`);e.addLog(`info`,`Listing resources`);let n=await t.listAllResources();e.setResources(n.resources||[])},[e.addLog]),r=(0,z.useCallback)(async t=>{let n=YA(e,`read resource`);e.addLog(`info`,`Reading resource: ${t}`);try{let e=await n.readResource(t);return bA.getInstance().trackUseMcpResourceRead({resourceUri:t,success:!0}).catch(()=>{}),e}catch(e){throw bA.getInstance().trackUseMcpResourceRead({resourceUri:t,success:!1,errorType:e instanceof Error?e.name:`UnknownError`}).catch(()=>{}),e}},[e.addLog]),i=(0,z.useCallback)(async()=>{let t=YA(e,`list prompts`);e.addLog(`info`,`Listing prompts`);let n=await t.listPrompts();e.setPrompts(n.prompts||[])},[e.addLog]),a=(0,z.useCallback)(async()=>{if(!(e.stateRef.current!==`ready`||!e.connectionRef.current))try{e.setTools(await e.connectionRef.current.listTools()||[])}catch(t){e.addLog(`error`,`Failed to refresh tools:`,t)}},[e.addLog]),o=(0,z.useCallback)(async()=>{if(!(e.stateRef.current!==`ready`||!e.connectionRef.current))try{let t=await e.connectionRef.current.listAllResources();e.setResources(t.resources||[])}catch(t){e.addLog(`warn`,`Failed to refresh resources:`,t)}},[e.addLog]),s=(0,z.useCallback)(async()=>{if(!(e.stateRef.current!==`ready`||!e.connectionRef.current))try{let t=await e.connectionRef.current.listPrompts();e.setPrompts(t.prompts||[])}catch(t){e.addLog(`warn`,`Failed to refresh prompts:`,t)}},[e.addLog]),c=(0,z.useCallback)(async()=>{let t=await YA(e,`refresh resource templates`).listResourceTemplates();e.isMounted()&&e.setResourceTemplates(t.resourceTemplates||[])},[e.addLog]);return{callTool:t,listResources:n,readResource:r,listPrompts:i,refreshTools:a,refreshResources:o,refreshPrompts:s,refreshResourceTemplates:c,refreshAll:(0,z.useCallback)(()=>Promise.all([a(),o(),c(),s()]).then(()=>void 0),[a,o,c,s]),getPrompt:(0,z.useCallback)(async(t,n)=>YA(e,`get prompt`).getPrompt(t,n||{}),[e.addLog]),complete:(0,z.useCallback)(async t=>YA(e,`request completion`).complete(t),[e.addLog])}}var ZA=3e3,QA=5e3;function $A(e){let{url:t,enabled:n=!0,callbackUrl:r=typeof window<`u`?Fk(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:i=`mcp:auth`,authProvider:a,headers:o,proxyConfig:s,oauthProxyUrl:c,autoProxyFallback:l=!1,logLevel:u=`silent`,autoRetry:d=!1,autoReconnect:f=!0,reconnectionOptions:p,preventAutoAuth:m=!0,useRedirectFlow:h=!1,onPopupWindow:g,timeout:_=3e4,wrapTransport:v,serverId:y,fetch:b,clientOptions:x,protocolNegotiation:S,onNotification:C,onSampling:w,onElicitation:T,oauth:ee}=e,E=`http`,D=ee?.clientId?.trim()||void 0,te=ee?.clientMetadataUrl?.trim()||void 0,ne=ee?.scope?.trim()||void 0,O=(0,z.useMemo)(()=>D?{client_id:D}:void 0,[D]),re=(0,z.useMemo)(()=>{let e=`useMcp:${t||`no-url`}`,n=$O.get(e);return u&&(n.level=u),n},[t,u]),k=o??{},ie=(0,z.useMemo)(()=>Pk(x),[x]),A=w,j=T,M=(0,z.useMemo)(()=>({name:`mcp-use`,title:`mcp-use`,version:kk(),description:`mcp-use is a complete TypeScript framework for building and using MCP`,icons:[{src:`https://mcp-use.com/logo.png`}],websiteUrl:`https://mcp-use.com`}),[]),ae=(0,z.useMemo)(()=>e.clientInfo?{...M,...e.clientInfo}:M,[e.clientInfo,M]),oe=(0,z.useMemo)(()=>WA(ae),[ae]),se=(0,z.useMemo)(()=>{if(!l)return{enabled:!1,proxyAddress:void 0};if(typeof l==`boolean`){let e=s?.proxyAddress;return{enabled:l&&!!e,proxyAddress:e}}let e=l.proxyAddress??s?.proxyAddress;return{enabled:l.enabled!==!1&&!!e,proxyAddress:e}},[l,s]),N=(0,z.useMemo)(()=>f===!1?{enabled:!1,initialDelay:0,healthCheckInterval:!1,healthCheckTimeout:3e4}:f===!0?{enabled:!0,initialDelay:ZA,healthCheckInterval:1e4,healthCheckTimeout:3e4}:typeof f==`number`?{enabled:!0,initialDelay:f,healthCheckInterval:1e4,healthCheckTimeout:3e4}:{enabled:f.enabled!==!1,initialDelay:f.initialDelay??ZA,healthCheckInterval:f.healthCheckInterval??1e4,healthCheckTimeout:f.healthCheckTimeout??3e4},[f]),[P,ce]=(0,z.useState)(void 0);(0,z.useEffect)(()=>{ce(void 0)},[t,s]);let le=(0,z.useMemo)(()=>{if(!P?.proxyAddress)return s;let e=s?.headers??{};return{...P,headers:{...e,...P.headers??{}}}},[P,s]),ue=le?.proxyAddress,de=le?.headers??{},fe=(0,z.useMemo)(()=>t||``,[t]),pe=(0,z.useMemo)(()=>({...de,...k}),[de,k]),[me,he]=(0,z.useState)(`discovering`),[ge,_e]=(0,z.useState)([]),[ve,ye]=(0,z.useState)([]),[be,F]=(0,z.useState)([]),[xe,Se]=(0,z.useState)([]),[Ce,we]=(0,z.useState)(e._initialServerInfo?.name?e._initialServerInfo:void 0),[Te,Ee]=(0,z.useState)(),[De,Oe]=(0,z.useState)(void 0),[ke,Ae]=(0,z.useState)(void 0),[je,Me]=(0,z.useState)(),[Ne,Pe]=(0,z.useState)({}),[Fe,Ie]=(0,z.useState)(void 0),[Le,Re]=(0,z.useState)([]),[ze,Be]=(0,z.useState)(void 0),[Ve,He]=(0,z.useState)(void 0),Ue=(0,z.useRef)(null),We=(0,z.useRef)(null),Ge=(0,z.useRef)(a??null),Ke=(0,z.useRef)(null),qe=(0,z.useRef)(!1),Je=(0,z.useRef)(!0),Ye=(0,z.useRef)(0),Xe=(0,z.useRef)(0),Ze=(0,z.useRef)(null),Qe=(0,z.useRef)(!1),$e=(0,z.useRef)(!1),et=(0,z.useRef)(me),tt=(0,z.useRef)(f),nt=(0,z.useRef)(null),rt=(0,z.useRef)(null),it=(0,z.useRef)(null),at=(0,z.useRef)(A),ot=(0,z.useRef)(j),st=(0,z.useRef)(A!==void 0),ct=(0,z.useRef)(j!==void 0),lt=(0,z.useRef)(C);A!==void 0&&(at.current=A),j!==void 0&&(ot.current=j),st.current=A!==void 0,ct.current=j!==void 0,lt.current=C;let ut=(0,z.useCallback)(async e=>at.current(e),[]),dt=(0,z.useCallback)(async e=>ot.current(e),[]),ft=(0,z.useCallback)(e=>{lt.current?.(e)},[]);(0,z.useEffect)(()=>{et.current=me,tt.current=f},[me,f]),(0,z.useEffect)(()=>{Ge.current=a??null},[a]);let I=(0,z.useCallback)((e,t,...n)=>{let r=n.length>0?`${t} ${n.map(e=>JSON.stringify(e)).join(` `)}`:t,i=`[useMcp] ${r}`;switch(e){case`error`:re.error(i);break;case`warn`:re.warn(i);break;case`info`:re.info(i);break;case`debug`:re.debug(i);break;default:re.info(i)}Je.current&&Re(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[re]),pt=XA({stateRef:et,connectionRef:We,hasClient:()=>Ue.current!==null,isMounted:()=>Je.current,setTools:_e,setResources:ye,setResourceTemplates:F,setPrompts:Se,addLog:I}),mt=(0,z.useCallback)(async(e=!1)=>{e||I(`info`,`Disconnecting...`),qe.current=!1,Ze.current&&clearTimeout(Ze.current),Ze.current=null;let t=Xe.current,n=Ue.current;if(n)try{let e=BA,t=n===Ue.current?We.current:null;t&&t._healthCheckCleanup&&(t._healthCheckCleanup(),t._healthCheckCleanup=null),t&&await n.closeSession(e)}catch(t){e||I(`warn`,`Error closing connection:`,t)}let r=Xe.current!==t;Ue.current===n&&!r&&(Ue.current=null,We.current=null),Je.current&&!e&&!r&&(he(`discovering`),_e([]),ye([]),F([]),Se([]),Ie(void 0),Be(void 0),He(void 0),we(void 0),Ee(void 0),Oe(void 0),Ae(void 0),Me(void 0),Pe({}))},[I]),ht=(0,z.useCallback)((e,n)=>{I(`error`,e,n??``);let r=n&&`code`in n?n.code:void 0,i=se.enabled&&!le?.proxyAddress,o=e.includes(`CORS`)||e.includes(`blocked by CORS policy`)||e.includes(`Failed to fetch`),s=r===400;if(i&&(o||s||typeof r==`number`&&r>=404&&r<500)&&!(r===401||r===403))return I(`info`,`Direct connection failed with ${o?`CORS error`:s?`HTTP 400 (Bad Request)`:`HTTP 4xx error`}. Trying with proxy...`),Ue.current=null,a||(Ge.current=null),I(`debug`,`Cleared client and auth provider for proxy fallback`),ce({proxyAddress:se.proxyAddress}),Je.current&&he(`discovering`),setTimeout(()=>{Je.current&&rt.current?.()},1e3),!0;if(Je.current){I(`info`,`Setting state to FAILED:`,e),he(`failed`),Ie(e);let t=Ge.current?.getLastAttemptedAuthUrl?.();t&&(Be(t),I(`info`,`Manual authentication URL may be available.`,t))}return qe.current=!1,t&&bA.getInstance().trackUseMcpConnection({url:t,transportType:E,success:!1,errorType:n?.name||`UnknownError`,hasOAuth:!!Ge.current,hasSampling:st.current,hasElicitation:ct.current}).catch(()=>{}),!1},[I,t,E,se,le,a]),gt=(0,z.useCallback)(async()=>{if(!n||!t){I(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`);return}if(qe.current){I(`debug`,`Connection attempt already in progress.`);return}if(!Je.current){I(`debug`,`Connect called after unmount, aborting.`);return}if(qe.current=!0,Xe.current+=1,Ye.current+=1,Ie(void 0),Be(void 0),nt.current=null,he(`discovering`),_e([]),ye([]),F([]),Se([]),we(void 0),Ee(void 0),Oe(void 0),Ae(void 0),Me(void 0),Pe({}),I(`info`,`Connecting attempt #${Ye.current} to ${t}...`),!Ge.current){let{provider:e,oauthProxyUrl:t}=qA({effectiveOAuthUrl:fe,storageKeyPrefix:i,oauthClientConfig:oe,callbackUrl:r,preventAutoAuth:m,useRedirectFlow:h,gatewayUrl:ue,oauthProxyUrl:c,onPopupWindow:g,proxyOAuthRequests:!0,staticClientInfo:O,clientMetadataUrl:te,scope:ne});Ge.current=e,t&&I(`debug`,`OAuth BFF enabled: ${t}`),I(`debug`,`BrowserOAuthClientProvider initialized with URL: ${fe}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ue?`enabled`:`disabled`}`)}Ue.current?I(`debug`,`BrowserMCPClient already exists, reusing.`):(Ue.current=new MA,I(`debug`,`BrowserMCPClient initialized in connect.`));let e=async n=>{if(!Je.current)return I(`debug`,`Connection attempt aborted - component unmounted`),`failed`;I(`info`,`Attempting connection with transport: ${n}`),I(`debug`,`Client ref status at start of tryConnectWithTransport: ${Ue.current?`initialized`:`NULL`}`);try{let e=BA,r={url:t,timeout:_,clientInfo:ae,...(()=>{let e=Ge.current?.getProxyFetch?.(b)??b;return e?{fetch:e}:{}})(),...ie&&{clientOptions:ie},...S!==void 0&&{protocolNegotiation:S},...p?{reconnectionOptions:p}:f===!1?{reconnectionOptions:{maxRetries:0}}:{}};if(ue&&(r.gatewayUrl=ue,I(`debug`,`Using proxy gateway: ${ue} for target: ${t}`)),pe&&Object.keys(pe).length>0&&(r.headers=pe),!Ue.current){if(!Je.current)return I(`debug`,`Connection aborted - component unmounted, client cleaned up`),`failed`;let e=Error(`Client not initialized - this is a bug in the connection flow`);throw I(`error`,`Client ref is null in tryConnectWithTransport but component is still mounted`),e}Ue.current.addServer(e,{...r,authProvider:Ge.current,onSampling:st.current?ut:void 0,onElicitation:ct.current?dt:void 0,onNotification:e=>{I(`debug`,`Notification received:`,e.method,e),ft(e),e.method===`notifications/tools/list_changed`?(I(`info`,`Tools list changed, auto-refreshing...`),pt.refreshTools().catch(e=>I(`warn`,`Auto-refresh tools failed:`,e))):e.method===`notifications/resources/list_changed`?(I(`info`,`Resources list changed, auto-refreshing...`),pt.refreshResources().catch(e=>I(`warn`,`Auto-refresh resources failed:`,e))):e.method===`notifications/prompts/list_changed`&&(I(`info`,`Prompts list changed, auto-refreshing...`),pt.refreshPrompts().catch(e=>I(`warn`,`Auto-refresh prompts failed:`,e)))},wrapTransport:v?n=>(I(`debug`,`Applying transport wrapper for server:`,e,`url:`,t),v(n,y??t)):void 0});let i=await Ue.current.connect(e);if(We.current=i,!Je.current)return I(`debug`,`Connection aborted after connection creation - component unmounted`),`failed`;I(`info`,`✅ Successfully connected to MCP server`),I(`info`,`Server info:`,i.info.server),I(`info`,`Server capabilities:`,i.info.capabilities),N.enabled&&N.healthCheckInterval!==!1&&(i._healthCheckCleanup=JA({gatewayUrl:ue,url:t,allHeaders:pe,getAuthHeaders:async()=>{try{let e=await Ge.current?.tokens?.();if(e?.access_token){let t=e.token_type||`bearer`;return{Authorization:`${t.charAt(0).toUpperCase()+t.slice(1)} ${e.access_token}`}}}catch{}return{}},isMountedRef:Je,stateRef:et,autoReconnectRef:tt,setState:he,addLog:I,connect:gt,defaultReconnectDelay:N.initialDelay,healthCheckIntervalMs:N.healthCheckInterval,healthCheckTimeoutMs:N.healthCheckTimeout})),bA.getInstance().trackUseMcpConnection({url:t,transportType:n,success:!0,hasOAuth:!!Ge.current,hasSampling:st.current,hasElicitation:ct.current}).catch(()=>{}),_e(i.tools||[]);let[a,o,s]=await Promise.all([i.listAllResources(),i.listPrompts(),i.supports(`resources`)?i.listResourceTemplates():Promise.resolve({resourceTemplates:[]})]);if(!Je.current)return I(`debug`,`Connection aborted after discovery - component unmounted`),`failed`;ye(a.resources||[]),Se(o.prompts||[]),F(s.resourceTemplates||[]);let{server:c,capabilities:l,protocolEra:u,protocolVersion:d,instructions:m,extensions:h}=i.info;if(Je.current&&(Oe(u),Ae(d),Me(m),Pe(h)),c){if(I(`debug`,`Server info:`,c),!Je.current)return I(`debug`,`Skipping state update - component unmounted`),`failed`;we(c),Ke.current=HA({serverInfo:c,url:t,isMounted:()=>Je.current,setServerInfo:we,addLog:I})}if(l){if(I(`debug`,`Server capabilities:`,l),!Je.current)return I(`debug`,`Skipping state update - component unmounted`),`failed`;Ee(l)}if(Ge.current){let e=await Ge.current.tokens?.();if(!Je.current)return I(`debug`,`Connection aborted after token fetch for auth tokens - component unmounted`),`failed`;if(e?.access_token){let t=e.expires_in?Date.now()+e.expires_in*1e3:void 0,n=null,r=null;try{n=await Ge.current.getTokenEndpoint?.()??null}catch{n=null}try{r=await Ge.current.getClientCredentials?.()??null}catch{r=null}if(!Je.current)return I(`debug`,`Skipping state update - component unmounted`),`failed`;He({access_token:e.access_token,token_type:e.token_type||`Bearer`,expires_at:t,refresh_token:e.refresh_token,scope:e.scope,...n?{token_endpoint:n}:{},...r?.client_id?{client_id:r.client_id}:{},...r?.client_secret?{client_secret:r.client_secret}:{}})}}return nt.current=n,he(`ready`),`success`}catch(r){let i=r,a=i?.message||String(r),o=Ge.current?.getLastAttemptedAuthUrl?.();if(o&&Ge.current&&m)return I(`info`,`OAuth already discovered (stored auth URL present); awaiting manual authentication.`),Je.current&&(he(`pending_auth`),Be(o)),qe.current=!1,`auth_redirect`;let s=GA(r),c=SA(r);if(s&&k&&Object.keys(k).length>0)return ht(`Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct.`),`failed`;if(s&&(!k||Object.keys(k).length===0))return ht(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(c){if(s)return ht(`Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`;if(Ge.current)if(I(`info`,`Authentication required. OAuth provider available.`),m){if(I(`info`,`Waiting for user to initiate authentication flow...`),Je.current){he(`pending_auth`);let e=Ge.current?.getLastAttemptedAuthUrl?.();e&&(Be(e),I(`info`,`Retrieved stored auth URL for manual authentication`))}return qe.current=!1,`auth_redirect`}else{I(`info`,`Triggering automatic OAuth authentication flow...`);try{if(await MS(Ge.current,{serverUrl:t,fetchFn:Ge.current.getProxyFetch?.()})===`REDIRECT`){let e=await Ge.current.getAuthorizationCode?.();if(!e)throw Error(`Authorization code not captured by headless provider`);await MS(Ge.current,{serverUrl:t,authorizationCode:e,fetchFn:Ge.current.getProxyFetch?.()})}return I(`info`,`OAuth flow completed, reconnecting...`),await e(n)}catch(e){return ht(`Automatic OAuth authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:Error(String(e))),`failed`}}return k&&Object.keys(k).length>0?(ht(`Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct.`),`failed`):(ht(`Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`)}return ht(a,i instanceof Error?i:Error(String(i)))?`auth_redirect`:`failed`}},a=`failed`;I(`debug`,`Connecting via streamable HTTP`),a=await e(`http`),(a===`success`||a===`failed`||a===`auth_redirect`)&&(qe.current=!1),I(`debug`,`Connection sequence finished with status: ${a}`)},[I,ht,mt,t,i,r,oe.name,oe.version,oe.uri,oe.logo_uri,O,te,ne,k,E,m,h,g,n,_,ae,ie,S,ue,c,pe,fe,ut,dt,ft]);(0,z.useEffect)(()=>{rt.current=gt,it.current=ht},[gt,ht]);let _t=(0,z.useCallback)(()=>{et.current===`failed`?(I(`info`,`Retry requested...`),rt.current?.()):I(`warn`,`Retry called but state is not 'failed' (state: ${et.current}). Ignoring.`)},[I]),vt=(0,z.useCallback)(async()=>{I(`info`,`Manual authentication requested...`);let e=et.current;if(e===`failed`)I(`info`,`Attempting to reconnect and authenticate via retry...`),_t();else if(e===`pending_auth`){I(`info`,`Proceeding with authentication from pending state...`);try{if(VA(Ge.current,`Auth Provider not available for manual auth`),VA(t,`Server URL is required for authentication`),a){I(`info`,`Using provided authProvider for manual authentication`);let e=new URL(t),n=e.origin+e.pathname.replace(/\/+$/,``);await MS(Ge.current,{serverUrl:n,fetchFn:Ge.current.getProxyFetch?.()}),rt.current?.();return}I(`info`,`Cleared ${Ge.current.clearStorage?.()??0} OAuth storage item(s) for fresh authentication`),he(`authenticating`);let e=null,n=null,{provider:o,oauthProxyUrl:s}=qA({effectiveOAuthUrl:fe,storageKeyPrefix:i,oauthClientConfig:oe,callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:h,gatewayUrl:ue,oauthProxyUrl:c,onPopupWindow:(t,r,i)=>{e=i;try{n=new URL(t).searchParams.get(`state`)}catch{}g?.(t,r,i)},proxyOAuthRequests:!0,staticClientInfo:O,clientMetadataUrl:te,scope:ne});s&&I(`info`,`Scoped OAuth proxy fetch enabled for manual auth`),Ge.current=o,I(`info`,`Triggering fresh OAuth authorization...`);let l=new URL(t),u=l.origin+l.pathname.replace(/\/+$/,``);try{await MS(o,{serverUrl:u,fetchFn:o.getProxyFetch?.()}),I(`info`,`OAuth flow completed (tokens obtained)`)}catch(e){I(`info`,`OAuth flow initiated (popup/redirect):`,e instanceof Error?e.message:`Redirecting...`)}let d=o.getLastAttemptedAuthUrl?.();if(d&&(Be(d),I(`info`,`Updated auth URL for fallback:`,d),!n))try{n=new URL(d).searchParams.get(`state`)}catch{}if(h)return;let f=o.getKey?.(`tokens`);if(!f){I(`warn`,`Could not derive tokens storage key; relying on callback listener.`);return}$e.current=!0;let p;try{p=await mk({popup:e,state:n,tokensKey:f})}finally{$e.current=!1}if(!Je.current)return;switch(p.kind){case`success`:I(`info`,`Authentication succeeded; reconnecting to MCP server...`),qe.current=!1,rt.current?.();break;case`cancelled`:I(`warn`,`Authentication popup was closed before completing. Returning to pending_auth.`),he(`pending_auth`);break;case`timeout`:I(`warn`,`Authentication timed out waiting for the popup. Returning to pending_auth.`),he(`pending_auth`);break;case`error`:ht(`Authentication failed: ${p.error}`);break;default:break}}catch(e){if(!Je.current)return;he(`pending_auth`),I(`error`,`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`)}}else if(e===`authenticating`){I(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=Ge.current?.getLastAttemptedAuthUrl?.();e&&!ze&&(Be(e),I(`info`,`Manual authentication URL retrieved:`,e))}else I(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[I,_t,ht,ze,t,h,g,i,oe.name,oe.uri,oe.logo_uri,O,te,ne,r,ae,a]),yt=(0,z.useCallback)(()=>{Ge.current?.clearStorage?(I(`info`,`Cleared ${Ge.current.clearStorage()} item(s) from localStorage for ${t}.`),Be(void 0),mt()):I(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,I,mt]);(0,z.useEffect)(()=>{if(typeof window>`u`)return;let e=(e,t)=>{if($e.current){I(`debug`,`Ignoring auth callback via ${t}; manual popup flow owns this result.`);return}let n=Ge.current?.serverUrlHash;if(e?.serverUrlHash&&n&&e.serverUrlHash!==n){I(`debug`,`Ignoring auth callback via ${t} for a different server.`);return}if(I(`info`,`Received auth callback via ${t}.`,e),Ze.current&&clearTimeout(Ze.current),Ze.current=null,e?.success)I(`info`,`Authentication successful via popup. Reconnecting client...`),qe.current&&I(`debug`,`Connection attempt already in progress, resetting flag to allow reconnection.`),qe.current=!1,setTimeout(()=>{Je.current&&(I(`debug`,`Initiating reconnection after successful auth callback.`),rt.current?.())},100);else{if(et.current!==`authenticating`&&et.current!==`pending_auth`){I(`debug`,`Ignoring stale auth failure callback (state=${et.current}).`);return}it.current?.(`Authentication failed in callback: ${e?.error||`Unknown reason.`}`)}},t=t=>{t.origin===window.location.origin&&t.data?.type===fk&&e(t.data,`postMessage`)};window.addEventListener(`message`,t),I(`debug`,`Auth callback message listener added.`);let n=null,r=t=>{t.data?.type===fk&&e(t.data,`BroadcastChannel`)};if(typeof BroadcastChannel<`u`)try{n=new BroadcastChannel(dk),n.addEventListener(`message`,r),I(`debug`,`Auth callback BroadcastChannel listener added.`)}catch(e){I(`warn`,`Failed to open auth callback BroadcastChannel; lost-opener popups will not reach this client.`,e),n=null}return()=>{if(window.removeEventListener(`message`,t),I(`debug`,`Auth callback message listener removed.`),n){try{n.removeEventListener(`message`,r),n.close()}catch{}I(`debug`,`Auth callback BroadcastChannel listener removed.`)}Ze.current&&clearTimeout(Ze.current)}},[I]),(0,z.useEffect)(()=>{if(Je.current=!0,!n||!t)return I(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`),he(`discovering`),()=>{Je.current=!1};if(I(`debug`,`useMcp mounted, initiating connection.`),Ye.current=0,a)Ge.current=a,I(`debug`,`Using externally provided authProvider`);else if(!Ge.current||Ge.current.serverUrl!==fe){let{provider:e,oauthProxyUrl:t}=qA({effectiveOAuthUrl:fe,storageKeyPrefix:i,oauthClientConfig:oe,callbackUrl:r,preventAutoAuth:m,useRedirectFlow:h,gatewayUrl:ue,oauthProxyUrl:c,onPopupWindow:g,proxyOAuthRequests:!0,staticClientInfo:O,clientMetadataUrl:te,scope:ne});Ge.current=e,t&&I(`debug`,`OAuth proxy URL in effect: ${t}`),I(`debug`,`BrowserOAuthClientProvider initialized/updated with URL: ${fe}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ue?`enabled`:`disabled`}`)}return gt(),()=>{Je.current=!1,I(`debug`,`useMcp unmounting, disconnecting.`),mt(!0)}},[t,n,i,r,oe.name,oe.version,oe.uri,oe.logo_uri,O,te,ne,h,ae,fe,s,a]);let bt=(0,z.useRef)(_t),xt=(0,z.useRef)(I);(0,z.useEffect)(()=>{bt.current=_t,xt.current=I},[_t,I]),(0,z.useEffect)(()=>{let e=null;if(me===`failed`&&d&&Ye.current>0){if(!Qe.current){Qe.current=!0;let t=typeof d==`number`?d:QA;xt.current(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{Qe.current=!1,Je.current&&et.current===`failed`&&bt.current()},t)}}else me!==`failed`&&(Qe.current=!1);return()=>{e&&(clearTimeout(e),Qe.current=!1)}},[me,d]);let St=(0,z.useCallback)(async()=>et.current===`ready`?Ce?.icon?Ce.icon:Ke.current?(I(`debug`,`Waiting for icon to finish loading...`),await Ke.current):(I(`debug`,`No icon available and no loading in progress`),null):(I(`warn`,`Cannot ensure icon loaded - not connected`),null),[Ce,I]);return{state:me,name:Ce?.name||t||``,tools:ge,resources:ve,resourceTemplates:be,prompts:xe,serverInfo:Ce,capabilities:Te,protocolEra:De,protocolVersion:ke,instructions:je,extensions:Ne,error:Fe,log:Le,authUrl:ze,authTokens:Ve,client:Ue.current,...pt,retry:_t,disconnect:mt,authenticate:vt,clearStorage:yt,ensureIconLoaded:St}}var ej=null;function tj(){return typeof window<`u`&&window.name.startsWith(`mcp_auth_`)}function nj(e,t,n){return{type:fk,success:e,...e?{}:{error:t??`Unknown error`},...n.state?{state:n.state}:{},...n.serverUrlHash?{serverUrlHash:n.serverUrlHash}:{}}}function rj(e){if(typeof BroadcastChannel>`u`)return;let t;try{t=new BroadcastChannel(dk),t.postMessage(e)}catch(e){console.warn(`[mcp-callback] Failed to broadcast callback result:`,e)}finally{t&&setTimeout(()=>{try{t?.close()}catch{}},0)}}function ij(e,t,n,r){if(typeof document>`u`)return;document.body.innerHTML=``;let i=document.createElement(`div`);i.style.fontFamily=`sans-serif`,i.style.padding=`20px`;let a=document.createElement(`h1`);a.textContent=e,i.appendChild(a);let o=document.createElement(`p`);o.textContent=t,n&&(o.style.color=`red`,o.style.backgroundColor=`#ffebeb`,o.style.border=`1px solid red`,o.style.padding=`10px`,o.style.borderRadius=`4px`),i.appendChild(o);let s=document.createElement(`a`);if(s.href=`#`,s.textContent=`Close this window`,s.onclick=e=>(e.preventDefault(),window.close(),!1),i.appendChild(s),r){let e=document.createTextNode(` or `),t=document.createElement(`a`);t.href=r,t.textContent=`return to the app`,i.append(e,t)}document.body.appendChild(i)}function aj(e){let t=`mcp:auth:state_${e}`,n=localStorage.getItem(t)?t:null;if(!n){let t=`:state_${e}`;for(let e=0;e<localStorage.length;e++){let r=localStorage.key(e);if(r?.endsWith(t)){n=r;break}}}let r=n?localStorage.getItem(n):null;if(!n||!r)throw Error(`Invalid or expired OAuth state "${e}".`);let i;try{i=JSON.parse(r)}catch{throw localStorage.removeItem(n),Error(`Failed to parse stored OAuth state.`)}return{key:n,value:i}}function oj(e,t){let n=new URL(e);n.searchParams.set(`auth_error`,`oauth_callback_failed`),n.searchParams.set(`auth_error_description`,t),window.location.href=n.toString()}function sj(e,t,n,r){let i=nj(e,t,r),a=n?.returnUrl,o=n?.flowType===`popup`||tj();if(n?.flowType===`redirect`&&a){e?window.location.href=a:oj(a,t??`Authentication failed.`);return}if(window.opener&&!window.opener.closed){window.opener.postMessage(i,window.location.origin),window.close();return}if(o){rj(i),ij(e?`Authentication Successful!`:`Authentication Error`,e?`You're authenticated. You can close this window and return to the app.`:t??`Authentication failed.`,!e,a);try{window.close()}catch{}return}if(a){e?window.location.href=a:oj(a,t??`Authentication failed.`);return}if(!e){ij(`Authentication Error`,t??`Authentication failed.`,!0);return}window.location.href=`/`}function cj(){return ej||=lj(),ej}async function lj(){let e=new URLSearchParams(window.location.search),t=e.get(`state`),n=null,r=null,i=null;try{if(!t)throw Error(`OAuth callback is missing the state parameter.`);let a=aj(t);if(n=a.key,r=a.value,!r.expiry||r.expiry<Date.now())throw localStorage.removeItem(n),Error(`OAuth state has expired. Please start authentication again.`);if(!r.providerOptions)throw Error(`Stored OAuth state is missing provider options.`);let{serverUrl:o,...s}=r.providerOptions;i=new Bk(o,s),await new LC(new URL(o),{authProvider:i,fetch:i.getProxyFetch()}).finishAuth(e),localStorage.removeItem(n),sj(!0,void 0,r,{state:t,serverUrlHash:r.serverUrlHash})}catch(e){let a=e instanceof Error?e.message:String(e);console.error(`[mcp-callback] OAuth callback failed:`,e),n&&localStorage.removeItem(n),i&&localStorage.removeItem(i.getKey(`last_auth_url`)),sj(!1,a,r,{state:t,serverUrlHash:r?.serverUrlHash})}}ek();var uj=[`url`,`displayName`,`enabled`,`proxyConfig`,`oauthProxyUrl`,`connectionMode`,`autoProxyFallback`,`callbackUrl`,`storageKeyPrefix`,`headers`,`logLevel`,`autoRetry`,`autoReconnect`,`reconnectionOptions`,`popupFeatures`,`preventAutoAuth`,`useRedirectFlow`,`clientOptions`,`protocolNegotiation`,`timeout`,`clientInfo`,`oauth`];function dj(e){let t={};for(let n of uj){let r=e[n];r!==void 0&&(t[n]=r)}return t}function fj(e){return dj(e)}var pj=500,mj=5*6e4;function hj(e){let[t,n]=(0,z.useState)([]),[r,i]=(0,z.useState)([]),[a,o]=(0,z.useState)([]),s=(0,z.useRef)(0),c=(0,z.useRef)(0),l=(0,z.useRef)(new Map),u=(0,z.useRef)(new Map),d=(0,z.useCallback)(e=>{for(let t of l.current.values())clearTimeout(t.timeout),t.reject(Error(e));l.current.clear();for(let t of u.current.values())clearTimeout(t.timeout),t.reject(Error(e));u.current.clear(),i([]),o([])},[]);(0,z.useEffect)(()=>()=>d(`MCP server connection was removed`),[d]);let f=(0,z.useCallback)(t=>{let r={id:globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random()}`,method:t.method,params:t.params,timestamp:Date.now(),read:!1};n(e=>[r,...e].slice(0,pj)),e.onNotificationReceived?.(r)},[e.onNotificationReceived]),p=(0,z.useCallback)((e,t)=>{let n=l.current.get(e);n&&(clearTimeout(n.timeout),l.current.delete(e),i(t=>t.filter(t=>t.id!==e)),n.resolve(t))},[]),m=(0,z.useCallback)((e,t)=>{let n=l.current.get(e);n&&(clearTimeout(n.timeout),l.current.delete(e),i(t=>t.filter(t=>t.id!==e)),n.reject(Error(t??`User rejected sampling request`)))},[]),h=(0,z.useCallback)(t=>new Promise((n,r)=>{let a=`sampling-${s.current++}`,o={id:a,request:{method:`sampling/createMessage`,params:t},timestamp:Date.now(),serverName:e.serverName},c=setTimeout(()=>m(a,`Sampling request timed out`),mj);l.current.set(a,{resolve:n,reject:r,timeout:c}),i(e=>[...e,o]),e.onSamplingRequest?.(o),e.onGlobalSamplingRequest?.(o,e.serverId,e.serverName,p,m)}),[p,e,m]),g=(0,z.useCallback)((e,t)=>{let n=u.current.get(e);n&&(clearTimeout(n.timeout),u.current.delete(e),o(t=>t.filter(t=>t.id!==e)),n.resolve(t))},[]),_=(0,z.useCallback)((e,t)=>{let n=u.current.get(e);n&&(clearTimeout(n.timeout),u.current.delete(e),o(t=>t.filter(t=>t.id!==e)),n.reject(Error(t??`User rejected elicitation request`)))},[]),v=(0,z.useCallback)(t=>new Promise((n,r)=>{let i=`elicitation-${c.current++}`,a={id:i,request:t,timestamp:Date.now(),serverName:e.serverName},s=setTimeout(()=>_(i,`Elicitation request timed out`),mj);u.current.set(i,{resolve:n,reject:r,timeout:s}),o(e=>[...e,a]),e.onElicitationRequest?.(a),e.onGlobalElicitationRequest?.(a,e.serverId,e.serverName,g,_)}),[g,e,_]),y=(0,z.useCallback)(e=>{n(t=>t.map(t=>t.id===e?{...t,read:!0}:t))},[]),b=(0,z.useCallback)(()=>n(e=>e.map(e=>({...e,read:!0}))),[]),x=(0,z.useCallback)(()=>n([]),[]);return{notifications:t,pendingSamplingRequests:r,pendingElicitationRequests:a,unreadNotificationCount:t.filter(e=>!e.read).length,markNotificationRead:y,markAllNotificationsRead:b,clearNotifications:x,approveSampling:p,rejectSampling:m,approveElicitation:g,rejectElicitation:_,onNotification:f,onSampling:h,onElicitation:v,rejectAll:d}}var gj=$O.get(`McpClientProvider`),_j=(0,z.createContext)(null);function vj(e,t){return JSON.stringify(e)===JSON.stringify(t)}function yj(e,t){return e.id===t.id&&vj(dj(e),dj(t))&&e.name===t.name&&e.state===t.state&&e.error===t.error&&e.authUrl===t.authUrl&&vj(e.authTokens,t.authTokens)&&e.protocolEra===t.protocolEra&&e.protocolVersion===t.protocolVersion&&vj(e.serverInfo,t.serverInfo)&&vj(e.capabilities,t.capabilities)&&e.instructions===t.instructions&&vj(e.extensions,t.extensions)&&vj(e.tools,t.tools)&&vj(e.resources,t.resources)&&vj(e.resourceTemplates,t.resourceTemplates)&&vj(e.prompts,t.prompts)&&vj(e.notifications,t.notifications)&&e.unreadNotificationCount===t.unreadNotificationCount&&vj(e.pendingSamplingRequests,t.pendingSamplingRequests)&&vj(e.pendingElicitationRequests,t.pendingElicitationRequests)&&e.client===t.client}function bj({id:e,options:t,defaultCallbackUrl:n,defaultOAuthProxyUrl:r,defaultProxyConfig:i,defaultAutoProxyFallback:a,clientInfo:o,cachedMetadata:s,onUpdate:c,onUpdateConfig:l,onUpdateDisplayName:u,onReconnect:d,rpcWrapTransport:f,onGlobalSamplingRequest:p,onGlobalElicitationRequest:m}){let{displayName:h,onSamplingRequest:g,onElicitationRequest:_,onNotificationReceived:v,wrapTransport:y}=t,b=(0,z.useMemo)(()=>{let{displayName:c,onSamplingRequest:l,onElicitationRequest:u,onNotificationReceived:d,wrapTransport:f,...p}=t;return{...p,callbackUrl:p.callbackUrl||n,oauthProxyUrl:p.oauthProxyUrl||r,proxyConfig:p.proxyConfig||i,autoProxyFallback:p.autoProxyFallback===void 0?a:p.autoProxyFallback,clientInfo:p.clientInfo?o?{...o,...p.clientInfo}:p.clientInfo:o,_initialServerInfo:s,serverId:e}},[t,n,r,i,a,o,s]),x=(0,z.useMemo)(()=>{if(!(!f&&!y))return t=>{let n=t;return f&&(n=f(n,e)),y&&(n=y(n,e)),n}},[f,y,e]),S=hj({serverId:e,serverName:h||e,onNotificationReceived:v,onSamplingRequest:g,onElicitationRequest:_,onGlobalSamplingRequest:p,onGlobalElicitationRequest:m}),C=$A({...b,onNotification:S.onNotification,onSampling:S.onSampling,onElicitation:S.onElicitation,wrapTransport:x});(0,z.useEffect)(()=>{C.state!==`ready`&&S.rejectAll(`MCP server connection is no longer active`)},[C.state,S.rejectAll]);let w=(0,z.useCallback)(t=>l(e,t),[e,l]),T=(0,z.useCallback)(n=>{let r=t.proxyConfig?.proxyAddress?.trim();return t.connectionMode===`proxy`&&r?l(e,{proxyConfig:{...t.proxyConfig,proxyAddress:r,...n?{headers:n}:{}},headers:void 0}):l(e,{headers:n})},[e,t.connectionMode,t.proxyConfig,l]),ee=(0,z.useCallback)(t=>u(e,t),[e,u]),E=(0,z.useCallback)(()=>d(e),[e,d]),D=(0,z.useRef)(c),te=(0,z.useRef)(null);return(0,z.useEffect)(()=>{D.current=c},[c]),(0,z.useEffect)(()=>{let n={...fj(t),...C,id:e,displayName:h||t.displayName||e,notifications:S.notifications,unreadNotificationCount:S.unreadNotificationCount,markNotificationRead:S.markNotificationRead,markAllNotificationsRead:S.markAllNotificationsRead,clearNotifications:S.clearNotifications,pendingSamplingRequests:S.pendingSamplingRequests,approveSampling:S.approveSampling,rejectSampling:S.rejectSampling,pendingElicitationRequests:S.pendingElicitationRequests,approveElicitation:S.approveElicitation,rejectElicitation:S.rejectElicitation,updateConfig:w,setHeaders:T,setDisplayName:ee,reconnect:E},r=te.current;!r||!yj(r,n)?(te.current=n,D.current(n)):gj.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`)},[e,h,t,t.url,C.state,C.error,C.authUrl,C.tools,C.resources,C.resourceTemplates,C.prompts,C.serverInfo,C.capabilities,C.protocolEra,C.protocolVersion,C.instructions,C.extensions,C.authTokens,S,w,T,ee,E]),null}function xj({children:e,mcpServers:t,defaultCallbackUrl:n,defaultOAuthProxyUrl:r,defaultProxyConfig:i,defaultAutoProxyFallback:a=!1,defaultServerConfig:o,clientInfo:s,storageProvider:c,enableRpcLogging:l=!1,onServerAdded:u,onServerRemoved:d,onServerStateChange:f,onSamplingRequest:p,onElicitationRequest:m}){let[h,g]=(0,z.useState)([]),[_,v]=(0,z.useState)([]),[y,b]=(0,z.useState)({}),[x,S]=(0,z.useState)(!1),C=(0,z.useRef)(!1),w=(0,z.useRef)([]);(0,z.useEffect)(()=>{w.current=_},[_]);let T=(0,z.useRef)({}),[ee,E]=(0,z.useState)(void 0),[D,te]=(0,z.useState)(!1);(0,z.useEffect)(()=>{if(!l||typeof window>`u`){E(void 0),te(!0);return}Promise.resolve().then(()=>(uk(),tk)).then(e=>{gj.debug(`[McpClientProvider] RPC logger loaded`),E(()=>e.wrapTransportForLogging),te(!0)}).catch(e=>{gj.error(`[McpClientProvider] Failed to load RPC logger:`,e),E(void 0),te(!0)})},[l]),(0,z.useEffect)(()=>{if(!D){gj.debug(`[McpClientProvider] Waiting for RPC logging to be ready before loading servers`);return}C.current||(C.current=!0,(async()=>{if(gj.debug(`[McpClientProvider] Loading servers, storageProvider:`,!!c,`mcpServers:`,t),!c){if(t){let e=Object.entries(t).map(([e,t])=>({id:e,options:t}));gj.debug(`[McpClientProvider] Loaded from mcpServers prop:`,e.length),g(e)}S(!0);return}try{let e=await Promise.resolve(c.getServers());if(gj.debug(`[McpClientProvider] Loaded from storage:`,Object.keys(e).length),c.getServerMetadata)try{let t=Object.keys(e).map(async e=>[e,await Promise.resolve(c.getServerMetadata(e))]),n=await Promise.all(t);T.current=Object.fromEntries(n.filter(e=>e[1]!==void 0)),gj.debug(`[McpClientProvider] Loaded cached metadata for`,Object.keys(T.current).length,`servers`)}catch(e){gj.warn(`[McpClientProvider] Failed to load cached metadata:`,e)}let n={...e,...t},r=Object.entries(n).map(([e,t])=>({id:e,options:t}));gj.debug(`[McpClientProvider] Total servers after merge:`,r.length),g(r),S(!0)}catch(e){gj.error(`[McpClientProvider] Failed to load from storage:`,e),t&&g(Object.entries(t).map(([e,t])=>({id:e,options:t}))),S(!0)}})())},[c,t,D]),(0,z.useEffect)(()=>{!c||!x||(async()=>{try{let e=h.reduce((e,t)=>(e[t.id]=fj(t.options),e),{});await Promise.resolve(c.setServers(e))}catch(e){gj.error(`[McpClientProvider] Failed to save to storage:`,e)}})()},[h,c,x]);let ne=(0,z.useCallback)(e=>{gj.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`,{toolCount:e.tools.length,state:e.state});let t=[];v(n=>{let r=n.findIndex(t=>t.id===e.id);if(r===-1)return gj.debug(`[McpClientProvider] Adding new server ${e.id} to state`),t.push(()=>u?.(e.id,e)),[...n,e];let i=n[r],a=i.state!==e.state,o=i.serverInfo!==e.serverInfo;if(gj.debug(`[McpClientProvider] Comparing server ${e.id}:`,{toolsChanged:i.tools!==e.tools,currentToolCount:i.tools.length,updatedToolCount:e.tools.length,stateChanged:a}),yj(i,e))return gj.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`),n;if(gj.debug(`[McpClientProvider] Updating server ${e.id} in state`),a&&t.push(()=>f?.(e.id,e.state)),o&&e.serverInfo&&c?.setServerMetadata){let t={name:e.serverInfo.name,version:e.serverInfo.version,title:e.serverInfo.title,websiteUrl:e.serverInfo.websiteUrl,icons:e.serverInfo.icons,icon:e.serverInfo.icon};T.current[e.id]=t,Promise.resolve(c.setServerMetadata(e.id,t)).catch(e=>{gj.error(`[McpClientProvider] Failed to save server metadata:`,e)})}let s=[...n];return s[r]=e,s}),t.length>0&&queueMicrotask(()=>{t.forEach(e=>e())})},[u,f,c]),O=(0,z.useCallback)((e,t)=>{g(n=>n.find(t=>t.id===e)?n:(gj.debug(`[McpClientProvider] Adding new server to configs:`,e),[...n,{id:e,options:t}]))},[]),re=(0,z.useCallback)(async(e,t)=>{let n=w.current.find(t=>t.id===e);if(v(t=>t.filter(t=>t.id!==e)),g(t=>t.filter(t=>t.id!==e)),b(t=>{let{[e]:n,...r}=t;return r}),n?.disconnect&&await n.disconnect(),t?.clearCredentials&&n?.clearStorage&&await n.clearStorage(),l){let{clearRpcLogs:t}=await Promise.resolve().then(()=>(uk(),tk));t(e)}d?.(e)},[l,d]),k=(0,z.useCallback)(async(e,t)=>{let n=h.find(t=>t.id===e);if(!n){gj.warn(`[McpClientProvider] Cannot update server "${e}" - not found`);return}let r={...n.options,...t};vj(dj(n.options),dj(r))||(await w.current.find(t=>t.id===e)?.disconnect(),v(t=>t.filter(t=>t.id!==e)),g(t=>t.map(t=>t.id===e?{id:e,options:r}:t)),b(t=>({...t,[e]:(t[e]??0)+1})))},[h]),ie=(0,z.useCallback)(async e=>{if(!h.find(t=>t.id===e)){gj.warn(`[McpClientProvider] Cannot reconnect server "${e}" - not found`);return}await w.current.find(t=>t.id===e)?.disconnect(),v(t=>t.filter(t=>t.id!==e)),b(t=>({...t,[e]:(t[e]??0)+1}))},[h]),A=(0,z.useCallback)(async(e,t)=>new Promise(n=>{let r=h.find(t=>t.id===e);if(!r){gj.warn(`[McpClientProvider] Cannot update server metadata for "${e}" - not found`),n();return}let i={...r.options,displayName:t.name};v(n=>n.map(n=>n.id===e?{...n,displayName:t.name}:n)),g(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r})}),[h]),j=(0,z.useCallback)(e=>_.find(t=>t.id===e),[_]),M=(0,z.useMemo)(()=>({servers:_,addServer:O,removeServer:re,updateServerMetadata:A,updateServer:k,getServer:j,storageLoaded:x}),[_,O,re,A,k,j,x]),{capabilities:ae,...oe}=s||{},se=(0,z.useMemo)(()=>Object.keys(oe).length?oe:void 0,[s]),N=(0,z.useMemo)(()=>h.map(e=>{let t=o?{...o,...e.options}:e.options;return ae&&(t={...t,clientOptions:{...t.clientOptions,capabilities:{...ae,...t.clientOptions?.capabilities}}}),{id:e.id,options:t}}),[h,ae,o]),P=typeof window<`u`&&/\/oauth\/callback\/?$/.test(window.location.pathname);return z.createElement(_j.Provider,{value:M},e,!P&&N.map(e=>z.createElement(bj,{key:`${e.id}-v${y[e.id]??0}`,id:e.id,options:e.options,defaultCallbackUrl:n,defaultOAuthProxyUrl:r,defaultProxyConfig:i,defaultAutoProxyFallback:a,clientInfo:se,cachedMetadata:T.current[e.id],onUpdate:ne,onUpdateConfig:k,onUpdateDisplayName:(e,t)=>A(e,{name:t}),onReconnect:ie,rpcWrapTransport:ee,onGlobalSamplingRequest:p,onGlobalElicitationRequest:m})))}function Sj(){let e=(0,z.useContext)(_j);if(!e)throw Error(`useMcpClient must be used within a McpClientProvider`);return e}var Cj=class{constructor(e=`mcp-client-servers`){this.storageKey=e,this.metadataKey=`${e}-metadata`}metadataKey;getServers(){try{let e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load servers:`,e),{}}}setServers(e){try{localStorage.setItem(this.storageKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save servers:`,e)}}setServer(e,t){let n=this.getServers();n[e]=t,this.setServers(n)}removeServer(e){let t=this.getServers();delete t[e],this.setServers(t),this.removeServerMetadata(e)}clear(){try{localStorage.removeItem(this.storageKey),localStorage.removeItem(this.metadataKey)}catch(e){console.error(`[LocalStorageProvider] Failed to clear:`,e)}}getAllMetadata(){try{let e=localStorage.getItem(this.metadataKey);return e?JSON.parse(e):{}}catch(e){return console.error(`[LocalStorageProvider] Failed to load metadata:`,e),{}}}setAllMetadata(e){try{localStorage.setItem(this.metadataKey,JSON.stringify(e))}catch(e){console.error(`[LocalStorageProvider] Failed to save metadata:`,e)}}getServerMetadata(e){return this.getAllMetadata()[e]}setServerMetadata(e,t){let n=this.getAllMetadata();n[e]={...t,cachedAt:Date.now()},this.setAllMetadata(n)}removeServerMetadata(e){let t=this.getAllMetadata();delete t[e],this.setAllMetadata(t)}};uk();function wj(e){let t={};if(!e)return t;for(let[n,r]of Object.entries(e))if(typeof r==`string`&&(r.trim().startsWith(`[`)||r.trim().startsWith(`{`)))try{t[n]=JSON.parse(r)}catch{t[n]=r}else t[n]=r;return t}function Tj(e){let{resourceResult:t,listingResource:n,cspMode:r,resourceUri:i}=e,a=(Array.isArray(t?.contents)?t.contents:[])[0],o=``,s;if(a&&(s=a.mimeType,typeof a.text==`string`?o=a.text:typeof a.blob==`string`&&(o=atob(a.blob))),!o)throw Error(`No HTML content in resource`);let c=n?._meta?.ui,l=a?._meta?.ui,u=c||l?{...c,...l}:void 0,d=u?.csp,f=u?.permissions,p=u?.prefersBorder??!1,m=s===BO,h=m?null:s?`Invalid MIME type "${s}" - SEP-1865 requires "${BO}"`:`Missing MIME type - SEP-1865 requires "${BO}"`;return h&&console.warn(`[ViewRenderer] MIME type validation:`,h,{resourceUri:i}),{html:o,declaredCsp:d,csp:r===`permissive`?void 0:d,permissions:f,prefersBorder:p,mimeType:s,mimeTypeValid:m,mimeTypeWarning:h}}function Ej(e,t){let{cspMode:n,permissions:r,widgetCsp:i}=t;e.searchParams.set(`v`,JSON.stringify({cspMode:n,permissions:r,widgetCsp:i})),e.searchParams.set(`csp_mode`,n),r&&Object.keys(r).length>0&&e.searchParams.set(`permissions`,JSON.stringify(r)),i&&Object.keys(i).length>0&&e.searchParams.set(`widget_csp`,JSON.stringify(i))}function Dj(e){let t=new URL(`https://sandbox.invalid/`);Ej(t,e);let n=kj(t.search);return new URL(URL.createObjectURL(new Blob([n],{type:`text/html`})))}var Oj=`<!doctype html>
|
|
197
197
|
<html>
|
|
198
198
|
<head>
|
|
199
199
|
<meta charset="utf-8" />
|
|
@@ -472,4 +472,4 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
|
|
|
472
472
|
# (optional) Use environment variables instead:
|
|
473
473
|
# env_http_headers = { `;let e=i.map(({name:e,header:t})=>`"${t}" = "${e}"`);r+=e.join(`, `),r+=` }`}}return{config:r,envVars:i}}function DL(e){if(e.length===0)return``;let t=`Set these environment variables in your shell:
|
|
474
474
|
|
|
475
|
-
`;for(let{name:n}of e)t+=`export ${n}="your-${n}-value"\n`;return t}function OL({className:e,size:t=`md`}){return(0,R.jsxs)(`svg`,{viewBox:`0 0 500 500`,className:A(`text-current`,{sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`}[t],e),fill:`currentColor`,fillRule:`nonzero`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`path`,{d:`M105.933 0C164.437 0.000116002 211.865 47.607 211.865 106.333C211.865 131.829 210.493 158.403 221.068 181.602L228.975 198.947C243.584 230.997 269.265 256.7 301.303 271.336L316.155 278.121C340.142 289.079 367.694 287.335 394.066 287.335C452.571 287.335 499.999 334.942 499.999 393.668C499.999 452.394 452.571 500.001 394.066 500.001C335.562 500.001 288.134 452.394 288.134 393.668C288.134 368.974 289.24 343.275 278.992 320.807L270.586 302.38C255.948 270.29 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.86252e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z`}),(0,R.jsx)(`circle`,{cx:`100.426`,cy:`399.575`,r:`100.426`}),(0,R.jsx)(`path`,{d:`M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z`})]})}function kL({className:e}){return(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,className:e,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:(0,R.jsx)(`path`,{d:`M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z`})})}function AL({className:e}){return(0,R.jsxs)(`svg`,{fill:`currentColor`,fillRule:`evenodd`,viewBox:`0 0 24 24`,className:e,xmlns:`http://www.w3.org/2000/svg`,"aria-label":`ModelContextProtocol`,children:[(0,R.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),(0,R.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`})]})}function jL({className:e}){return(0,R.jsx)(`svg`,{viewBox:`0 -28.5 256 256`,className:e,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:(0,R.jsx)(`path`,{d:`M216.856339,16.5966031 C200.285002,8.84328665 182.566144,3.2084988 164.041564,0 C161.766523,4.11318106 159.108624,9.64549908 157.276099,14.0464379 C137.583995,11.0849896 118.072967,11.0849896 98.7430163,14.0464379 C96.9108417,9.64549908 94.1925838,4.11318106 91.8971895,0 C73.3526068,3.2084988 55.6133949,8.86399117 39.0420583,16.6376612 C5.61752293,67.146514 -3.4433191,116.400813 1.08711069,164.955721 C23.2560196,181.510915 44.7403634,191.567697 65.8621325,198.148576 C71.0772151,190.971126 75.7283628,183.341335 79.7352139,175.300261 C72.104019,172.400575 64.7949724,168.822202 57.8887866,164.667963 C59.7209612,163.310589 61.5131304,161.891452 63.2445898,160.431257 C105.36741,180.133187 151.134928,180.133187 192.754523,160.431257 C194.506336,161.891452 196.298154,163.310589 198.110326,164.667963 C191.183787,168.842556 183.854737,172.420929 176.223542,175.320965 C180.230393,183.341335 184.861538,190.991831 190.096624,198.16893 C211.238746,191.588051 232.743023,181.531619 254.911949,164.955721 C260.227747,108.668201 245.831087,59.8662432 216.856339,16.5966031 Z M85.4738752,135.09489 C72.8290281,135.09489 62.4592217,123.290155 62.4592217,108.914901 C62.4592217,94.5396472 72.607595,82.7145587 85.4738752,82.7145587 C98.3405064,82.7145587 108.709962,94.5189427 108.488529,108.914901 C108.508531,123.290155 98.3405064,135.09489 85.4738752,135.09489 Z M170.525237,135.09489 C157.88039,135.09489 147.510584,123.290155 147.510584,108.914901 C147.510584,94.5396472 157.658606,82.7145587 170.525237,82.7145587 C183.391518,82.7145587 193.761324,94.5189427 193.539891,108.914901 C193.539891,123.290155 183.391518,135.09489 170.525237,135.09489 Z`,fillRule:`nonzero`})})}function ML({isOpen:e,onOpenChange:t,tools:n,prompts:r,resources:i,savedRequests:a,connections:o,selectedServer:s,tunnelUrl:c,onNavigate:l,onServerSelect:u}){let[d,f]=(0,z.useState)(``),[p,m]=(0,z.useState)(0),h=(0,z.useRef)(null),g=(0,z.useRef)(null),_=KN(),v=w.pill,{activeIndex:y,itemRects:b,sessionRef:x,handlers:S,registerItem:C,measureItems:ee}=_n(h),E=s?c?`${c}/mcp`:s.url:null,D=s?.name||`MCP Server`,te=s?_M(s):void 0,ne=s?[{id:`open-in-cursor`,name:`Open in Cursor`,description:`Add this server to Cursor`,type:`global`,category:`Open in Client`,action:()=>{try{let e=yL(E,D,te);window.location.href=e,GF.success(`Opening in Cursor...`),t(!1)}catch{GF.error(`Failed to open in Cursor`)}}},{id:`open-in-claude-code`,name:`Open in Claude Code`,description:`Add this server to Claude Code CLI`,type:`global`,category:`Open in Client`,action:()=>{let{command:e}=wL(E,D,te);Qj(e),GF.success(`Command copied to clipboard`),t(!1)}},{id:`open-in-claude-desktop`,name:`Open in Claude Desktop`,description:`Download .mcpb configuration file`,type:`global`,category:`Open in Client`,action:()=>{try{CL(E,D,te),GF.success(`Downloaded .mcpb file`),t(!1)}catch{GF.error(`Failed to download configuration file`)}}},{id:`open-in-vscode`,name:`Open in VS Code`,description:`Add this server to VS Code`,type:`global`,category:`Open in Client`,action:()=>{try{let e=bL(E,D,te);window.location.href=e,GF.success(`Opening in VS Code...`),t(!1)}catch{GF.error(`Failed to open in VS Code`)}}},{id:`open-in-vscode-insiders`,name:`Open in VS Code Insiders`,description:`Add this server to VS Code Insiders`,type:`global`,category:`Open in Client`,action:()=>{try{let e=xL(E,D,te);window.location.href=e,GF.success(`Opening in VS Code Insiders...`),t(!1)}catch{GF.error(`Failed to open in VS Code Insiders`)}}},{id:`open-in-gemini`,name:`Open in Gemini CLI`,description:`Add this server to Gemini CLI`,type:`global`,category:`Open in Client`,action:()=>{let{command:e}=TL(E,D,te);Qj(e),GF.success(`Command copied to clipboard`),t(!1)}},{id:`open-in-codex`,name:`Open in Codex CLI`,description:`Add this server to Codex CLI`,type:`global`,category:`Open in Client`,action:()=>{let{config:e}=EL(E,D,te);Qj(e),GF.success(`Config copied to clipboard`),t(!1)}}]:[],O=[{id:`connect-server`,name:`Connect Server`,description:`Add a new MCP server connection`,type:`global`,category:`Navigation`,action:()=>_(`/`)},{id:`mcp-use-website`,name:`MCP Use Website`,description:`Visit mcp-use.com for tools and resources`,type:`global`,category:`Documentation`,action:()=>window.open(`https://mcp-use.com`,`_blank`)},{id:`mcp-use-docs`,name:`How to Create an MCP Server`,description:`Step-by-step guide to building MCP servers`,type:`global`,category:`Documentation`,action:()=>window.open(`https://mcp-use.com/docs`,`_blank`)},{id:`mcp-docs`,name:`MCP Official Documentation`,description:`Learn about the Model Context Protocol`,type:`global`,category:`Documentation`,action:()=>window.open(`https://modelcontextprotocol.io/docs/getting-started/intro`,`_blank`)},{id:`discord`,name:`Join Discord Community`,description:`Connect with the MCP community`,type:`global`,category:`Community`,action:()=>window.open(`https://discord.gg/XkNkSkMz3V`,`_blank`)},{id:`clear-localstorage`,name:`Clear localStorage & Reload`,description:`Having trouble connecting? Clear stored auth data and refresh`,type:`global`,category:`Troubleshooting`,action:()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&(n.startsWith(`mcp:auth`)||n.startsWith(`mcp-inspector`))&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),GF.success(`Cleared ${e.length} localStorage item(s). Refreshing page...`,{duration:2e3}),setTimeout(()=>{window.location.reload()},500),t(!1)}}],re=o.map(e=>({id:`server-${e.id}`,name:lM(e),description:`Connected server (${e.state})`,type:`global`,category:`Connected Servers`,metadata:{serverId:e.id,state:e.state},action:()=>u(e.id)})),k=[...O,...ne,...re,...n.map(e=>({id:`tool-${e.name}`,name:e.name,description:e.description,type:`tool`,category:e._serverName?`Tools - ${e._serverName}`:`Tools`,metadata:{inputSchema:e.inputSchema,serverId:e._serverId,serverName:e._serverName}})),...r.map(e=>({id:`prompt-${e.name}`,name:e.name,description:e.description,type:`prompt`,category:e._serverName?`Prompts - ${e._serverName}`:`Prompts`,metadata:{arguments:e.arguments,serverId:e._serverId,serverName:e._serverName}})),...i.map(e=>({id:`resource-${e.uri}`,name:e.name,description:e.description,type:`resource`,category:e._serverName?`Resources - ${e._serverName}`:`Resources`,metadata:{uri:e.uri,mimeType:e.mimeType,serverId:e._serverId,serverName:e._serverName}})),...a.map(e=>({id:`saved-${e.id}`,name:e.name,description:`Saved request for ${e.toolName}`,type:`saved-request`,category:`Saved Requests`,metadata:{toolName:e.toolName,args:e.args,savedAt:e.savedAt,serverId:e.serverId,serverName:e.serverName}}))].filter(e=>d.trim()?`${e.name} ${e.description||``} ${e.category}`.toLowerCase().includes(d.trim().toLowerCase()):!0),ie=(0,z.useCallback)(e=>{if(console.warn(`[CommandPalette] Item selected:`,{itemType:e.type,itemName:e.name,itemId:e.id,metadata:e.metadata}),e.action)console.warn(`[CommandPalette] Executing action for global item`),e.action(),t(!1);else if(e.type===`global`)e.metadata?.serverId&&(console.warn(`[CommandPalette] Selecting server:`,e.metadata.serverId),u(e.metadata.serverId),t(!1));else{let n=e.type===`resource`?e.metadata?.uri:e.name,r=e.type===`tool`?`tools`:e.type===`prompt`?`prompts`:e.type===`saved-request`?`tools`:`resources`;fetch(`http://127.0.0.1:7371/ingest/4e7482c5-571f-4071-bd09-762c357289f4`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Debug-Session-Id":`831b88`},body:JSON.stringify({sessionId:`831b88`,location:`CommandPalette.tsx:handleSelect`,message:`palette navigate item`,data:{itemType:e.type,itemName:e.name,itemIdentifier:n,tabName:r,serverId:e.metadata?.serverId??null},timestamp:Date.now(),hypothesisId:`H1`})}).catch(()=>{}),console.warn(`[CommandPalette] Navigating to item:`,{tab:r,itemIdentifier:n,serverId:e.metadata?.serverId}),l(r,n,e.metadata?.serverId),t(!1)}},[l,t,u]),j=(e,t,n)=>{switch(e){case`tool`:return(0,R.jsx)(`div`,{className:`bg-blue-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(qi,{className:`h-4 w-4 text-blue-500`})});case`prompt`:return(0,R.jsx)(`div`,{className:`bg-purple-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(vi,{className:`h-4 w-4 text-purple-500`})});case`resource`:return(0,R.jsx)(`div`,{className:`bg-green-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Qr,{className:`h-4 w-4 text-green-500`})});case`saved-request`:return(0,R.jsx)(`div`,{className:`bg-orange-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(ri,{className:`h-4 w-4 text-orange-500`})});case`global`:if(t===`Navigation`)return(0,R.jsx)(`div`,{className:`bg-gray-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(ki,{className:`h-4 w-4 text-gray-600 dark:text-gray-300`})});if(t===`Open in Client`){if(n?.includes(`Cursor`))return(0,R.jsx)(`div`,{className:`bg-gray-200 dark:bg-gray-800 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/cursor`,alt:`Cursor`,className:`h-4 w-4`})});if(n?.includes(`Claude Code`)||n?.includes(`Claude Desktop`))return(0,R.jsx)(`div`,{className:`bg-orange-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`})});if(n?.includes(`VS Code`))return(0,R.jsx)(`div`,{className:`bg-blue-600/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(kL,{className:`h-4 w-4 text-blue-600`})});if(n?.includes(`Gemini`))return(0,R.jsx)(`div`,{className:`bg-purple-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/googlegemini`,alt:`Gemini`,className:`h-4 w-4`})});if(n?.includes(`Codex`))return(0,R.jsx)(`div`,{className:`bg-green-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:`https://inspector-cdn.mcp-use.com/providers/openai.png`,alt:`Codex`,className:`h-4 w-4`})})}return t===`Documentation`?n?.includes(`MCP Use`)||n?.includes(`mcp-use`)?(0,R.jsx)(`div`,{className:`bg-black/10 dark:bg-white/10 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(OL,{className:`h-4 w-4 text-black dark:text-white`,size:`sm`})}):(0,R.jsx)(`div`,{className:`bg-orange-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Yr,{className:`h-4 w-4 text-orange-500`})}):t===`Community`?(0,R.jsx)(`div`,{className:`bg-purple-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(jL,{className:`h-4 w-4 text-purple-500`})}):t===`Troubleshooting`?(0,R.jsx)(`div`,{className:`bg-yellow-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Pr,{className:`h-4 w-4 text-yellow-500`})}):t===`Connected Servers`?(0,R.jsx)(`div`,{className:`bg-cyan-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Ni,{className:`h-4 w-4 text-cyan-500`})}):(0,R.jsx)(`div`,{className:`bg-gray-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Yr,{className:`h-4 w-4 text-gray-500`})});default:return(0,R.jsx)(`div`,{className:`bg-gray-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(T,{className:`h-4 w-4 text-gray-500`})})}};(0,z.useEffect)(()=>{e&&(f(``),m(0),requestAnimationFrame(()=>g.current?.focus()))},[e]),(0,z.useEffect)(()=>{h.current&&(h.current.scrollTop=0),m(0)},[d]),(0,z.useEffect)(()=>{p>=k.length&&m(Math.max(0,k.length-1))},[p,k.length]),(0,z.useLayoutEffect)(()=>{e&&ee()},[e,ee,k]);let M=b[p]??null,ae=y===null?null:b[y],oe=y!==null&&y!==p;return e?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-50 bg-black/40 backdrop-blur-sm`,"aria-label":`Close command palette`,onClick:()=>t(!1)}),(0,R.jsxs)(`div`,{role:`dialog`,"aria-label":`Command Palette`,"data-testid":`command-palette-dialog`,className:`fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-[51] max-w-[640px] w-[calc(100vw-2rem)] sm:w-full p-2 bg-white dark:bg-zinc-900/90 backdrop-blur-xl rounded-xl overflow-hidden border border-border shadow-[var(--cmdk-shadow)] transition-transform duration-100 ease-out outline-none`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),m(e=>Math.min(e+1,k.length-1))):e.key===`ArrowUp`?(e.preventDefault(),m(e=>Math.max(e-1,0))):e.key===`Enter`&&k[p]?(e.preventDefault(),ie(k[p])):e.key===`Escape`&&(e.preventDefault(),t(!1))},children:[(0,R.jsx)(`input`,{ref:g,placeholder:`What do you need?`,value:d,onChange:e=>f(e.target.value),className:`border-none w-full text-[17px] px-4 pt-2 pb-4 outline-none bg-transparent text-foreground border-b border-border mb-0 rounded-none placeholder:text-muted-foreground`,"data-testid":`command-palette-input`}),(0,R.jsxs)(`div`,{ref:h,onMouseEnter:S.onMouseEnter,onMouseMove:S.onMouseMove,onMouseLeave:S.onMouseLeave,className:`relative isolate min-h-[200px] sm:min-h-[330px] max-h-[400px] overflow-auto overscroll-contain transition-[height] duration-100 ease-out px-1`,"data-testid":`command-palette-list`,children:[(0,R.jsx)(en,{children:M&&(0,R.jsx)(qe.div,{"aria-hidden":!0,className:A(`pointer-events-none absolute bg-active`,v.bg),initial:!1,animate:{top:M.top,left:M.left,width:M.width,height:M.height,opacity:oe?.8:1},exit:{opacity:0,transition:At.moderate.exit},transition:{...At.moderate,opacity:{duration:.08}}})}),(0,R.jsx)(en,{children:ae&&(0,R.jsx)(qe.div,{"aria-hidden":!0,className:A(`pointer-events-none absolute bg-hover`,v.bg),initial:{opacity:0,top:M?.top??ae.top,left:M?.left??ae.left,width:M?.width??ae.width,height:M?.height??ae.height},animate:{opacity:1,top:ae.top,left:ae.left,width:ae.width,height:ae.height},exit:{opacity:0,transition:At.fast.exit},transition:{...At.fast,opacity:{duration:.08}}},x.current)}),k.length===0?(0,R.jsx)(`div`,{className:`text-sm flex items-center justify-center h-12 whitespace-pre-wrap text-muted-foreground`,children:`No results found.`}):k.map((e,t)=>(0,R.jsxs)(`button`,{ref:e=>C(t,e),type:`button`,"data-testid":`command-palette-item-${e.id}`,"data-proximity-index":t,onClick:()=>ie(e),className:`[content-visibility:auto] relative z-10 cursor-pointer h-12 text-sm flex items-center gap-3 px-3 text-foreground select-none w-full text-left mt-1 first:mt-0`,children:[j(e.type,e.category,e.name),(0,R.jsx)(`span`,{className:`font-medium truncate flex-1 min-w-0`,children:e.name}),(()=>{let t=e.metadata?.serverId;if(!t||e.category===`Connected Servers`)return null;let n=o.find(e=>e.id===t);return n?(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[(0,R.jsx)(oL,{server:n,size:`xs`}),(0,R.jsx)(`span`,{className:`text-xs truncate max-w-[9rem]`,children:lM(n)})]}):null})()]},e.id))]}),(0,R.jsxs)(`div`,{className:`border-t border-border px-4 py-3 pb-1 flex items-center justify-between text-xs text-muted-foreground `,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`t`}),(0,R.jsx)(`span`,{children:`Tools`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`p`}),(0,R.jsx)(`span`,{children:`Prompts`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`r`}),(0,R.jsx)(`span`,{children:`Resources`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`c`}),(0,R.jsx)(`span`,{children:`Chat`})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`h`}),(0,R.jsx)(`span`,{children:`Home`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center px-2 h-5 font-mono text-[10px] font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`esc`}),(0,R.jsx)(`span`,{children:`Close`})]})]})]})]})]}):null}var NL=`openid profile email offline_access`,PL=`mcp-inspector:manufact-auth`,FL=`manufact:session-changed`,IL={loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null},LL=new Map,RL=new Set,zL=new Map,BL=new Map;function VL(e){let t=LL.get(e);if(t)return t;let n={...IL,loaded:!1};return LL.set(e,n),n}function HL(){return typeof window>`u`?null:window.localStorage}function UL(e){return new URL(e).origin}function WL(e,t){let n=new URL(e),r=new URL(t),i=new Set([`localhost`,`127.0.0.1`]);return i.has(n.hostname)&&i.has(r.hostname)?n.origin===r.origin:(n.hostname===`manufact.com`||n.hostname.endsWith(`.manufact.com`))&&(r.hostname===`manufact.com`||r.hostname.endsWith(`.manufact.com`))}function GL(e){let t=window.__MANUFACT_LOGIN_URL__;if(t)return new URL(t).origin;let n=new URL(e);return n.hostname===`localhost`||n.hostname===`127.0.0.1`?`${n.protocol}//${n.hostname}:3000`:`${n.protocol}//manufact.com`}function KL(e){return`${GL(e)}/login`}function qL(e){return`${GL(e)}/auth/embedded-sign-out`}function JL(e,t){return`${PL}:${t}:${e}`}function YL(e){return HL()?.getItem(JL(e,`skip-session`))===`1`}function XL(e,t){let n=JL(e,`skip-session`);t?HL()?.setItem(n,`1`):HL()?.removeItem(n)}function ZL(e){return`${PL}:state:${e}`}function QL(e){let t=HL()?.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return HL()?.removeItem(e),null}}function $L(e,t){HL()?.setItem(e,JSON.stringify(t))}function eR(e,t){LL.set(e,{...LL.get(e)??IL,...t}),RL.forEach(e=>e()),window.dispatchEvent(new CustomEvent(FL))}function tR(e){let t=``;return e.forEach(e=>{t+=String.fromCharCode(e)}),btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function nR(e=32){let t=new Uint8Array(e);return crypto.getRandomValues(t),tR(t)}async function rR(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e));return tR(new Uint8Array(t))}async function iR(e){let t=await fetch(`${e}/api/auth/.well-known/openid-configuration`);if(!t.ok)throw Error(`Manufact OAuth discovery failed`);return await t.json()}function aR(){return`${window.location.origin}${rM()}/auth/callback`}async function oR(e,t){let n=aR(),r=JL(e,`client`),i=QL(r);if(i?.client_id&&i.redirect_uri===n)return i;if(!t.registration_endpoint)throw Error(`Manufact OAuth registration is unavailable`);let a=await fetch(t.registration_endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({client_name:`mcp-use Inspector`,redirect_uris:[n],grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],token_endpoint_auth_method:`none`,scope:NL})});if(!a.ok)throw Error(`Could not register Inspector with Manufact`);let o=await a.json();if(!o.client_id)throw Error(`Manufact returned no OAuth client ID`);let s={...o,redirect_uri:n};return $L(r,s),s}async function sR(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams(t)}),r=await n.json().catch(()=>({}));if(!n.ok||!r.access_token)throw Error(r.error_description??`Manufact token exchange failed`);return{access_token:r.access_token,refresh_token:r.refresh_token,token_type:r.token_type,expires_at:Date.now()+(r.expires_in??3600)*1e3}}async function cR(e,t){if(!t.refresh_token)return null;let n=BL.get(e);if(n)return n;let r=(async()=>{try{let n=await iR(e),r=QL(JL(e,`client`));if(!r?.client_id)return null;let i=await sR(n.token_endpoint,{grant_type:`refresh_token`,refresh_token:t.refresh_token,client_id:r.client_id}),a={...i,refresh_token:i.refresh_token??t.refresh_token};return $L(JL(e,`tokens`),a),a}catch{return HL()?.removeItem(JL(e,`tokens`)),null}finally{BL.delete(e)}})();return BL.set(e,r),r}async function lR(e){let t=QL(JL(e,`tokens`));return t?.access_token?t.expires_at>Date.now()+3e4?t:cR(e,t):null}async function uR(e,t){let n=await iR(e);if(!n.userinfo_endpoint)return null;let r=await fetch(n.userinfo_endpoint,{headers:{Authorization:`Bearer ${t}`}});if(!r.ok)return null;let i=await r.json();return i.sub?{id:i.sub,name:i.name,email:i.email,image:i.picture}:null}async function dR(e){try{let t=await fetch(`${e}/api/auth/get-session`,{credentials:`include`});return t.ok?(await t.json())?.user??null:null}catch{return null}}async function fR(e){let t=zL.get(e);if(t)return t;LL.set(e,{...LL.get(e)??IL,loaded:!1});let n=(async()=>{try{let t=WL(typeof window<`u`?window.location.href:e,e),n=YL(e),r=await lR(e),i=r?await uR(e,r.access_token):null;if(i&&r){XL(e,!1),eR(e,{loaded:!0,accessToken:r.access_token,user:i,mode:`oauth`});return}r&&!i&&HL()?.removeItem(JL(e,`tokens`));let a=t&&!n?await dR(e):null;if(a){eR(e,{loaded:!0,accessToken:null,user:a,mode:`session`});return}eR(e,{loaded:!0,accessToken:null,user:null,mode:null})}catch{eR(e,{loaded:!0,accessToken:null,user:null,mode:null})}})().finally(()=>zL.delete(e));return zL.set(e,n),n}async function pR(e){let t=UL(e);XL(t,!1);let n=window.open(``,`manufact-oauth`,`width=600,height=700,resizable=yes,scrollbars=yes`);if(!n)throw Error(`Allow popups to sign in with Manufact`);if(eR(t,{authorizing:!0}),WL(window.location.href,t)){n.location.href=KL(t);let e=window.setInterval(async()=>{if(n.closed){window.clearInterval(e),eR(t,{authorizing:!1});return}let r=await dR(t);r&&(window.clearInterval(e),n.close(),eR(t,{loaded:!0,authorizing:!1,accessToken:null,user:r,mode:`session`}))},1e3);return}try{let e=await iR(t),r=await oR(t,e),i=nR(64),a=nR(),o=aR();$L(ZL(a),{authOrigin:t,clientId:r.client_id,redirectUri:o,codeVerifier:i,expiresAt:Date.now()+600*1e3});let s=new URL(e.authorization_endpoint);s.searchParams.set(`response_type`,`code`),s.searchParams.set(`client_id`,r.client_id),s.searchParams.set(`redirect_uri`,o),s.searchParams.set(`scope`,NL),s.searchParams.set(`state`,a),s.searchParams.set(`code_challenge`,await rR(i)),s.searchParams.set(`code_challenge_method`,`S256`),s.searchParams.set(`prompt`,`consent`),n.location.href=s.toString();let c=window.setInterval(()=>{n.closed&&(window.clearInterval(c),fR(t).finally(()=>eR(t,{authorizing:!1})))},500)}catch(e){throw n.close(),eR(t,{authorizing:!1}),e}}async function mR(e=new URL(window.location.href)){let t=e.searchParams.get(`state`),n=e.searchParams.get(`code`),r=e.searchParams.get(`error_description`)??e.searchParams.get(`error`);if(r)throw Error(r);if(!t||!n)throw Error(`Missing OAuth code or state`);let i=ZL(t),a=QL(i);if(HL()?.removeItem(i),!a||a.expiresAt<Date.now())throw Error(`OAuth state is invalid or expired`);let o=await sR((await iR(a.authOrigin)).token_endpoint,{grant_type:`authorization_code`,code:n,redirect_uri:a.redirectUri,client_id:a.clientId,code_verifier:a.codeVerifier});$L(JL(a.authOrigin,`tokens`),o),XL(a.authOrigin,!1);let s=await uR(a.authOrigin,o.access_token);eR(a.authOrigin,{loaded:!0,authorizing:!1,accessToken:o.access_token,user:s,mode:`oauth`}),window.opener?.postMessage({type:`manufact:oauth-complete`,authOrigin:a.authOrigin},window.location.origin)}function hR(e){let t=UL(e);HL()?.removeItem(JL(t,`tokens`)),eR(t,{loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null})}async function gR(e){let t=QL(JL(e,`tokens`)),n=QL(JL(e,`client`)),r=t?.refresh_token??t?.access_token;if(!n?.client_id||!r)return null;try{let i=(await iR(e)).revocation_endpoint??`${e}/api/auth/oauth2/revoke`;return(await fetch(i,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({client_id:n.client_id,token:r,token_type_hint:t?.refresh_token?`refresh_token`:`access_token`})})).status}catch{return-1}}async function _R(e){let t=GL(e),n=window.open(qL(e),`manufact-sign-out`,`width=420,height=320`);return n?new Promise(r=>{let i=!1,a=e=>{i||(i=!0,window.clearTimeout(o),window.clearInterval(c),window.removeEventListener(`message`,s),r(e))},o=window.setTimeout(()=>{a({attempted:!0,signOutOk:!1,signOutStatus:null})},3e4),s=e=>{e.origin===t&&e.data?.type===`manufact:sign-out-complete`&&a({attempted:!0,signOutOk:!0,signOutStatus:200})},c=window.setInterval(()=>{n.closed&&dR(e).then(e=>{a({attempted:!0,signOutOk:!e,signOutStatus:e?401:200})})},500);window.addEventListener(`message`,s)}):{attempted:!0,signOutOk:!1,signOutStatus:null}}async function vR(e,t){let n=UL(e),r=!!QL(JL(n,`tokens`))?.access_token;t===`oauth`||r?(await gR(n),XL(n,!0)):t===`session`&&(await _R(n),XL(n,!1)),hR(e)}function yR(e){let t=e?UL(e):null,n=(0,z.useSyncExternalStore)((0,z.useCallback)(e=>(RL.add(e),()=>RL.delete(e)),[]),(0,z.useCallback)(()=>t?VL(t):IL,[t]),()=>IL);return(0,z.useEffect)(()=>{if(!t)return;fR(t);let e=e=>{e.origin===window.location.origin&&e.data?.type===`manufact:oauth-complete`&&e.data.authOrigin===t&&fR(t).finally(()=>eR(t,{authorizing:!1}))},n=e=>{e.key!==JL(t,`tokens`)||!e.newValue||fR(t).finally(()=>eR(t,{authorizing:!1}))};return window.addEventListener(`message`,e),window.addEventListener(`storage`,n),()=>{window.removeEventListener(`message`,e),window.removeEventListener(`storage`,n)}},[t]),{...n,authorize:(0,z.useCallback)(async()=>{e&&await pR(e)},[e]),logout:(0,z.useCallback)(async()=>{e&&await vR(e,n.mode)},[e,n.mode])}}var bR=(0,z.lazy)(()=>tS(()=>import(`./ChatTab-CiAqtqhj.js`).then(e=>({default:e.ChatTab})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))),xR=(0,z.lazy)(()=>tS(()=>import(`./ToolsTab-BHk8GCmd.js`).then(e=>({default:e.ToolsTab})),__vite__mapDeps([21,1,2,3,4,5,7,6,8,9,22,23,24,13,17,18,19,25,26,27,12,28,29,30]))),SR=(0,z.lazy)(()=>tS(()=>import(`./PromptsTab-CA-SZs43.js`).then(e=>({default:e.PromptsTab})),__vite__mapDeps([31,1,2,3,4,5,7,6,8,9,25,27,12,28,29,30,16,18,20]))),CR=(0,z.lazy)(()=>tS(()=>import(`./ResourcesTab-DdMIW_af.js`).then(e=>({default:e.ResourcesTab})),__vite__mapDeps([32,1,2,3,4,5,8,22,7,6,9,23,24,13,17,18,19,33,25,26,27,12,28,29,14]))),wR=(0,z.lazy)(()=>tS(()=>import(`./SamplingTab-DjyDG01W.js`).then(e=>({default:e.SamplingTab})),__vite__mapDeps([34,1,2,3,4,5,7,6,8,9,27,12,28,23,24,13,14,18]))),TR=(0,z.lazy)(()=>tS(()=>import(`./ElicitationTab-B3Eg0_Jm.js`).then(e=>({default:e.ElicitationTab})),__vite__mapDeps([35,1,2,3,4,5,9,27,12,28,23,15,16,18]))),ER=(0,z.lazy)(()=>tS(()=>import(`./NotificationsTab-BgLjxuos.js`).then(e=>({default:e.NotificationsTab})),__vite__mapDeps([36,1,2,3,4,5,33,26,27,12,28,29]))),DR=(0,z.lazy)(()=>tS(()=>import(`./ServerMetadataTab-Q4PlqP_B.js`).then(e=>({default:e.ServerMetadataTab})),__vite__mapDeps([37,1,2,3,4,5,10,8,9,28,12,38]))),OR=(0,z.lazy)(()=>tS(()=>import(`./ConnectionSettingsTab-CTh6MFKE.js`).then(e=>({default:e.ConnectionSettingsTab})),__vite__mapDeps([39,1,2,3,4,5,28,12,38])));function kR({children:e}){return(0,R.jsx)(z.Suspense,{fallback:(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsx)(aL,{className:`size-6`})}),children:e})}var AR=`anthropic/claude-sonnet-4.6`;function jR({isManaged:e,enableFreeTierUpgrade:t,isAuthenticated:n}){return e&&t&&!n}function MR({isLoopback:e,chatApiUrl:t}){return e&&!!t}function NR(e,t,n=!1,r){let i=e.replace(/\/chat\/stream\/?$/,`/llm`);return{provider:`openai-compatible`,model:r??`anthropic/claude-sonnet-4.6`,apiKey:t??`server-managed`,baseUrl:i,...n?{credentials:`include`}:{}}}function PR(e){return e?{Authorization:`Bearer ${e}`}:void 0}var FR=`mcp-inspector:managed-model`;function IR(e){return`${FR}:${e}`}function LR(e){try{return localStorage.getItem(IR(e))}catch{return null}}function RR(e,t,n,r){let i=e?new URL(e).origin:null,[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)(AR),[l,u]=(0,z.useState)(()=>i?LR(i)??`anthropic/claude-sonnet-4.6`:AR),[d,f]=(0,z.useState)(!1),p=(0,z.useCallback)(e=>{if(u(e),i)try{localStorage.setItem(IR(i),e)}catch{}},[i]);return(0,z.useEffect)(()=>{if(!r||!i)return;let e=!1;return f(!0),(async()=>{try{let r=PR(t),a=await fetch(`${i}/api/v1/models`,{headers:r,credentials:n===`session`?`include`:`same-origin`});if(!a.ok)return;let s=await a.json();if(e)return;let l=s.models??[];o(l);let d=s.defaultModelId??`anthropic/claude-sonnet-4.6`;c(d);let f=new Set(l.map(e=>e.id)),p=LR(i);p&&f.has(p)?u(p):f.has(d)?u(d):l[0]&&u(l[0].id)}finally{e||f(!1)}})(),()=>{e=!0}},[r,i,t,n]),{models:a,selectedModelId:l,setSelectedModelId:p,isLoading:d,selectedModel:a.find(e=>e.id===l)??null,defaultModelId:s}}var zR=[`tools`,`prompts`,`resources`,`chat`,`sampling`,`elicitation`,`notifications`,`server-metadata`,`connection-settings`];function BR(e){return zR.includes(e)?e:`tools`}function VR({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:i,onUpdateConnection:a,children:o}){let{embeddedConfig:s}=fL(),c=BR(t),[l,u]=(0,z.useState)(()=>new Set([c]));(0,z.useEffect)(()=>{let e=BR(t);u(t=>t.has(e)?t:new Set(t).add(e))},[t]);let{accessToken:d,mode:f,user:p}=yR(s.chatApiUrl),m=PR(d),h=f===`session`?`include`:void 0,g=p!=null,_=s.chatApiUrl,v=!!e?.url&&oM(e.url),y=e?MR({isLoopback:v,chatApiUrl:s.chatApiUrl,enableFreeTierUpgrade:s.chatEnableFreeTierUpgrade}):!1,b=RR(_,d,f,!!e&&!!_&&g),x=y?NR(_,d,f===`session`,g?b.selectedModelId:void 0):s.managedLlmConfig??(_&&!v?{provider:`anthropic`,model:`claude-haiku-4-5`,apiKey:`server-managed`}:void 0);if(!e&&s.forceConnected)return s.chatApiUrl?(0,R.jsx)(kR,{children:(0,R.jsx)(bR,{connection:{id:`force-connected`,url:``,displayName:``,name:``,state:`ready`,tools:[],prompts:[],resources:[]},isConnected:!0,prompts:[],serverId:`force-connected`,callPrompt:async()=>({messages:[]}),readResource:async()=>({contents:[]}),useClientSide:!1,chatApiUrl:s.chatApiUrl,extraHeaders:m,credentials:h,managedLlmConfig:s.managedLlmConfig??{provider:`anthropic`,model:`claude-haiku-4-5`,apiKey:`server-managed`},enableFreeTierUpgrade:s.chatEnableFreeTierUpgrade,hideTitle:s.chatHideTitle,hideModelBadge:s.chatHideModelBadge??!0,hideServerUrl:s.chatHideServerUrl??!0,clearButtonLabel:s.chatClearButtonLabel,clearButtonHideIcon:s.chatClearButtonHideIcon,clearButtonHideShortcut:s.chatClearButtonHideShortcut,clearButtonVariant:s.chatClearButtonVariant,chatQuickQuestions:s.chatQuickQuestions,chatFollowups:s.chatFollowups,hideClearButton:s.chatHideClearButton,hideToolSelector:s.chatHideToolSelector,enableKeyboardShortcuts:!1},`chat-force-connected`)}):(0,R.jsx)(R.Fragment,{children:o});if(!e)return(0,R.jsx)(R.Fragment,{children:o});let S=e=>s.visibleTabs?s.visibleTabs.includes(e):!0,C=zR;return(0,R.jsxs)(kR,{children:[S(`tools`)&&l.has(`tools`)&&(0,R.jsx)(`div`,{style:{display:t===`tools`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(xR,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state===`ready`,refreshTools:e.refreshTools},`tools-${e.id}`)}),S(`prompts`)&&l.has(`prompts`)&&(0,R.jsx)(`div`,{style:{display:t===`prompts`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(SR,{ref:r,prompts:e.prompts,callPrompt:(t,n)=>e.getPrompt(t,n?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,typeof t==`string`?t:String(t??``)])):void 0),serverId:e.id,isConnected:e.state===`ready`,refreshPrompts:e.refreshPrompts},`prompts-${e.id}`)}),S(`resources`)&&l.has(`resources`)&&(0,R.jsx)(`div`,{style:{display:t===`resources`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(CR,{ref:i,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state===`ready`,mcpServerUrl:e.url||``,refreshResources:e.refreshResources},`resources-${e.id}`)}),S(`chat`)&&l.has(`chat`)&&(0,R.jsx)(`div`,{style:{display:t===`chat`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(bR,{connection:e,isConnected:s.forceConnected||e.state===`ready`,prompts:e.prompts,serverId:e.id,callPrompt:(t,n)=>e.getPrompt(t,n?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,typeof t==`string`?t:String(t??``)])):void 0),readResource:e.readResource,useClientSide:y||!_,chatApiUrl:_,extraHeaders:m,credentials:s.chatCredentials??h,managedLlmConfig:x,managedCloudModel:b,enableFreeTierUpgrade:s.chatEnableFreeTierUpgrade,hideTitle:s.chatHideTitle,hideModelBadge:s.chatHideModelBadge??!1,hideServerUrl:s.chatHideServerUrl??!!_,clearButtonLabel:s.chatClearButtonLabel,clearButtonHideIcon:s.chatClearButtonHideIcon,clearButtonHideShortcut:s.chatClearButtonHideShortcut,clearButtonVariant:s.chatClearButtonVariant,chatQuickQuestions:s.chatQuickQuestions,chatFollowups:s.chatFollowups,hideClearButton:s.chatHideClearButton,hideToolSelector:s.chatHideToolSelector,streamProtocol:s.chatStreamProtocol,managedKeyUnavailable:v&&!_&&!y},`chat-${e.id}`)}),S(`sampling`)&&l.has(`sampling`)&&(0,R.jsx)(`div`,{style:{display:t===`sampling`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(wR,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state===`ready`,mcpServerUrl:e.url??``},`sampling-${e.id}`)}),S(`elicitation`)&&l.has(`elicitation`)&&(0,R.jsx)(`div`,{style:{display:t===`elicitation`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(TR,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state===`ready`},`elicitation-${e.id}`)}),S(`notifications`)&&l.has(`notifications`)&&(0,R.jsx)(`div`,{style:{display:t===`notifications`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(ER,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state===`ready`},`notifications-${e.id}`)}),S(`server-metadata`)&&l.has(`server-metadata`)&&(0,R.jsx)(`div`,{style:{display:t===`server-metadata`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(DR,{connection:e},`server-metadata-${e.id}`)}),S(`connection-settings`)&&l.has(`connection-settings`)&&a&&(0,R.jsx)(`div`,{style:{display:t===`connection-settings`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(OR,{connection:e,onSave:a},`connection-settings-${e.id}`)}),!C.includes(t)&&(0,R.jsx)(R.Fragment,{children:o})]})}var HR=z.createContext(void 0);function UR(){let e=z.use(HR);if(!e)throw Error(`useTabs must be used within a TabsProvider`);return e}var WR=z.createContext(void 0);function GR(){return z.use(WR)}function KR({ref:e,children:t,defaultValue:n,value:r,onValueChange:i,className:a,collapsed:o,onCollapsedChange:s,...c}){let[l,u]=z.useState(n||``),d=r!==void 0,f=o!==void 0,[p,m]=z.useState(!1),h=z.useCallback(e=>{d||u(e),i?.(e)},[d,i]);return(0,R.jsx)(HR,{value:{activeValue:d?r:l,handleValueChange:h,collapsed:f?o:p,handleCollapsedChange:z.useCallback(e=>{f||m(e),s?.(e)},[f,s])},children:(0,R.jsx)(`div`,{ref:e,className:A(`flex flex-col gap-2`,a),...c,children:t})})}KR.displayName=`Tabs`;function qR({ref:e,children:t,className:n,variant:r=`default`,collapsible:i=!1,...a}){let{activeValue:o,collapsed:s,handleCollapsedChange:c}=UR(),[l,u]=z.useState({width:0,left:0}),d=z.useRef(null),f=z.useRef(null),p=z.useRef(null),m=z.useCallback(()=>{let e=d.current;if(!e)return;let t=e.querySelector(`div:first-child`);if(!t)return;let n=t.querySelector(`button[data-tab-value="${o}"]`);if(n&&o){let e=t.getBoundingClientRect(),r=n.getBoundingClientRect();u({width:r.width,left:r.left-e.left})}else u({width:0,left:0})},[o]),h=z.useCallback(()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(m,16)},[m]);z.useEffect(()=>{let e=setTimeout(m,10);return()=>clearTimeout(e)},[m,s]),z.useEffect(()=>{let e=d.current;if(!e)return;f.current=new ResizeObserver(()=>{h()}),f.current.observe(e);let t=e.querySelector(`div:first-child`);return t&&t.querySelectorAll(`button[data-tab-value]`).forEach(e=>{f.current&&f.current.observe(e)}),()=>{f.current&&f.current.disconnect(),p.current&&clearTimeout(p.current)}},[h]),z.useEffect(()=>{let e=()=>{h()};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[h]);let g=z.useRef(null);return z.useEffect(()=>{g.current&&(g.current.style.width=`${l.width}px`,g.current.style.left=`${l.left}px`)},[l]),(0,R.jsx)(WR,{value:{variant:r,collapsed:s,handleCollapsedChange:c},children:(0,R.jsx)(`div`,{ref:d,className:A(`relative flex items-center bg-none gap-1`,r==="default"&&`p-1 rounded-full border border-zinc-300 dark:border-zinc-600`,r===`underline`&&`border-b border-zinc-200 dark:border-zinc-700`,n),...a,children:(0,R.jsxs)(`div`,{role:`tablist`,className:`flex-1 flex items-center relative`,children:[t,(0,R.jsx)(`span`,{ref:g,className:A(`absolute transition-all duration-[250ms] ease-in-out z-0`,r==="default"&&`bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600`,r===`underline`&&`bottom-0 h-0.5 bg-black dark:bg-white`)})]})})})}qR.displayName=`TabsList`;var JR=({children:e,title:t,collapsed:n})=>!t||!n?e:(0,R.jsx)(nt,{children:(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`span`,{className:`contents`,children:e}),nativeButton:!1}),(0,R.jsx)(Et,{children:t})]})}),YR=z.forwardRef(({children:e,value:t,className:n,disabled:r,icon:i,title:a,showDot:o=!1,alwaysExpanded:s=!1,badge:c,...l},u)=>{let{activeValue:d,handleValueChange:f,collapsed:p}=UR(),m=GR()?.variant||`default`,h=d===t,g=!p||h||s;return(0,R.jsx)(JR,{title:a,collapsed:p&&!g,children:(0,R.jsxs)(`button`,{ref:u,disabled:r,onClick:()=>f(t),"data-tab-value":t,"data-tab-active":h,role:`tab`,"aria-selected":h?`true`:`false`,title:p&&!g&&a?a:void 0,className:A(`relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-all duration-[250ms] ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer`,m==="default"&&`py-2.5`,m==="default"&&`rounded-md px-4`,m===`underline`&&`px-6 py-3 border-b-2 border-transparent`,h&&`text-foreground`,!h&&`text-muted-foreground hover:text-foreground`,n),...l,children:[i&&(0,R.jsx)(i,{className:A(`h-4 w-4 shrink-0 transition-all duration-[250ms] ease-in-out`,g&&`mr-2`,!g&&`mr-0!`)}),o&&(0,R.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-orange-500 dark:bg-orange-400 border-2 border-white dark:border-zinc-900 rounded-full transition-opacity duration-300 z-10 animate-status-pulse-orange`}),(0,R.jsx)(`span`,{className:A(`min-w-0 transition-all duration-[250ms] ease-in-out overflow-hidden`,g?`w-auto opacity-100`:`w-0 opacity-0`),children:e}),c]})})});YR.displayName=`TabsTrigger`;function XR(e){return yR(e)}var ZR=z.createContext(void 0);function QR(){let e=z.useContext(ZR);if(e===void 0)throw Error(Ve(13));return e}var $R={imageLoadingStatus:()=>null},ez=z.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=z.useState(`idle`),c={imageLoadingStatus:o},l=z.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=We(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:$R});return(0,R.jsx)(ZR.Provider,{value:l,children:u})});function tz(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i}){let[a,o]=z.useState(`idle`);return be(()=>{if(!e&&!i)return o(`error`),mt;let a=!0,s=new window.Image,c=e=>()=>{a&&o(e)};return o(`loading`),s.onload=c(`loaded`),s.onerror=c(`error`),t&&(s.referrerPolicy=t),s.crossOrigin=n??null,r&&(s.sizes=r),i&&(s.srcset=i),e&&(s.src=e),s.complete&&o(s.naturalWidth>0?`loaded`:`error`),()=>{a=!1}},[e,i,r,n,t]),a}var nz={...$R,...bt},rz=z.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,style:a,...o}=e,{setImageLoadingStatus:s}=QR(),c=tz(o.src,o),l=c===`loaded`,{mounted:u,transitionStatus:d,setMounted:f}=lt(l),p=z.useRef(null),h=m(e=>{i?.(e),s(e)});be(()=>{c!==`idle`&&h(c)},[c,h]),be(()=>()=>s(`idle`),[s]),x({open:l,ref:p,onComplete(){l||f(!1)}});let g=We(`img`,e,{state:{imageLoadingStatus:c,transitionStatus:d},ref:[t,p],props:o,stateAttributesMapping:nz,enabled:u});return u?g:null}),iz=z.forwardRef(function(e,t){let{className:n,render:r,delay:i,style:a,...o}=e,{imageLoadingStatus:s}=QR(),[c,l]=z.useState(i===void 0),u=Se();return z.useEffect(()=>(i===void 0?l(!0):u.start(i,()=>l(!0)),u.clear),[u,i]),We(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:$R,enabled:s!==`loaded`&&(i===void 0||c)})});function az({className:e,size:t=`default`,...n}){return(0,R.jsx)(ez,{"data-slot":`avatar`,"data-size":t,className:A(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,e),...n})}function oz({className:e,...t}){return(0,R.jsx)(rz,{"data-slot":`avatar-image`,className:A(`aspect-square size-full rounded-full object-cover`,e),...t})}function sz({className:e,...t}){return(0,R.jsx)(iz,{"data-slot":`avatar-fallback`,className:A(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}function cz(e,t){return e?.[0]?e[0].toUpperCase():t?.[0]?t[0].toUpperCase():`U`}function lz({chatApiUrl:e,dashboardUrl:t=`https://manufact.com/cloud`,fallback:n=null,onUserResolved:r}){let{user:i,loaded:a,authorizing:o,authorize:s,logout:c,mode:l}=XR(e),u=(0,z.useRef)(void 0);if((0,z.useEffect)(()=>{if(!a)return;let e=i?.id??null;u.current!==e&&(u.current=e,r?.(i))},[a,i,r]),!a)return null;if(!i)return(0,R.jsxs)(R.Fragment,{children:[n,(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`rounded-full px-4 text-[13px]`,disabled:o,onClick:()=>{s().catch(e=>GF.error(e instanceof Error?e.message:`Authorization failed`))},children:o?`Authorizing…`:`Sign in`})]});let d=cz(i.name,i.email),f=i.name??i.email??`User`;return(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,R.jsx)(jt,{variant:`ghost`,className:`relative h-8 w-8 shrink-0 rounded-full p-0 mr-2`,"aria-label":`User menu`,children:(0,R.jsxs)(az,{className:`h-8 w-8 border border-zinc-300 dark:border-zinc-600`,children:[(0,R.jsx)(oz,{src:i.image??``,alt:f}),(0,R.jsx)(sz,{className:`text-sm`,children:d})]})}),nativeButton:!0}),(0,R.jsxs)(Ya,{className:`w-56`,align:`end`,forceMount:!0,children:[(0,R.jsx)(Xa,{className:`font-normal`,children:(0,R.jsxs)(`div`,{className:`flex flex-col space-y-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium leading-none truncate`,children:f}),i.email&&i.email!==f&&(0,R.jsx)(`p`,{className:`text-xs leading-none text-muted-foreground truncate`,children:i.email})]})}),(0,R.jsx)(eo,{}),(0,R.jsx)(Za,{render:(0,R.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:[(0,R.jsx)(ci,{className:`mr-2 h-4 w-4`}),`Go to dashboard`]})}),(0,R.jsx)(eo,{}),(0,R.jsxs)(Za,{onClick:()=>{c().catch(()=>GF.error(`Sign out failed`))},children:[(0,R.jsx)(mi,{className:`mr-2 h-4 w-4`}),l===`session`?`Sign out of Manufact`:`Disconnect Inspector`]})]})]})}function uz({count:e,isActive:t,size:n=`md`}){return e<=0?null:(0,R.jsx)(`span`,{className:A(t?`dark:bg-black`:`dark:bg-zinc-700`,`shrink-0 ml-1 bg-zinc-200 text-zinc-700 dark:text-zinc-300 rounded-full font-medium`,n===`sm`&&`text-[10px] px-1.5 py-0.5`,n===`md`&&`text-xs px-2 py-0.5`),children:e})}var dz=`flex h-10 items-center gap-2`;function fz({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,vsCodeInsiders:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:r=``,onSuccess:i,onError:a,trigger:o}){let[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(!1),{url:p,name:m,headers:h}=e,g=e=>{try{ET(new Do({client:e})).catch(()=>{})}catch{}},_=()=>{g(`cursor`);try{let e=yL(p,m,h);window.location.href=e,i?.(`Cursor`)}catch(e){console.error(`Failed to generate Cursor deep link:`,e),a?.(e)}},v=()=>{g(`vscode`);try{let e=bL(p,m,h);window.location.href=e,i?.(`VS Code`)}catch(e){console.error(`Failed to generate VS Code deep link:`,e),a?.(e)}},y=()=>{g(`vscode-insiders`);try{let e=xL(p,m,h);window.location.href=e,i?.(`VS Code Insiders`)}catch(e){console.error(`Failed to generate VS Code Insiders deep link:`,e),a?.(e)}},b=()=>{g(`claude-desktop`);try{CL(p,m,h),i?.(`Claude Desktop`)}catch(e){console.error(`Failed to download .mcpb file:`,e),a?.(e)}},x=()=>{g(`claude-code`),u(`claude-code`),c(!0)},S=()=>{g(`gemini-cli`),u(`gemini-cli`),c(!0)},C=()=>{g(`codex-cli`),u(`codex-cli`),c(!0)},w=async e=>{try{await Qj(e),f(!0),setTimeout(()=>f(!1),2e3)}catch(e){console.error(`Failed to copy:`,e),a?.(e)}},T=()=>{if(l===`claude-code`){let{command:e,envVars:t}=wL(p,m,h),n=DL(t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(XI,{children:[(0,R.jsx)(eL,{children:`Add to Claude Code`}),(0,R.jsx)(tL,{children:`Execute the following command in your shell to add this server to Claude Code.`})]}),(0,R.jsxs)(ZI,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,R.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,R.jsx)(`span`,{children:`Ensure the Claude Code executable is available in your path`})]}),(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,R.jsx)(`span`,{children:`Execute the following snippet in your shell:`})]})]})]}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>w(e),children:d?(0,R.jsx)(Fr,{className:`size-3.5 text-green-600`}):(0,R.jsx)(Wr,{className:`size-3.5`})})}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:e})})]}),n&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Environment Variables`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:`After installation, set these environment variables in your shell:`}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:n})})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The MCP configuration supports environment variable expansion using `,(0,R.jsx)(`code`,{className:`text-foreground`,children:"${VAR}"}),` `,`syntax.`]})]})]})}if(l===`gemini-cli`){let{command:e,envVars:t}=TL(p,m,h),n=DL(t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(XI,{children:[(0,R.jsx)(eL,{children:`Add to Gemini CLI`}),(0,R.jsx)(tL,{children:`Execute the following command in your shell to add this server to Gemini CLI.`})]}),(0,R.jsxs)(ZI,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,R.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,R.jsx)(`span`,{children:`Ensure the Gemini CLI executable is available in your path`})]}),n&&(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,R.jsx)(`span`,{children:`Set these environment variables in your shell before running the command:`})]}),(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:n?`3.`:`2.`}),(0,R.jsx)(`span`,{children:`Execute the following snippet in your shell:`})]})]})]}),n&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Environment Variables`}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:n})})]}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>w(e),children:d?(0,R.jsx)(Fr,{className:`size-3.5 text-green-600`}):(0,R.jsx)(Wr,{className:`size-3.5`})})}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:e})})]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Restart Gemini CLI to load the new configuration.`})]})]})}if(l===`codex-cli`){let{config:e,envVars:t}=EL(p,m,h);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(XI,{children:[(0,R.jsx)(eL,{children:`Add to Codex CLI`}),(0,R.jsxs)(tL,{children:[`Add this configuration to your`,` `,(0,R.jsx)(`code`,{className:`text-foreground`,children:`~/.codex/config.toml`}),` `,`file.`]})]}),(0,R.jsxs)(ZI,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Add this configuration to your`,` `,(0,R.jsx)(`code`,{className:`text-foreground`,children:`~/.codex/config.toml`}),`:`]})]}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>w(e),children:d?(0,R.jsx)(Fr,{className:`size-3.5 text-green-600`}):(0,R.jsx)(Wr,{className:`size-3.5`})})}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:e})})]}),t.length>0&&(0,R.jsx)(`div`,{children:(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`(optional) If you would rather use variables from your system's environment, replace the`,` `,(0,R.jsx)(`code`,{className:`text-foreground`,children:`http_headers`}),` key with the `,(0,R.jsx)(`code`,{className:`text-foreground`,children:`env_http_headers`}),` `,`key as shown in the commented section above.`]})}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Restart Codex CLI to load the new configuration.`})]})]})}return null},ee=(0,R.jsxs)(jt,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${r}`,children:[(0,R.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,R.jsx)(ki,{className:`size-3`}),`Client`]}),(0,R.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,R.jsx)(Ir,{className:`size-3`})]})]}),E=o?typeof o==`function`?o({isOpen:!1,onClick:()=>{}}):o:ee;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,z.isValidElement)(E)?E:ee,nativeButton:!0}),(0,R.jsxs)(Ya,{align:`end`,className:`w-auto min-w-[300px]`,children:[t.map(e=>(0,R.jsxs)(Za,{onClick:async()=>{await e.onClick()},className:dz,children:[e.icon,(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:e.label})]},e.id)),t.length>0&&(0,R.jsx)(eo,{}),n.cursor&&(0,R.jsxs)(Za,{onClick:_,className:dz,children:[(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/cursor`,alt:`Cursor`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Cursor`})]}),n.claudeCode&&(0,R.jsxs)(Za,{onClick:x,className:dz,children:[(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Claude Code`})]}),n.claudeDesktop&&(0,R.jsxs)(Za,{onClick:b,className:dz,children:[(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Claude Desktop`})]}),n.vsCode&&(0,R.jsxs)(Za,{onClick:v,className:dz,children:[(0,R.jsx)(kL,{className:`h-4 w-4 text-blue-500`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`VS Code`})]}),n.vsCodeInsiders&&(0,R.jsxs)(Za,{onClick:y,className:dz,children:[(0,R.jsx)(kL,{className:`h-4 w-4 text-teal-400`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`VS Code Insiders`})]}),n.geminiCli&&(0,R.jsxs)(Za,{onClick:S,className:dz,children:[(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/googlegemini`,alt:`Gemini`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Gemini CLI`})]}),n.codexCli&&(0,R.jsxs)(Za,{onClick:C,className:dz,children:[(0,R.jsx)(`img`,{src:`https://inspector-cdn.mcp-use.com/providers/openai.png`,alt:`Codex`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Codex CLI`})]})]})]}),(0,R.jsx)(qI,{open:s,onOpenChange:c,children:(0,R.jsx)(YI,{scrollable:!0,className:`max-w-3xl max-h-[80vh]`,children:T()})})]})}function pz({className:e,state:t=`collapsed`,to:n=`/`,showLabel:r=t===`expanded`,pinSymbolInIconColumn:i=!1,size:a}){let[o,s]=(0,z.useState)(!1),c=1.5,l=.2/c,u=.8999999999999999/c,d=t===`expanded`&&r,f=a??(i?20:t===`expanded`?40:20),p=(0,R.jsx)(`div`,{className:`relative`,children:(0,R.jsxs)(qe.svg,{viewBox:`0 0 500 500`,initial:`rest`,animate:o?`hover`:`rest`,className:`text-foreground`,style:{width:f,height:f},children:[(0,R.jsxs)(qe.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:c,times:[0,l,u,1],ease:`easeInOut`}}},fill:`currentColor`,fillRule:`nonzero`,stroke:`currentColor`,strokeWidth:4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`path`,{d:`M105.933 0C164.437 0.000116002 211.865 47.607 211.865 106.333C211.865 131.829 210.493 158.403 221.068 181.602L228.975 198.947C243.584 230.997 269.265 256.7 301.303 271.336L316.155 278.121C340.142 289.079 367.694 287.335 394.066 287.335C452.571 287.335 499.999 334.942 499.999 393.668C499.999 452.394 452.571 500.001 394.066 500.001C335.562 500.001 288.134 452.394 288.134 393.668C288.134 368.974 289.24 343.275 278.992 320.807L270.586 302.38C255.948 270.29 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.86252e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z`}),(0,R.jsx)(`circle`,{cx:`100.426`,cy:`399.575`,r:`100.426`}),(0,R.jsx)(`path`,{d:`M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z`})]}),(0,R.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(mz,{d:`M105.933 0C164.437 0.000116002 211.865 47.607 211.865 106.333C211.865 131.829 210.493 158.403 221.068 181.602L228.975 198.947C243.584 230.997 269.265 256.7 301.303 271.336L316.155 278.121C340.142 289.079 367.694 287.335 394.066 287.335C452.571 287.335 499.999 334.942 499.999 393.668C499.999 452.394 452.571 500.001 394.066 500.001C335.562 500.001 288.134 452.394 288.134 393.668C288.134 368.974 289.24 343.275 278.992 320.807L270.586 302.38C255.948 270.29 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.86252e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z`,times:{T0:0,T1:l,T2:u,T3:1},total:c}),(0,R.jsx)(hz,{cx:100.426,cy:399.575,r:100.426,times:{T0:0,T1:l,T2:u,T3:1},total:c}),(0,R.jsx)(mz,{d:`M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z`,times:{T0:0,T1:l,T2:u,T3:1},total:c})]})]})}),m=r?(0,R.jsxs)(`span`,{className:A(`font-ubuntu flex items-center gap-2 whitespace-nowrap`,i?A(`pl-(--sidebar-nav-text-pl-absolute)`,d?`relative opacity-100 blur-0`:`pointer-events-none absolute left-0 top-1/2 w-0 -translate-y-1/2 overflow-hidden opacity-0 blur-[3px]`):`mr-3`),children:[(0,R.jsx)(`span`,{className:`text-xl font-bold leading-none text-foreground [text-box:trim-both_cap_alphabetic]`,children:`mcp-use`}),(0,R.jsx)(`span`,{className:`text-lg font-sans font-light leading-none tracking-wide text-muted-foreground [text-box:trim-both_cap_alphabetic]`,children:`Inspector`})]}):null,h=i?(0,R.jsxs)(`div`,{className:A(`relative flex shrink-0 items-center`,d?`min-w-(--sidebar-width-icon)`:`w-(--sidebar-width-icon)`),children:[(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-0 flex w-(--sidebar-width-icon) items-center justify-center`,children:(0,R.jsx)(`div`,{className:`pointer-events-auto`,children:p})}),m]}):(0,R.jsxs)(R.Fragment,{children:[p,m]});return(0,R.jsx)(fF,{to:n,className:A(`flex items-center transition-opacity`,!i&&`-my-3`,e),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:h})}function mz({d:e,times:t,total:n}){let{T0:r,T1:i,T2:a,T3:o}=t;return(0,R.jsx)(qe.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,i,a,o],ease:`easeInOut`}}}})}function hz({cx:e,cy:t,r:n,times:r,total:i}){let{T0:a,T1:o,T2:s,T3:c}=r;return(0,R.jsx)(qe.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:i,times:[a,o,s,c],ease:`easeInOut`}}}})}var gz=(0,z.createContext)(void 0);function _z(){let e=(0,z.use)(gz);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e}function vz({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,forcedTheme:r}){let[i,a]=(0,z.useState)(r||t),[o,s]=(0,z.useState)(!1),c=()=>typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,l=i===`system`?c():i,u=e=>{let t=document.documentElement,i=e===`system`?c():e;t.classList.remove(`light`,`dark`),t.classList.add(i),r||localStorage.setItem(n,e)};return(0,z.useEffect)(()=>{s(!0);let e=localStorage.getItem(n),i=r||e||t;a(i),u(i)},[t,n,r]),(0,z.useEffect)(()=>{if(i!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>{u(`system`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[i]),(0,z.useEffect)(()=>{o&&u(i)},[i,o]),(0,R.jsx)(gz,{value:{theme:i,setTheme:e=>{if(r){console.warn(`[ThemeProvider] Theme is forced via URL parameter, ignoring setTheme call`);return}a(e)},resolvedTheme:l},children:e})}function yz({ref:e,shimmerColor:t,shimmerSize:n=`0.05em`,shimmerDuration:r=`3s`,borderRadius:i=`100px`,background:a,className:o,children:s,...c}){let{theme:l}=_z();return(0,R.jsxs)(`button`,{style:{"--spread":`90deg`,"--shimmer-color":t||(l===`dark`?`#000000`:`#ffffff`),"--radius":i,"--speed":r,"--cut":n,"--bg":a||(l===`dark`?`rgba(255, 255, 255, 1)`:`rgba(0, 0, 0, 1)`)},className:A(`group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]`,`transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px`,`dark:text-white text-black dark:border-white/10 border-black/10`,o),ref:e,...c,children:[(0,R.jsx)(`div`,{className:A(`-z-30 blur-[2px]`,`@container-[size] absolute inset-0 overflow-visible`),children:(0,R.jsx)(`div`,{className:`animate-shimmer-slide absolute inset-0 aspect-[1] h-[100cqh] rounded-none mask-none`,children:(0,R.jsx)(`div`,{className:`animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]`})})}),s,(0,R.jsx)(`div`,{className:A(`absolute inset-0 size-full`,`rounded-2xl px-4 py-1.5 text-sm font-medium`,`transform-gpu transition-all duration-300 ease-in-out`,`dark:shadow-[inset_0_-8px_10px_#0000001f] dark:group-hover:shadow-[inset_0_-6px_10px_#0000003f] dark:group-active:shadow-[inset_0_-10px_10px_#0000003f] shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]`)}),(0,R.jsx)(`div`,{className:A(`absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] bg-black dark:bg-white`)})]})}yz.displayName=`ShimmerButton`;function bz(e){switch(e){case`ready`:return`bg-emerald-600 animate-status-pulse`;case`failed`:return`bg-rose-600 animate-status-pulse-red`;default:return`bg-yellow-500 animate-status-pulse-yellow`}}function xz(e){switch(e){case`ready`:return`Connected`;case`failed`:return`Failed`;default:return e}}function Sz({status:e,className:t}){return(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`div`,{className:A(`w-2 h-2 rounded-full shrink-0`,bz(e),t)}),nativeButton:!1}),(0,R.jsx)(Et,{children:(0,R.jsx)(`p`,{children:xz(e)})})]})}var Cz=`h-6 px-2 text-xs bg-yellow-500/20 border-0 dark:bg-yellow-400/10 text-yellow-800 dark:text-yellow-500 shrink-0`;function wz(e){try{sessionStorage.setItem(sI,JSON.stringify({url:e.url,name:e.name||`Auto-connected Server`,transportType:e.transportType||`http`,connectionMode:`auto`}))}catch{}}function Tz({server:e,className:t}){let{state:n,authUrl:r,authenticate:i}=e;return n!==`pending_auth`&&n!==`authenticating`?null:n===`authenticating`?(0,R.jsxs)(jt,{size:`sm`,variant:`outline`,disabled:!0,className:A(Cz,t),children:[(0,R.jsx)(di,{className:`h-3 w-3 animate-spin mr-1`}),`Authenticating`]}):i?(0,R.jsx)(jt,{"data-testid":`server-header-authenticate`,size:`sm`,variant:`outline`,className:A(Cz,t),onClick:t=>{t.stopPropagation(),wz(e),i()},children:`Authenticate`}):r?(0,R.jsx)(jt,{size:`sm`,variant:`outline`,className:A(Cz,t),render:(0,R.jsx)(`a`,{href:r,"data-testid":`server-header-authenticate`,onClick:t=>{t.stopPropagation(),wz(e)}}),nativeButton:!1,children:`Authenticate`}):null}function Ez({connections:e,selectedServer:t,onServerSelect:n,mobileMode:r=!1,variant:i=`default`}){let a=KN(),o=t=>{e.some(e=>e.id===t)&&n(t)},s=(0,R.jsxs)(Ya,{className:`w-[calc(100vw-2rem)] sm:w-[300px]`,align:`start`,children:[(0,R.jsx)(Xa,{className:`cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:()=>a(`/`),children:`MCP Servers`}),(0,R.jsx)(eo,{}),e.length===0?(0,R.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center`,children:`No servers connected. Go to the dashboard to add one.`}):e.map(e=>(0,R.jsxs)(Za,{onClick:()=>o(e.id),className:`flex items-center gap-3`,children:[(0,R.jsx)(oL,{server:e,size:`sm`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:lM(e)}),(0,R.jsx)(Sz,{status:e.state})]})]},e.id)),(0,R.jsx)(eo,{}),(0,R.jsx)(Za,{onClick:()=>a(`/`),children:(0,R.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:`+ Add new server`})})]});return r?(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,R.jsx)(`div`,{className:`relative`,children:(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,R.jsxs)(jt,{variant:`ghost`,className:`h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5`,children:[t?(0,R.jsx)(oL,{server:t,size:`md`}):(0,R.jsx)(Ni,{className:`h-5 w-5`}),(0,R.jsx)(Ir,{className:`h-4 w-4`})]}),nativeButton:!0}),s]})})}):i===`header`?(0,R.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,R.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-2 min-w-0 border-0 bg-transparent p-0 cursor-pointer text-foreground transition-opacity hover:opacity-80`,children:[t&&(0,R.jsx)(oL,{server:t,size:`sm`,className:`!size-5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate text-sm leading-none [text-box:trim-both_cap_alphabetic]`,children:t?lM(t):`Select server`}),t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Sz,{status:t.state}),(0,R.jsx)(Tz,{server:t})]}),(0,R.jsx)(Ir,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),nativeButton:!0}),s]})}):(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,R.jsx)(`div`,{className:`relative`,children:(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,R.jsxs)(yz,{className:A(`min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200`,!t&&`pl-4`),children:[t&&(0,R.jsx)(oL,{server:t,size:`md`,className:`mr-2`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,R.jsx)(`span`,{className:`truncate lg:max-w-[120px] xl:max-w-none`,children:t?lM(t):`Select server to inspect`}),t&&(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:t.error&&t.state!==`ready`?(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`button`,{onClick:e=>{e.stopPropagation()},className:`w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors`,title:`Click to copy error message`,"aria-label":`Copy error message to clipboard`}),nativeButton:!0}),(0,R.jsx)(Et,{children:(0,R.jsx)(`p`,{className:`max-w-xs`,children:t.error})})]}):(0,R.jsx)(`div`,{className:`w-2 h-2 rounded-full ${t.state===`ready`?`bg-emerald-600 animate-status-pulse`:t.state===`failed`?`bg-rose-600 animate-status-pulse-red`:`bg-yellow-500 animate-status-pulse-yellow`}`})})]})]}),nativeButton:!0}),s]})})})}function Dz(e){if(!e)return null;try{let t=new URL(e);if(t.protocol===`https:`)return t.origin}catch{}return null}function Oz(e,t){return e===`tools`?t.tools.length:e===`prompts`?t.prompts.length:e===`resources`?t.resources.length:e===`sampling`?t.pendingSamplingRequests?.length||0:e===`elicitation`?t.pendingElicitationRequests?.length||0:e===`notifications`?t.unreadNotificationCount:0}function kz(e,t,n){return n&&t>0&&[`sampling`,`elicitation`,`notifications`].includes(e)}var Az=[{id:`server-metadata`,label:`Server Metadata`,icon:si},{id:`separator`},{id:`chat`,label:`Chat`,icon:_i,alwaysExpanded:!0},{id:`separator`},{id:`tools`,label:`Tools`,icon:qi},{id:`prompts`,label:`Prompts`,icon:vi},{id:`resources`,label:`Resources`,icon:$r},{id:`sampling`,label:`Sampling`,icon:ti},{id:`elicitation`,label:`Elicitation`,icon:Li},{id:`notifications`,label:`Notifications`,icon:Mr},{id:`separator`},{id:`connection-settings`,label:`Connection Settings`,icon:Pi}],jz=z.createContext(void 0);function Mz(e){let t=z.useContext(jz);if(t===void 0&&!e)throw Error(Ve(47));return t}function Nz(){return{...kt(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}var Pz={...ze,disabled:Vt(e=>e.disabled),instantType:Vt(e=>e.instantType),openMethod:Vt(e=>e.openMethod),openChangeReason:Vt(e=>e.openChangeReason),modal:Vt(e=>e.modal),focusManagerModal:Vt(e=>e.focusManagerModal),stickIfOpen:Vt(e=>e.stickIfOpen),titleElementId:Vt(e=>e.titleElementId),descriptionElementId:Vt(e=>e.descriptionElementId),openOnHover:Vt(e=>e.openOnHover),closeDelay:Vt(e=>e.closeDelay),hasViewport:Vt(e=>e.hasViewport)},Fz=class e extends Kt{constructor(e,t,n=!1){let r={...Nz(),...e},i=new xt;r.open&&e?.mounted===void 0&&(r.mounted=!0),r.floatingRootContext=at(i,t,n),super(r,{popupRef:z.createRef(),backdropRef:z.createRef(),internalBackdropRef:z.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:z.createRef(),beforeContentFocusGuardRef:z.createRef(),stickIfOpenTimeout:new zt,triggerElements:i},Pz)}setOpen=(e,t)=>{let n=t.reason===c,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=Ue(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};Ft(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),br.flushSync(s)):s(),r||i?this.set(`instantType`,r?`click`:`dismiss`):t.reason===`focus-out`?this.set(`instantType`,`focus`):this.set(`instantType`,void 0)};static useStore(t,n){let{store:r,internalStore:i}=Qe(t,(t,r)=>new e(n,t,r));return z.useEffect(()=>i?.disposeEffect(),[i]),r}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()};function Iz({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=Fz.useStore(s?.store,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});Ye(u,n,r,l),u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`),m=st()!=null;u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),tt(u,d),Ge(u);let{forceUnmount:h}=Ct(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o,nested:m}),z.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]);let g=z.useCallback(()=>{u.setOpen(!1,ae(De))},[u]);z.useImperativeHandle(e.actionsRef,()=>({unmount:h,close:g}),[h,g]);let _=d||f,v=z.useMemo(()=>({store:u}),[u]);return(0,R.jsxs)(jz.Provider,{value:v,children:[_&&(0,R.jsx)(Rz,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})}function Lz(e){return Mz(!0)?(0,R.jsx)(Iz,{props:e}):(0,R.jsx)(dt,{children:(0,R.jsx)(Iz,{props:e})})}function Rz({store:e,modal:t}){let n=y(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}});return ht(e,{activeTriggerProps:n.reference??St,inactiveTriggerProps:n.trigger??St,popupProps:z.useMemo(()=>Ut(Mt,n.floating),[n.floating])}),null}var zz=z.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:c,payload:l,openOnHover:u=!1,delay:d=300,closeDelay:f=0,id:p,...m}=e,h=Mz(!0),g=c?.store??h?.store;if(!g)throw Error(Ve(74));let _=N(p),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=z.useRef(null),{registerTrigger:C,isMountedByThisTrigger:w}=Fe(_,S,g,{payload:l,disabled:a,openOnHover:u,closeDelay:f}),T=g.useState(`openChangeReason`),ee=g.useState(`stickIfOpen`),E=g.useState(`openMethod`),D=g.useState(`focusManagerModal`),ne=s(y,{enabled:!a&&y!=null&&u&&(E!==`touch`||T!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:he(),restMs:d,delay:{close:f},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),O=Sn(y,{enabled:y!=null,stickIfOpen:ee}),re=dn(()=>g.select(`open`),e=>{g.set(`openMethod`,e)}),k=g.useState(`triggerProps`,w),{getButtonProps:ie,buttonRef:A}=Pe({disabled:a,native:o}),j={open(e){return e&&T===`trigger-press`?it.open(e):Re.open(e)}},{preFocusGuardRef:M,handlePreFocusGuardFocus:ae,handleFocusTargetFocus:oe}=xr(g,S),se=We(`button`,e,{state:{disabled:a,open:b},ref:[A,t,C,S],props:[O.reference,ne,k,re,{[te]:``,id:_,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},m,ie],stateAttributesMapping:j});return w&&!D?(0,R.jsxs)(z.Fragment,{children:[(0,R.jsx)(Dt,{ref:M,onFocus:ae}),(0,R.jsx)(z.Fragment,{children:se},_),(0,R.jsx)(Dt,{ref:g.context.triggerFocusTargetRef,onFocus:oe})]}):(0,R.jsx)(z.Fragment,{children:se},_)}),Bz=z.createContext(void 0);function Vz(){let e=z.useContext(Bz);if(e===void 0)throw Error(Ve(45));return e}var Hz=z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=Mz();return i.useState(`mounted`)||n?(0,R.jsx)(Bz.Provider,{value:n,children:(0,R.jsx)(me,{ref:t,...r})}):null}),Uz=z.createContext(void 0);function Wz(){let e=z.useContext(Uz);if(!e)throw Error(Ve(46));return e}var Gz=z.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o=`absolute`,side:s=`bottom`,align:c=`center`,sideOffset:l=0,alignOffset:u=0,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p=5,arrowPadding:m=5,sticky:h=!1,disableAnchorTracking:g=!1,collisionAvoidance:v=ve,...y}=e,{store:b}=Mz(),x=Vz(),S=d(),C=b.useState(`floatingRootContext`),w=b.useState(`mounted`),T=b.useState(`open`),ee=b.useState(`openChangeReason`),E=b.useState(`activeTriggerElement`),D=b.useState(`modal`),te=b.useState(`openMethod`),O=b.useState(`positionerElement`),re=b.useState(`instantType`),k=b.useState(`transitionStatus`),ie=b.useState(`hasViewport`),A=z.useRef(null),j=_(O,!1,!1),M=ne({anchor:a,floatingRootContext:C,positionMethod:o,mounted:w,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:h,disableAnchorTracking:g,keepMounted:x,nodeId:S,collisionAvoidance:v,adaptiveOrigin:ie?ke:void 0}),ae=C.useState(`domReferenceElement`);be(()=>{let e=ae,t=A.current;if(e&&(A.current=e),t&&e&&e!==t){b.set(`instantType`,void 0);let e=new AbortController;return j(()=>{b.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[ae,j,b]),an(T&&D===!0&&ee!==`trigger-hover`,te===`touch`,O,E);let oe=z.useCallback(e=>{b.set(`positionerElement`,e)},[b]),se=wt(e,{open:T,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:re},{styles:M.positionerStyles,transitionStatus:k,props:y,refs:[t,oe],hidden:!w,inert:!T});return(0,R.jsxs)(Uz.Provider,{value:M,children:[w&&D===!0&&ee!==`trigger-hover`&&(0,R.jsx)(wn,{ref:b.context.internalBackdropRef,inert:sn(!T),cutout:E}),(0,R.jsx)(ue,{id:S,children:se})]})}),Kz=z.createContext(void 0);function qz(){let[e,t]=z.useState(0),n=m(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:z.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}function Jz(e){let{value:t,children:n}=e;return(0,R.jsx)(Kz.Provider,{value:t,children:n})}var Yz={...Ot,...bt},Xz=z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,{store:c}=Mz(),l=Wz(),u=Cn(!0)!=null,{context:d,hasClosePart:f}=qz(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),S=c.useState(`mounted`),C=c.useState(`openChangeReason`),w=c.useState(`activeTriggerElement`),T=c.useState(`floatingRootContext`),ee=T.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),te=c.useState(`closeDelay`),ne=s.id??ee;x({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Ke(T,{enabled:D&&!E,closeDelay:te});let O=a===void 0?ft(c.context.popupRef):a,re=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,re);let k=z.useCallback(e=>{c.set(`popupElement`,e)},[c]),ie=We(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,k],props:[_,{id:ne,role:`dialog`,...Mt,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Qt.has(e.key)&&e.stopPropagation()}},je(g),s],stateAttributesMapping:Yz});return(0,R.jsx)(rn,{context:T,openInteractionType:m,modal:re,disabled:!S||C===`trigger-hover`,initialFocus:O,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:ut(w)?w:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,R.jsx)(Jz,{value:d,children:ie})})});function Zz({...e}){return(0,R.jsx)(Lz,{"data-slot":`popover`,...e})}function Qz(e){return(0,R.jsx)(zz,{"data-slot":`popover-trigger`,...e})}function $z({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,R.jsx)(Hz,{children:(0,R.jsx)(Gz,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,R.jsx)(Xz,{"data-slot":`popover-content`,className:A(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}var eB={success:`border-emerald-700/20 bg-emerald-700/10 text-emerald-700 dark:border-emerald-400/30 dark:bg-emerald-400/10 dark:text-emerald-400`,failed:`border-red-500/20 bg-red-500/10 text-red-500 dark:border-red-400/30 dark:bg-red-400/10 dark:text-red-400`,warning:`border-amber-700/20 bg-amber-700/10 text-amber-700 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-400`,loading:`border-purple-500/20 bg-purple-500/10 text-purple-500 dark:border-purple-400/30 dark:bg-purple-400/10 dark:text-purple-400 animate-spin`},tB=`size-4 shrink-0 rounded-full border p-0.5`;function nB({state:e,className:t}){let n=A(tB,eB[e],t);switch(e){case`success`:return(0,R.jsx)(Fr,{className:n,"aria-hidden":!0});case`failed`:return(0,R.jsx)(zr,{className:n,"aria-hidden":!0});case`warning`:return(0,R.jsx)(Wi,{className:n,"aria-hidden":!0});case`loading`:return(0,R.jsx)(di,{className:n,"aria-hidden":!0});default:return null}}function rB(){return`text-emerald-700 dark:text-emerald-400`}function iB({onStop:e,showCopiedBanner:t=!1}){return(0,R.jsxs)(R.Fragment,{children:[t&&(0,R.jsxs)(`div`,{className:A(`flex items-center gap-2 text-sm -mt-1`,rB()),children:[(0,R.jsx)(nB,{state:`success`}),(0,R.jsx)(`span`,{children:`URL copied to clipboard`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`h4`,{className:`font-semibold text-sm`,children:`Tunnel URL`}),(0,R.jsxs)(`a`,{href:`https://manufact.com/docs/tunneling`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[`Docs`,(0,R.jsx)(Ar,{className:`size-3`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Use in ChatGPT & Claude`}),(0,R.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,R.jsxs)(`span`,{children:[`Enable`,` `,(0,R.jsx)(`a`,{href:`https://chatgpt.com/plugins#settings/Security`,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline underline-offset-2 hover:text-purple-600 dark:hover:text-purple-400`,children:`dev mode`}),` `,`from settings`]})]}),(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`a`,{href:`https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins`,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline underline-offset-2 hover:text-purple-600 dark:hover:text-purple-400`,children:`Add a connector`}),` `,`in App & Connectors`]})]}),(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`3.`}),(0,R.jsx)(`span`,{children:`Use the tunnel URL in the input`})]})]})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void e(),className:`flex items-center gap-1.5 text-xs text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors cursor-pointer`,children:[(0,R.jsx)(zi,{className:`size-3 fill-current`}),`Stop Tunnel`]})]})}function aB(e){try{let t=new URL(e),n=t.pathname+t.search;return t.host+(n&&n!==`/`?n:``)}catch{return e}}function oB({copied:e,onCopy:t,className:n}){return(0,R.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t()},"aria-label":e?`URL copied`:`Copy URL`,className:A(`shrink-0 p-0.5 rounded-sm text-muted-foreground hover:text-foreground transition-opacity opacity-0 group-hover:opacity-100`,n),children:e?(0,R.jsx)(nB,{state:`success`,className:`size-3.5`}):(0,R.jsx)(Wr,{className:`size-3.5`})})}function sB({url:e,className:t,tunnelPopover:n}){let[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(!1);if(!e)return null;let s=aB(e),c=n?.mcpUrl??e,l=!!n,u=async()=>{try{await Qj(c),i(!0),setTimeout(()=>i(!1),2e3)}catch{GF.error(`Failed to copy URL`)}};(0,z.useEffect)(()=>{if(!n?.autoCopyOnOpen){o(!1);return}o(!0),i(!0);let e=setTimeout(()=>i(!1),2e3);return()=>clearTimeout(e)},[n?.autoCopyOnOpen]);let d=(0,R.jsxs)(R.Fragment,{children:[l?(0,R.jsx)(Lr,{className:`size-3.5 shrink-0`}):(0,R.jsx)(ei,{className:`size-3.5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate max-w-[min(24rem,30vw)]`,children:s})]}),f=A(`flex items-center gap-1 min-w-0 truncate text-left text-sm cursor-pointer`,l?`text-purple-600 dark:text-purple-400`:`text-blue-500`);return(0,R.jsxs)(`div`,{className:A(`group flex items-center gap-1.5 min-w-0`,t),children:[l?(0,R.jsxs)(Zz,{open:n.open,onOpenChange:n.onOpenChange,children:[(0,R.jsx)(Qz,{render:(0,R.jsx)(`button`,{type:`button`,className:A(f,`hover:opacity-80`),children:d}),nativeButton:!0}),(0,R.jsx)($z,{className:`w-[calc(100vw-2rem)] sm:w-96`,align:`start`,sideOffset:4,children:(0,R.jsx)(iB,{showCopiedBanner:a,onStop:async()=>{n.onOpenChange(!1),await n.onStop()}})})]}):(0,R.jsx)(`span`,{className:f,children:d}),(0,R.jsx)(oB,{copied:r,onCopy:()=>void u()})]})}function cB({devFromCli:e,isTunnelStarting:t,waitTicks:n,onStart:r}){if(t)return(0,R.jsxs)(`button`,{disabled:!0,className:`flex items-center gap-2 h-8 px-3 bg-violet-50 dark:bg-violet-950/40 border border-violet-200 dark:border-violet-800 rounded-full opacity-75 cursor-wait shrink-0`,children:[(0,R.jsx)(di,{className:`size-4 text-violet-500 dark:text-violet-400 animate-spin`}),(0,R.jsxs)(`span`,{className:`text-sm font-medium text-violet-600 dark:text-violet-300 hidden lg:inline`,children:[`Start Tunnel `,(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[n,`s`]})]})]});let i=e===!0,a=e===null;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void r(),disabled:!i||a,title:e===!1?"Run `mcp-use dev` from your project to enable tunneling.":a?`Checking dev server…`:void 0,className:A(`flex items-center gap-2 h-8 px-3 border rounded-full transition-colors shrink-0`,i&&!a?`bg-violet-50 dark:bg-violet-950/40 border-violet-200 dark:border-violet-800 hover:bg-violet-100 dark:hover:bg-violet-900/50 cursor-pointer`:`bg-violet-50/60 dark:bg-violet-950/20 border-violet-200 dark:border-violet-800 cursor-not-allowed opacity-70`),children:[a?(0,R.jsx)(di,{className:`size-4 text-violet-500 dark:text-violet-400 animate-spin`}):(0,R.jsx)(Lr,{className:`size-4 text-violet-500 dark:text-violet-400`}),(0,R.jsx)(`span`,{className:`text-sm font-medium text-violet-600 dark:text-violet-300 hidden lg:inline`,children:`Start Tunnel`})]})}async function lB(){try{let e=await fetch(iM(`dev/info`));return e.ok?await e.json():null}catch{return null}}function uB({tunnelUrl:e,setTunnelUrl:t,isTunnelStarting:n,setIsTunnelStarting:r,onTunnelStarted:i}){let[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(0),d=(0,z.useCallback)((e,n)=>{let r=n?.syncTunnel??!1;if(o(!!e.fromCli),e.mcpUrl&&c(e.mcpUrl),!r)return;if(e.tunnelUrl){t(new URL(e.tunnelUrl).origin);return}let i=Dz(e.mcpUrl??null);if(i){t(i);return}t(null)},[t]);return(0,z.useEffect)(()=>{if(!n){u(20);return}u(20);let e=setInterval(()=>u(e=>e>0?e-1:0),1e3);return()=>clearInterval(e)},[n]),(0,z.useEffect)(()=>{let e=!1;return(async()=>{let t=await lB();e||(t?d(t,{syncTunnel:!0}):o(!1))})(),()=>{e=!0}},[d]),{devFromCli:a,mcpUrl:s,waitTicks:l,handleStartTunnel:(0,z.useCallback)(async()=>{if(a===!1){GF.error("Start Tunnel requires `mcp-use dev` from your project directory.");return}r(!0);let e=!1;try{let t=await fetch(iM(`dev/start-tunnel`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));GF.error(e.error||`Failed to start tunnel`);return}let n=await lB();if(n?.tunnelUrl||n?.mcpUrl){d(n,{syncTunnel:!0});let e=n.mcpUrl??(n.tunnelUrl?`${n.tunnelUrl.replace(/\/+$/,``)}/mcp`:null);e&&Zj(e),i?.()}e=!0}catch{GF.error(`Failed to start tunnel`)}finally{r(!1)}try{ET(new Co({action:`start`,success:e})).catch(()=>{})}catch{}},[d,a,i,r]),handleStopTunnel:(0,z.useCallback)(async()=>{r(!0);let n=!1;try{let e=await fetch(iM(`dev/stop-tunnel`),{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));GF.error(t.error||`Failed to stop tunnel`);return}t(null),c(null),GF.success(`Tunnel stopped`),n=!0}catch{GF.error(`Failed to stop tunnel`)}finally{r(!1)}try{ET(new Co({action:`stop`,success:n,tunnelUrl:e})).catch(()=>{})}catch{}},[r,t,e])}}function dB(e){let t=window.matchMedia(`(min-width: 1024px)`);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function fB(){return window.matchMedia(`(min-width: 1024px)`).matches}function pB(){return!0}function mB(){return(0,z.useSyncExternalStore)(dB,fB,pB)}function hB(e){let[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(!1),a=mB(),o=(0,z.useCallback)(()=>{n(!0),i(!0)},[]);return(0,z.useEffect)(()=>{e||(n(!1),i(!1))},[e]),(0,z.useEffect)(()=>{if(!e)return;let t=new URLSearchParams(window.location.search);if(!t.has(`openTunnelPopover`))return;n(!0),i(!0),t.delete(`openTunnelPopover`);let r=t.toString();window.history.replaceState({},``,`${window.location.pathname}${r?`?${r}`:``}`)},[e]),{open:t,onOpenChange:(0,z.useCallback)(e=>{n(e),e||i(!1)},[]),isLgUp:a,autoCopyOnOpen:r,openWithAutoCopy:o}}function gB({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:i,embedded:a=!1,sidebarCollapsed:o=!1}){let{tunnelUrl:s,isTunnelStarting:c,setTunnelUrl:l,setIsTunnelStarting:u,embeddedConfig:d}=fL(),[f,p]=(0,z.useState)(!1),[m]=(0,z.useState)(!0),h=hB(s),g=uB({tunnelUrl:s,setTunnelUrl:l,isTunnelStarting:c,setIsTunnelStarting:u,onTunnelStarted:h.openWithAutoCopy});if(d.singleTab)return null;let _=d.visibleTabs?Az.filter(e=>e.id===`separator`||d.visibleTabs.includes(e.id)):Az,v=!!t,y=!!t&&(oM(t.url??``)||sM(t.url??``)||!!s),b=t?s?`${s.replace(/\/+$/,``)}${nM()}`:t.url??``:``,x=g.mcpUrl??(s?`${s.replace(/\/+$/,``)}${nM()}`:null),S=(e,n)=>{if(!t||!b)return null;let r=e===`desktop`?h.isLgUp:!h.isLgUp;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(sB,{url:b,className:n,tunnelPopover:s&&x&&r?{mcpUrl:x,onStop:g.handleStopTunnel,open:h.open,onOpenChange:h.onOpenChange,autoCopyOnOpen:h.autoCopyOnOpen}:void 0}),y&&!s&&(0,R.jsx)(cB,{devFromCli:g.devFromCli,isTunnelStarting:c,waitTicks:g.waitTicks,onStart:g.handleStartTunnel})]})},C=()=>a?null:(0,R.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 flex-shrink-0`,children:[t&&(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(fz,{serverConfig:{url:b,name:lM(t),headers:_M(t),serverId:t.id},onSuccess:e=>GF.success(`Opening in ${e}...`),onError:e=>GF.error(`Failed: ${e.message}`),trigger:(0,R.jsxs)(jt,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center`,"aria-label":`Add to Client`,children:[(0,R.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,R.jsx)(ki,{className:`size-3`}),`Client`]}),(0,R.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,R.jsx)(Ir,{className:`size-3`})]})]})})}),(0,R.jsx)(`a`,{href:f?`https://manufact.com/cloud?ref=mcp-use-inspector`:`https://manufact.com/signup?ref=mcp-use-inspector`,target:`_blank`,rel:`noopener noreferrer`,onClick:()=>{try{ET(new wo({referrer:`mcp-use-inspector`})).catch(()=>{})}catch{}},className:`inline-flex h-8 items-center justify-center rounded-full border border-blue-500/25 bg-blue-500/10 px-4 text-[13px] text-blue-500 outline-none cursor-pointer transition-colors hover:bg-blue-500/15 dark:border-blue-400/30 dark:bg-blue-400/10 dark:text-blue-400 dark:hover:bg-blue-400/15 focus-visible:ring-1 focus-visible:ring-ring`,children:(0,R.jsx)(`span`,{className:`[text-box:trim-both_cap_alphabetic]`,children:`Deploy`})}),d.chatApiUrl?(0,R.jsx)(lz,{chatApiUrl:d.chatApiUrl,onUserResolved:e=>p(!!e)}):null]});return(0,R.jsxs)(`header`,{className:`w-full shrink-0`,children:[(0,R.jsxs)(`div`,{className:`hidden lg:flex h-(--header-height) items-center justify-between gap-3 px-4 md:pl-0 md:pr-6`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:A(`hidden lg:block shrink-0`,v&&o&&`-mr-[calc(var(--sidebar-width-icon)/2-0.625rem)]`),children:(0,R.jsx)(pz,{pinSymbolInIconColumn:!0,showLabel:!v||!o,state:v&&o?`collapsed`:`expanded`})}),(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground/60 shrink-0 [text-box:trim-both_cap_alphabetic]`,children:`/`}),(0,R.jsx)(Ez,{connections:e,selectedServer:t,onServerSelect:r,variant:`header`}),S(`desktop`)]})}),C()]}),(0,R.jsxs)(`div`,{className:`flex lg:hidden flex-col gap-3`,children:[(0,R.jsx)(`div`,{className:`flex items-center justify-between w-full`,children:!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`flex-1 flex justify-start`,children:(0,R.jsx)(Ez,{connections:e,selectedServer:t,onServerSelect:r,mobileMode:!0})}),(0,R.jsx)(`div`,{className:`flex-shrink-0 flex justify-center`,children:(0,R.jsx)(pz,{state:`collapsed`,showLabel:!0})}),(0,R.jsx)(`div`,{className:`flex-1 flex justify-end`,children:C()})]})}),t&&b&&!a&&(0,R.jsx)(`div`,{className:`flex items-center gap-2 px-1 min-w-0`,children:S(`mobile`,`min-w-0`)}),t&&(0,R.jsx)(`div`,{className:`w-full lg:hidden`,children:(0,R.jsx)(KR,{value:n,onValueChange:e=>i(e),collapsed:m,children:(0,R.jsx)(qR,{className:`w-full justify-center border-0 bg-transparent p-0`,children:_.map((e,r)=>{if(e.id===`separator`)return(0,R.jsx)(`div`,{className:`h-5 w-px bg-zinc-300 dark:bg-zinc-600 mx-1 shrink-0`},`separator-${r}`);let i=Oz(e.id,t),a=kz(e.id,i,m);return(0,R.jsx)(YR,{value:e.id,"data-testid":`tab-${e.id}`,icon:e.icon,showDot:a,badge:(0,R.jsx)(uz,{count:i,isActive:n===e.id,size:`sm`}),alwaysExpanded:`alwaysExpanded`in e&&e.alwaysExpanded,className:A(`[&>svg]:mr-0 flex-1 flex-row gap-2 relative`,m&&`pl-2`),children:(0,R.jsx)(`span`,{className:`sr-only`,children:e.label})},e.id)})})})})]})]})}function _B({collapsed:e,onToggle:t}){let n=e?`Expand sidebar`:`Collapse sidebar`;return(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsxs)(jt,{type:`button`,variant:`ghost`,size:`icon-sm`,tabIndex:-1,"aria-label":n,onClick:t,className:A(`border-border absolute top-1/2 right-0 z-30 hidden size-7 min-h-7 min-w-7 -translate-y-1/2 translate-x-1/2 rounded-full border bg-background lg:flex`,`opacity-0 transition-opacity duration-200 group-hover/sidebar:opacity-100 focus-visible:opacity-100`),children:[(0,R.jsx)(Ci,{className:`size-4`}),(0,R.jsx)(`span`,{className:`sr-only`,children:n})]}),nativeButton:!0}),(0,R.jsx)(Et,{side:`right`,children:n})]})}function vB({className:e}){return(0,R.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentcolor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,children:[(0,R.jsx)(`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`}),(0,R.jsx)(`path`,{d:`M9 18c-4.51 2-5-2-7-2`})]})}var yB=z.createContext(void 0);function bB(){let e=z.useContext(yB);if(e===void 0)throw Error(Ve(63));return e}var xB=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),SB={...Tn,checked(e){return e?{[xB.checked]:``}:{[xB.unchecked]:``}}};function CB(e,t,n,r=!0,i){let[a,o]=z.useState(),s=N(i?`${i}-label`:void 0),c=e??t??a;return be(()=>{let i=e||t||!r?void 0:wB(n.current,s);a!==i&&o(i)}),c}function wB(e,t){let n=TB(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function TB(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}var EB=z.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:_,style:y,...b}=e,{clearErrors:x}=An(),{state:S,setTouched:C,setDirty:w,validityData:T,setFilled:ee,setFocused:E,validationMode:D,disabled:te,name:ne,validation:O}=On(),{labelId:re}=kn(),k=te||m,ie=ne??l,A=z.useRef(null),j=Ze(A,c,O.inputRef),M=z.useRef(null),oe=N(),se=cn({id:s,implicit:!1,controlRef:M}),P=u?void 0:se,[ce,le]=Yt({controlled:n,default:!!i,name:`Switch`,state:`checked`});En(M,oe,ce,void 0,!k,l),be(()=>{A.current&&ee(A.current.checked)},[A,ee]),Dn(ce,()=>{x(ie),w(ce!==T.initialValue),ee(ce),O.change(ce)});let{getButtonProps:ue,buttonRef:de}=Pe({disabled:k,native:u}),fe=CB(a,re,A,!u,P),pe={id:u?se:oe,role:`switch`,"aria-checked":ce,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":fe,onFocus(){k||E(!0)},onBlur(){let e=A.current;!e||k||(C(!0),E(!1),D===`onBlur`&&O.commit(e.checked))},onClick(e){if(f||k)return;e.preventDefault();let t=A.current;t&&t.dispatchEvent(new(v(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))}},me=Ut({checked:ce,disabled:k,form:o,id:P,name:ie,required:p,style:ie?Le:rt,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:j,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=ae(Ae,e.nativeEvent);d?.(t,n),!n.isCanceled&&le(t)},onFocus(){M.current?.focus()}},e=>O.getValidationProps(k,e),_===void 0?St:{value:_}),he=z.useMemo(()=>({...S,checked:ce,disabled:k,readOnly:f,required:p}),[S,ce,k,f,p]),ge=We(`span`,e,{state:he,ref:[t,M,de],props:[pe,b,ue,e=>O.getValidationProps(k,e)],stateAttributesMapping:SB});return(0,R.jsxs)(yB.Provider,{value:he,children:[ge,!ce&&ie&&g!==void 0&&(0,R.jsx)(`input`,{type:`hidden`,form:o,name:ie,value:g,disabled:k}),(0,R.jsx)(`input`,{...me,suppressHydrationWarning:!0})]})}),DB=z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return We(`span`,e,{state:bB(),ref:t,stateAttributesMapping:SB,props:a})}),OB=34,kB=20,AB=16,jB=2,MB=4,NB=2;function PB(e){return`label`in e&&typeof e.label==`string`}var FB=(0,z.forwardRef)(({label:e,checked:t,onToggle:n,disabled:r=!1,thumbTransition:i,uncheckedTrackColor:a,uncheckedTrackColorHovered:o,className:s,...c},l)=>{let u=(0,z.useId)(),d=(0,z.useRef)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(!1),g=(0,z.useRef)(!1),_=(0,z.useRef)(!1),v=(0,z.useRef)(null),y=na(t?16:jB);(0,z.useEffect)(()=>{d.current=!0},[]);let b=m?20:f?18:AB,x=m?AB-MB:AB,S=m?4:jB,C=b-AB,w=t?16-C:jB;(0,z.useEffect)(()=>{g.current||(d.current?Da(y,w,i??At.moderate):y.set(w))},[w,y,i]);let T=(0,z.useCallback)(e=>{r||e.pointerType===`mouse`&&e.button!==0||(h(!0),g.current=!1,_.current=!1,v.current={clientX:e.clientX,originX:y.get()},e.currentTarget.setPointerCapture(e.pointerId))},[r,y]),ee=(0,z.useCallback)(e=>{if(!v.current)return;let t=e.clientX-v.current.clientX;if(!g.current){if(Math.abs(t)<NB)return;g.current=!0}let n=jB,r=OB-jB-20,i=v.current.originX+t;y.set(Math.max(n,Math.min(r,i)))},[y]),E=(0,z.useCallback)(e=>{v.current&&=(h(!1),g.current&&(_.current=!0,g.current=!1,e&&(y.get()>14/2===t?Da(y,t?16:jB,i??At.moderate):n()),requestAnimationFrame(()=>{_.current=!1})),null)},[t,n,y,i]);return(0,R.jsxs)(`div`,{ref:l,className:A(`relative z-10 flex items-center gap-2.5 px-3 py-2 cursor-pointer select-none touch-none`,r&&`opacity-50 pointer-events-none`,s),onPointerEnter:e=>{e.pointerType===`mouse`&&p(!0)},onPointerLeave:()=>p(!1),onPointerDown:T,onPointerMove:ee,onPointerUp:()=>E(!0),onPointerCancel:()=>{v.current&&=(h(!1),g.current&&(g.current=!1,Da(y,t?16:jB,i??At.moderate)),null)},onClick:()=>{r||_.current||n()},...c,children:[(0,R.jsx)(EB,{checked:t,"aria-labelledby":u,onCheckedChange:()=>{_.current||n()},disabled:r,tabIndex:0,className:A(`relative shrink-0 rounded-full outline-none cursor-pointer`,`transition-colors duration-80`,`focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)] focus-visible:ring-offset-2 focus-visible:ring-offset-background`),style:{width:OB,height:kB,backgroundColor:t?f?`color-mix(in oklab, var(--primary) 88%, black)`:`var(--primary)`:f?o??`color-mix(in oklab, var(--accent), rgb(var(--overlay)) 10%)`:a??`var(--accent)`},onClick:e=>e.stopPropagation(),children:(0,R.jsx)(DB,{render:e=>{let{style:t,onDrag:n,onDragStart:r,onDragEnd:a,onAnimationStart:o,onAnimationEnd:s,onAnimationIteration:c,...l}=e;return(0,R.jsx)(qe.span,{...l,className:`absolute top-0 left-0 block rounded-full bg-white shadow-sm`,initial:!1,style:{...t,x:y},animate:{y:S,width:b,height:x},transition:d.current?i??At.moderate:{duration:0}})}})}),(0,R.jsx)(`span`,{id:u,className:A(`text-[13px] [text-box:trim-both_cap_alphabetic] transition-[color] duration-80`,t?`text-foreground`:`text-muted-foreground`),children:e})]})});FB.displayName=`FluidSwitch`;var IB=(0,z.forwardRef)(({checked:e,defaultChecked:t=!1,onCheckedChange:n,disabled:r=!1,className:i},a)=>{let[o,s]=(0,z.useState)(t),c=e??o;return(0,R.jsx)(EB,{ref:a,checked:c,disabled:r,onCheckedChange:t=>{e===void 0&&s(t),n?.(t)},className:A(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-colors duration-80`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]`,`disabled:cursor-not-allowed disabled:opacity-50`,`data-checked:bg-primary data-unchecked:bg-input`,i),children:(0,R.jsx)(DB,{className:A(`pointer-events-none block size-4 rounded-full bg-background shadow-sm ring-0 transition-transform duration-80`,`data-checked:translate-x-4 data-unchecked:translate-x-0`)})})});IB.displayName=`ShadcnSwitch`;var LB=(0,z.forwardRef)((e,t)=>PB(e)?(0,R.jsx)(FB,{ref:t,...e}):(0,R.jsx)(IB,{ref:t,...e}));LB.displayName=`Switch`;function RB({className:e}){return(0,R.jsx)(`svg`,{viewBox:`0 -28.5 256 256`,className:e,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":!0,children:(0,R.jsx)(`path`,{d:`M216.856339,16.5966031 C200.285002,8.84328665 182.566144,3.2084988 164.041564,0 C161.766523,4.11318106 159.108624,9.64549908 157.276099,14.0464379 C137.583995,11.0849896 118.072967,11.0849896 98.7430163,14.0464379 C96.9108417,9.64549908 94.1925838,4.11318106 91.8971895,0 C73.3526068,3.2084988 55.6133949,8.86399117 39.0420583,16.6376612 C5.61752293,67.146514 -3.4433191,116.400813 1.08711069,164.955721 C23.2560196,181.510915 44.7403634,191.567697 65.8621325,198.148576 C71.0772151,190.971126 75.7283628,183.341335 79.7352139,175.300261 C72.104019,172.400575 64.7949724,168.822202 57.8887866,164.667963 C59.7209612,163.310589 61.5131304,161.891452 63.2445898,160.431257 C105.36741,180.133187 151.134928,180.133187 192.754523,160.431257 C194.506336,161.891452 196.298154,163.310589 198.110326,164.667963 C191.183787,168.842556 183.854737,172.420929 176.223542,175.320965 C180.230393,183.341335 184.861538,190.991831 190.096624,198.16893 C211.238746,191.588051 232.743023,181.531619 254.911949,164.955721 C260.227747,108.668201 245.831087,59.8662432 216.856339,16.5966031 Z M85.4738752,135.09489 C72.8290281,135.09489 62.4592217,123.290155 62.4592217,108.914901 C62.4592217,94.5396472 72.607595,82.7145587 85.4738752,82.7145587 C98.3405064,82.7145587 108.709962,94.5189427 108.488529,108.914901 C108.508531,123.290155 98.3405064,135.09489 85.4738752,135.09489 Z M170.525237,135.09489 C157.88039,135.09489 147.510584,123.290155 147.510584,108.914901 C147.510584,94.5396472 157.658606,82.7145587 170.525237,82.7145587 C183.391518,82.7145587 193.761324,94.5189427 193.539891,108.914901 C193.539891,123.290155 183.391518,135.09489 170.525237,135.09489 Z`,fillRule:`nonzero`})})}var zB=`flex size-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,BB=`color-mix(in oklab, var(--sidebar-foreground) 22%, var(--sidebar))`,VB=`color-mix(in oklab, var(--sidebar-foreground) 30%, var(--sidebar))`,HB=`data-unchecked:!bg-zinc-300 dark:data-unchecked:!bg-zinc-600`;function UB({collapsed:e,rpcLoggerOpen:t,onRpcLoggerOpenChange:n,onCommandPaletteOpen:r}){let{embeddedConfig:i}=fL(),{theme:a,setTheme:o}=_z(),{user:s}=XR(i.chatApiUrl),c=s?`https://manufact.com/cloud?ref=mcp-use-inspector`:`https://manufact.com/signup?ref=mcp-use-inspector`,l=()=>{try{ET(new wo({referrer:`mcp-use-inspector-sidebar`})).catch(()=>{})}catch{}};return(0,R.jsx)(`footer`,{className:`mt-auto shrink-0`,children:(0,R.jsxs)(`div`,{className:A(`flex flex-col`,e?`items-center gap-2 px-2 py-3`:`gap-3 px-(--sidebar-nav-inset-x) py-4`),children:[e?(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`div`,{className:`flex size-8 items-center justify-center`,children:(0,R.jsx)(LB,{checked:t,onCheckedChange:n,"aria-label":`RPC Panel`,className:A(`scale-75`,HB)})}),nativeButton:!1}),(0,R.jsx)(Et,{side:`right`,children:`RPC Panel`})]}):(0,R.jsx)(LB,{label:`RPC Panel`,checked:t,onToggle:()=>n(!t),uncheckedTrackColor:BB,uncheckedTrackColorHovered:VB,className:`w-full flex-row-reverse justify-between`}),e?(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,onClick:l,className:zB,"aria-label":`Deploying your MCP Server? Try manufact.com`,children:(0,R.jsx)(Ar,{className:`size-4`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:`right`,children:`Deploying your MCP Server? Try manufact.com`})]}):(0,R.jsxs)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,onClick:l,className:`relative block rounded-xl border border-sidebar-border bg-white p-3 transition-colors hover:bg-sidebar-accent/50 dark:bg-black`,children:[(0,R.jsx)(Ar,{className:`absolute top-2.5 right-2.5 size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,R.jsx)(`p`,{className:`pr-5 text-xs leading-snug text-muted-foreground`,children:`Deploying your MCP Server?`}),(0,R.jsxs)(`p`,{className:`mt-0.5 text-xs leading-snug`,children:[`Try`,` `,(0,R.jsx)(`span`,{className:`font-medium underline underline-offset-2`,children:`manufact.com`})]})]}),(0,R.jsxs)(`div`,{className:A(`flex`,e?`flex-col items-center gap-1`:`flex-row items-center gap-2`),children:[(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`a`,{href:`https://github.com/mcp-use/mcp-use`,target:`_blank`,rel:`noopener noreferrer`,className:zB,"aria-label":`GitHub`,children:(0,R.jsx)(vB,{className:`size-4`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:e?`right`:`top`,children:`GitHub`})]}),(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`a`,{href:`https://discord.gg/XkNkSkMz3V`,target:`_blank`,rel:`noopener noreferrer`,className:zB,"aria-label":`Discord`,children:(0,R.jsx)(RB,{className:`size-4`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:e?`right`:`top`,children:`Discord`})]}),(0,R.jsxs)(qa,{children:[(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(Ja,{render:(0,R.jsx)(`button`,{type:`button`,className:zB,"aria-label":`Theme`,children:a===`light`?(0,R.jsx)(Vi,{className:`size-4`}):a===`dark`?(0,R.jsx)(bi,{className:`size-4`}):(0,R.jsx)(yi,{className:`size-4`})}),nativeButton:!0}),nativeButton:!0}),(0,R.jsx)(Et,{side:e?`right`:`top`,children:`Theme`})]}),(0,R.jsx)(Ya,{side:e?`right`:`top`,align:e?`start`:`center`,className:`w-40`,children:(0,R.jsxs)(Qa,{value:a,onValueChange:e=>o(e),children:[(0,R.jsxs)($a,{value:`light`,children:[(0,R.jsx)(Vi,{className:`size-4 mr-2`}),`Light`]}),(0,R.jsxs)($a,{value:`dark`,children:[(0,R.jsx)(bi,{className:`size-4 mr-2`}),`Dark`]}),(0,R.jsxs)($a,{value:`system`,children:[(0,R.jsx)(yi,{className:`size-4 mr-2`}),`System`]})]})})]}),(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`button`,{type:`button`,onClick:r,className:zB,"aria-label":`Command Palette`,"data-testid":`command-palette-trigger-button`,children:(0,R.jsx)(Ur,{className:`size-4`})}),nativeButton:!0}),(0,R.jsxs)(Et,{side:e?`right`:`top`,children:[`Command Palette (`,`⌘`,`K)`]})]})]})]})})}function WB(e,t){let n=0,r=0,i=e;for(;i&&i!==t;)n+=i.offsetTop,r+=i.offsetLeft,i=i.offsetParent;if(i!==t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return{top:r.top-n.top,left:r.left-n.left,width:r.width,height:r.height}}return{top:n,left:r,width:e.offsetWidth,height:e.offsetHeight}}function GB(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.top!==i.top||n.left!==i.left||n.width!==i.width||n.height!==i.height)return!1}return!0}function KB(e,t={}){let{axis:n=`y`}=t,r=(0,z.useRef)(new Map),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)({}),c=(0,z.useRef)({}),l=(0,z.useRef)(0),u=(0,z.useRef)(null),d=(0,z.useRef)(null),f=(0,z.useCallback)(()=>{let t=e.current;if(!t)return;let n={};r.current.forEach((e,r)=>{n[r]=WB(e,t)}),!GB(c.current,n)&&(c.current=n,s(n))},[e]),p=(0,z.useCallback)((e,t)=>{t?r.current.set(e,t):r.current.delete(e),d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null,f()})},[f]),m=(0,z.useCallback)(t=>{let r=t.clientX,i=t.clientY;u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null;let t=e.current;if(!t)return;let o=t.getBoundingClientRect(),s=n===`x`?r:i,l=null,d=1/0,f=null,p=c.current,m=n===`x`?t.scrollLeft:t.scrollTop,h=n===`x`?t.clientLeft:t.clientTop,g=n===`x`?o.left:o.top,_=n===`x`?t.offsetWidth:t.offsetHeight,v=n===`x`?o.width:o.height,y=_>0?v/_:1;for(let[e,t]of Object.entries(p)){let r=g+(h+(n===`x`?t.left:t.top)-m)*y,i=(n===`x`?t.width:t.height)*y,a=r+i;s>=r&&s<=a&&(f=e);let o=r+i/2,c=Math.abs(s-o);c<d&&(d=c,l=e)}a(f??l)})},[n,e]),h=(0,z.useCallback)(()=>{l.current+=1},[]),g=(0,z.useCallback)(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),a(null)},[]);return(0,z.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>{d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null,f()})});return n.observe(t),()=>n.disconnect()},[e,f]),(0,z.useEffect)(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),d.current!==null&&cancelAnimationFrame(d.current)},[]),{activeKey:i,itemRects:o,sessionRef:l,handlers:{onMouseMove:m,onMouseEnter:h,onMouseLeave:g},registerItem:p,measureItems:f}}function qB(e){if(!e)return{left:0,right:0};let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--sidebar-nav-pill-bleed`))||0,r=Number.parseFloat(t.getPropertyValue(`--sidebar-nav-scrollbar-width`))||0,i=Number.parseFloat(t.getPropertyValue(`--sidebar-nav-pill-outer-trim-right`))||0;return{left:n,right:n+r+i}}function JB(e,t){return{...e,left:e.left-t.left,width:e.width+t.left+t.right}}var YB=(0,z.createContext)(null);function XB(){let e=(0,z.useContext)(YB),t=(0,z.useRef)(e?.registerItem);t.current=e?.registerItem;let n=(0,z.useRef)(new Map);return(0,z.useCallback)(e=>{let r=n.current,i=r.get(e);return i||(i=n=>t.current?.(e,n),r.set(e,i)),i},[])}function ZB({children:e,isActiveKey:t,className:n}){let r=(0,z.useRef)(null),{activeKey:i,itemRects:a,sessionRef:o,handlers:s,registerItem:c,measureItems:l}=KB(r),u=(0,z.useMemo)(()=>({registerItem:c}),[c]),d=Object.keys(a).find(e=>t(e))??null;(0,z.useLayoutEffect)(()=>{l()},[l,e,d]);let f=qB(r.current),p=i?a[i]:null,m=d?a[d]:null,h=p?JB(p,f):null,g=m?JB(m,f):null,_=i!==null&&i!==d;return(0,R.jsx)(YB.Provider,{value:u,children:(0,R.jsxs)(`div`,{ref:r,onMouseEnter:s.onMouseEnter,onMouseMove:s.onMouseMove,onMouseLeave:s.onMouseLeave,className:A(`relative isolate`,n),children:[(0,R.jsx)(en,{initial:!1,children:g&&d?(0,R.jsx)(qe.div,{"aria-hidden":!0,className:`pointer-events-none absolute -z-20 rounded-full bg-sidebar-accent`,initial:{opacity:0,top:g.top,left:g.left,width:g.width,height:g.height},animate:{opacity:_?.85:1,top:g.top,left:g.left,width:g.width,height:g.height},exit:{opacity:0,transition:At.fast.exit},transition:{opacity:{duration:.08},top:{duration:0},left:{duration:0},width:{duration:0},height:{duration:0}}},d):null}),(0,R.jsx)(en,{children:h?(0,R.jsx)(qe.div,{"aria-hidden":!0,className:`pointer-events-none absolute -z-10 rounded-full bg-sidebar-accent`,initial:{opacity:0,top:g?.top??h.top,left:g?.left??h.left,width:g?.width??h.width,height:g?.height??h.height},animate:{opacity:1,top:h.top,left:h.left,width:h.width,height:h.height},exit:{opacity:0,transition:At.fast.exit},transition:{...At.fast,opacity:{duration:.08}}},o.current):null}),e]})})}var QB=A(`pointer-events-auto absolute right-(--sidebar-nav-trailing-right) top-1/2 z-10 flex h-(--sidebar-nav-trailing-size) min-w-(--sidebar-nav-trailing-size) -translate-y-1/2 items-center justify-center`,A(`transition-[opacity,filter] duration-200 ease-out`,`opacity-100 blur-0`,`group-data-[collapsible=icon]:opacity-0 group-data-[collapsible=icon]:blur-[3px] group-data-[collapsible=icon]:pointer-events-none`,`group-data-[collapsed=true]:opacity-0 group-data-[collapsed=true]:blur-[3px] group-data-[collapsed=true]:pointer-events-none`)),$B=A(`truncate transition-[opacity,filter,margin] duration-200 ease-out`,`group-data-[collapsible=icon]:hidden`,`group-data-[collapsed=true]:hidden`),eV=A(`peer/menu-button flex cursor-pointer items-center gap-2 overflow-hidden rounded-full py-2 text-left text-sm outline-hidden ring-sidebar-ring hover:text-sidebar-accent-foreground group-hover/menu-item:text-sidebar-accent-foreground focus-visible:ring-2 active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:font-medium data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,`transition-[width,max-width,height,padding,border-radius] duration-200 ease-out`,`h-8 text-sm`);function tV({count:e}){return(0,R.jsx)(`span`,{className:A(`inline-flex h-5 shrink-0 items-center justify-center border border-border bg-zinc-200 px-1 text-[10px] font-medium tabular-nums leading-none text-foreground dark:bg-zinc-700`,String(e).length>=3?`min-w-5 rounded-md`:`size-5 min-w-5 rounded-full`),children:e})}function nV(e){return e.id!==`separator`}function rV({activeTab:e,onTabChange:t,selectedServer:n,visibleTabs:r,collapsed:i}){let a=XB();return(0,R.jsx)(`ul`,{className:`flex w-full min-w-0 flex-col gap-1 px-(--sidebar-nav-inset-x) group`,"data-collapsed":i,"aria-label":`Inspector tabs`,children:(r?Az.filter(e=>nV(e)&&r.includes(e.id)):Az.filter(nV)).map((r,o)=>{let s=Oz(r.id,n),c=kz(r.id,s,i),l=r.icon,u=e===r.id,d=s>0||c,f=(0,R.jsxs)(`button`,{ref:a(r.id),type:`button`,"data-testid":`tab-${r.id}`,"data-active":u?!0:void 0,onClick:()=>t(r.id),className:A(eV,i?`size-8! w-8! max-w-8! shrink-0 justify-center gap-0 p-0!`:`w-full max-w-full sidebar-nav-pill-bleed-x pl-(--sidebar-nav-icon-pl-bleed) pr-(--sidebar-nav-pr-bleed)`,d&&!i&&`pr-[calc(var(--sidebar-nav-trailing-right)+var(--sidebar-nav-trailing-size))]`),children:[(0,R.jsx)(l,{className:`size-4 shrink-0`}),(0,R.jsx)(`span`,{className:$B,children:r.label})]});return(0,R.jsxs)(`li`,{className:A(`group/menu-item relative`,o===0&&`mt-4`),children:[i?(0,R.jsxs)(gt,{delayDuration:0,children:[(0,R.jsx)(Ie,{render:f,nativeButton:!0}),(0,R.jsx)(Et,{side:`right`,children:s>0?`${r.label} (${s})`:r.label})]}):f,d&&!i?(0,R.jsx)(`div`,{className:QB,children:s>0?(0,R.jsx)(tV,{count:s}):c?(0,R.jsx)(`span`,{className:`inline-flex h-2 w-2 shrink-0 rounded-full bg-yellow-500 animate-status-pulse-yellow`}):null}):null]},r.id)})})}function iV({activeTab:e,onTabChange:t,selectedServer:n,visibleTabs:r,collapsed:i,onCollapsedChange:a,rpcLoggerOpen:o,onRpcLoggerOpenChange:s,onCommandPaletteOpen:c}){return(0,R.jsxs)(`aside`,{className:A(`group/sidebar relative hidden lg:flex flex-col shrink-0 text-sidebar-foreground transition-[width] duration-200 ease-out @container/sidebar`,i?`w-(--sidebar-width-icon)`:`w-(--sidebar-width)`),"data-collapsed":i,"data-collapsible":i?`icon`:`expanded`,children:[(0,R.jsx)(`div`,{className:`sidebar-nav-scroll flex-1 overflow-y-auto overflow-x-hidden min-h-0`,children:(0,R.jsx)(ZB,{isActiveKey:t=>t===e,className:`pb-2`,children:(0,R.jsx)(rV,{activeTab:e,onTabChange:t,selectedServer:n,visibleTabs:r,collapsed:i})})}),(0,R.jsx)(UB,{collapsed:i,rpcLoggerOpen:o,onRpcLoggerOpenChange:s,onCommandPaletteOpen:c}),(0,R.jsx)(_B,{collapsed:i,onToggle:()=>a(!i)})]})}function aV(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/t**r*100)/100+` `+n[r]}function oV(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(1))} ${n[r]}`}var sV=100*1024,cV=1024*20;function lV(e,t){if(e==null)return e;if(typeof e==`string`)return e.length>t?e.substring(0,t)+`... (truncated)`:e;if(Array.isArray(e))return e.map(e=>lV(e,t));if(typeof e==`object`){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=lV(e[r],t));return n}return e}function uV(e){let t=JSON.stringify(e,null,2);return new TextEncoder().encode(t).length>sV?lV(e,cV):e}function dV(e){let t=JSON.stringify(e,null,2),n=new TextEncoder().encode(t).length,r=n>sV,i;if(r){let t=lV(e,cV);i=JSON.stringify(t,null,2)}else i=t;return{isLarge:r,size:n,sizeFormatted:aV(n),preview:i,full:t}}function fV(e,t){try{let n=JSON.stringify(e,null,2),r=globalThis.Blob,i=new r([n],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=t||`data-${Date.now()}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)}catch(e){throw console.error(`Failed to download JSON:`,e),e}}var pV={key:`text-sky-600 dark:text-sky-400`,string:`text-emerald-600 dark:text-emerald-400`,number:`text-amber-600 dark:text-amber-400`,boolean:`text-violet-600 dark:text-violet-400`,null:`text-zinc-500 dark:text-zinc-400`,punctuation:`text-muted-foreground`};function mV(e){let t=[],n=0,r=(e,n)=>{n&&t.push({kind:e,text:n})};for(;n<e.length;){let t=e[n];if(t===`"`){let t=n;for(n++;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e[n]===`"`){n++;break}n++}let i=e.slice(t,n),a=n;for(;a<e.length&&/[ \t]/.test(e[a]);)a++;r(e[a]===`:`?`key`:`string`,i);continue}if(/[0-9-]/.test(t)){let t=n;for(e[n]===`-`&&n++;n<e.length&&/[0-9.eE+-]/.test(e[n]);)n++;r(`number`,e.slice(t,n));continue}if(e.startsWith(`true`,n)||e.startsWith(`false`,n)){let t=e.startsWith(`true`,n)?`true`:`false`;r(`boolean`,t),n+=t.length;continue}if(e.startsWith(`null`,n)){r(`null`,`null`),n+=4;continue}if(/[{}[\],:]/.test(t)){r(`punctuation`,t),n++;continue}r(`punctuation`,t),n++}return t}function hV(e){return mV(e).map((e,t)=>(0,R.jsx)(`span`,{className:pV[e.kind],children:e.text},t))}var gV={string:`text-emerald-600 dark:text-emerald-400`,number:`text-amber-600 dark:text-amber-400`,boolean:`text-violet-600 dark:text-violet-400`,null:`text-zinc-500 dark:text-zinc-400`,key:`text-sky-600 dark:text-sky-400`,punctuation:`text-muted-foreground`};function _V(e){return e===null?(0,R.jsx)(`span`,{className:gV.null,children:`null`}):typeof e==`string`?(0,R.jsx)(`span`,{className:gV.string,children:JSON.stringify(e)}):typeof e==`number`?(0,R.jsx)(`span`,{className:gV.number,children:String(e)}):typeof e==`boolean`?(0,R.jsx)(`span`,{className:gV.boolean,children:String(e)}):(0,R.jsx)(`span`,{className:gV.string,children:JSON.stringify(e)})}function vV(e){return Array.isArray(e)?`[${e.length}]`:`{${Object.keys(e).length}}`}function yV({label:e,value:t,depth:n,defaultExpanded:r}){let i=typeof t==`object`&&t&&!Array.isArray(t)?Object.keys(t).length>0:Array.isArray(t)?t.length>0:!1,[a,o]=(0,z.useState)(i&&(r||n===0));if(!i){let r=Array.isArray(t)?`[]`:`{}`;return typeof t==`object`&&t?(0,R.jsxs)(`div`,{className:`font-mono text-[0.8rem] leading-relaxed`,style:{paddingLeft:n*12},children:[e!=null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:gV.key,children:JSON.stringify(e)}),(0,R.jsx)(`span`,{className:gV.punctuation,children:`: `})]}),(0,R.jsx)(`span`,{className:gV.punctuation,children:r})]}):(0,R.jsxs)(`div`,{className:`font-mono text-[0.8rem] leading-relaxed`,style:{paddingLeft:n*12},children:[e!=null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:gV.key,children:JSON.stringify(e)}),(0,R.jsx)(`span`,{className:gV.punctuation,children:`: `})]}),_V(t)]})}let s=Array.isArray(t)?t.map((e,t)=>[String(t),e]):Object.entries(t),c=Array.isArray(t),l=c?`[`:`{`,u=c?`]`:`}`;return(0,R.jsxs)(`div`,{className:`font-mono text-[0.8rem] leading-relaxed`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-0.5`,style:{paddingLeft:n*12},children:[(0,R.jsx)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(e=>!e),className:`mt-0.5 inline-flex shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground`,children:(0,R.jsx)(O,{className:A(`h-3.5 w-3.5 transition-transform`,a&&`rotate-90`)})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[e!=null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:gV.key,children:JSON.stringify(e)}),(0,R.jsx)(`span`,{className:gV.punctuation,children:`: `})]}),(0,R.jsx)(`span`,{className:gV.punctuation,children:l}),!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`mx-1 text-xs text-muted-foreground hover:text-foreground`,children:vV(t)}),(0,R.jsx)(`span`,{className:gV.punctuation,children:u})]})]})]}),a&&(0,R.jsxs)(`div`,{children:[s.map(([e,t])=>(0,R.jsx)(yV,{label:e,value:t,depth:n+1,defaultExpanded:r},`${n}-${e}`)),(0,R.jsx)(`div`,{style:{paddingLeft:n*12},children:(0,R.jsx)(`span`,{className:gV.punctuation,children:u})})]})]})}function bV({data:e,defaultExpanded:t=!0,className:n}){return(0,R.jsx)(`div`,{className:A(`text-gray-900 dark:text-gray-100 [overflow-wrap:anywhere]`,n),"data-testid":`collapsible-json`,children:(0,R.jsx)(yV,{value:e,depth:0,defaultExpanded:t})})}var xV=`font-mono text-[0.8rem] text-gray-900 dark:text-gray-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`;function SV({data:e,filename:t,className:n,collapsible:r=!1,defaultExpanded:i=!0,...a}){let o=dV(e),s=uV(e),c=o.isLarge?(0,R.jsx)(`div`,{className:`mb-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex-1`,children:[(0,R.jsxs)(`p`,{className:`text-sm font-medium text-yellow-800 dark:text-yellow-300 mb-1`,children:[`JSON is too large (`,o.sizeFormatted,`)`]}),(0,R.jsx)(`p`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:`Showing full structure with truncated values. Download the full JSON file to see complete values.`})]}),(0,R.jsxs)(jt,{variant:`outline`,size:`sm`,onClick:()=>{fV(e,t)},className:`shrink-0`,children:[(0,R.jsx)(qr,{className:`h-4 w-4 mr-1`}),`Download`]})]})}):null;return r?(0,R.jsxs)(`div`,{className:n,...a,children:[c,(0,R.jsx)(bV,{data:s,defaultExpanded:i})]}):o.isLarge?(0,R.jsxs)(`div`,{className:n,...a,children:[c,(0,R.jsx)(`pre`,{className:xV,children:(0,R.jsx)(`code`,{children:hV(o.preview)})})]}):(0,R.jsx)(`div`,{className:n,...a,children:(0,R.jsx)(`pre`,{className:xV,children:(0,R.jsx)(`code`,{children:hV(o.preview)})})})}function CV(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var wV=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.indeterminate=`data-indeterminate`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({});function TV(e){return z.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[wV.checked]:``}:{[wV.unchecked]:``}},...Tn}),[e.indeterminate])}var EV=z.createContext({disabled:!1});function DV(){return z.useContext(EV)}var OV=z.createContext(void 0);function kV(e=!0){let t=z.useContext(OV);if(t===void 0&&!e)throw Error(Ve(3));return t}var AV=z.createContext(void 0);function jV(){let e=z.useContext(AV);if(e===void 0)throw Error(Ve(14));return e}var MV=`data-parent`,NV=z.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:m=!1,render:h,required:g=!1,uncheckedValue:_,value:y,nativeButton:b=!1,style:x,...S}=e,{clearErrors:C}=An(),{disabled:w,name:T,setDirty:ee,setFilled:E,setFocused:D,setTouched:te,state:ne,validationMode:O,validityData:re,validation:k}=On(),ie=DV(),{labelId:A,controlId:j,registerControlId:M,getDescriptionProps:oe}=kn(),se=kV(),P=se?.parent,ce=P&&se.allValues,le=w||ie.disabled||se?.disabled||o,ue=T??d,de=y??ue,fe=N(),pe=N(),me=j;ce?me=p?pe:`${P.id}-${de}`:c&&(me=c);let he={};ce&&(p?he=se.parent.getParentProps():de&&(he=se.parent.getChildProps(de)));let{checked:ge=n,indeterminate:_e=l,onCheckedChange:ve,...ye}=he,F=se?.value,xe=se?.setValue,Se=se?.defaultValue,Ce=z.useRef(null),we=Bt(()=>Symbol(`checkbox-control`)),Te=z.useRef(!1),{getButtonProps:Ee,buttonRef:De}=Pe({disabled:le,native:b}),Oe=se?.validation??k,[ke,je]=Yt({controlled:de&&F&&!p?F.includes(de):ge,default:de&&Se&&!p?Se.includes(de):i,name:`Checkbox`,state:`checked`}),Me=ce?!!ge:ke,Ne=ce&&_e||l;be(()=>{M!==mt&&(Te.current=!0,M(we.current,me))},[me,M,we]),z.useEffect(()=>{let e=we.current;return()=>{!Te.current||M===mt||(Te.current=!1,M(e,void 0))}},[M,we]),En(Ce,fe,ke,void 0,!se&&!le,d);let Fe=z.useRef(null),Ie=Ze(u,Fe,Oe.inputRef,Oe.registerInput),Re=CB(a,A,Fe,!b,me??void 0);be(()=>{Fe.current&&(Fe.current.indeterminate=Ne,ke&&E(!0))},[ke,Ne,E]),Dn(ke,()=>{se||(C(ue),E(ke),ee(ke!==re.initialValue),Oe.change(ke))});let ze=Ut({checked:ke,disabled:le,form:s,name:p?void 0:ue,id:b?void 0:me??void 0,required:g,ref:Ie,style:ue?Le:rt,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(m){e.preventDefault();return}let t=e.currentTarget.checked,n=ae(Ae,e.nativeEvent);f?.(t,n),!n.isCanceled&&(ve?.(t,n),!n.isCanceled&&(je(t),de&&F&&xe&&!p&&!ce&&xe(t?[...F,de]:F.filter(e=>e!==de),n)))},onFocus(){Ce.current?.focus()}},y===void 0?St:{value:(se?ke&&y:y)||``},oe,e=>Oe.getValidationProps(le,e));z.useEffect(()=>{if(!P||!de)return;let e=P.disabledStatesRef.current;return e.set(de,le),()=>{e.delete(de)}},[P,le,de]);let Be=z.useMemo(()=>({...ne,checked:Me,disabled:le,readOnly:m,required:g,indeterminate:Ne}),[ne,Me,le,m,g,Ne]),Ve=TV(Be),He=We(`span`,e,{state:Be,ref:[De,Ce,t,se?.registerControlRef],props:[{id:b?me??void 0:fe,role:`checkbox`,"aria-checked":Ne?`mixed`:Me,"aria-readonly":m||void 0,"aria-required":g||void 0,"aria-labelledby":Re,[MV]:p?``:void 0,onFocus(){le||D(!0)},onBlur(){let e=Fe.current;e&&(te(!0),D(!1),O===`onBlur`&&Oe.commit(se?F:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=Fe.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),v(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||CV(t)?.click()})},onClick(e){if(m||le)return;e.preventDefault();let t=Fe.current;t&&t.dispatchEvent(new(v(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))}},S,ye,Ee,oe,e=>Oe.getValidationProps(le,e)],stateAttributesMapping:Ve});return(0,R.jsxs)(AV.Provider,{value:Be,children:[He,!ke&&!se&&ue&&!p&&_!==void 0&&(0,R.jsx)(`input`,{type:`hidden`,form:s,name:ue,value:_,disabled:le}),(0,R.jsx)(`input`,{...ze,suppressHydrationWarning:!0})]})}),PV=z.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=jV(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=lt(c),f=z.useRef(null),p={...s,transitionStatus:u};x({open:c,ref:f,onComplete(){c||d(!1)}});let m={...TV(s),...bt,...Tn},h=a||l,g=We(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null}),FV=(0,z.createContext)(null);function IV(){let e=(0,z.useContext)(FV);if(!e)throw Error(`useCheckboxGroup must be used within a CheckboxGroup`);return e}var LV=(0,z.forwardRef)(({children:e,checkedIndices:t,orientation:n=`vertical`,className:r,...i},a)=>{let o=(0,z.useRef)(null),s=n===`horizontal`,{activeIndex:c,setActiveIndex:l,handlers:u,registerItem:d,measureItems:f}=_n(o,{axis:s?`x`:`y`});(0,z.useEffect)(()=>{f()},[f,e]);let p=s?`ArrowLeft`:`ArrowUp`,m=s?`ArrowRight`:`ArrowDown`;return(0,R.jsx)(FV.Provider,{value:{registerItem:d,activeIndex:c},children:(0,R.jsx)(`div`,{ref:e=>{o.current=e,typeof a==`function`?a(e):a&&(a.current=e)},onMouseEnter:u.onMouseEnter,onMouseMove:u.onMouseMove,onMouseLeave:u.onMouseLeave,onFocus:e=>{let t=e.target.closest(`[data-proximity-index]`)?.getAttribute(`data-proximity-index`);t!=null&&l(Number(t))},onBlur:e=>{o.current?.contains(e.relatedTarget)||l(null)},onKeyDown:e=>{let t=Array.from(o.current?.querySelectorAll(`[data-proximity-index]`)??[]),n=t.indexOf(e.target);n!==-1&&([p,m].includes(e.key)?(e.preventDefault(),t[e.key===m?(n+1)%t.length:(n-1+t.length)%t.length]?.focus()):e.key===`Home`?(e.preventDefault(),t[0]?.focus()):e.key===`End`&&(e.preventDefault(),t[t.length-1]?.focus()))},role:`group`,className:A(`relative flex max-w-full select-none`,s?`w-auto flex-row`:`w-72 flex-col`,r),...i,children:e})})});LV.displayName=`CheckboxGroup`;var RV=(0,z.forwardRef)(({label:e,index:t,checked:n,onToggle:r,size:i=`default`,className:a,...o},s)=>{let c=(0,z.useRef)(null),l=(0,z.useRef)(!1),{registerItem:u,activeIndex:d}=IV();(0,z.useEffect)(()=>(u(t,c.current),()=>u(t,null)),[t,u]),(0,z.useEffect)(()=>{l.current=!0},[]);let f=d===t,p=!l.current,m=D(),h=i===`sm`;return(0,R.jsxs)(`div`,{ref:e=>{c.current=e,typeof s==`function`?s(e):s&&(s.current=e)},"data-proximity-index":t,tabIndex:0,role:`checkbox`,"aria-checked":n,"aria-label":e,onClick:r,onMouseDown:e=>{let t=e.target.closest(`button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);t&&t!==e.currentTarget||(e.preventDefault(),e.currentTarget.focus())},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),r())},className:A(`relative z-10 flex items-center cursor-pointer outline-none`,h?`h-7 gap-1.5 px-2`:`h-8 gap-2.5 px-3`,m.item,`focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]`,a),...o,children:[(0,R.jsxs)(NV,{checked:n,tabIndex:-1,"aria-hidden":!0,className:A(`pointer-events-none relative shrink-0 appearance-none bg-transparent p-0 border-0 outline-none`,h?`size-[13px]`:`size-[15px]`),children:[(0,R.jsx)(`div`,{className:A(`absolute inset-0 rounded-[5px] border-solid transition-all duration-80 border-[1.5px]`,n?`border-border`:f?`border-neutral-400 dark:border-neutral-500`:`border-border`)}),(0,R.jsx)(en,{children:n&&(0,R.jsx)(PV,{keepMounted:!0,render:e=>{let{style:t,onDrag:n,onDragStart:r,onDragEnd:i,onAnimationStart:a,onAnimationEnd:o,onAnimationIteration:s,...c}=e;return(0,R.jsx)(qe.svg,{...c,width:h?14:18,height:h?14:18,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-foreground`,initial:{opacity:1},animate:{opacity:1},exit:{opacity:1},children:(0,R.jsx)(qe.path,{d:`M6 12L10 16L18 8`,initial:{pathLength:+!!p},animate:{pathLength:1,transition:{duration:.08,ease:`easeOut`}},exit:{pathLength:0,transition:{duration:.04,ease:`easeIn`}}})})}})})]}),(0,R.jsxs)(`span`,{className:`inline-grid items-center self-center leading-none`,children:[(0,R.jsx)(`span`,{className:`col-start-1 row-start-1 invisible leading-none`,style:{fontVariationSettings:He.semibold},"aria-hidden":`true`,children:e}),(0,R.jsx)(`span`,{className:A(`col-start-1 row-start-1 leading-none transition-[color,font-variation-settings] duration-80`,h?`text-[11px]`:`text-[13px]`,n||f?`text-foreground`:`text-muted-foreground`),style:{fontVariationSettings:n?He.semibold:He.normal},children:e})]})]})});RV.displayName=`CheckboxItem`;var zV=36,BV=188,VV=6;function HV(e,t,n){let[r,i]=(0,z.useState)(0),[a,o]=(0,z.useState)(0),s=(0,z.useMemo)(()=>{let n=[],r=[],i=0;for(let a of e){n.push(i);let e=zV+(t.has(a.id)?BV:0);r.push(e),i+=e}return{offsets:n,heights:r,totalHeight:i}},[t,e]),c=(0,z.useMemo)(()=>{if(e.length===0)return{totalHeight:0,visibleItems:[]};let{offsets:t,heights:n,totalHeight:i}=s,o=r+a,c=0;for(;c<e.length&&t[c]+n[c]<r;)c++;c=Math.max(0,c-VV);let l=c;for(;l<e.length&&t[l]<o;)l++;l=Math.min(e.length,l+VV);let u=[];for(let r=c;r<l;r++)u.push({index:r,item:e[r],top:t[r],height:n[r]});return{totalHeight:i,visibleItems:u}},[e,s,r,a]),l=(0,z.useCallback)(()=>{let e=n.current;e&&i(e.scrollTop)},[n]);return(0,z.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{o(e.clientHeight),i(e.scrollTop)};t();let r=new ResizeObserver(t);return r.observe(e),e.addEventListener(`scroll`,l,{passive:!0}),()=>{r.disconnect(),e.removeEventListener(`scroll`,l)}},[l,n,e.length]),c}var UV=300,WV=/(?:^|\/)notifications\//;function GV(e){let t=e;return typeof t?.method==`string`?t.method:null}function KV(e){let t=e.message;if(t?.id!==void 0&&t.id!==null||t?.result!==void 0||t?.error!==void 0)return null;let n=GV(e.message);return!n||!WV.test(n)?null:[e.source,e.serverId,e.widgetId??``,e.direction,n].join(`|`)}function qV(e,t,n=Date.now()){let r=KV(e),i=KV(t);if(!r||r!==i)return!1;let a=Date.parse(e.timestamp);return Number.isNaN(a)?!1:n-a<=UV}function JV(e,t){return{...e,timestamp:t.timestamp,message:t.message,repeatCount:(e.repeatCount??1)+1}}var YV=new class{maxEntries;entries=[];listeners=new Set;nextId=0;emitFrame=null;constructor(e=1e3){this.maxEntries=e}publish(e){let t=this.entries[this.entries.length-1];if(t&&qV(t,e,Date.parse(e.timestamp))){this.entries[this.entries.length-1]=JV(t,e),this.scheduleEmit();return}this.entries.push({...e,id:`rpc-${++this.nextId}`}),this.entries.length>this.maxEntries&&this.entries.splice(0,this.entries.length-this.maxEntries),this.scheduleEmit()}getSnapshot=()=>this.entries;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));clear(e={}){let t=new Set(e.serverIds??[]),n=new Set(e.sources??[]);t.size===0&&n.size===0?this.entries=[]:this.entries=this.entries.filter(e=>!((t.size===0||t.has(e.serverId))&&(n.size===0||n.has(e.source)))),this.scheduleEmit()}peekCoalesceKey(e){return KV(e)}scheduleEmit(){if(this.emitFrame===null){if(typeof requestAnimationFrame>`u`){this.emit();return}this.emitFrame=requestAnimationFrame(()=>{this.emitFrame=null,this.emit()})}}emit(){this.listeners.forEach(e=>e())}},XV;function ZV(e){YV.publish({source:`mcp`,serverId:e.serverId,direction:e.direction,timestamp:e.timestamp,message:e.message})}function QV(){XV||=(rk().forEach(ZV),ik(ZV))}QV();function $V({serverIds:e,onCountChange:t,onClearRef:n,onExportRef:r}={}){let i=(0,z.useRef)(null),[a,o]=(0,z.useState)(new Set),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(()=>new Set([`mcp`,`widget`])),p=(0,z.useSyncExternalStore)(YV.subscribe,YV.getSnapshot,YV.getSnapshot),m=async e=>{try{await Qj(JSON.stringify(e,null,2)),GF.success(`Message copied to clipboard`)}catch(e){console.error(`Failed to copy message:`,e),GF.error(`Failed to copy to clipboard`)}},h=(0,z.useMemo)(()=>{if(!e?.length)return p;let t=new Set(e);return p.filter(e=>t.has(e.serverId))},[p,e]),g=(0,z.useMemo)(()=>{let e=new Set;return d.has(`mcp`)&&e.add(0),d.has(`widget`)&&e.add(1),e},[d]),_=(0,z.useCallback)(e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),v=(0,z.useMemo)(()=>{let e=h;d.size>0&&(e=e.filter(e=>d.has(e.source)));let t=s.trim().toLowerCase();return t&&(e=e.filter(e=>{let n=tH(e);return e.serverId.toLowerCase().includes(t)||e.widgetId?.toLowerCase().includes(t)||e.source.includes(t)||n.toLowerCase().includes(t)||e.direction.toLowerCase().includes(t)||JSON.stringify(e.message).toLowerCase().includes(t)})),[...e].reverse()},[h,s,d]),{totalHeight:y,visibleItems:b}=HV(v,a,i),x=(0,z.useCallback)(e=>{o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),S=(0,z.useCallback)(async()=>{let t=d.size===0||d.size===2?void 0:[...d];(!t||t.includes(`mcp`))&&(e?.length?e.forEach(e=>ak(e)):ak()),YV.clear({serverIds:e,sources:t}),o(new Set)},[e,d]),C=(0,z.useCallback)(async()=>{try{await Qj(JSON.stringify(v,null,2)),GF.success(`Copied ${v.length} messages`)}catch(e){console.error(`Failed to copy messages:`,e),GF.error(`Failed to copy to clipboard`)}},[v]),w=(0,z.useCallback)(()=>{let e=new Blob([JSON.stringify(v,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`mcp-rpc-traffic-${new Date().toISOString().replaceAll(`:`,`-`)}.json`,n.click(),URL.revokeObjectURL(t)},[v]);return(0,z.useEffect)(()=>{t?.(v.length)},[v.length,t]),(0,z.useEffect)(()=>(n&&(n.current=S),()=>{n&&(n.current=null)}),[S,n]),(0,z.useEffect)(()=>(r&&(r.current=C),()=>{r&&(r.current=null)}),[C,r]),(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 pr-2 pt-2 pl-1`,children:[(0,R.jsx)(`h2`,{className:`text-xs font-medium text-foreground`,children:`RPC Logs`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`size-7 p-0`,onClick:C,disabled:v.length===0,"aria-label":`Copy filtered RPC traffic`,title:`Copy filtered`,children:(0,R.jsx)(Wr,{className:`size-3.5`})}),(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`size-7 p-0`,onClick:w,disabled:v.length===0,"aria-label":`Download filtered RPC traffic as JSON`,title:`Download JSON`,children:(0,R.jsx)(qr,{className:`size-3.5`})}),(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`size-7 p-0`,onClick:S,disabled:p.length===0,"aria-label":`Clear RPC traffic`,title:`Clear`,children:(0,R.jsx)(Ui,{className:`size-3.5`})})]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center pr-2 pb-2 pt-1 pl-1`,children:[(0,R.jsxs)(`div`,{className:`relative min-w-0 flex-1 transition-[flex-grow] duration-200 ease-out`,children:[(0,R.jsx)(T,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(Nt,{value:s,onChange:e=>c(e.target.value),onFocus:()=>u(!0),onBlur:()=>u(!1),placeholder:`Search`,"aria-label":`Search RPC traffic`,className:`h-8 w-full pl-7 text-xs shadow-none transition-[width] duration-200 ease-out`})]}),(0,R.jsx)(`div`,{"aria-hidden":l,className:A(`shrink-0 overflow-hidden transition-[max-width,opacity,margin] duration-200 ease-out`,l?`pointer-events-none ml-0 max-w-0 opacity-0`:`ml-2 max-w-32 opacity-100`),children:(0,R.jsxs)(LV,{checkedIndices:g,orientation:`horizontal`,"aria-label":`Filter RPC traffic by source`,className:`w-auto shrink-0`,children:[(0,R.jsx)(RV,{index:0,label:`MCP`,size:`sm`,checked:d.has(`mcp`),onToggle:()=>_(`mcp`)}),(0,R.jsx)(RV,{index:1,label:`UI`,size:`sm`,checked:d.has(`widget`),onToggle:()=>_(`widget`)})]})})]}),(0,R.jsx)(`div`,{ref:i,className:`min-h-0 flex-1 overflow-y-auto pb-10`,style:{maskImage:`linear-gradient(to bottom, black 0, black calc(100% - 3rem), transparent 100%)`,WebkitMaskImage:`linear-gradient(to bottom, black 0, black calc(100% - 3rem), transparent 100%)`},children:v.length===0?(0,R.jsxs)(`div`,{className:`text-center py-8`,children:[(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No messages yet`}),(0,R.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:`JSON-RPC messages will appear here`})]}):(0,R.jsx)(`div`,{className:`relative w-full`,style:{height:y},children:b.map(({item:e,top:t,height:n})=>(0,R.jsx)(eH,{item:e,top:t,height:n,expanded:a.has(e.id),onToggle:()=>x(e.id),onCopy:()=>m(e.message)},e.id))})})]})}function eH({item:e,top:t,height:n,expanded:r,onToggle:i,onCopy:a}){let o=tH(e),s=nH(e),c=e.repeatCount&&e.repeatCount>1?` ×${e.repeatCount}`:``;return(0,R.jsxs)(`div`,{className:`absolute inset-x-0 overflow-hidden`,style:{top:t,height:n},"data-testid":`rpc-message-${o.replace(/\//g,`-`)}`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:i,className:`flex h-9 w-full cursor-pointer items-center gap-2 py-2 pr-3 pl-1 text-left text-muted-foreground transition-colors hover:text-foreground`,children:[(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:e.direction===`receive`?(0,R.jsx)(Dr,{className:`size-3.5 text-blue-500`}):(0,R.jsx)(Ar,{className:`size-3.5 text-emerald-500`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:`left`,children:s})]}),(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center`,children:e.source===`mcp`?(0,R.jsx)(AL,{className:`size-3`}):(0,R.jsx)(wi,{className:`size-3`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:`left`,children:e.source===`mcp`?`MCP server`:`UI widget`})]}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:[o,c?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:c}):null]}),(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`time`,{dateTime:e.timestamp,className:`shrink-0 cursor-default font-mono text-[10px] tabular-nums text-muted-foreground underline decoration-dotted underline-offset-2`,children:new Date(e.timestamp).toLocaleTimeString()}),nativeButton:!1}),(0,R.jsx)(Et,{side:`left`,children:new Date(e.timestamp).toLocaleString()})]})]}),r?(0,R.jsxs)(`div`,{className:`relative mx-3 mb-2 max-h-44 overflow-auto rounded-lg p-2 pr-8`,children:[(0,R.jsx)(SV,{data:e.message,className:`[&_pre]:!text-[10px] [&_pre]:!leading-4`}),(0,R.jsx)(jt,{variant:`secondary`,size:`icon-sm`,onClick:a,className:`absolute right-1 top-1 size-6 rounded-full p-0`,title:`Copy message`,"aria-label":`Copy message`,children:(0,R.jsx)(Wr,{className:`size-3`})})]}):null]})}function tH(e){let t=GV(e.message);if(t)return t;let n=e.message;return n?.result===void 0?n?.error===void 0?`unknown`:`error`:`result`}function nH(e){return e.source===`widget`?e.direction===`send`?`Host → Widget`:`Widget → Host`:e.direction===`send`?`Inspector → MCP`:`MCP → Inspector`}function rH({serverId:e,open:t}){return(0,R.jsx)(`aside`,{"aria-label":`RPC Panel`,"aria-hidden":!t,className:A(`relative hidden min-h-0 shrink-0 flex-col overflow-hidden transition-[width,margin] duration-200 ease-out lg:flex`,t?`w-(--rpc-panel-width) lg:mr-[18px]`:`w-0 lg:mr-0`),children:(0,R.jsx)(`div`,{className:A(`flex h-full min-h-0 w-(--rpc-panel-width) flex-col transition-opacity duration-200 ease-out`,t?`opacity-100`:`pointer-events-none opacity-0`),children:(0,R.jsx)($V,{serverIds:[e]})})})}function iH(e){return`${e.replace(/\/+$/,``)}${nM()}`}function aH({tunnelUrl:e,tunnelMcpUrl:t,selectedServerId:n,selectedServer:r,configLoaded:i,removeConnection:a,updateConnection:o,connections:s}){let c=(0,z.useRef)(null),l=(0,z.useRef)(!1),u=(0,z.useRef)(null),[d,f]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{!d||r?.url!==u.current||r.state!==`ready`&&r.state!==`failed`||(f(!1),l.current=!1,u.current=null)},[d,r]),(0,z.useEffect)(()=>{n&&oM(n)?c.current=n:r?.url&&oM(r.url)&&(c.current=r.url)},[r?.url,n]),(0,z.useEffect)(()=>{if(!i||!n||!r||l.current)return;let d=r.url??``,p=oM(d),m=sM(d),h=t??(e?iH(e):null),g=null;e&&h&&p?g=h:!e&&m&&c.current&&(g=c.current),!(!g||g===d)&&(l.current=!0,u.current=g,f(!0),(async()=>{try{g!==n&&s.some(e=>e.id===g)&&await a(g),await o(n,yM({...xM(n)??bM(r),url:g}))}catch{f(!1),u.current=null,l.current=!1}})())},[i,s,a,r,n,t,e,o]),(0,z.useEffect)(()=>{d||(l.current=!1)},[d]),d}function oH({children:e}){let t=KN(),n=UN(),{servers:r,addServer:i,removeServer:a,updateServerMetadata:o,updateServer:s,storageLoaded:c}=Sj(),l=(0,z.useCallback)(async(e,t)=>{try{await s(e,yM(t)),hM(e,t)}catch(t){console.error(`[Layout] Failed to update connection ${e}:`,t)}},[s]),u=(0,z.useCallback)(async(e,t)=>{try{await o(e,t)}catch(t){console.error(`[Layout] Failed to update connection metadata for ${e}:`,t)}},[o]),{selectedServerId:d,setSelectedServerId:f,activeTab:p,setActiveTab:m,navigateToItem:h,setTunnelUrl:g,tunnelUrl:_,isEmbedded:v,embeddedConfig:y,setEmbeddedMode:b}=fL(),[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(()=>{try{return localStorage.getItem(`inspector-sidebar-collapsed`)===`true`}catch{return!1}}),[T,ee]=(0,z.useState)(()=>{try{return localStorage.getItem(`inspector-rpc-logger-open`)===`true`}catch{return!1}});(0,z.useEffect)(()=>{try{localStorage.setItem(`inspector-sidebar-collapsed`,C?`true`:`false`)}catch{}},[C]),(0,z.useEffect)(()=>{try{localStorage.setItem(`inspector-rpc-logger-open`,String(T))}catch{}},[T]);let{savedRequests:E}=hL();(0,z.useEffect)(()=>{let e=new URLSearchParams(n.search),t=e.get(`embedded`)===`true`,r=e.get(`embeddedConfig`);if(t){let e={};if(r)try{e=JSON.parse(r)}catch(e){console.error(`Failed to parse embeddedConfig:`,e)}b(!0,e),e.defaultTab&&m(e.defaultTab)}},[]),(0,z.useEffect)(()=>{let e=new URLSearchParams(n.search).get(`tunnelUrl`);e!==null&&g(e)},[n.search,g]),(0,z.useEffect)(()=>{let e=new URLSearchParams(n.search).get(`tab`);e&&[`tools`,`prompts`,`resources`,`chat`,`sampling`,`elicitation`,`notifications`,`server-metadata`,`connection-settings`].includes(e)&&m(e)},[n.search,m]);let D=(0,z.useRef)(null),te=(0,z.useRef)(Date.now()),ne=(0,z.useRef)(new Set),O=(0,z.useRef)(0);(0,z.useEffect)(()=>{let e=()=>{O.current++};return window.addEventListener(`mcp-tool-executed`,e),()=>window.removeEventListener(`mcp-tool-executed`,e)},[]),(0,z.useEffect)(()=>{let e=()=>{try{ET(new Oo({durationSeconds:Math.round((Date.now()-te.current)/1e3),tabsVisited:ne.current.size,toolsExecuted:O.current})).catch(()=>{})}catch{}};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[]);let re=(0,z.useCallback)(e=>{try{ET(new Eo({tab:e,previousTab:D.current})).catch(()=>{})}catch{}D.current=e,ne.current.add(e),m(e);let r=new URLSearchParams(n.search);r.set(`tab`,e),t(`/?${r.toString()}`,{replace:!0})},[m,t,n.search]);(0,z.useEffect)(()=>{let e=e=>{let t=e.detail.requestId;d&&h(d,`sampling`,t)},t=e=>{let t=e.detail.requestId;d&&h(d,`elicitation`,t)},n=e=>{let t=e.detail.toolName;d&&t?h(d,`tools`,t):d&&re(`tools`)};return window.addEventListener(`navigate-to-sampling`,e),window.addEventListener(`navigate-to-elicitation`,t),window.addEventListener(`navigate-to-tool-result`,n),()=>{window.removeEventListener(`navigate-to-sampling`,e),window.removeEventListener(`navigate-to-elicitation`,t),window.removeEventListener(`navigate-to-tool-result`,n)}},[d,re,h]);let k=(0,z.useRef)(null),ie=(0,z.useRef)(null),j=(0,z.useRef)(null),{isAutoConnecting:M}=dI({connections:r,addServer:i,removeConnection:a,configLoaded:c,embedded:v});(0,z.useEffect)(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`)?`#000000`:`#f3f3f3`;document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let ae=(0,z.useCallback)(e=>{ET(new xo({trigger:e})).catch(()=>{}),S(!0)},[]),oe=e=>{if(!r.find(t=>t.id===e))return;f(e);let i=new URLSearchParams(n.search),a=i.get(`tunnelUrl`),o=i.get(`tab`),s=new URLSearchParams;s.set(`server`,e),a&&s.set(`tunnelUrl`,a),o&&s.set(`tab`,o),t(`/?${s.toString()}`)},se=(0,z.useCallback)(e=>{if(!d)return;let t=xM(d)||r.find(e=>e.id===d);e.url===d?t&&wM(t,e)?(u(d,{name:e.name||e.url}),hM(d,e)):l(d,e):(a(d),i(e.url,yM(e))),GF.success(`Connection settings updated`)},[d,r,a,i,u,l]),N=(e,i,a)=>{if(fetch(`http://127.0.0.1:7371/ingest/4e7482c5-571f-4071-bd09-762c357289f4`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Debug-Session-Id":`831b88`},body:JSON.stringify({sessionId:`831b88`,location:`Layout.tsx:handleCommandPaletteNavigate`,message:`layout navigate entry`,data:{tab:e,itemName:i??null,serverId:a??null,hasServerId:!!a},timestamp:Date.now(),hypothesisId:`H1`})}).catch(()=>{}),console.warn(`[Layout] handleCommandPaletteNavigate called:`,{tab:e,itemName:i,serverId:a}),a){let o=r.find(e=>e.id===a);if(console.warn(`[Layout] Server lookup:`,{serverId:a,serverFound:!!o,serverState:o?.state}),!o||o.state!==`ready`){console.warn(`[Layout] Server not ready, showing error`),GF.error(`Server is not connected and cannot be inspected`);return}console.warn(`[Layout] Calling navigateToItem:`,{serverId:a,tab:e,itemName:i}),fetch(`http://127.0.0.1:7371/ingest/4e7482c5-571f-4071-bd09-762c357289f4`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Debug-Session-Id":`831b88`},body:JSON.stringify({sessionId:`831b88`,location:`Layout.tsx:navigateToItem-call`,message:`calling navigateToItem`,data:{serverId:a,tab:e,itemName:i??null,serverState:o?.state??null},timestamp:Date.now(),hypothesisId:`H1`})}).catch(()=>{}),h(a,e,i);let s=new URLSearchParams(n.search),c=s.get(`tunnelUrl`),l=s.get(`tab`),u=new URLSearchParams;u.set(`server`,a),c&&u.set(`tunnelUrl`,c),e?u.set(`tab`,e):l&&u.set(`tab`,l);let d=`/?${u.toString()}`;console.warn(`[Layout] Navigating to:`,d),t(d)}else console.warn(`[Layout] No serverId, just updating tab to:`,e),re(e)},P=r.find(e=>e.id===d),ce=aH({tunnelUrl:_,selectedServerId:d,selectedServer:P,configLoaded:c,removeConnection:a,updateConnection:s,connections:r}),le=P?P.tools.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.tools.map(t=>({...t,_serverId:e.id,_serverName:lM(e)})):[]),ue=P?P.prompts.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.prompts.map(t=>({...t,_serverId:e.id,_serverName:lM(e)})):[]),de=P?P.resources.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.resources.map(t=>({...t,_serverId:e.id,_serverName:lM(e)})):[]);(0,z.useEffect)(()=>{if(ce)return;let e=new URLSearchParams(n.search),i=e.get(`server`);if(i&&(i.startsWith(`http://`)||i.startsWith(`https://`))&&!r.find(e=>e.id===i)){let n=new URLSearchParams(e);n.delete(`server`),n.set(`autoConnect`,i),t(`/?${n.toString()}`,{replace:!0});return}i!==d&&f(i)},[n.search,d,f,r,t,ce]),(0,z.useEffect)(()=>{if(ce)return;let e=new URLSearchParams(n.search).get(`server`);if(e&&!r.find(t=>t.id===e)){let e=setTimeout(()=>t(`/`),3e3);return()=>clearTimeout(e)}},[n.search,t,r,ce]),(0,z.useEffect)(()=>{if(!v)return;let e=e=>{if(!e.data||typeof e.data!=`object`||e.data.type!==`mcp-inspector:connect_servers`)return;let t=e.data.servers;if(!Array.isArray(t)||t.length===0)return;let n=null;for(let e of t){if(!e.url||typeof e.url!=`string`)continue;let t=e.url,a=e.name??`Server`,o={...e.headers??{}};if(e.auth?.access_token){let t=e.auth.token_type||`bearer`;o.Authorization=`${t.charAt(0).toUpperCase()+t.slice(1)} ${e.auth.access_token}`}let s=typeof e.proxyConfig?.proxyAddress==`string`?e.proxyConfig.proxyAddress.trim():``,c=``;try{new URL(t).origin!==window.location.origin&&(c=uM())}catch{c=uM()}let l=s||c,u=dM(e.connectionMode,e.connectionType,!!s),d=yM({url:t,name:a,transportType:`http`,connectionMode:u,connectionType:u===`proxy`?`Via Proxy`:`Direct`,proxyConfig:u===`proxy`&&l?{proxyAddress:l,...Object.keys(o).length>0?{headers:o}:{}}:void 0,headers:o,autoProxyFallback:u===`auto`&&l?{enabled:!0,proxyAddress:l}:!1});r.find(e=>e.url===t)||i(t,d),n||=t}window.parent!==window&&window.parent.postMessage({type:`mcp-inspector:servers_connected`,count:t.length},`*`)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[v,r,i]);let fe=(0,z.useRef)(!1);(0,z.useEffect)(()=>{if(!v||fe.current||d)return;let e=r.find(e=>e.state===`ready`);if(e){fe.current=!0,f(e.id);let r=new URLSearchParams(n.search);r.set(`server`,e.id),t(`/?${r.toString()}`,{replace:!0})}},[v,r,d,f,t,n.search]),pL({onCommandPalette:()=>ae(`keyboard`),onToolsTab:()=>{P&&re(`tools`)},onPromptsTab:()=>{P&&re(`prompts`)},onResourcesTab:()=>{P&&re(`resources`)},onChatTab:()=>{P&&re(`chat`)},onHome:()=>{t(`/`)},onFocusSearch:()=>{p===`tools`&&k.current?k.current.focusSearch():p===`prompts`&&ie.current?ie.current.focusSearch():p===`resources`&&j.current&&j.current.focusSearch()},onBlurSearch:()=>{p===`tools`&&k.current?k.current.blurSearch():p===`prompts`&&ie.current?ie.current.blurSearch():p===`resources`&&j.current&&j.current.blurSearch()}});let pe=new URLSearchParams(n.search).get(`server`),me=!c&&!!pe&&!pe.startsWith(`http://`)&&!pe.startsWith(`https://`),he=M||me||ce,ge=P?.id??`home`,_e=he?`boot`:ge,[ve,ye]=(0,z.useState)(_e);(0,z.useLayoutEffect)(()=>{if(_e===ve)return;let e=()=>(0,br.flushSync)(()=>ye(_e));typeof document.startViewTransition==`function`?document.startViewTransition(e):e()},[_e,ve]);let be=ve===`boot`,F=be||ve===`home`?void 0:r.find(e=>e.id===ve),xe=v&&y.singleTab,Se=v?{backgroundColor:y.backgroundColor||`#f3f3f3`,padding:xe?`0`:y.padding||`0.5rem`}:{},Ce=v?xe?`h-screen flex flex-col`:`h-screen flex flex-col gap-2 sm:gap-4`:`h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-4 lg:px-0 pb-4`,we=xe?`flex-1 w-full bg-white dark:bg-black p-0 overflow-auto`:A(`flex-1 min-h-0 w-full bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 overflow-auto`,!F&&`lg:mx-4`,F&&`lg:mr-4`);return(0,R.jsxs)(nt,{children:[(0,R.jsx)(`div`,{className:`inspector-view-transition h-screen bg-[#f3f3f3] dark:bg-black`,children:be?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center bg-[#f3f3f3] dark:bg-black`,children:(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,R.jsx)(aL,{className:`h-8 w-8 text-zinc-600 dark:text-zinc-400`}),(0,R.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Connecting to MCP server...`})]})}):(0,R.jsxs)(`div`,{className:Ce,style:Se,children:[!xe&&(0,R.jsx)(gB,{connections:r,selectedServer:F,activeTab:p,onServerSelect:oe,onTabChange:re,embedded:v,sidebarCollapsed:C}),(0,R.jsxs)(`div`,{className:xe?`flex-1 min-h-0`:`flex flex-1 min-h-0 min-w-0`,children:[F&&!xe&&(0,R.jsx)(iV,{activeTab:p,onTabChange:re,selectedServer:F,visibleTabs:y.visibleTabs,collapsed:C,onCollapsedChange:w,rpcLoggerOpen:T,onRpcLoggerOpenChange:ee,onCommandPaletteOpen:()=>ae(`button`)}),(0,R.jsx)(`main`,{className:we,children:(0,R.jsx)(VR,{selectedServer:F,activeTab:p,toolsSearchRef:k,promptsSearchRef:ie,resourcesSearchRef:j,onUpdateConnection:se,children:e})}),F&&!xe&&(0,R.jsx)(rH,{serverId:F.id,open:T})]})]})}),(0,R.jsx)(ML,{isOpen:x,onOpenChange:S,tools:le,prompts:ue,resources:de,savedRequests:E,connections:r,selectedServer:P,tunnelUrl:_,onNavigate:N,onServerSelect:oe})]})}function sH({...e}){let{resolvedTheme:t}=_z();return(0,R.jsx)(oI,{theme:t,className:`toaster group`,style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`},...e})}var cH=(0,z.createContext)(void 0),lH={deviceType:`desktop`,customViewport:{width:768,height:1024},cspMode:`permissive`,displayModeOverride:null,capabilities:{hover:!0,touch:!1},safeAreaInsets:{top:0,right:0,bottom:0,left:0},locale:`en-US`,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`};function uH({children:e}){let[t,n]=(0,z.useState)({activeWidgetId:null,widgets:new Map,playground:lH}),r=(0,z.useCallback)(e=>{n(t=>({...t,activeWidgetId:e}))},[]),i=(0,z.useCallback)((e,t)=>{n(n=>{if(n.widgets.has(e))return n;let r=new Map(n.widgets);return r.set(e,{...t,cspViolations:[]}),{...n,widgets:r}})},[]),a=(0,z.useCallback)(e=>{n(t=>{let n=new Map(t.widgets);return n.delete(e),{...t,widgets:n,activeWidgetId:t.activeWidgetId===e?null:t.activeWidgetId}})},[]),o=(0,z.useRef)(t);o.current=t;let s=(0,z.useCallback)(e=>o.current.widgets.get(e),[]),c=(0,z.useCallback)((e,t)=>{n(n=>{let r=n.widgets.get(e);if(!r)return n;let i={cspViolations:[...r.cspViolations,t]};t.originalPolicy&&r.effectivePolicy===void 0&&(i.effectivePolicy=t.originalPolicy);let a=new Map(n.widgets);return a.set(e,{...r,...i}),{...n,widgets:a}})},[]),l=(0,z.useCallback)(e=>{n(t=>{let n=t.widgets.get(e);if(!n)return t;let r=new Map(t.widgets);return r.set(e,{...n,cspViolations:[]}),{...t,widgets:r}})},[]),u=(0,z.useCallback)((e,t)=>{n(n=>{let r=n.widgets.get(e);if(!r)return n;let i=new Map(n.widgets);return i.set(e,{...r,modelContext:t}),{...n,widgets:i}})},[]),d=(0,z.useCallback)((e,t)=>{n(n=>{let r=n.widgets.get(e);if(!r)return n;let i=new Map(n.widgets);return i.set(e,{...r,widgetState:t}),{...n,widgets:i}})},[]),f=(0,z.useCallback)((e,t,r)=>{n(n=>{let i=n.widgets.get(e);if(!i)return n;let a=new Map(n.widgets);return a.set(e,{...i,declaredCsp:t,...r!==void 0&&{effectivePolicy:r}}),{...n,widgets:a}})},[]),p=(0,z.useCallback)(e=>{n(t=>({...t,playground:{...t.playground,...e}}))},[]),m=(0,z.useCallback)(()=>{n(e=>({...e,widgets:new Map,activeWidgetId:null}))},[]),h=(0,z.useCallback)(()=>{let e=new Map;for(let[n,r]of t.widgets)r.modelContext&&e.set(n,r.modelContext);return e},[t.widgets]);return(0,R.jsx)(cH,{value:(0,z.useMemo)(()=>({...t,setActiveWidget:r,addWidget:i,removeWidget:a,getWidget:s,addCspViolation:c,clearCspViolations:l,setWidgetModelContext:u,setWidgetState:d,setWidgetDeclaredCsp:f,updatePlaygroundSettings:p,clearAllWidgets:m,getAllModelContexts:h}),[t,r,i,a,s,c,l,u,d,f,p,m,h]),children:e})}function dH(){let e=(0,z.use)(cH);if(!e)throw Error(`useWidgetDebug must be used within WidgetDebugProvider`);return e}var fH={mobile:{width:390,height:844,name:`iPhone 14`},tablet:{width:820,height:1180,name:`iPad Air`},desktop:{width:1440,height:900,name:`Desktop`},custom:{width:768,height:1024,name:`Custom`}},pH=(0,z.lazy)(()=>tS(()=>import(`./OAuthCallback-Bp-jLoQs.js`).then(e=>({default:e.OAuthCallback})),__vite__mapDeps([40,1,5]))),mH=(0,z.lazy)(()=>tS(()=>import(`./ManufactOAuthCallback-B-tdkUA2.js`).then(e=>({default:e.ManufactOAuthCallback})),__vite__mapDeps([41,1,5]))),hH=(0,z.lazy)(()=>tS(()=>import(`./ViewPreview-DWtmwzCb.js`).then(e=>({default:e.ViewPreview})),__vite__mapDeps([42,1,5,19])));function gH({activeTabRef:e}){let{activeTab:t}=fL();return(0,z.useEffect)(()=>{e.current=t},[t,e]),null}function _H(){let e=(0,z.useRef)(`tools`),t=new URLSearchParams(window.location.search),n=t.get(`embedded`)===`true`,r=t.get(`theme`),i=(0,z.useMemo)(()=>n?void 0:new TM(`mcp-inspector-connections`),[n]),a=uM(),o=a?.replace(/\/proxy\/?$/,`/oauth`),s=rM();return(0,z.useEffect)(()=>{wT()},[]),(0,z.useEffect)(()=>{let e=t.get(`auth_error`);if(!e)return;let n=t.get(`auth_error_description`);GF.error(`OAuth authentication failed: ${n||e}`,{duration:1/0,closeButton:!0});let r=new URLSearchParams(t);r.delete(`auth_error`),r.delete(`auth_error_description`);let i=r.toString();window.history.replaceState({},``,`${window.location.pathname}${i?`?${i}`:``}`)},[]),(0,R.jsx)(vz,{forcedTheme:r||void 0,children:(0,R.jsx)(pe,{defaultShape:`pill`,children:(0,R.jsx)(uH,{children:(0,R.jsx)(xj,{storageProvider:i,enableRpcLogging:!0,defaultCallbackUrl:`${window.location.origin}${s}/oauth/callback`,defaultOAuthProxyUrl:o,defaultAutoProxyFallback:a?{enabled:!0,proxyAddress:a}:!1,defaultServerConfig:{preventAutoAuth:!0,useRedirectFlow:!0},clientInfo:{name:`mcp-use Inspector`,version:ko(),websiteUrl:`https://mcp-use.com`,icons:[{src:`https://mcp-use.com/logo.png`}],capabilities:{extensions:{"io.modelcontextprotocol/ui":{mimeTypes:[`text/html;profile=mcp-app`]}}}},onServerAdded:(e,t)=>{console.log(`[Inspector] Server added:`,e,t.state)},onServerRemoved:e=>{console.log(`[Inspector] Server removed:`,e)},onServerStateChange:(e,t)=>{console.log(`[Inspector] Server state changed:`,e,t)},onSamplingRequest:(e,t,n,r,i)=>{let a=GF((0,R.jsx)(Fn,{title:`Sampling Request Received`,description:`New request from ${n}`,actions:[{label:`View Details`,testId:`sampling-toast-view-details`,onClick:()=>{let t=new CustomEvent(`navigate-to-sampling`,{detail:{requestId:e.id}});window.dispatchEvent(t),GF.dismiss(a)}},{label:`Approve`,testId:`sampling-toast-approve`,onClick:()=>{r(e.id,In),GF.success(`Sampling request approved`),GF.dismiss(a)}},{label:`Deny`,testId:`sampling-toast-deny`,onClick:()=>{i(e.id,`User denied from toast`),GF.dismiss(a)}}]}),{duration:1/0})},onElicitationRequest:(t,n,r,i,a)=>{if(e.current===`chat`)return;let o=t.request.mode||`form`,s=t.request.message,c=o===`url`&&`url`in t.request?t.request.url:void 0,l=GF((0,R.jsx)(Fn,{title:`Elicitation Request Received`,description:`From ${r}: ${s}`,extra:o===`url`&&c?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 font-mono`,children:c}):void 0,actions:[{label:`View Details`,testId:`elicitation-toast-view-details`,onClick:()=>{let e=new CustomEvent(`navigate-to-elicitation`,{detail:{requestId:t.id}});window.dispatchEvent(e),GF.dismiss(l)}},...o===`url`&&c?[{label:`Open URL`,testId:`elicitation-toast-open-url`,onClick:()=>{window.open(c,`_blank`),GF.dismiss(l)}}]:[],{label:`Cancel`,testId:`elicitation-toast-cancel`,onClick:()=>{a(t.id,`User cancelled from toast`),GF.dismiss(l)}}]}),{duration:1/0})},children:(0,R.jsxs)(dL,{children:[(0,R.jsx)(gH,{activeTabRef:e}),(0,R.jsx)(lF,{basename:s,children:(0,R.jsxs)(bP,{children:[(0,R.jsx)(vP,{path:`/oauth/callback`,element:(0,R.jsx)(kR,{children:(0,R.jsx)(pH,{})})}),(0,R.jsx)(vP,{path:`/auth/callback`,element:(0,R.jsx)(kR,{children:(0,R.jsx)(mH,{})})}),(0,R.jsx)(vP,{path:`/preview/:view`,element:(0,R.jsx)(kR,{children:(0,R.jsx)(hH,{})})}),(0,R.jsx)(vP,{path:`/`,element:(0,R.jsx)(oH,{children:(0,R.jsx)(lL,{})})})]})}),(0,R.jsx)(sH,{position:`top-center`})]})})})})})}var vH=document.getElementById(`root`);vH?Pn.createRoot(vH).render((0,R.jsx)(_H,{})):console.error(`[inspector] Root element not found`);export{JN as $,Zr as $t,YI as A,qa as At,zI as B,Pi as Bt,pL as C,To as Ct,rL as D,mo as Dt,iL as E,ho as Et,eL as F,Ji as Ft,wI as G,yi as Gt,MI as H,Oi as Ht,JI as I,qi as It,gI as J,si as Jt,yI as K,vi as Kt,HI as L,Ui as Lt,$I as M,Za as Mt,XI as N,Ja as Nt,qI as O,So as Ot,QI as P,Pa as Pt,GF as Q,$r as Qt,VI as R,Hi as Rt,hL as S,hf as St,aL as T,go as Tt,EI as U,wi as Ut,NI as V,ki as Vt,TI as W,bi as Wt,pI as X,ri as Xt,hI as Y,ai as Yt,mI as Z,ti as Zt,Qz as _,ET as _t,NV as a,Ir as an,cM as at,jR as b,tS as bt,DV as c,jr as cn,iM as ct,fV as d,Yj as dt,Xr as en,bF as et,oV as f,Lj as ft,$z as g,Sj as gt,Zz as h,cj as ht,PV as i,Vr as in,bM as it,tL as j,Ya as jt,ZI as k,to as kt,SV as l,vr as ln,Qj as lt,CB as m,Rj as mt,dH as n,qr as nn,uM as nt,MV as o,Fr as on,lM as ot,LB as p,zj as pt,fI as q,di as qt,YV as r,Wr as rn,xM as rt,OV as s,Mr as sn,nM as st,fH as t,Yr as tn,gM as tt,dV as u,_r as un,$j as ut,_z as v,RC as vt,fL as w,vo as wt,mR as x,Mb as xt,XR as y,Q as yt,BI as z,Li as zt};
|
|
475
|
+
`;for(let{name:n}of e)t+=`export ${n}="your-${n}-value"\n`;return t}function OL({className:e,size:t=`md`}){return(0,R.jsxs)(`svg`,{viewBox:`0 0 500 500`,className:A(`text-current`,{sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`}[t],e),fill:`currentColor`,fillRule:`nonzero`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`path`,{d:`M105.933 0C164.437 0.000116002 211.865 47.607 211.865 106.333C211.865 131.829 210.493 158.403 221.068 181.602L228.975 198.947C243.584 230.997 269.265 256.7 301.303 271.336L316.155 278.121C340.142 289.079 367.694 287.335 394.066 287.335C452.571 287.335 499.999 334.942 499.999 393.668C499.999 452.394 452.571 500.001 394.066 500.001C335.562 500.001 288.134 452.394 288.134 393.668C288.134 368.974 289.24 343.275 278.992 320.807L270.586 302.38C255.948 270.29 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.86252e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z`}),(0,R.jsx)(`circle`,{cx:`100.426`,cy:`399.575`,r:`100.426`}),(0,R.jsx)(`path`,{d:`M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z`})]})}function kL({className:e}){return(0,R.jsx)(`svg`,{viewBox:`0 0 24 24`,className:e,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:(0,R.jsx)(`path`,{d:`M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z`})})}function AL({className:e}){return(0,R.jsxs)(`svg`,{fill:`currentColor`,fillRule:`evenodd`,viewBox:`0 0 24 24`,className:e,xmlns:`http://www.w3.org/2000/svg`,"aria-label":`ModelContextProtocol`,children:[(0,R.jsx)(`path`,{d:`M15.688 2.343a2.588 2.588 0 00-3.61 0l-9.626 9.44a.863.863 0 01-1.203 0 .823.823 0 010-1.18l9.626-9.44a4.313 4.313 0 016.016 0 4.116 4.116 0 011.204 3.54 4.3 4.3 0 013.609 1.18l.05.05a4.115 4.115 0 010 5.9l-8.706 8.537a.274.274 0 000 .393l1.788 1.754a.823.823 0 010 1.18.863.863 0 01-1.203 0l-1.788-1.753a1.92 1.92 0 010-2.754l8.706-8.538a2.47 2.47 0 000-3.54l-.05-.049a2.588 2.588 0 00-3.607-.003l-7.172 7.034-.002.002-.098.097a.863.863 0 01-1.204 0 .823.823 0 010-1.18l7.273-7.133a2.47 2.47 0 00-.003-3.537z`}),(0,R.jsx)(`path`,{d:`M14.485 4.703a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a4.115 4.115 0 000 5.9 4.314 4.314 0 006.016 0l7.12-6.982a.823.823 0 000-1.18.863.863 0 00-1.204 0l-7.119 6.982a2.588 2.588 0 01-3.61 0 2.47 2.47 0 010-3.54l7.12-6.982z`})]})}function jL({className:e}){return(0,R.jsx)(`svg`,{viewBox:`0 -28.5 256 256`,className:e,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:(0,R.jsx)(`path`,{d:`M216.856339,16.5966031 C200.285002,8.84328665 182.566144,3.2084988 164.041564,0 C161.766523,4.11318106 159.108624,9.64549908 157.276099,14.0464379 C137.583995,11.0849896 118.072967,11.0849896 98.7430163,14.0464379 C96.9108417,9.64549908 94.1925838,4.11318106 91.8971895,0 C73.3526068,3.2084988 55.6133949,8.86399117 39.0420583,16.6376612 C5.61752293,67.146514 -3.4433191,116.400813 1.08711069,164.955721 C23.2560196,181.510915 44.7403634,191.567697 65.8621325,198.148576 C71.0772151,190.971126 75.7283628,183.341335 79.7352139,175.300261 C72.104019,172.400575 64.7949724,168.822202 57.8887866,164.667963 C59.7209612,163.310589 61.5131304,161.891452 63.2445898,160.431257 C105.36741,180.133187 151.134928,180.133187 192.754523,160.431257 C194.506336,161.891452 196.298154,163.310589 198.110326,164.667963 C191.183787,168.842556 183.854737,172.420929 176.223542,175.320965 C180.230393,183.341335 184.861538,190.991831 190.096624,198.16893 C211.238746,191.588051 232.743023,181.531619 254.911949,164.955721 C260.227747,108.668201 245.831087,59.8662432 216.856339,16.5966031 Z M85.4738752,135.09489 C72.8290281,135.09489 62.4592217,123.290155 62.4592217,108.914901 C62.4592217,94.5396472 72.607595,82.7145587 85.4738752,82.7145587 C98.3405064,82.7145587 108.709962,94.5189427 108.488529,108.914901 C108.508531,123.290155 98.3405064,135.09489 85.4738752,135.09489 Z M170.525237,135.09489 C157.88039,135.09489 147.510584,123.290155 147.510584,108.914901 C147.510584,94.5396472 157.658606,82.7145587 170.525237,82.7145587 C183.391518,82.7145587 193.761324,94.5189427 193.539891,108.914901 C193.539891,123.290155 183.391518,135.09489 170.525237,135.09489 Z`,fillRule:`nonzero`})})}function ML({isOpen:e,onOpenChange:t,tools:n,prompts:r,resources:i,savedRequests:a,connections:o,selectedServer:s,tunnelUrl:c,onNavigate:l,onServerSelect:u}){let[d,f]=(0,z.useState)(``),[p,m]=(0,z.useState)(0),h=(0,z.useRef)(null),g=(0,z.useRef)(null),_=KN(),v=w.pill,{activeIndex:y,itemRects:b,sessionRef:x,handlers:S,registerItem:C,measureItems:ee}=_n(h),E=s?c?`${c}/mcp`:s.url:null,D=s?.name||`MCP Server`,te=s?_M(s):void 0,ne=s?[{id:`open-in-cursor`,name:`Open in Cursor`,description:`Add this server to Cursor`,type:`global`,category:`Open in Client`,action:()=>{try{let e=yL(E,D,te);window.location.href=e,GF.success(`Opening in Cursor...`),t(!1)}catch{GF.error(`Failed to open in Cursor`)}}},{id:`open-in-claude-code`,name:`Open in Claude Code`,description:`Add this server to Claude Code CLI`,type:`global`,category:`Open in Client`,action:()=>{let{command:e}=wL(E,D,te);Qj(e),GF.success(`Command copied to clipboard`),t(!1)}},{id:`open-in-claude-desktop`,name:`Open in Claude Desktop`,description:`Download .mcpb configuration file`,type:`global`,category:`Open in Client`,action:()=>{try{CL(E,D,te),GF.success(`Downloaded .mcpb file`),t(!1)}catch{GF.error(`Failed to download configuration file`)}}},{id:`open-in-vscode`,name:`Open in VS Code`,description:`Add this server to VS Code`,type:`global`,category:`Open in Client`,action:()=>{try{let e=bL(E,D,te);window.location.href=e,GF.success(`Opening in VS Code...`),t(!1)}catch{GF.error(`Failed to open in VS Code`)}}},{id:`open-in-vscode-insiders`,name:`Open in VS Code Insiders`,description:`Add this server to VS Code Insiders`,type:`global`,category:`Open in Client`,action:()=>{try{let e=xL(E,D,te);window.location.href=e,GF.success(`Opening in VS Code Insiders...`),t(!1)}catch{GF.error(`Failed to open in VS Code Insiders`)}}},{id:`open-in-gemini`,name:`Open in Gemini CLI`,description:`Add this server to Gemini CLI`,type:`global`,category:`Open in Client`,action:()=>{let{command:e}=TL(E,D,te);Qj(e),GF.success(`Command copied to clipboard`),t(!1)}},{id:`open-in-codex`,name:`Open in Codex CLI`,description:`Add this server to Codex CLI`,type:`global`,category:`Open in Client`,action:()=>{let{config:e}=EL(E,D,te);Qj(e),GF.success(`Config copied to clipboard`),t(!1)}}]:[],O=[{id:`connect-server`,name:`Connect Server`,description:`Add a new MCP server connection`,type:`global`,category:`Navigation`,action:()=>_(`/`)},{id:`mcp-use-website`,name:`MCP Use Website`,description:`Visit mcp-use.com for tools and resources`,type:`global`,category:`Documentation`,action:()=>window.open(`https://mcp-use.com`,`_blank`)},{id:`mcp-use-docs`,name:`How to Create an MCP Server`,description:`Step-by-step guide to building MCP servers`,type:`global`,category:`Documentation`,action:()=>window.open(`https://mcp-use.com/docs`,`_blank`)},{id:`mcp-docs`,name:`MCP Official Documentation`,description:`Learn about the Model Context Protocol`,type:`global`,category:`Documentation`,action:()=>window.open(`https://modelcontextprotocol.io/docs/getting-started/intro`,`_blank`)},{id:`discord`,name:`Join Discord Community`,description:`Connect with the MCP community`,type:`global`,category:`Community`,action:()=>window.open(`https://discord.gg/XkNkSkMz3V`,`_blank`)},{id:`clear-localstorage`,name:`Clear localStorage & Reload`,description:`Having trouble connecting? Clear stored auth data and refresh`,type:`global`,category:`Troubleshooting`,action:()=>{let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n&&(n.startsWith(`mcp:auth`)||n.startsWith(`mcp-inspector`))&&e.push(n)}e.forEach(e=>localStorage.removeItem(e)),GF.success(`Cleared ${e.length} localStorage item(s). Refreshing page...`,{duration:2e3}),setTimeout(()=>{window.location.reload()},500),t(!1)}}],re=o.map(e=>({id:`server-${e.id}`,name:lM(e),description:`Connected server (${e.state})`,type:`global`,category:`Connected Servers`,metadata:{serverId:e.id,state:e.state},action:()=>u(e.id)})),k=[...O,...ne,...re,...n.map(e=>({id:`tool-${e.name}`,name:e.name,description:e.description,type:`tool`,category:e._serverName?`Tools - ${e._serverName}`:`Tools`,metadata:{inputSchema:e.inputSchema,serverId:e._serverId,serverName:e._serverName}})),...r.map(e=>({id:`prompt-${e.name}`,name:e.name,description:e.description,type:`prompt`,category:e._serverName?`Prompts - ${e._serverName}`:`Prompts`,metadata:{arguments:e.arguments,serverId:e._serverId,serverName:e._serverName}})),...i.map(e=>({id:`resource-${e.uri}`,name:e.name,description:e.description,type:`resource`,category:e._serverName?`Resources - ${e._serverName}`:`Resources`,metadata:{uri:e.uri,mimeType:e.mimeType,serverId:e._serverId,serverName:e._serverName}})),...a.map(e=>({id:`saved-${e.id}`,name:e.name,description:`Saved request for ${e.toolName}`,type:`saved-request`,category:`Saved Requests`,metadata:{toolName:e.toolName,args:e.args,savedAt:e.savedAt,serverId:e.serverId,serverName:e.serverName}}))].filter(e=>d.trim()?`${e.name} ${e.description||``} ${e.category}`.toLowerCase().includes(d.trim().toLowerCase()):!0),ie=(0,z.useCallback)(e=>{if(console.warn(`[CommandPalette] Item selected:`,{itemType:e.type,itemName:e.name,itemId:e.id,metadata:e.metadata}),e.action)console.warn(`[CommandPalette] Executing action for global item`),e.action(),t(!1);else if(e.type===`global`)e.metadata?.serverId&&(console.warn(`[CommandPalette] Selecting server:`,e.metadata.serverId),u(e.metadata.serverId),t(!1));else{let n=e.type===`resource`?e.metadata?.uri:e.name,r=e.type===`tool`?`tools`:e.type===`prompt`?`prompts`:e.type===`saved-request`?`tools`:`resources`;fetch(`http://127.0.0.1:7371/ingest/4e7482c5-571f-4071-bd09-762c357289f4`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Debug-Session-Id":`831b88`},body:JSON.stringify({sessionId:`831b88`,location:`CommandPalette.tsx:handleSelect`,message:`palette navigate item`,data:{itemType:e.type,itemName:e.name,itemIdentifier:n,tabName:r,serverId:e.metadata?.serverId??null},timestamp:Date.now(),hypothesisId:`H1`})}).catch(()=>{}),console.warn(`[CommandPalette] Navigating to item:`,{tab:r,itemIdentifier:n,serverId:e.metadata?.serverId}),l(r,n,e.metadata?.serverId),t(!1)}},[l,t,u]),j=(e,t,n)=>{switch(e){case`tool`:return(0,R.jsx)(`div`,{className:`bg-blue-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(qi,{className:`h-4 w-4 text-blue-500`})});case`prompt`:return(0,R.jsx)(`div`,{className:`bg-purple-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(vi,{className:`h-4 w-4 text-purple-500`})});case`resource`:return(0,R.jsx)(`div`,{className:`bg-green-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Qr,{className:`h-4 w-4 text-green-500`})});case`saved-request`:return(0,R.jsx)(`div`,{className:`bg-orange-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(ri,{className:`h-4 w-4 text-orange-500`})});case`global`:if(t===`Navigation`)return(0,R.jsx)(`div`,{className:`bg-gray-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(ki,{className:`h-4 w-4 text-gray-600 dark:text-gray-300`})});if(t===`Open in Client`){if(n?.includes(`Cursor`))return(0,R.jsx)(`div`,{className:`bg-gray-200 dark:bg-gray-800 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/cursor`,alt:`Cursor`,className:`h-4 w-4`})});if(n?.includes(`Claude Code`)||n?.includes(`Claude Desktop`))return(0,R.jsx)(`div`,{className:`bg-orange-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`})});if(n?.includes(`VS Code`))return(0,R.jsx)(`div`,{className:`bg-blue-600/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(kL,{className:`h-4 w-4 text-blue-600`})});if(n?.includes(`Gemini`))return(0,R.jsx)(`div`,{className:`bg-purple-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/googlegemini`,alt:`Gemini`,className:`h-4 w-4`})});if(n?.includes(`Codex`))return(0,R.jsx)(`div`,{className:`bg-green-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(`img`,{src:`https://inspector-cdn.mcp-use.com/providers/openai.png`,alt:`Codex`,className:`h-4 w-4`})})}return t===`Documentation`?n?.includes(`MCP Use`)||n?.includes(`mcp-use`)?(0,R.jsx)(`div`,{className:`bg-black/10 dark:bg-white/10 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(OL,{className:`h-4 w-4 text-black dark:text-white`,size:`sm`})}):(0,R.jsx)(`div`,{className:`bg-orange-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Yr,{className:`h-4 w-4 text-orange-500`})}):t===`Community`?(0,R.jsx)(`div`,{className:`bg-purple-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(jL,{className:`h-4 w-4 text-purple-500`})}):t===`Troubleshooting`?(0,R.jsx)(`div`,{className:`bg-yellow-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Pr,{className:`h-4 w-4 text-yellow-500`})}):t===`Connected Servers`?(0,R.jsx)(`div`,{className:`bg-cyan-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Ni,{className:`h-4 w-4 text-cyan-500`})}):(0,R.jsx)(`div`,{className:`bg-gray-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(Yr,{className:`h-4 w-4 text-gray-500`})});default:return(0,R.jsx)(`div`,{className:`bg-gray-500/20 rounded-full p-2 flex items-center justify-center shrink-0`,children:(0,R.jsx)(T,{className:`h-4 w-4 text-gray-500`})})}};(0,z.useEffect)(()=>{e&&(f(``),m(0),requestAnimationFrame(()=>g.current?.focus()))},[e]),(0,z.useEffect)(()=>{h.current&&(h.current.scrollTop=0),m(0)},[d]),(0,z.useEffect)(()=>{p>=k.length&&m(Math.max(0,k.length-1))},[p,k.length]),(0,z.useLayoutEffect)(()=>{e&&ee()},[e,ee,k]);let M=b[p]??null,ae=y===null?null:b[y],oe=y!==null&&y!==p;return e?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-50 bg-black/40 backdrop-blur-sm`,"aria-label":`Close command palette`,onClick:()=>t(!1)}),(0,R.jsxs)(`div`,{role:`dialog`,"aria-label":`Command Palette`,"data-testid":`command-palette-dialog`,className:`fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 z-[51] max-w-[640px] w-[calc(100vw-2rem)] sm:w-full p-2 bg-white dark:bg-zinc-900/90 backdrop-blur-xl rounded-xl overflow-hidden border border-border shadow-[var(--cmdk-shadow)] transition-transform duration-100 ease-out outline-none`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),m(e=>Math.min(e+1,k.length-1))):e.key===`ArrowUp`?(e.preventDefault(),m(e=>Math.max(e-1,0))):e.key===`Enter`&&k[p]?(e.preventDefault(),ie(k[p])):e.key===`Escape`&&(e.preventDefault(),t(!1))},children:[(0,R.jsx)(`input`,{ref:g,placeholder:`What do you need?`,value:d,onChange:e=>f(e.target.value),className:`border-none w-full text-[17px] px-4 pt-2 pb-4 outline-none bg-transparent text-foreground border-b border-border mb-0 rounded-none placeholder:text-muted-foreground`,"data-testid":`command-palette-input`}),(0,R.jsxs)(`div`,{ref:h,onMouseEnter:S.onMouseEnter,onMouseMove:S.onMouseMove,onMouseLeave:S.onMouseLeave,className:`relative isolate min-h-[200px] sm:min-h-[330px] max-h-[400px] overflow-auto overscroll-contain transition-[height] duration-100 ease-out px-1`,"data-testid":`command-palette-list`,children:[(0,R.jsx)(en,{children:M&&(0,R.jsx)(qe.div,{"aria-hidden":!0,className:A(`pointer-events-none absolute bg-active`,v.bg),initial:!1,animate:{top:M.top,left:M.left,width:M.width,height:M.height,opacity:oe?.8:1},exit:{opacity:0,transition:At.moderate.exit},transition:{...At.moderate,opacity:{duration:.08}}})}),(0,R.jsx)(en,{children:ae&&(0,R.jsx)(qe.div,{"aria-hidden":!0,className:A(`pointer-events-none absolute bg-hover`,v.bg),initial:{opacity:0,top:M?.top??ae.top,left:M?.left??ae.left,width:M?.width??ae.width,height:M?.height??ae.height},animate:{opacity:1,top:ae.top,left:ae.left,width:ae.width,height:ae.height},exit:{opacity:0,transition:At.fast.exit},transition:{...At.fast,opacity:{duration:.08}}},x.current)}),k.length===0?(0,R.jsx)(`div`,{className:`text-sm flex items-center justify-center h-12 whitespace-pre-wrap text-muted-foreground`,children:`No results found.`}):k.map((e,t)=>(0,R.jsxs)(`button`,{ref:e=>C(t,e),type:`button`,"data-testid":`command-palette-item-${e.id}`,"data-proximity-index":t,onClick:()=>ie(e),className:`[content-visibility:auto] relative z-10 cursor-pointer h-12 text-sm flex items-center gap-3 px-3 text-foreground select-none w-full text-left mt-1 first:mt-0`,children:[j(e.type,e.category,e.name),(0,R.jsx)(`span`,{className:`font-medium truncate flex-1 min-w-0`,children:e.name}),(()=>{let t=e.metadata?.serverId;if(!t||e.category===`Connected Servers`)return null;let n=o.find(e=>e.id===t);return n?(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 text-muted-foreground`,children:[(0,R.jsx)(oL,{server:n,size:`xs`}),(0,R.jsx)(`span`,{className:`text-xs truncate max-w-[9rem]`,children:lM(n)})]}):null})()]},e.id))]}),(0,R.jsxs)(`div`,{className:`border-t border-border px-4 py-3 pb-1 flex items-center justify-between text-xs text-muted-foreground `,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`t`}),(0,R.jsx)(`span`,{children:`Tools`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`p`}),(0,R.jsx)(`span`,{children:`Prompts`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`r`}),(0,R.jsx)(`span`,{children:`Resources`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`c`}),(0,R.jsx)(`span`,{children:`Chat`})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center w-5 h-5 font-mono font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`h`}),(0,R.jsx)(`span`,{children:`Home`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`inline-flex items-center justify-center px-2 h-5 font-mono text-[10px] font-medium rounded shadow-sm bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-foreground leading-none`,children:`esc`}),(0,R.jsx)(`span`,{children:`Close`})]})]})]})]})]}):null}var NL=`openid profile email offline_access`,PL=`mcp-inspector:manufact-auth`,FL=`manufact:session-changed`,IL={loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null},LL=new Map,RL=new Set,zL=new Map,BL=new Map;function VL(e){let t=LL.get(e);if(t)return t;let n={...IL,loaded:!1};return LL.set(e,n),n}function HL(){return typeof window>`u`?null:window.localStorage}function UL(e){return new URL(e).origin}function WL(e,t){let n=new URL(e),r=new URL(t),i=new Set([`localhost`,`127.0.0.1`]);return i.has(n.hostname)&&i.has(r.hostname)?n.origin===r.origin:(n.hostname===`manufact.com`||n.hostname.endsWith(`.manufact.com`))&&(r.hostname===`manufact.com`||r.hostname.endsWith(`.manufact.com`))}function GL(e){let t=window.__MANUFACT_LOGIN_URL__;if(t)return new URL(t).origin;let n=new URL(e);return n.hostname===`localhost`||n.hostname===`127.0.0.1`?`${n.protocol}//${n.hostname}:3000`:`${n.protocol}//manufact.com`}function KL(e){return`${GL(e)}/login`}function qL(e){return`${GL(e)}/auth/embedded-sign-out`}function JL(e,t){return`${PL}:${t}:${e}`}function YL(e){return HL()?.getItem(JL(e,`skip-session`))===`1`}function XL(e,t){let n=JL(e,`skip-session`);t?HL()?.setItem(n,`1`):HL()?.removeItem(n)}function ZL(e){return`${PL}:state:${e}`}function QL(e){let t=HL()?.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return HL()?.removeItem(e),null}}function $L(e,t){HL()?.setItem(e,JSON.stringify(t))}function eR(e,t){LL.set(e,{...LL.get(e)??IL,...t}),RL.forEach(e=>e()),window.dispatchEvent(new CustomEvent(FL))}function tR(e){let t=``;return e.forEach(e=>{t+=String.fromCharCode(e)}),btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function nR(e=32){let t=new Uint8Array(e);return crypto.getRandomValues(t),tR(t)}async function rR(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e));return tR(new Uint8Array(t))}async function iR(e){let t=await fetch(`${e}/api/auth/.well-known/openid-configuration`);if(!t.ok)throw Error(`Manufact OAuth discovery failed`);return await t.json()}function aR(){return`${window.location.origin}${rM()}/auth/callback`}async function oR(e,t){let n=aR(),r=JL(e,`client`),i=QL(r);if(i?.client_id&&i.redirect_uri===n)return i;if(!t.registration_endpoint)throw Error(`Manufact OAuth registration is unavailable`);let a=await fetch(t.registration_endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({client_name:`mcp-use Inspector`,redirect_uris:[n],grant_types:[`authorization_code`,`refresh_token`],response_types:[`code`],token_endpoint_auth_method:`none`,scope:NL})});if(!a.ok)throw Error(`Could not register Inspector with Manufact`);let o=await a.json();if(!o.client_id)throw Error(`Manufact returned no OAuth client ID`);let s={...o,redirect_uri:n};return $L(r,s),s}async function sR(e,t){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams(t)}),r=await n.json().catch(()=>({}));if(!n.ok||!r.access_token)throw Error(r.error_description??`Manufact token exchange failed`);return{access_token:r.access_token,refresh_token:r.refresh_token,token_type:r.token_type,expires_at:Date.now()+(r.expires_in??3600)*1e3}}async function cR(e,t){if(!t.refresh_token)return null;let n=BL.get(e);if(n)return n;let r=(async()=>{try{let n=await iR(e),r=QL(JL(e,`client`));if(!r?.client_id)return null;let i=await sR(n.token_endpoint,{grant_type:`refresh_token`,refresh_token:t.refresh_token,client_id:r.client_id}),a={...i,refresh_token:i.refresh_token??t.refresh_token};return $L(JL(e,`tokens`),a),a}catch{return HL()?.removeItem(JL(e,`tokens`)),null}finally{BL.delete(e)}})();return BL.set(e,r),r}async function lR(e){let t=QL(JL(e,`tokens`));return t?.access_token?t.expires_at>Date.now()+3e4?t:cR(e,t):null}async function uR(e,t){let n=await iR(e);if(!n.userinfo_endpoint)return null;let r=await fetch(n.userinfo_endpoint,{headers:{Authorization:`Bearer ${t}`}});if(!r.ok)return null;let i=await r.json();return i.sub?{id:i.sub,name:i.name,email:i.email,image:i.picture}:null}async function dR(e){try{let t=await fetch(`${e}/api/auth/get-session`,{credentials:`include`});return t.ok?(await t.json())?.user??null:null}catch{return null}}async function fR(e){let t=zL.get(e);if(t)return t;LL.set(e,{...LL.get(e)??IL,loaded:!1});let n=(async()=>{try{let t=WL(typeof window<`u`?window.location.href:e,e),n=YL(e),r=await lR(e),i=r?await uR(e,r.access_token):null;if(i&&r){XL(e,!1),eR(e,{loaded:!0,accessToken:r.access_token,user:i,mode:`oauth`});return}r&&!i&&HL()?.removeItem(JL(e,`tokens`));let a=t&&!n?await dR(e):null;if(a){eR(e,{loaded:!0,accessToken:null,user:a,mode:`session`});return}eR(e,{loaded:!0,accessToken:null,user:null,mode:null})}catch{eR(e,{loaded:!0,accessToken:null,user:null,mode:null})}})().finally(()=>zL.delete(e));return zL.set(e,n),n}async function pR(e){let t=UL(e);XL(t,!1);let n=window.open(``,`manufact-oauth`,`width=600,height=700,resizable=yes,scrollbars=yes`);if(!n)throw Error(`Allow popups to sign in with Manufact`);if(eR(t,{authorizing:!0}),WL(window.location.href,t)){n.location.href=KL(t);let e=window.setInterval(async()=>{if(n.closed){window.clearInterval(e),eR(t,{authorizing:!1});return}let r=await dR(t);r&&(window.clearInterval(e),n.close(),eR(t,{loaded:!0,authorizing:!1,accessToken:null,user:r,mode:`session`}))},1e3);return}try{let e=await iR(t),r=await oR(t,e),i=nR(64),a=nR(),o=aR();$L(ZL(a),{authOrigin:t,clientId:r.client_id,redirectUri:o,codeVerifier:i,expiresAt:Date.now()+600*1e3});let s=new URL(e.authorization_endpoint);s.searchParams.set(`response_type`,`code`),s.searchParams.set(`client_id`,r.client_id),s.searchParams.set(`redirect_uri`,o),s.searchParams.set(`scope`,NL),s.searchParams.set(`state`,a),s.searchParams.set(`code_challenge`,await rR(i)),s.searchParams.set(`code_challenge_method`,`S256`),s.searchParams.set(`prompt`,`consent`),n.location.href=s.toString();let c=window.setInterval(()=>{n.closed&&(window.clearInterval(c),fR(t).finally(()=>eR(t,{authorizing:!1})))},500)}catch(e){throw n.close(),eR(t,{authorizing:!1}),e}}async function mR(e=new URL(window.location.href)){let t=e.searchParams.get(`state`),n=e.searchParams.get(`code`),r=e.searchParams.get(`error_description`)??e.searchParams.get(`error`);if(r)throw Error(r);if(!t||!n)throw Error(`Missing OAuth code or state`);let i=ZL(t),a=QL(i);if(HL()?.removeItem(i),!a||a.expiresAt<Date.now())throw Error(`OAuth state is invalid or expired`);let o=await sR((await iR(a.authOrigin)).token_endpoint,{grant_type:`authorization_code`,code:n,redirect_uri:a.redirectUri,client_id:a.clientId,code_verifier:a.codeVerifier});$L(JL(a.authOrigin,`tokens`),o),XL(a.authOrigin,!1);let s=await uR(a.authOrigin,o.access_token);eR(a.authOrigin,{loaded:!0,authorizing:!1,accessToken:o.access_token,user:s,mode:`oauth`}),window.opener?.postMessage({type:`manufact:oauth-complete`,authOrigin:a.authOrigin},window.location.origin)}function hR(e){let t=UL(e);HL()?.removeItem(JL(t,`tokens`)),eR(t,{loaded:!0,authorizing:!1,accessToken:null,user:null,mode:null})}async function gR(e){let t=QL(JL(e,`tokens`)),n=QL(JL(e,`client`)),r=t?.refresh_token??t?.access_token;if(!n?.client_id||!r)return null;try{let i=(await iR(e)).revocation_endpoint??`${e}/api/auth/oauth2/revoke`;return(await fetch(i,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({client_id:n.client_id,token:r,token_type_hint:t?.refresh_token?`refresh_token`:`access_token`})})).status}catch{return-1}}async function _R(e){let t=GL(e),n=window.open(qL(e),`manufact-sign-out`,`width=420,height=320`);return n?new Promise(r=>{let i=!1,a=e=>{i||(i=!0,window.clearTimeout(o),window.clearInterval(c),window.removeEventListener(`message`,s),r(e))},o=window.setTimeout(()=>{a({attempted:!0,signOutOk:!1,signOutStatus:null})},3e4),s=e=>{e.origin===t&&e.data?.type===`manufact:sign-out-complete`&&a({attempted:!0,signOutOk:!0,signOutStatus:200})},c=window.setInterval(()=>{n.closed&&dR(e).then(e=>{a({attempted:!0,signOutOk:!e,signOutStatus:e?401:200})})},500);window.addEventListener(`message`,s)}):{attempted:!0,signOutOk:!1,signOutStatus:null}}async function vR(e,t){let n=UL(e),r=!!QL(JL(n,`tokens`))?.access_token;t===`oauth`||r?(await gR(n),XL(n,!0)):t===`session`&&(await _R(n),XL(n,!1)),hR(e)}function yR(e){let t=e?UL(e):null,n=(0,z.useSyncExternalStore)((0,z.useCallback)(e=>(RL.add(e),()=>RL.delete(e)),[]),(0,z.useCallback)(()=>t?VL(t):IL,[t]),()=>IL);return(0,z.useEffect)(()=>{if(!t)return;fR(t);let e=e=>{e.origin===window.location.origin&&e.data?.type===`manufact:oauth-complete`&&e.data.authOrigin===t&&fR(t).finally(()=>eR(t,{authorizing:!1}))},n=e=>{e.key!==JL(t,`tokens`)||!e.newValue||fR(t).finally(()=>eR(t,{authorizing:!1}))};return window.addEventListener(`message`,e),window.addEventListener(`storage`,n),()=>{window.removeEventListener(`message`,e),window.removeEventListener(`storage`,n)}},[t]),{...n,authorize:(0,z.useCallback)(async()=>{e&&await pR(e)},[e]),logout:(0,z.useCallback)(async()=>{e&&await vR(e,n.mode)},[e,n.mode])}}var bR=(0,z.lazy)(()=>tS(()=>import(`./ChatTab-Cy8eyFYI.js`).then(e=>({default:e.ChatTab})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))),xR=(0,z.lazy)(()=>tS(()=>import(`./ToolsTab-DJWF7Q_x.js`).then(e=>({default:e.ToolsTab})),__vite__mapDeps([21,1,2,3,4,5,7,6,8,9,22,23,24,13,17,18,19,25,26,27,12,28,29,30]))),SR=(0,z.lazy)(()=>tS(()=>import(`./PromptsTab-DsQVOjKH.js`).then(e=>({default:e.PromptsTab})),__vite__mapDeps([31,1,2,3,4,5,7,6,8,9,25,27,12,28,29,30,16,18,20]))),CR=(0,z.lazy)(()=>tS(()=>import(`./ResourcesTab-Bw8_p6M1.js`).then(e=>({default:e.ResourcesTab})),__vite__mapDeps([32,1,2,3,4,5,8,22,7,6,9,23,24,13,17,18,19,33,25,26,27,12,28,29,14]))),wR=(0,z.lazy)(()=>tS(()=>import(`./SamplingTab-BrcF1zJF.js`).then(e=>({default:e.SamplingTab})),__vite__mapDeps([34,1,2,3,4,5,7,6,8,9,27,12,28,23,24,13,14,18]))),TR=(0,z.lazy)(()=>tS(()=>import(`./ElicitationTab-wDKgU1qL.js`).then(e=>({default:e.ElicitationTab})),__vite__mapDeps([35,1,2,3,4,5,9,27,12,28,23,15,16,18]))),ER=(0,z.lazy)(()=>tS(()=>import(`./NotificationsTab-JevzvJTg.js`).then(e=>({default:e.NotificationsTab})),__vite__mapDeps([36,1,2,3,4,5,33,26,27,12,28,29]))),DR=(0,z.lazy)(()=>tS(()=>import(`./ServerMetadataTab-Bydeh1Po.js`).then(e=>({default:e.ServerMetadataTab})),__vite__mapDeps([37,1,2,3,4,5,10,8,9,28,12,38]))),OR=(0,z.lazy)(()=>tS(()=>import(`./ConnectionSettingsTab-sDZGaUJn.js`).then(e=>({default:e.ConnectionSettingsTab})),__vite__mapDeps([39,1,2,3,4,5,28,12,38])));function kR({children:e}){return(0,R.jsx)(z.Suspense,{fallback:(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsx)(aL,{className:`size-6`})}),children:e})}var AR=`anthropic/claude-sonnet-4.6`;function jR({isManaged:e,enableFreeTierUpgrade:t,isAuthenticated:n}){return e&&t&&!n}function MR({isLoopback:e,chatApiUrl:t}){return e&&!!t}function NR(e,t,n=!1,r){let i=e.replace(/\/chat\/stream\/?$/,`/llm`);return{provider:`openai-compatible`,model:r??`anthropic/claude-sonnet-4.6`,apiKey:t??`server-managed`,baseUrl:i,...n?{credentials:`include`}:{}}}function PR(e){return e?{Authorization:`Bearer ${e}`}:void 0}var FR=`mcp-inspector:managed-model`;function IR(e){return`${FR}:${e}`}function LR(e){try{return localStorage.getItem(IR(e))}catch{return null}}function RR(e,t,n,r){let i=e?new URL(e).origin:null,[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)(AR),[l,u]=(0,z.useState)(()=>i?LR(i)??`anthropic/claude-sonnet-4.6`:AR),[d,f]=(0,z.useState)(!1),p=(0,z.useCallback)(e=>{if(u(e),i)try{localStorage.setItem(IR(i),e)}catch{}},[i]);return(0,z.useEffect)(()=>{if(!r||!i)return;let e=!1;return f(!0),(async()=>{try{let r=PR(t),a=await fetch(`${i}/api/v1/models`,{headers:r,credentials:n===`session`?`include`:`same-origin`});if(!a.ok)return;let s=await a.json();if(e)return;let l=s.models??[];o(l);let d=s.defaultModelId??`anthropic/claude-sonnet-4.6`;c(d);let f=new Set(l.map(e=>e.id)),p=LR(i);p&&f.has(p)?u(p):f.has(d)?u(d):l[0]&&u(l[0].id)}finally{e||f(!1)}})(),()=>{e=!0}},[r,i,t,n]),{models:a,selectedModelId:l,setSelectedModelId:p,isLoading:d,selectedModel:a.find(e=>e.id===l)??null,defaultModelId:s}}var zR=[`tools`,`prompts`,`resources`,`chat`,`sampling`,`elicitation`,`notifications`,`server-metadata`,`connection-settings`];function BR(e){return zR.includes(e)?e:`tools`}function VR({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:i,onUpdateConnection:a,children:o}){let{embeddedConfig:s}=fL(),c=BR(t),[l,u]=(0,z.useState)(()=>new Set([c]));(0,z.useEffect)(()=>{let e=BR(t);u(t=>t.has(e)?t:new Set(t).add(e))},[t]);let{accessToken:d,mode:f,user:p}=yR(s.chatApiUrl),m=PR(d),h=f===`session`?`include`:void 0,g=p!=null,_=s.chatApiUrl,v=!!e?.url&&oM(e.url),y=e?MR({isLoopback:v,chatApiUrl:s.chatApiUrl,enableFreeTierUpgrade:s.chatEnableFreeTierUpgrade}):!1,b=RR(_,d,f,!!e&&!!_&&g),x=y?NR(_,d,f===`session`,g?b.selectedModelId:void 0):s.managedLlmConfig??(_&&!v?{provider:`anthropic`,model:`claude-haiku-4-5`,apiKey:`server-managed`}:void 0);if(!e&&s.forceConnected)return s.chatApiUrl?(0,R.jsx)(kR,{children:(0,R.jsx)(bR,{connection:{id:`force-connected`,url:``,displayName:``,name:``,state:`ready`,tools:[],prompts:[],resources:[]},isConnected:!0,prompts:[],serverId:`force-connected`,callPrompt:async()=>({messages:[]}),readResource:async()=>({contents:[]}),useClientSide:!1,chatApiUrl:s.chatApiUrl,extraHeaders:m,credentials:h,managedLlmConfig:s.managedLlmConfig??{provider:`anthropic`,model:`claude-haiku-4-5`,apiKey:`server-managed`},enableFreeTierUpgrade:s.chatEnableFreeTierUpgrade,hideTitle:s.chatHideTitle,hideModelBadge:s.chatHideModelBadge??!0,hideServerUrl:s.chatHideServerUrl??!0,clearButtonLabel:s.chatClearButtonLabel,clearButtonHideIcon:s.chatClearButtonHideIcon,clearButtonHideShortcut:s.chatClearButtonHideShortcut,clearButtonVariant:s.chatClearButtonVariant,chatQuickQuestions:s.chatQuickQuestions,chatFollowups:s.chatFollowups,hideClearButton:s.chatHideClearButton,hideToolSelector:s.chatHideToolSelector,enableKeyboardShortcuts:!1},`chat-force-connected`)}):(0,R.jsx)(R.Fragment,{children:o});if(!e)return(0,R.jsx)(R.Fragment,{children:o});let S=e=>s.visibleTabs?s.visibleTabs.includes(e):!0,C=zR;return(0,R.jsxs)(kR,{children:[S(`tools`)&&l.has(`tools`)&&(0,R.jsx)(`div`,{style:{display:t===`tools`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(xR,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state===`ready`,refreshTools:e.refreshTools},`tools-${e.id}`)}),S(`prompts`)&&l.has(`prompts`)&&(0,R.jsx)(`div`,{style:{display:t===`prompts`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(SR,{ref:r,prompts:e.prompts,callPrompt:(t,n)=>e.getPrompt(t,n?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,typeof t==`string`?t:String(t??``)])):void 0),serverId:e.id,isConnected:e.state===`ready`,refreshPrompts:e.refreshPrompts},`prompts-${e.id}`)}),S(`resources`)&&l.has(`resources`)&&(0,R.jsx)(`div`,{style:{display:t===`resources`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(CR,{ref:i,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state===`ready`,mcpServerUrl:e.url||``,refreshResources:e.refreshResources},`resources-${e.id}`)}),S(`chat`)&&l.has(`chat`)&&(0,R.jsx)(`div`,{style:{display:t===`chat`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(bR,{connection:e,isConnected:s.forceConnected||e.state===`ready`,prompts:e.prompts,serverId:e.id,callPrompt:(t,n)=>e.getPrompt(t,n?Object.fromEntries(Object.entries(n).map(([e,t])=>[e,typeof t==`string`?t:String(t??``)])):void 0),readResource:e.readResource,useClientSide:y||!_,chatApiUrl:_,extraHeaders:m,credentials:s.chatCredentials??h,managedLlmConfig:x,managedCloudModel:b,enableFreeTierUpgrade:s.chatEnableFreeTierUpgrade,hideTitle:s.chatHideTitle,hideModelBadge:s.chatHideModelBadge??!1,hideServerUrl:s.chatHideServerUrl??!!_,clearButtonLabel:s.chatClearButtonLabel,clearButtonHideIcon:s.chatClearButtonHideIcon,clearButtonHideShortcut:s.chatClearButtonHideShortcut,clearButtonVariant:s.chatClearButtonVariant,chatQuickQuestions:s.chatQuickQuestions,chatFollowups:s.chatFollowups,hideClearButton:s.chatHideClearButton,hideToolSelector:s.chatHideToolSelector,streamProtocol:s.chatStreamProtocol,managedKeyUnavailable:v&&!_&&!y},`chat-${e.id}`)}),S(`sampling`)&&l.has(`sampling`)&&(0,R.jsx)(`div`,{style:{display:t===`sampling`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(wR,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state===`ready`,mcpServerUrl:e.url??``},`sampling-${e.id}`)}),S(`elicitation`)&&l.has(`elicitation`)&&(0,R.jsx)(`div`,{style:{display:t===`elicitation`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(TR,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state===`ready`},`elicitation-${e.id}`)}),S(`notifications`)&&l.has(`notifications`)&&(0,R.jsx)(`div`,{style:{display:t===`notifications`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(ER,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state===`ready`},`notifications-${e.id}`)}),S(`server-metadata`)&&l.has(`server-metadata`)&&(0,R.jsx)(`div`,{style:{display:t===`server-metadata`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(DR,{connection:e},`server-metadata-${e.id}`)}),S(`connection-settings`)&&l.has(`connection-settings`)&&a&&(0,R.jsx)(`div`,{style:{display:t===`connection-settings`?`block`:`none`},className:`h-full`,children:(0,R.jsx)(OR,{connection:e,onSave:a},`connection-settings-${e.id}`)}),!C.includes(t)&&(0,R.jsx)(R.Fragment,{children:o})]})}var HR=z.createContext(void 0);function UR(){let e=z.use(HR);if(!e)throw Error(`useTabs must be used within a TabsProvider`);return e}var WR=z.createContext(void 0);function GR(){return z.use(WR)}function KR({ref:e,children:t,defaultValue:n,value:r,onValueChange:i,className:a,collapsed:o,onCollapsedChange:s,...c}){let[l,u]=z.useState(n||``),d=r!==void 0,f=o!==void 0,[p,m]=z.useState(!1),h=z.useCallback(e=>{d||u(e),i?.(e)},[d,i]);return(0,R.jsx)(HR,{value:{activeValue:d?r:l,handleValueChange:h,collapsed:f?o:p,handleCollapsedChange:z.useCallback(e=>{f||m(e),s?.(e)},[f,s])},children:(0,R.jsx)(`div`,{ref:e,className:A(`flex flex-col gap-2`,a),...c,children:t})})}KR.displayName=`Tabs`;function qR({ref:e,children:t,className:n,variant:r=`default`,collapsible:i=!1,...a}){let{activeValue:o,collapsed:s,handleCollapsedChange:c}=UR(),[l,u]=z.useState({width:0,left:0}),d=z.useRef(null),f=z.useRef(null),p=z.useRef(null),m=z.useCallback(()=>{let e=d.current;if(!e)return;let t=e.querySelector(`div:first-child`);if(!t)return;let n=t.querySelector(`button[data-tab-value="${o}"]`);if(n&&o){let e=t.getBoundingClientRect(),r=n.getBoundingClientRect();u({width:r.width,left:r.left-e.left})}else u({width:0,left:0})},[o]),h=z.useCallback(()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(m,16)},[m]);z.useEffect(()=>{let e=setTimeout(m,10);return()=>clearTimeout(e)},[m,s]),z.useEffect(()=>{let e=d.current;if(!e)return;f.current=new ResizeObserver(()=>{h()}),f.current.observe(e);let t=e.querySelector(`div:first-child`);return t&&t.querySelectorAll(`button[data-tab-value]`).forEach(e=>{f.current&&f.current.observe(e)}),()=>{f.current&&f.current.disconnect(),p.current&&clearTimeout(p.current)}},[h]),z.useEffect(()=>{let e=()=>{h()};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[h]);let g=z.useRef(null);return z.useEffect(()=>{g.current&&(g.current.style.width=`${l.width}px`,g.current.style.left=`${l.left}px`)},[l]),(0,R.jsx)(WR,{value:{variant:r,collapsed:s,handleCollapsedChange:c},children:(0,R.jsx)(`div`,{ref:d,className:A(`relative flex items-center bg-none gap-1`,r==="default"&&`p-1 rounded-full border border-zinc-300 dark:border-zinc-600`,r===`underline`&&`border-b border-zinc-200 dark:border-zinc-700`,n),...a,children:(0,R.jsxs)(`div`,{role:`tablist`,className:`flex-1 flex items-center relative`,children:[t,(0,R.jsx)(`span`,{ref:g,className:A(`absolute transition-all duration-[250ms] ease-in-out z-0`,r==="default"&&`bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600`,r===`underline`&&`bottom-0 h-0.5 bg-black dark:bg-white`)})]})})})}qR.displayName=`TabsList`;var JR=({children:e,title:t,collapsed:n})=>!t||!n?e:(0,R.jsx)(nt,{children:(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`span`,{className:`contents`,children:e}),nativeButton:!1}),(0,R.jsx)(Et,{children:t})]})}),YR=z.forwardRef(({children:e,value:t,className:n,disabled:r,icon:i,title:a,showDot:o=!1,alwaysExpanded:s=!1,badge:c,...l},u)=>{let{activeValue:d,handleValueChange:f,collapsed:p}=UR(),m=GR()?.variant||`default`,h=d===t,g=!p||h||s;return(0,R.jsx)(JR,{title:a,collapsed:p&&!g,children:(0,R.jsxs)(`button`,{ref:u,disabled:r,onClick:()=>f(t),"data-tab-value":t,"data-tab-active":h,role:`tab`,"aria-selected":h?`true`:`false`,title:p&&!g&&a?a:void 0,className:A(`relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-all duration-[250ms] ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer`,m==="default"&&`py-2.5`,m==="default"&&`rounded-md px-4`,m===`underline`&&`px-6 py-3 border-b-2 border-transparent`,h&&`text-foreground`,!h&&`text-muted-foreground hover:text-foreground`,n),...l,children:[i&&(0,R.jsx)(i,{className:A(`h-4 w-4 shrink-0 transition-all duration-[250ms] ease-in-out`,g&&`mr-2`,!g&&`mr-0!`)}),o&&(0,R.jsx)(`span`,{className:`absolute top-1.5 right-1.5 w-2 h-2 bg-orange-500 dark:bg-orange-400 border-2 border-white dark:border-zinc-900 rounded-full transition-opacity duration-300 z-10 animate-status-pulse-orange`}),(0,R.jsx)(`span`,{className:A(`min-w-0 transition-all duration-[250ms] ease-in-out overflow-hidden`,g?`w-auto opacity-100`:`w-0 opacity-0`),children:e}),c]})})});YR.displayName=`TabsTrigger`;function XR(e){return yR(e)}var ZR=z.createContext(void 0);function QR(){let e=z.useContext(ZR);if(e===void 0)throw Error(Ve(13));return e}var $R={imageLoadingStatus:()=>null},ez=z.forwardRef(function(e,t){let{className:n,render:r,style:i,...a}=e,[o,s]=z.useState(`idle`),c={imageLoadingStatus:o},l=z.useMemo(()=>({imageLoadingStatus:o,setImageLoadingStatus:s}),[o,s]),u=We(`span`,e,{state:c,ref:t,props:a,stateAttributesMapping:$R});return(0,R.jsx)(ZR.Provider,{value:l,children:u})});function tz(e,{referrerPolicy:t,crossOrigin:n,sizes:r,srcSet:i}){let[a,o]=z.useState(`idle`);return be(()=>{if(!e&&!i)return o(`error`),mt;let a=!0,s=new window.Image,c=e=>()=>{a&&o(e)};return o(`loading`),s.onload=c(`loaded`),s.onerror=c(`error`),t&&(s.referrerPolicy=t),s.crossOrigin=n??null,r&&(s.sizes=r),i&&(s.srcset=i),e&&(s.src=e),s.complete&&o(s.naturalWidth>0?`loaded`:`error`),()=>{a=!1}},[e,i,r,n,t]),a}var nz={...$R,...bt},rz=z.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,style:a,...o}=e,{setImageLoadingStatus:s}=QR(),c=tz(o.src,o),l=c===`loaded`,{mounted:u,transitionStatus:d,setMounted:f}=lt(l),p=z.useRef(null),h=m(e=>{i?.(e),s(e)});be(()=>{c!==`idle`&&h(c)},[c,h]),be(()=>()=>s(`idle`),[s]),x({open:l,ref:p,onComplete(){l||f(!1)}});let g=We(`img`,e,{state:{imageLoadingStatus:c,transitionStatus:d},ref:[t,p],props:o,stateAttributesMapping:nz,enabled:u});return u?g:null}),iz=z.forwardRef(function(e,t){let{className:n,render:r,delay:i,style:a,...o}=e,{imageLoadingStatus:s}=QR(),[c,l]=z.useState(i===void 0),u=Se();return z.useEffect(()=>(i===void 0?l(!0):u.start(i,()=>l(!0)),u.clear),[u,i]),We(`span`,e,{state:{imageLoadingStatus:s},ref:t,props:o,stateAttributesMapping:$R,enabled:s!==`loaded`&&(i===void 0||c)})});function az({className:e,size:t=`default`,...n}){return(0,R.jsx)(ez,{"data-slot":`avatar`,"data-size":t,className:A(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,e),...n})}function oz({className:e,...t}){return(0,R.jsx)(rz,{"data-slot":`avatar-image`,className:A(`aspect-square size-full rounded-full object-cover`,e),...t})}function sz({className:e,...t}){return(0,R.jsx)(iz,{"data-slot":`avatar-fallback`,className:A(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}function cz(e,t){return e?.[0]?e[0].toUpperCase():t?.[0]?t[0].toUpperCase():`U`}function lz({chatApiUrl:e,dashboardUrl:t=`https://manufact.com/cloud`,fallback:n=null,onUserResolved:r}){let{user:i,loaded:a,authorizing:o,authorize:s,logout:c,mode:l}=XR(e),u=(0,z.useRef)(void 0);if((0,z.useEffect)(()=>{if(!a)return;let e=i?.id??null;u.current!==e&&(u.current=e,r?.(i))},[a,i,r]),!a)return null;if(!i)return(0,R.jsxs)(R.Fragment,{children:[n,(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`rounded-full px-4 text-[13px]`,disabled:o,onClick:()=>{s().catch(e=>GF.error(e instanceof Error?e.message:`Authorization failed`))},children:o?`Authorizing…`:`Sign in`})]});let d=cz(i.name,i.email),f=i.name??i.email??`User`;return(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,R.jsx)(jt,{variant:`ghost`,className:`relative h-8 w-8 shrink-0 rounded-full p-0 mr-2`,"aria-label":`User menu`,children:(0,R.jsxs)(az,{className:`h-8 w-8 border border-zinc-300 dark:border-zinc-600`,children:[(0,R.jsx)(oz,{src:i.image??``,alt:f}),(0,R.jsx)(sz,{className:`text-sm`,children:d})]})}),nativeButton:!0}),(0,R.jsxs)(Ya,{className:`w-56`,align:`end`,forceMount:!0,children:[(0,R.jsx)(Xa,{className:`font-normal`,children:(0,R.jsxs)(`div`,{className:`flex flex-col space-y-1`,children:[(0,R.jsx)(`p`,{className:`text-sm font-medium leading-none truncate`,children:f}),i.email&&i.email!==f&&(0,R.jsx)(`p`,{className:`text-xs leading-none text-muted-foreground truncate`,children:i.email})]})}),(0,R.jsx)(eo,{}),(0,R.jsx)(Za,{render:(0,R.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,children:[(0,R.jsx)(ci,{className:`mr-2 h-4 w-4`}),`Go to dashboard`]})}),(0,R.jsx)(eo,{}),(0,R.jsxs)(Za,{onClick:()=>{c().catch(()=>GF.error(`Sign out failed`))},children:[(0,R.jsx)(mi,{className:`mr-2 h-4 w-4`}),l===`session`?`Sign out of Manufact`:`Disconnect Inspector`]})]})]})}function uz({count:e,isActive:t,size:n=`md`}){return e<=0?null:(0,R.jsx)(`span`,{className:A(t?`dark:bg-black`:`dark:bg-zinc-700`,`shrink-0 ml-1 bg-zinc-200 text-zinc-700 dark:text-zinc-300 rounded-full font-medium`,n===`sm`&&`text-[10px] px-1.5 py-0.5`,n===`md`&&`text-xs px-2 py-0.5`),children:e})}var dz=`flex h-10 items-center gap-2`;function fz({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,vsCodeInsiders:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:r=``,onSuccess:i,onError:a,trigger:o}){let[s,c]=(0,z.useState)(!1),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(!1),{url:p,name:m,headers:h}=e,g=e=>{try{ET(new Do({client:e})).catch(()=>{})}catch{}},_=()=>{g(`cursor`);try{let e=yL(p,m,h);window.location.href=e,i?.(`Cursor`)}catch(e){console.error(`Failed to generate Cursor deep link:`,e),a?.(e)}},v=()=>{g(`vscode`);try{let e=bL(p,m,h);window.location.href=e,i?.(`VS Code`)}catch(e){console.error(`Failed to generate VS Code deep link:`,e),a?.(e)}},y=()=>{g(`vscode-insiders`);try{let e=xL(p,m,h);window.location.href=e,i?.(`VS Code Insiders`)}catch(e){console.error(`Failed to generate VS Code Insiders deep link:`,e),a?.(e)}},b=()=>{g(`claude-desktop`);try{CL(p,m,h),i?.(`Claude Desktop`)}catch(e){console.error(`Failed to download .mcpb file:`,e),a?.(e)}},x=()=>{g(`claude-code`),u(`claude-code`),c(!0)},S=()=>{g(`gemini-cli`),u(`gemini-cli`),c(!0)},C=()=>{g(`codex-cli`),u(`codex-cli`),c(!0)},w=async e=>{try{await Qj(e),f(!0),setTimeout(()=>f(!1),2e3)}catch(e){console.error(`Failed to copy:`,e),a?.(e)}},T=()=>{if(l===`claude-code`){let{command:e,envVars:t}=wL(p,m,h),n=DL(t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(XI,{children:[(0,R.jsx)(eL,{children:`Add to Claude Code`}),(0,R.jsx)(tL,{children:`Execute the following command in your shell to add this server to Claude Code.`})]}),(0,R.jsxs)(ZI,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,R.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,R.jsx)(`span`,{children:`Ensure the Claude Code executable is available in your path`})]}),(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,R.jsx)(`span`,{children:`Execute the following snippet in your shell:`})]})]})]}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>w(e),children:d?(0,R.jsx)(Fr,{className:`size-3.5 text-green-600`}):(0,R.jsx)(Wr,{className:`size-3.5`})})}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:e})})]}),n&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Environment Variables`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mb-2`,children:`After installation, set these environment variables in your shell:`}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:n})})]}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`The MCP configuration supports environment variable expansion using `,(0,R.jsx)(`code`,{className:`text-foreground`,children:"${VAR}"}),` `,`syntax.`]})]})]})}if(l===`gemini-cli`){let{command:e,envVars:t}=TL(p,m,h),n=DL(t);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(XI,{children:[(0,R.jsx)(eL,{children:`Add to Gemini CLI`}),(0,R.jsx)(tL,{children:`Execute the following command in your shell to add this server to Gemini CLI.`})]}),(0,R.jsxs)(ZI,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,R.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,R.jsx)(`span`,{children:`Ensure the Gemini CLI executable is available in your path`})]}),n&&(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,R.jsx)(`span`,{children:`Set these environment variables in your shell before running the command:`})]}),(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:n?`3.`:`2.`}),(0,R.jsx)(`span`,{children:`Execute the following snippet in your shell:`})]})]})]}),n&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Environment Variables`}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:n})})]}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>w(e),children:d?(0,R.jsx)(Fr,{className:`size-3.5 text-green-600`}):(0,R.jsx)(Wr,{className:`size-3.5`})})}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:e})})]}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Restart Gemini CLI to load the new configuration.`})]})]})}if(l===`codex-cli`){let{config:e,envVars:t}=EL(p,m,h);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(XI,{children:[(0,R.jsx)(eL,{children:`Add to Codex CLI`}),(0,R.jsxs)(tL,{children:[`Add this configuration to your`,` `,(0,R.jsx)(`code`,{className:`text-foreground`,children:`~/.codex/config.toml`}),` `,`file.`]})]}),(0,R.jsxs)(ZI,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Instructions`}),(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Add this configuration to your`,` `,(0,R.jsx)(`code`,{className:`text-foreground`,children:`~/.codex/config.toml`}),`:`]})]}),(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`h-7 px-2 bg-background hover:bg-accent border border-border`,onClick:()=>w(e),children:d?(0,R.jsx)(Fr,{className:`size-3.5 text-green-600`}):(0,R.jsx)(Wr,{className:`size-3.5`})})}),(0,R.jsx)(`pre`,{className:`bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto`,children:(0,R.jsx)(`code`,{children:e})})]}),t.length>0&&(0,R.jsx)(`div`,{children:(0,R.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`(optional) If you would rather use variables from your system's environment, replace the`,` `,(0,R.jsx)(`code`,{className:`text-foreground`,children:`http_headers`}),` key with the `,(0,R.jsx)(`code`,{className:`text-foreground`,children:`env_http_headers`}),` `,`key as shown in the commented section above.`]})}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Restart Codex CLI to load the new configuration.`})]})]})}return null},ee=(0,R.jsxs)(jt,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${r}`,children:[(0,R.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,R.jsx)(ki,{className:`size-3`}),`Client`]}),(0,R.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,R.jsx)(Ir,{className:`size-3`})]})]}),E=o?typeof o==`function`?o({isOpen:!1,onClick:()=>{}}):o:ee;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,z.isValidElement)(E)?E:ee,nativeButton:!0}),(0,R.jsxs)(Ya,{align:`end`,className:`w-auto min-w-[300px]`,children:[t.map(e=>(0,R.jsxs)(Za,{onClick:async()=>{await e.onClick()},className:dz,children:[e.icon,(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:e.label})]},e.id)),t.length>0&&(0,R.jsx)(eo,{}),n.cursor&&(0,R.jsxs)(Za,{onClick:_,className:dz,children:[(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/cursor`,alt:`Cursor`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Cursor`})]}),n.claudeCode&&(0,R.jsxs)(Za,{onClick:x,className:dz,children:[(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Claude Code`})]}),n.claudeDesktop&&(0,R.jsxs)(Za,{onClick:b,className:dz,children:[(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/claude`,alt:`Claude`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Claude Desktop`})]}),n.vsCode&&(0,R.jsxs)(Za,{onClick:v,className:dz,children:[(0,R.jsx)(kL,{className:`h-4 w-4 text-blue-500`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`VS Code`})]}),n.vsCodeInsiders&&(0,R.jsxs)(Za,{onClick:y,className:dz,children:[(0,R.jsx)(kL,{className:`h-4 w-4 text-teal-400`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`VS Code Insiders`})]}),n.geminiCli&&(0,R.jsxs)(Za,{onClick:S,className:dz,children:[(0,R.jsx)(`img`,{src:`https://cdn.simpleicons.org/googlegemini`,alt:`Gemini`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Gemini CLI`})]}),n.codexCli&&(0,R.jsxs)(Za,{onClick:C,className:dz,children:[(0,R.jsx)(`img`,{src:`https://inspector-cdn.mcp-use.com/providers/openai.png`,alt:`Codex`,className:`h-4 w-4`}),(0,R.jsx)(`span`,{className:`min-w-0 max-w-full whitespace-nowrap`,children:`Codex CLI`})]})]})]}),(0,R.jsx)(qI,{open:s,onOpenChange:c,children:(0,R.jsx)(YI,{scrollable:!0,className:`max-w-3xl max-h-[80vh]`,children:T()})})]})}function pz({className:e,state:t=`collapsed`,to:n=`/`,showLabel:r=t===`expanded`,pinSymbolInIconColumn:i=!1,size:a}){let[o,s]=(0,z.useState)(!1),c=1.5,l=.2/c,u=.8999999999999999/c,d=t===`expanded`&&r,f=a??(i?20:t===`expanded`?40:20),p=(0,R.jsx)(`div`,{className:`relative`,children:(0,R.jsxs)(qe.svg,{viewBox:`0 0 500 500`,initial:`rest`,animate:o?`hover`:`rest`,className:`text-foreground`,style:{width:f,height:f},children:[(0,R.jsxs)(qe.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:c,times:[0,l,u,1],ease:`easeInOut`}}},fill:`currentColor`,fillRule:`nonzero`,stroke:`currentColor`,strokeWidth:4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(`path`,{d:`M105.933 0C164.437 0.000116002 211.865 47.607 211.865 106.333C211.865 131.829 210.493 158.403 221.068 181.602L228.975 198.947C243.584 230.997 269.265 256.7 301.303 271.336L316.155 278.121C340.142 289.079 367.694 287.335 394.066 287.335C452.571 287.335 499.999 334.942 499.999 393.668C499.999 452.394 452.571 500.001 394.066 500.001C335.562 500.001 288.134 452.394 288.134 393.668C288.134 368.974 289.24 343.275 278.992 320.807L270.586 302.38C255.948 270.29 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.86252e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z`}),(0,R.jsx)(`circle`,{cx:`100.426`,cy:`399.575`,r:`100.426`}),(0,R.jsx)(`path`,{d:`M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z`})]}),(0,R.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeWidth:4,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,R.jsx)(mz,{d:`M105.933 0C164.437 0.000116002 211.865 47.607 211.865 106.333C211.865 131.829 210.493 158.403 221.068 181.602L228.975 198.947C243.584 230.997 269.265 256.7 301.303 271.336L316.155 278.121C340.142 289.079 367.694 287.335 394.066 287.335C452.571 287.335 499.999 334.942 499.999 393.668C499.999 452.394 452.571 500.001 394.066 500.001C335.562 500.001 288.134 452.394 288.134 393.668C288.134 368.974 289.24 343.275 278.992 320.807L270.586 302.38C255.948 270.29 230.214 244.565 198.118 229.939L180.164 221.758C157.282 211.331 131.078 212.666 105.933 212.666C47.4278 212.666 4.86252e-05 165.059 0 106.333C0 47.607 47.4278 0 105.933 0Z`,times:{T0:0,T1:l,T2:u,T3:1},total:c}),(0,R.jsx)(hz,{cx:100.426,cy:399.575,r:100.426,times:{T0:0,T1:l,T2:u,T3:1},total:c}),(0,R.jsx)(mz,{d:`M500 100.426C500 155.889 455.037 200.851 399.574 200.851C344.11 200.851 299.148 155.889 299.148 100.426C299.148 44.962 344.11 0 399.574 0C455.037 0 500 44.962 500 100.426Z`,times:{T0:0,T1:l,T2:u,T3:1},total:c})]})]})}),m=r?(0,R.jsxs)(`span`,{className:A(`font-ubuntu flex items-center gap-2 whitespace-nowrap`,i?A(`pl-(--sidebar-nav-text-pl-absolute)`,d?`relative opacity-100 blur-0`:`pointer-events-none absolute left-0 top-1/2 w-0 -translate-y-1/2 overflow-hidden opacity-0 blur-[3px]`):`mr-3`),children:[(0,R.jsx)(`span`,{className:`text-xl font-bold leading-none text-foreground [text-box:trim-both_cap_alphabetic]`,children:`mcp-use`}),(0,R.jsx)(`span`,{className:`text-lg font-sans font-light leading-none tracking-wide text-muted-foreground [text-box:trim-both_cap_alphabetic]`,children:`Inspector`})]}):null,h=i?(0,R.jsxs)(`div`,{className:A(`relative flex shrink-0 items-center`,d?`min-w-(--sidebar-width-icon)`:`w-(--sidebar-width-icon)`),children:[(0,R.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 left-0 flex w-(--sidebar-width-icon) items-center justify-center`,children:(0,R.jsx)(`div`,{className:`pointer-events-auto`,children:p})}),m]}):(0,R.jsxs)(R.Fragment,{children:[p,m]});return(0,R.jsx)(fF,{to:n,className:A(`flex items-center transition-opacity`,!i&&`-my-3`,e),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),children:h})}function mz({d:e,times:t,total:n}){let{T0:r,T1:i,T2:a,T3:o}=t;return(0,R.jsx)(qe.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,i,a,o],ease:`easeInOut`}}}})}function hz({cx:e,cy:t,r:n,times:r,total:i}){let{T0:a,T1:o,T2:s,T3:c}=r;return(0,R.jsx)(qe.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:i,times:[a,o,s,c],ease:`easeInOut`}}}})}var gz=(0,z.createContext)(void 0);function _z(){let e=(0,z.use)(gz);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e}function vz({children:e,defaultTheme:t=`system`,storageKey:n=`theme`,forcedTheme:r}){let[i,a]=(0,z.useState)(r||t),[o,s]=(0,z.useState)(!1),c=()=>typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,l=i===`system`?c():i,u=e=>{let t=document.documentElement,i=e===`system`?c():e;t.classList.remove(`light`,`dark`),t.classList.add(i),r||localStorage.setItem(n,e)};return(0,z.useEffect)(()=>{s(!0);let e=localStorage.getItem(n),i=r||e||t;a(i),u(i)},[t,n,r]),(0,z.useEffect)(()=>{if(i!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>{u(`system`)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[i]),(0,z.useEffect)(()=>{o&&u(i)},[i,o]),(0,R.jsx)(gz,{value:{theme:i,setTheme:e=>{if(r){console.warn(`[ThemeProvider] Theme is forced via URL parameter, ignoring setTheme call`);return}a(e)},resolvedTheme:l},children:e})}function yz({ref:e,shimmerColor:t,shimmerSize:n=`0.05em`,shimmerDuration:r=`3s`,borderRadius:i=`100px`,background:a,className:o,children:s,...c}){let{theme:l}=_z();return(0,R.jsxs)(`button`,{style:{"--spread":`90deg`,"--shimmer-color":t||(l===`dark`?`#000000`:`#ffffff`),"--radius":i,"--speed":r,"--cut":n,"--bg":a||(l===`dark`?`rgba(255, 255, 255, 1)`:`rgba(0, 0, 0, 1)`)},className:A(`group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]`,`transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px`,`dark:text-white text-black dark:border-white/10 border-black/10`,o),ref:e,...c,children:[(0,R.jsx)(`div`,{className:A(`-z-30 blur-[2px]`,`@container-[size] absolute inset-0 overflow-visible`),children:(0,R.jsx)(`div`,{className:`animate-shimmer-slide absolute inset-0 aspect-[1] h-[100cqh] rounded-none mask-none`,children:(0,R.jsx)(`div`,{className:`animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]`})})}),s,(0,R.jsx)(`div`,{className:A(`absolute inset-0 size-full`,`rounded-2xl px-4 py-1.5 text-sm font-medium`,`transform-gpu transition-all duration-300 ease-in-out`,`dark:shadow-[inset_0_-8px_10px_#0000001f] dark:group-hover:shadow-[inset_0_-6px_10px_#0000003f] dark:group-active:shadow-[inset_0_-10px_10px_#0000003f] shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]`)}),(0,R.jsx)(`div`,{className:A(`absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] bg-black dark:bg-white`)})]})}yz.displayName=`ShimmerButton`;function bz(e){switch(e){case`ready`:return`bg-emerald-600 animate-status-pulse`;case`failed`:return`bg-rose-600 animate-status-pulse-red`;default:return`bg-yellow-500 animate-status-pulse-yellow`}}function xz(e){switch(e){case`ready`:return`Connected`;case`failed`:return`Failed`;default:return e}}function Sz({status:e,className:t}){return(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`div`,{className:A(`w-2 h-2 rounded-full shrink-0`,bz(e),t)}),nativeButton:!1}),(0,R.jsx)(Et,{children:(0,R.jsx)(`p`,{children:xz(e)})})]})}var Cz=`h-6 px-2 text-xs bg-yellow-500/20 border-0 dark:bg-yellow-400/10 text-yellow-800 dark:text-yellow-500 shrink-0`;function wz(e){try{sessionStorage.setItem(sI,JSON.stringify({url:e.url,name:e.name||`Auto-connected Server`,transportType:e.transportType||`http`,connectionMode:`auto`}))}catch{}}function Tz({server:e,className:t}){let{state:n,authUrl:r,authenticate:i}=e;return n!==`pending_auth`&&n!==`authenticating`?null:n===`authenticating`?(0,R.jsxs)(jt,{size:`sm`,variant:`outline`,disabled:!0,className:A(Cz,t),children:[(0,R.jsx)(di,{className:`h-3 w-3 animate-spin mr-1`}),`Authenticating`]}):i?(0,R.jsx)(jt,{"data-testid":`server-header-authenticate`,size:`sm`,variant:`outline`,className:A(Cz,t),onClick:t=>{t.stopPropagation(),wz(e),i()},children:`Authenticate`}):r?(0,R.jsx)(jt,{size:`sm`,variant:`outline`,className:A(Cz,t),render:(0,R.jsx)(`a`,{href:r,"data-testid":`server-header-authenticate`,onClick:t=>{t.stopPropagation(),wz(e)}}),nativeButton:!1,children:`Authenticate`}):null}function Ez({connections:e,selectedServer:t,onServerSelect:n,mobileMode:r=!1,variant:i=`default`}){let a=KN(),o=t=>{e.some(e=>e.id===t)&&n(t)},s=(0,R.jsxs)(Ya,{className:`w-[calc(100vw-2rem)] sm:w-[300px]`,align:`start`,children:[(0,R.jsx)(Xa,{className:`cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800`,onClick:()=>a(`/`),children:`MCP Servers`}),(0,R.jsx)(eo,{}),e.length===0?(0,R.jsx)(`div`,{className:`px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center`,children:`No servers connected. Go to the dashboard to add one.`}):e.map(e=>(0,R.jsxs)(Za,{onClick:()=>o(e.id),className:`flex items-center gap-3`,children:[(0,R.jsx)(oL,{server:e,size:`sm`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:lM(e)}),(0,R.jsx)(Sz,{status:e.state})]})]},e.id)),(0,R.jsx)(eo,{}),(0,R.jsx)(Za,{onClick:()=>a(`/`),children:(0,R.jsx)(`span`,{className:`text-blue-600 dark:text-blue-400`,children:`+ Add new server`})})]});return r?(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,R.jsx)(`div`,{className:`relative`,children:(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,R.jsxs)(jt,{variant:`ghost`,className:`h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5`,children:[t?(0,R.jsx)(oL,{server:t,size:`md`}):(0,R.jsx)(Ni,{className:`h-5 w-5`}),(0,R.jsx)(Ir,{className:`h-4 w-4`})]}),nativeButton:!0}),s]})})}):i===`header`?(0,R.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,R.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-2 min-w-0 border-0 bg-transparent p-0 cursor-pointer text-foreground transition-opacity hover:opacity-80`,children:[t&&(0,R.jsx)(oL,{server:t,size:`sm`,className:`!size-5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate text-sm leading-none [text-box:trim-both_cap_alphabetic]`,children:t?lM(t):`Select server`}),t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Sz,{status:t.state}),(0,R.jsx)(Tz,{server:t})]}),(0,R.jsx)(Ir,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),nativeButton:!0}),s]})}):(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,R.jsx)(`div`,{className:`relative`,children:(0,R.jsxs)(qa,{children:[(0,R.jsx)(Ja,{render:(0,R.jsxs)(yz,{className:A(`min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200`,!t&&`pl-4`),children:[t&&(0,R.jsx)(oL,{server:t,size:`md`,className:`mr-2`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 flex-1`,children:[(0,R.jsx)(`span`,{className:`truncate lg:max-w-[120px] xl:max-w-none`,children:t?lM(t):`Select server to inspect`}),t&&(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:t.error&&t.state!==`ready`?(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`button`,{onClick:e=>{e.stopPropagation()},className:`w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors`,title:`Click to copy error message`,"aria-label":`Copy error message to clipboard`}),nativeButton:!0}),(0,R.jsx)(Et,{children:(0,R.jsx)(`p`,{className:`max-w-xs`,children:t.error})})]}):(0,R.jsx)(`div`,{className:`w-2 h-2 rounded-full ${t.state===`ready`?`bg-emerald-600 animate-status-pulse`:t.state===`failed`?`bg-rose-600 animate-status-pulse-red`:`bg-yellow-500 animate-status-pulse-yellow`}`})})]})]}),nativeButton:!0}),s]})})})}function Dz(e){if(!e)return null;try{let t=new URL(e);if(t.protocol===`https:`)return t.origin}catch{}return null}function Oz(e,t){return e===`tools`?t.tools.length:e===`prompts`?t.prompts.length:e===`resources`?t.resources.length:e===`sampling`?t.pendingSamplingRequests?.length||0:e===`elicitation`?t.pendingElicitationRequests?.length||0:e===`notifications`?t.unreadNotificationCount:0}function kz(e,t,n){return n&&t>0&&[`sampling`,`elicitation`,`notifications`].includes(e)}var Az=[{id:`server-metadata`,label:`Server Metadata`,icon:si},{id:`separator`},{id:`chat`,label:`Chat`,icon:_i,alwaysExpanded:!0},{id:`separator`},{id:`tools`,label:`Tools`,icon:qi},{id:`prompts`,label:`Prompts`,icon:vi},{id:`resources`,label:`Resources`,icon:$r},{id:`sampling`,label:`Sampling`,icon:ti},{id:`elicitation`,label:`Elicitation`,icon:Li},{id:`notifications`,label:`Notifications`,icon:Mr},{id:`separator`},{id:`connection-settings`,label:`Connection Settings`,icon:Pi}],jz=z.createContext(void 0);function Mz(e){let t=z.useContext(jz);if(t===void 0&&!e)throw Error(Ve(47));return t}function Nz(){return{...kt(),disabled:!1,modal:!1,focusManagerModal:!1,instantType:void 0,openMethod:null,openChangeReason:null,titleElementId:void 0,descriptionElementId:void 0,stickIfOpen:!0,nested:!1,openOnHover:!1,closeDelay:0,hasViewport:!1}}var Pz={...ze,disabled:Vt(e=>e.disabled),instantType:Vt(e=>e.instantType),openMethod:Vt(e=>e.openMethod),openChangeReason:Vt(e=>e.openChangeReason),modal:Vt(e=>e.modal),focusManagerModal:Vt(e=>e.focusManagerModal),stickIfOpen:Vt(e=>e.stickIfOpen),titleElementId:Vt(e=>e.titleElementId),descriptionElementId:Vt(e=>e.descriptionElementId),openOnHover:Vt(e=>e.openOnHover),closeDelay:Vt(e=>e.closeDelay),hasViewport:Vt(e=>e.hasViewport)},Fz=class e extends Kt{constructor(e,t,n=!1){let r={...Nz(),...e},i=new xt;r.open&&e?.mounted===void 0&&(r.mounted=!0),r.floatingRootContext=at(i,t,n),super(r,{popupRef:z.createRef(),backdropRef:z.createRef(),internalBackdropRef:z.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerFocusTargetRef:z.createRef(),beforeContentFocusGuardRef:z.createRef(),stickIfOpenTimeout:new zt,triggerElements:i},Pz)}setOpen=(e,t)=>{let n=t.reason===c,r=t.reason===`trigger-press`&&t.event.detail===0,i=!e&&(t.reason===`escape-key`||t.reason==null),a=Ue(t),o=this.select(`activeTriggerId`);if(!e&&t.reason===`close-press`&&t.trigger==null&&o!=null&&(t.trigger=this.context.triggerElements.getById(o)??this.select(`activeTriggerElement`)??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let s=()=>{let n={open:e,openChangeReason:t.reason};Ft(n,e,t.trigger,a()),this.update(n)};n?(this.set(`stickIfOpen`,!0),this.context.stickIfOpenTimeout.start(500,()=>{this.set(`stickIfOpen`,!1)}),br.flushSync(s)):s(),r||i?this.set(`instantType`,r?`click`:`dismiss`):t.reason===`focus-out`?this.set(`instantType`,`focus`):this.set(`instantType`,void 0)};static useStore(t,n){let{store:r,internalStore:i}=Qe(t,(t,r)=>new e(n,t,r));return z.useEffect(()=>i?.disposeEffect(),[i]),r}disposeEffect=()=>this.context.stickIfOpenTimeout.disposeEffect()};function Iz({props:e}){let{children:t,open:n,defaultOpen:r=!1,onOpenChange:i,onOpenChangeComplete:a,modal:o=!1,handle:s,triggerId:c,defaultTriggerId:l=null}=e,u=Fz.useStore(s?.store,{modal:o,open:r,openProp:n,activeTriggerId:l,triggerIdProp:c});Ye(u,n,r,l),u.useControlledProp(`openProp`,n),u.useControlledProp(`triggerIdProp`,c);let d=u.useState(`open`),f=u.useState(`mounted`),p=u.useState(`payload`),m=st()!=null;u.useContextCallback(`onOpenChange`,i),u.useContextCallback(`onOpenChangeComplete`,a),tt(u,d),Ge(u);let{forceUnmount:h}=Ct(d,u,()=>{u.update({stickIfOpen:!0,openChangeReason:null})});u.useSyncedValues({modal:o,nested:m}),z.useEffect(()=>{d||u.context.stickIfOpenTimeout.clear()},[u,d]);let g=z.useCallback(()=>{u.setOpen(!1,ae(De))},[u]);z.useImperativeHandle(e.actionsRef,()=>({unmount:h,close:g}),[h,g]);let _=d||f,v=z.useMemo(()=>({store:u}),[u]);return(0,R.jsxs)(jz.Provider,{value:v,children:[_&&(0,R.jsx)(Rz,{store:u,modal:o}),typeof t==`function`?t({payload:p}):t]})}function Lz(e){return Mz(!0)?(0,R.jsx)(Iz,{props:e}):(0,R.jsx)(dt,{children:(0,R.jsx)(Iz,{props:e})})}function Rz({store:e,modal:t}){let n=y(e.useState(`floatingRootContext`),{outsidePressEvent:{mouse:t===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}});return ht(e,{activeTriggerProps:n.reference??St,inactiveTriggerProps:n.trigger??St,popupProps:z.useMemo(()=>Ut(Mt,n.floating),[n.floating])}),null}var zz=z.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,handle:c,payload:l,openOnHover:u=!1,delay:d=300,closeDelay:f=0,id:p,...m}=e,h=Mz(!0),g=c?.store??h?.store;if(!g)throw Error(Ve(74));let _=N(p),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=z.useRef(null),{registerTrigger:C,isMountedByThisTrigger:w}=Fe(_,S,g,{payload:l,disabled:a,openOnHover:u,closeDelay:f}),T=g.useState(`openChangeReason`),ee=g.useState(`stickIfOpen`),E=g.useState(`openMethod`),D=g.useState(`focusManagerModal`),ne=s(y,{enabled:!a&&y!=null&&u&&(E!==`touch`||T!==`trigger-press`),mouseOnly:!0,move:!1,handleClose:he(),restMs:d,delay:{close:f},triggerElementRef:S,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),O=Sn(y,{enabled:y!=null,stickIfOpen:ee}),re=dn(()=>g.select(`open`),e=>{g.set(`openMethod`,e)}),k=g.useState(`triggerProps`,w),{getButtonProps:ie,buttonRef:A}=Pe({disabled:a,native:o}),j={open(e){return e&&T===`trigger-press`?it.open(e):Re.open(e)}},{preFocusGuardRef:M,handlePreFocusGuardFocus:ae,handleFocusTargetFocus:oe}=xr(g,S),se=We(`button`,e,{state:{disabled:a,open:b},ref:[A,t,C,S],props:[O.reference,ne,k,re,{[te]:``,id:_,"aria-haspopup":`dialog`,"aria-expanded":b,"aria-controls":x},m,ie],stateAttributesMapping:j});return w&&!D?(0,R.jsxs)(z.Fragment,{children:[(0,R.jsx)(Dt,{ref:M,onFocus:ae}),(0,R.jsx)(z.Fragment,{children:se},_),(0,R.jsx)(Dt,{ref:g.context.triggerFocusTargetRef,onFocus:oe})]}):(0,R.jsx)(z.Fragment,{children:se},_)}),Bz=z.createContext(void 0);function Vz(){let e=z.useContext(Bz);if(e===void 0)throw Error(Ve(45));return e}var Hz=z.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i}=Mz();return i.useState(`mounted`)||n?(0,R.jsx)(Bz.Provider,{value:n,children:(0,R.jsx)(me,{ref:t,...r})}):null}),Uz=z.createContext(void 0);function Wz(){let e=z.useContext(Uz);if(!e)throw Error(Ve(46));return e}var Gz=z.forwardRef(function(e,t){let{render:n,className:r,style:i,anchor:a,positionMethod:o=`absolute`,side:s=`bottom`,align:c=`center`,sideOffset:l=0,alignOffset:u=0,collisionBoundary:f=`clipping-ancestors`,collisionPadding:p=5,arrowPadding:m=5,sticky:h=!1,disableAnchorTracking:g=!1,collisionAvoidance:v=ve,...y}=e,{store:b}=Mz(),x=Vz(),S=d(),C=b.useState(`floatingRootContext`),w=b.useState(`mounted`),T=b.useState(`open`),ee=b.useState(`openChangeReason`),E=b.useState(`activeTriggerElement`),D=b.useState(`modal`),te=b.useState(`openMethod`),O=b.useState(`positionerElement`),re=b.useState(`instantType`),k=b.useState(`transitionStatus`),ie=b.useState(`hasViewport`),A=z.useRef(null),j=_(O,!1,!1),M=ne({anchor:a,floatingRootContext:C,positionMethod:o,mounted:w,side:s,sideOffset:l,align:c,alignOffset:u,arrowPadding:m,collisionBoundary:f,collisionPadding:p,sticky:h,disableAnchorTracking:g,keepMounted:x,nodeId:S,collisionAvoidance:v,adaptiveOrigin:ie?ke:void 0}),ae=C.useState(`domReferenceElement`);be(()=>{let e=ae,t=A.current;if(e&&(A.current=e),t&&e&&e!==t){b.set(`instantType`,void 0);let e=new AbortController;return j(()=>{b.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[ae,j,b]),an(T&&D===!0&&ee!==`trigger-hover`,te===`touch`,O,E);let oe=z.useCallback(e=>{b.set(`positionerElement`,e)},[b]),se=wt(e,{open:T,side:M.side,align:M.align,anchorHidden:M.anchorHidden,instant:re},{styles:M.positionerStyles,transitionStatus:k,props:y,refs:[t,oe],hidden:!w,inert:!T});return(0,R.jsxs)(Uz.Provider,{value:M,children:[w&&D===!0&&ee!==`trigger-hover`&&(0,R.jsx)(wn,{ref:b.context.internalBackdropRef,inert:sn(!T),cutout:E}),(0,R.jsx)(ue,{id:S,children:se})]})}),Kz=z.createContext(void 0);function qz(){let[e,t]=z.useState(0),n=m(()=>(t(e=>e+1),()=>{t(e=>Math.max(0,e-1))}));return{context:z.useMemo(()=>({register:n}),[n]),hasClosePart:e>0}}function Jz(e){let{value:t,children:n}=e;return(0,R.jsx)(Kz.Provider,{value:t,children:n})}var Yz={...Ot,...bt},Xz=z.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,{store:c}=Mz(),l=Wz(),u=Cn(!0)!=null,{context:d,hasClosePart:f}=qz(),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`instantType`),g=c.useState(`transitionStatus`),_=c.useState(`popupProps`),v=c.useState(`titleElementId`),y=c.useState(`descriptionElementId`),b=c.useState(`modal`),S=c.useState(`mounted`),C=c.useState(`openChangeReason`),w=c.useState(`activeTriggerElement`),T=c.useState(`floatingRootContext`),ee=T.useState(`floatingId`),E=c.useState(`disabled`),D=c.useState(`openOnHover`),te=c.useState(`closeDelay`),ne=s.id??ee;x({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete?.(!0)}}),Ke(T,{enabled:D&&!E,closeDelay:te});let O=a===void 0?ft(c.context.popupRef):a,re=b!==!1&&f;c.useSyncedValue(`focusManagerModal`,re);let k=z.useCallback(e=>{c.set(`popupElement`,e)},[c]),ie=We(`div`,e,{state:{open:p,side:l.side,align:l.align,instant:h,transitionStatus:g},ref:[t,c.context.popupRef,k],props:[_,{id:ne,role:`dialog`,...Mt,"aria-labelledby":v,"aria-describedby":y,onKeyDown(e){u&&Qt.has(e.key)&&e.stopPropagation()}},je(g),s],stateAttributesMapping:Yz});return(0,R.jsx)(rn,{context:T,openInteractionType:m,modal:re,disabled:!S||C===`trigger-hover`,initialFocus:O,returnFocus:o,restoreFocus:`popup`,previousFocusableElement:ut(w)?w:void 0,nextFocusableElement:c.context.triggerFocusTargetRef,beforeContentFocusGuardRef:c.context.beforeContentFocusGuardRef,children:(0,R.jsx)(Jz,{value:d,children:ie})})});function Zz({...e}){return(0,R.jsx)(Lz,{"data-slot":`popover`,...e})}function Qz(e){return(0,R.jsx)(zz,{"data-slot":`popover-trigger`,...e})}function $z({className:e,align:t=`center`,alignOffset:n=0,side:r=`bottom`,sideOffset:i=4,...a}){return(0,R.jsx)(Hz,{children:(0,R.jsx)(Gz,{align:t,alignOffset:n,side:r,sideOffset:i,className:`isolate z-50`,children:(0,R.jsx)(Xz,{"data-slot":`popover-content`,className:A(`z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-md bg-popover p-4 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...a})})})}var eB={success:`border-emerald-700/20 bg-emerald-700/10 text-emerald-700 dark:border-emerald-400/30 dark:bg-emerald-400/10 dark:text-emerald-400`,failed:`border-red-500/20 bg-red-500/10 text-red-500 dark:border-red-400/30 dark:bg-red-400/10 dark:text-red-400`,warning:`border-amber-700/20 bg-amber-700/10 text-amber-700 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-400`,loading:`border-purple-500/20 bg-purple-500/10 text-purple-500 dark:border-purple-400/30 dark:bg-purple-400/10 dark:text-purple-400 animate-spin`},tB=`size-4 shrink-0 rounded-full border p-0.5`;function nB({state:e,className:t}){let n=A(tB,eB[e],t);switch(e){case`success`:return(0,R.jsx)(Fr,{className:n,"aria-hidden":!0});case`failed`:return(0,R.jsx)(zr,{className:n,"aria-hidden":!0});case`warning`:return(0,R.jsx)(Wi,{className:n,"aria-hidden":!0});case`loading`:return(0,R.jsx)(di,{className:n,"aria-hidden":!0});default:return null}}function rB(){return`text-emerald-700 dark:text-emerald-400`}function iB({onStop:e,showCopiedBanner:t=!1}){return(0,R.jsxs)(R.Fragment,{children:[t&&(0,R.jsxs)(`div`,{className:A(`flex items-center gap-2 text-sm -mt-1`,rB()),children:[(0,R.jsx)(nB,{state:`success`}),(0,R.jsx)(`span`,{children:`URL copied to clipboard`})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`h4`,{className:`font-semibold text-sm`,children:`Tunnel URL`}),(0,R.jsxs)(`a`,{href:`https://manufact.com/docs/tunneling`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[`Docs`,(0,R.jsx)(Ar,{className:`size-3`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h5`,{className:`font-semibold text-sm mb-2`,children:`Use in ChatGPT & Claude`}),(0,R.jsxs)(`ol`,{className:`space-y-2 text-xs text-muted-foreground`,children:[(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`1.`}),(0,R.jsxs)(`span`,{children:[`Enable`,` `,(0,R.jsx)(`a`,{href:`https://chatgpt.com/plugins#settings/Security`,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline underline-offset-2 hover:text-purple-600 dark:hover:text-purple-400`,children:`dev mode`}),` `,`from settings`]})]}),(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`2.`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`a`,{href:`https://chatgpt.com/plugins#settings/Connectors?create-connector=true&redirectAfter=%2Fplugins`,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-foreground underline underline-offset-2 hover:text-purple-600 dark:hover:text-purple-400`,children:`Add a connector`}),` `,`in App & Connectors`]})]}),(0,R.jsxs)(`li`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`font-semibold text-foreground`,children:`3.`}),(0,R.jsx)(`span`,{children:`Use the tunnel URL in the input`})]})]})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void e(),className:`flex items-center gap-1.5 text-xs text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors cursor-pointer`,children:[(0,R.jsx)(zi,{className:`size-3 fill-current`}),`Stop Tunnel`]})]})}function aB(e){try{let t=new URL(e),n=t.pathname+t.search;return t.host+(n&&n!==`/`?n:``)}catch{return e}}function oB({copied:e,onCopy:t,className:n}){return(0,R.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),t()},"aria-label":e?`URL copied`:`Copy URL`,className:A(`shrink-0 p-0.5 rounded-sm text-muted-foreground hover:text-foreground transition-opacity opacity-0 group-hover:opacity-100`,n),children:e?(0,R.jsx)(nB,{state:`success`,className:`size-3.5`}):(0,R.jsx)(Wr,{className:`size-3.5`})})}function sB({url:e,className:t,tunnelPopover:n}){let[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(!1);if(!e)return null;let s=aB(e),c=n?.mcpUrl??e,l=!!n,u=async()=>{try{await Qj(c),i(!0),setTimeout(()=>i(!1),2e3)}catch{GF.error(`Failed to copy URL`)}};(0,z.useEffect)(()=>{if(!n?.autoCopyOnOpen){o(!1);return}o(!0),i(!0);let e=setTimeout(()=>i(!1),2e3);return()=>clearTimeout(e)},[n?.autoCopyOnOpen]);let d=(0,R.jsxs)(R.Fragment,{children:[l?(0,R.jsx)(Lr,{className:`size-3.5 shrink-0`}):(0,R.jsx)(ei,{className:`size-3.5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate max-w-[min(24rem,30vw)]`,children:s})]}),f=A(`flex items-center gap-1 min-w-0 truncate text-left text-sm cursor-pointer`,l?`text-purple-600 dark:text-purple-400`:`text-blue-500`);return(0,R.jsxs)(`div`,{className:A(`group flex items-center gap-1.5 min-w-0`,t),children:[l?(0,R.jsxs)(Zz,{open:n.open,onOpenChange:n.onOpenChange,children:[(0,R.jsx)(Qz,{render:(0,R.jsx)(`button`,{type:`button`,className:A(f,`hover:opacity-80`),children:d}),nativeButton:!0}),(0,R.jsx)($z,{className:`w-[calc(100vw-2rem)] sm:w-96`,align:`start`,sideOffset:4,children:(0,R.jsx)(iB,{showCopiedBanner:a,onStop:async()=>{n.onOpenChange(!1),await n.onStop()}})})]}):(0,R.jsx)(`span`,{className:f,children:d}),(0,R.jsx)(oB,{copied:r,onCopy:()=>void u()})]})}function cB({devFromCli:e,isTunnelStarting:t,waitTicks:n,onStart:r}){if(t)return(0,R.jsxs)(`button`,{disabled:!0,className:`flex items-center gap-2 h-8 px-3 bg-violet-50 dark:bg-violet-950/40 border border-violet-200 dark:border-violet-800 rounded-full opacity-75 cursor-wait shrink-0`,children:[(0,R.jsx)(di,{className:`size-4 text-violet-500 dark:text-violet-400 animate-spin`}),(0,R.jsxs)(`span`,{className:`text-sm font-medium text-violet-600 dark:text-violet-300 hidden lg:inline`,children:[`Start Tunnel `,(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[n,`s`]})]})]});let i=e===!0,a=e===null;return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>void r(),disabled:!i||a,title:e===!1?"Run `mcp-use dev` from your project to enable tunneling.":a?`Checking dev server…`:void 0,className:A(`flex items-center gap-2 h-8 px-3 border rounded-full transition-colors shrink-0`,i&&!a?`bg-violet-50 dark:bg-violet-950/40 border-violet-200 dark:border-violet-800 hover:bg-violet-100 dark:hover:bg-violet-900/50 cursor-pointer`:`bg-violet-50/60 dark:bg-violet-950/20 border-violet-200 dark:border-violet-800 cursor-not-allowed opacity-70`),children:[a?(0,R.jsx)(di,{className:`size-4 text-violet-500 dark:text-violet-400 animate-spin`}):(0,R.jsx)(Lr,{className:`size-4 text-violet-500 dark:text-violet-400`}),(0,R.jsx)(`span`,{className:`text-sm font-medium text-violet-600 dark:text-violet-300 hidden lg:inline`,children:`Start Tunnel`})]})}async function lB(){try{let e=await fetch(iM(`dev/info`));return e.ok?await e.json():null}catch{return null}}function uB(){return typeof window>`u`?!1:window.__MCP_INSPECTOR_MODE__!==`standalone`}function dB({tunnelUrl:e,setTunnelUrl:t,isTunnelStarting:n,setIsTunnelStarting:r,onTunnelStarted:i}){let[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(0),d=(0,z.useCallback)((e,n)=>{let r=n?.syncTunnel??!1;if(o(!!e.fromCli),e.mcpUrl&&c(e.mcpUrl),!r)return;if(e.tunnelUrl){t(new URL(e.tunnelUrl).origin);return}let i=Dz(e.mcpUrl??null);if(i){t(i);return}t(null)},[t]);return(0,z.useEffect)(()=>{if(!n){u(20);return}u(20);let e=setInterval(()=>u(e=>e>0?e-1:0),1e3);return()=>clearInterval(e)},[n]),(0,z.useEffect)(()=>{let e=!1;if(!uB()){o(!1);return}return(async()=>{let t=await lB();e||(t?d(t,{syncTunnel:!0}):o(!1))})(),()=>{e=!0}},[d]),{devFromCli:a,mcpUrl:s,waitTicks:l,handleStartTunnel:(0,z.useCallback)(async()=>{if(a===!1){GF.error("Start Tunnel requires `mcp-use dev` from your project directory.");return}r(!0);let e=!1;try{let t=await fetch(iM(`dev/start-tunnel`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));GF.error(e.error||`Failed to start tunnel`);return}let n=await lB();if(n?.tunnelUrl||n?.mcpUrl){d(n,{syncTunnel:!0});let e=n.mcpUrl??(n.tunnelUrl?`${n.tunnelUrl.replace(/\/+$/,``)}/mcp`:null);e&&Zj(e),i?.()}e=!0}catch{GF.error(`Failed to start tunnel`)}finally{r(!1)}try{ET(new Co({action:`start`,success:e})).catch(()=>{})}catch{}},[d,a,i,r]),handleStopTunnel:(0,z.useCallback)(async()=>{r(!0);let n=!1;try{let e=await fetch(iM(`dev/stop-tunnel`),{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));GF.error(t.error||`Failed to stop tunnel`);return}t(null),c(null),GF.success(`Tunnel stopped`),n=!0}catch{GF.error(`Failed to stop tunnel`)}finally{r(!1)}try{ET(new Co({action:`stop`,success:n,tunnelUrl:e})).catch(()=>{})}catch{}},[r,t,e])}}function fB(e){let t=window.matchMedia(`(min-width: 1024px)`);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)}function pB(){return window.matchMedia(`(min-width: 1024px)`).matches}function mB(){return!0}function hB(){return(0,z.useSyncExternalStore)(fB,pB,mB)}function gB(e){let[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(!1),a=hB(),o=(0,z.useCallback)(()=>{n(!0),i(!0)},[]);return(0,z.useEffect)(()=>{e||(n(!1),i(!1))},[e]),(0,z.useEffect)(()=>{if(!e)return;let t=new URLSearchParams(window.location.search);if(!t.has(`openTunnelPopover`))return;n(!0),i(!0),t.delete(`openTunnelPopover`);let r=t.toString();window.history.replaceState({},``,`${window.location.pathname}${r?`?${r}`:``}`)},[e]),{open:t,onOpenChange:(0,z.useCallback)(e=>{n(e),e||i(!1)},[]),isLgUp:a,autoCopyOnOpen:r,openWithAutoCopy:o}}function _B({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:i,embedded:a=!1,sidebarCollapsed:o=!1}){let{tunnelUrl:s,isTunnelStarting:c,setTunnelUrl:l,setIsTunnelStarting:u,embeddedConfig:d}=fL(),[f,p]=(0,z.useState)(!1),[m]=(0,z.useState)(!0),h=gB(s),g=dB({tunnelUrl:s,setTunnelUrl:l,isTunnelStarting:c,setIsTunnelStarting:u,onTunnelStarted:h.openWithAutoCopy});if(d.singleTab)return null;let _=d.visibleTabs?Az.filter(e=>e.id===`separator`||d.visibleTabs.includes(e.id)):Az,v=!!t,y=!!t&&(oM(t.url??``)||sM(t.url??``)||!!s),b=t?s?`${s.replace(/\/+$/,``)}${nM()}`:t.url??``:``,x=g.mcpUrl??(s?`${s.replace(/\/+$/,``)}${nM()}`:null),S=(e,n)=>{if(!t||!b)return null;let r=e===`desktop`?h.isLgUp:!h.isLgUp;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(sB,{url:b,className:n,tunnelPopover:s&&x&&r?{mcpUrl:x,onStop:g.handleStopTunnel,open:h.open,onOpenChange:h.onOpenChange,autoCopyOnOpen:h.autoCopyOnOpen}:void 0}),y&&!s&&(0,R.jsx)(cB,{devFromCli:g.devFromCli,isTunnelStarting:c,waitTicks:g.waitTicks,onStart:g.handleStartTunnel})]})},C=()=>a?null:(0,R.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 flex-shrink-0`,children:[t&&(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(fz,{serverConfig:{url:b,name:lM(t),headers:_M(t),serverId:t.id},onSuccess:e=>GF.success(`Opening in ${e}...`),onError:e=>GF.error(`Failed: ${e.message}`),trigger:(0,R.jsxs)(jt,{variant:`ghost`,className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center`,"aria-label":`Add to Client`,children:[(0,R.jsxs)(`span`,{className:`xl:hidden hidden sm:flex items-center gap-1`,children:[(0,R.jsx)(ki,{className:`size-3`}),`Client`]}),(0,R.jsxs)(`span`,{className:`hidden xl:flex items-center gap-1`,children:[`Add to Client`,(0,R.jsx)(Ir,{className:`size-3`})]})]})})}),(0,R.jsx)(`a`,{href:f?`https://manufact.com/cloud?ref=mcp-use-inspector`:`https://manufact.com/signup?ref=mcp-use-inspector`,target:`_blank`,rel:`noopener noreferrer`,onClick:()=>{try{ET(new wo({referrer:`mcp-use-inspector`})).catch(()=>{})}catch{}},className:`inline-flex h-8 items-center justify-center rounded-full border border-blue-500/25 bg-blue-500/10 px-4 text-[13px] text-blue-500 outline-none cursor-pointer transition-colors hover:bg-blue-500/15 dark:border-blue-400/30 dark:bg-blue-400/10 dark:text-blue-400 dark:hover:bg-blue-400/15 focus-visible:ring-1 focus-visible:ring-ring`,children:(0,R.jsx)(`span`,{className:`[text-box:trim-both_cap_alphabetic]`,children:`Deploy`})}),d.chatApiUrl?(0,R.jsx)(lz,{chatApiUrl:d.chatApiUrl,onUserResolved:e=>p(!!e)}):null]});return(0,R.jsxs)(`header`,{className:`w-full shrink-0`,children:[(0,R.jsxs)(`div`,{className:`hidden lg:flex h-(--header-height) items-center justify-between gap-3 px-4 md:pl-0 md:pr-6`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:A(`hidden lg:block shrink-0`,v&&o&&`-mr-[calc(var(--sidebar-width-icon)/2-0.625rem)]`),children:(0,R.jsx)(pz,{pinSymbolInIconColumn:!0,showLabel:!v||!o,state:v&&o?`collapsed`:`expanded`})}),(0,R.jsx)(`span`,{className:`text-sm text-muted-foreground/60 shrink-0 [text-box:trim-both_cap_alphabetic]`,children:`/`}),(0,R.jsx)(Ez,{connections:e,selectedServer:t,onServerSelect:r,variant:`header`}),S(`desktop`)]})}),C()]}),(0,R.jsxs)(`div`,{className:`flex lg:hidden flex-col gap-3`,children:[(0,R.jsx)(`div`,{className:`flex items-center justify-between w-full`,children:!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`flex-1 flex justify-start`,children:(0,R.jsx)(Ez,{connections:e,selectedServer:t,onServerSelect:r,mobileMode:!0})}),(0,R.jsx)(`div`,{className:`flex-shrink-0 flex justify-center`,children:(0,R.jsx)(pz,{state:`collapsed`,showLabel:!0})}),(0,R.jsx)(`div`,{className:`flex-1 flex justify-end`,children:C()})]})}),t&&b&&!a&&(0,R.jsx)(`div`,{className:`flex items-center gap-2 px-1 min-w-0`,children:S(`mobile`,`min-w-0`)}),t&&(0,R.jsx)(`div`,{className:`w-full lg:hidden`,children:(0,R.jsx)(KR,{value:n,onValueChange:e=>i(e),collapsed:m,children:(0,R.jsx)(qR,{className:`w-full justify-center border-0 bg-transparent p-0`,children:_.map((e,r)=>{if(e.id===`separator`)return(0,R.jsx)(`div`,{className:`h-5 w-px bg-zinc-300 dark:bg-zinc-600 mx-1 shrink-0`},`separator-${r}`);let i=Oz(e.id,t),a=kz(e.id,i,m);return(0,R.jsx)(YR,{value:e.id,"data-testid":`tab-${e.id}`,icon:e.icon,showDot:a,badge:(0,R.jsx)(uz,{count:i,isActive:n===e.id,size:`sm`}),alwaysExpanded:`alwaysExpanded`in e&&e.alwaysExpanded,className:A(`[&>svg]:mr-0 flex-1 flex-row gap-2 relative`,m&&`pl-2`),children:(0,R.jsx)(`span`,{className:`sr-only`,children:e.label})},e.id)})})})})]})]})}function vB({collapsed:e,onToggle:t}){let n=e?`Expand sidebar`:`Collapse sidebar`;return(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsxs)(jt,{type:`button`,variant:`ghost`,size:`icon-sm`,tabIndex:-1,"aria-label":n,onClick:t,className:A(`border-border absolute top-1/2 right-0 z-30 hidden size-7 min-h-7 min-w-7 -translate-y-1/2 translate-x-1/2 rounded-full border bg-background lg:flex`,`opacity-0 transition-opacity duration-200 group-hover/sidebar:opacity-100 focus-visible:opacity-100`),children:[(0,R.jsx)(Ci,{className:`size-4`}),(0,R.jsx)(`span`,{className:`sr-only`,children:n})]}),nativeButton:!0}),(0,R.jsx)(Et,{side:`right`,children:n})]})}function yB({className:e}){return(0,R.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentcolor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,children:[(0,R.jsx)(`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`}),(0,R.jsx)(`path`,{d:`M9 18c-4.51 2-5-2-7-2`})]})}var bB=z.createContext(void 0);function xB(){let e=z.useContext(bB);if(e===void 0)throw Error(Ve(63));return e}var SB=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),CB={...Tn,checked(e){return e?{[SB.checked]:``}:{[SB.unchecked]:``}}};function wB(e,t,n,r=!0,i){let[a,o]=z.useState(),s=N(i?`${i}-label`:void 0),c=e??t??a;return be(()=>{let i=e||t||!r?void 0:TB(n.current,s);a!==i&&o(i)}),c}function TB(e,t){let n=EB(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function EB(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}var DB=z.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,"aria-labelledby":a,form:o,id:s,inputRef:c,name:l,nativeButton:u=!1,onCheckedChange:d,readOnly:f=!1,required:p=!1,disabled:m=!1,render:h,uncheckedValue:g,value:_,style:y,...b}=e,{clearErrors:x}=An(),{state:S,setTouched:C,setDirty:w,validityData:T,setFilled:ee,setFocused:E,validationMode:D,disabled:te,name:ne,validation:O}=On(),{labelId:re}=kn(),k=te||m,ie=ne??l,A=z.useRef(null),j=Ze(A,c,O.inputRef),M=z.useRef(null),oe=N(),se=cn({id:s,implicit:!1,controlRef:M}),P=u?void 0:se,[ce,le]=Yt({controlled:n,default:!!i,name:`Switch`,state:`checked`});En(M,oe,ce,void 0,!k,l),be(()=>{A.current&&ee(A.current.checked)},[A,ee]),Dn(ce,()=>{x(ie),w(ce!==T.initialValue),ee(ce),O.change(ce)});let{getButtonProps:ue,buttonRef:de}=Pe({disabled:k,native:u}),fe=wB(a,re,A,!u,P),pe={id:u?se:oe,role:`switch`,"aria-checked":ce,"aria-readonly":f||void 0,"aria-required":p||void 0,"aria-labelledby":fe,onFocus(){k||E(!0)},onBlur(){let e=A.current;!e||k||(C(!0),E(!1),D===`onBlur`&&O.commit(e.checked))},onClick(e){if(f||k)return;e.preventDefault();let t=A.current;t&&t.dispatchEvent(new(v(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))}},me=Ut({checked:ce,disabled:k,form:o,id:P,name:ie,required:p,style:ie?Le:rt,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:j,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(f){e.preventDefault();return}let t=e.currentTarget.checked,n=ae(Ae,e.nativeEvent);d?.(t,n),!n.isCanceled&&le(t)},onFocus(){M.current?.focus()}},e=>O.getValidationProps(k,e),_===void 0?St:{value:_}),he=z.useMemo(()=>({...S,checked:ce,disabled:k,readOnly:f,required:p}),[S,ce,k,f,p]),ge=We(`span`,e,{state:he,ref:[t,M,de],props:[pe,b,ue,e=>O.getValidationProps(k,e)],stateAttributesMapping:CB});return(0,R.jsxs)(bB.Provider,{value:he,children:[ge,!ce&&ie&&g!==void 0&&(0,R.jsx)(`input`,{type:`hidden`,form:o,name:ie,value:g,disabled:k}),(0,R.jsx)(`input`,{...me,suppressHydrationWarning:!0})]})}),OB=z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return We(`span`,e,{state:xB(),ref:t,stateAttributesMapping:CB,props:a})}),kB=34,AB=20,jB=16,MB=2,NB=4,PB=2;function FB(e){return`label`in e&&typeof e.label==`string`}var IB=(0,z.forwardRef)(({label:e,checked:t,onToggle:n,disabled:r=!1,thumbTransition:i,uncheckedTrackColor:a,uncheckedTrackColorHovered:o,className:s,...c},l)=>{let u=(0,z.useId)(),d=(0,z.useRef)(!1),[f,p]=(0,z.useState)(!1),[m,h]=(0,z.useState)(!1),g=(0,z.useRef)(!1),_=(0,z.useRef)(!1),v=(0,z.useRef)(null),y=na(t?16:MB);(0,z.useEffect)(()=>{d.current=!0},[]);let b=m?20:f?18:jB,x=m?jB-NB:jB,S=m?4:MB,C=b-jB,w=t?16-C:MB;(0,z.useEffect)(()=>{g.current||(d.current?Da(y,w,i??At.moderate):y.set(w))},[w,y,i]);let T=(0,z.useCallback)(e=>{r||e.pointerType===`mouse`&&e.button!==0||(h(!0),g.current=!1,_.current=!1,v.current={clientX:e.clientX,originX:y.get()},e.currentTarget.setPointerCapture(e.pointerId))},[r,y]),ee=(0,z.useCallback)(e=>{if(!v.current)return;let t=e.clientX-v.current.clientX;if(!g.current){if(Math.abs(t)<PB)return;g.current=!0}let n=MB,r=kB-MB-20,i=v.current.originX+t;y.set(Math.max(n,Math.min(r,i)))},[y]),E=(0,z.useCallback)(e=>{v.current&&=(h(!1),g.current&&(_.current=!0,g.current=!1,e&&(y.get()>14/2===t?Da(y,t?16:MB,i??At.moderate):n()),requestAnimationFrame(()=>{_.current=!1})),null)},[t,n,y,i]);return(0,R.jsxs)(`div`,{ref:l,className:A(`relative z-10 flex items-center gap-2.5 px-3 py-2 cursor-pointer select-none touch-none`,r&&`opacity-50 pointer-events-none`,s),onPointerEnter:e=>{e.pointerType===`mouse`&&p(!0)},onPointerLeave:()=>p(!1),onPointerDown:T,onPointerMove:ee,onPointerUp:()=>E(!0),onPointerCancel:()=>{v.current&&=(h(!1),g.current&&(g.current=!1,Da(y,t?16:MB,i??At.moderate)),null)},onClick:()=>{r||_.current||n()},...c,children:[(0,R.jsx)(DB,{checked:t,"aria-labelledby":u,onCheckedChange:()=>{_.current||n()},disabled:r,tabIndex:0,className:A(`relative shrink-0 rounded-full outline-none cursor-pointer`,`transition-colors duration-80`,`focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)] focus-visible:ring-offset-2 focus-visible:ring-offset-background`),style:{width:kB,height:AB,backgroundColor:t?f?`color-mix(in oklab, var(--primary) 88%, black)`:`var(--primary)`:f?o??`color-mix(in oklab, var(--accent), rgb(var(--overlay)) 10%)`:a??`var(--accent)`},onClick:e=>e.stopPropagation(),children:(0,R.jsx)(OB,{render:e=>{let{style:t,onDrag:n,onDragStart:r,onDragEnd:a,onAnimationStart:o,onAnimationEnd:s,onAnimationIteration:c,...l}=e;return(0,R.jsx)(qe.span,{...l,className:`absolute top-0 left-0 block rounded-full bg-white shadow-sm`,initial:!1,style:{...t,x:y},animate:{y:S,width:b,height:x},transition:d.current?i??At.moderate:{duration:0}})}})}),(0,R.jsx)(`span`,{id:u,className:A(`text-[13px] [text-box:trim-both_cap_alphabetic] transition-[color] duration-80`,t?`text-foreground`:`text-muted-foreground`),children:e})]})});IB.displayName=`FluidSwitch`;var LB=(0,z.forwardRef)(({checked:e,defaultChecked:t=!1,onCheckedChange:n,disabled:r=!1,className:i},a)=>{let[o,s]=(0,z.useState)(t),c=e??o;return(0,R.jsx)(DB,{ref:a,checked:c,disabled:r,onCheckedChange:t=>{e===void 0&&s(t),n?.(t)},className:A(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-xs transition-colors duration-80`,`focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]`,`disabled:cursor-not-allowed disabled:opacity-50`,`data-checked:bg-primary data-unchecked:bg-input`,i),children:(0,R.jsx)(OB,{className:A(`pointer-events-none block size-4 rounded-full bg-background shadow-sm ring-0 transition-transform duration-80`,`data-checked:translate-x-4 data-unchecked:translate-x-0`)})})});LB.displayName=`ShadcnSwitch`;var RB=(0,z.forwardRef)((e,t)=>FB(e)?(0,R.jsx)(IB,{ref:t,...e}):(0,R.jsx)(LB,{ref:t,...e}));RB.displayName=`Switch`;function zB({className:e}){return(0,R.jsx)(`svg`,{viewBox:`0 -28.5 256 256`,className:e,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,"aria-hidden":!0,children:(0,R.jsx)(`path`,{d:`M216.856339,16.5966031 C200.285002,8.84328665 182.566144,3.2084988 164.041564,0 C161.766523,4.11318106 159.108624,9.64549908 157.276099,14.0464379 C137.583995,11.0849896 118.072967,11.0849896 98.7430163,14.0464379 C96.9108417,9.64549908 94.1925838,4.11318106 91.8971895,0 C73.3526068,3.2084988 55.6133949,8.86399117 39.0420583,16.6376612 C5.61752293,67.146514 -3.4433191,116.400813 1.08711069,164.955721 C23.2560196,181.510915 44.7403634,191.567697 65.8621325,198.148576 C71.0772151,190.971126 75.7283628,183.341335 79.7352139,175.300261 C72.104019,172.400575 64.7949724,168.822202 57.8887866,164.667963 C59.7209612,163.310589 61.5131304,161.891452 63.2445898,160.431257 C105.36741,180.133187 151.134928,180.133187 192.754523,160.431257 C194.506336,161.891452 196.298154,163.310589 198.110326,164.667963 C191.183787,168.842556 183.854737,172.420929 176.223542,175.320965 C180.230393,183.341335 184.861538,190.991831 190.096624,198.16893 C211.238746,191.588051 232.743023,181.531619 254.911949,164.955721 C260.227747,108.668201 245.831087,59.8662432 216.856339,16.5966031 Z M85.4738752,135.09489 C72.8290281,135.09489 62.4592217,123.290155 62.4592217,108.914901 C62.4592217,94.5396472 72.607595,82.7145587 85.4738752,82.7145587 C98.3405064,82.7145587 108.709962,94.5189427 108.488529,108.914901 C108.508531,123.290155 98.3405064,135.09489 85.4738752,135.09489 Z M170.525237,135.09489 C157.88039,135.09489 147.510584,123.290155 147.510584,108.914901 C147.510584,94.5396472 157.658606,82.7145587 170.525237,82.7145587 C183.391518,82.7145587 193.761324,94.5189427 193.539891,108.914901 C193.539891,123.290155 183.391518,135.09489 170.525237,135.09489 Z`,fillRule:`nonzero`})})}var BB=`flex size-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,VB=`color-mix(in oklab, var(--sidebar-foreground) 22%, var(--sidebar))`,HB=`color-mix(in oklab, var(--sidebar-foreground) 30%, var(--sidebar))`,UB=`data-unchecked:!bg-zinc-300 dark:data-unchecked:!bg-zinc-600`;function WB({collapsed:e,rpcLoggerOpen:t,onRpcLoggerOpenChange:n,onCommandPaletteOpen:r}){let{embeddedConfig:i}=fL(),{theme:a,setTheme:o}=_z(),{user:s}=XR(i.chatApiUrl),c=s?`https://manufact.com/cloud?ref=mcp-use-inspector`:`https://manufact.com/signup?ref=mcp-use-inspector`,l=()=>{try{ET(new wo({referrer:`mcp-use-inspector-sidebar`})).catch(()=>{})}catch{}};return(0,R.jsx)(`footer`,{className:`mt-auto shrink-0`,children:(0,R.jsxs)(`div`,{className:A(`flex flex-col`,e?`items-center gap-2 px-2 py-3`:`gap-3 px-(--sidebar-nav-inset-x) py-4`),children:[e?(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`div`,{className:`flex size-8 items-center justify-center`,children:(0,R.jsx)(RB,{checked:t,onCheckedChange:n,"aria-label":`RPC Panel`,className:A(`scale-75`,UB)})}),nativeButton:!1}),(0,R.jsx)(Et,{side:`right`,children:`RPC Panel`})]}):(0,R.jsx)(RB,{label:`RPC Panel`,checked:t,onToggle:()=>n(!t),uncheckedTrackColor:VB,uncheckedTrackColorHovered:HB,className:`w-full flex-row-reverse justify-between`}),e?(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,onClick:l,className:BB,"aria-label":`Deploying your MCP Server? Try manufact.com`,children:(0,R.jsx)(Ar,{className:`size-4`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:`right`,children:`Deploying your MCP Server? Try manufact.com`})]}):(0,R.jsxs)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,onClick:l,className:`relative block rounded-xl border border-sidebar-border bg-white p-3 transition-colors hover:bg-sidebar-accent/50 dark:bg-black`,children:[(0,R.jsx)(Ar,{className:`absolute top-2.5 right-2.5 size-3.5 text-muted-foreground`,"aria-hidden":!0}),(0,R.jsx)(`p`,{className:`pr-5 text-xs leading-snug text-muted-foreground`,children:`Deploying your MCP Server?`}),(0,R.jsxs)(`p`,{className:`mt-0.5 text-xs leading-snug`,children:[`Try`,` `,(0,R.jsx)(`span`,{className:`font-medium underline underline-offset-2`,children:`manufact.com`})]})]}),(0,R.jsxs)(`div`,{className:A(`flex`,e?`flex-col items-center gap-1`:`flex-row items-center gap-2`),children:[(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`a`,{href:`https://github.com/mcp-use/mcp-use`,target:`_blank`,rel:`noopener noreferrer`,className:BB,"aria-label":`GitHub`,children:(0,R.jsx)(yB,{className:`size-4`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:e?`right`:`top`,children:`GitHub`})]}),(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`a`,{href:`https://discord.gg/XkNkSkMz3V`,target:`_blank`,rel:`noopener noreferrer`,className:BB,"aria-label":`Discord`,children:(0,R.jsx)(zB,{className:`size-4`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:e?`right`:`top`,children:`Discord`})]}),(0,R.jsxs)(qa,{children:[(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(Ja,{render:(0,R.jsx)(`button`,{type:`button`,className:BB,"aria-label":`Theme`,children:a===`light`?(0,R.jsx)(Vi,{className:`size-4`}):a===`dark`?(0,R.jsx)(bi,{className:`size-4`}):(0,R.jsx)(yi,{className:`size-4`})}),nativeButton:!0}),nativeButton:!0}),(0,R.jsx)(Et,{side:e?`right`:`top`,children:`Theme`})]}),(0,R.jsx)(Ya,{side:e?`right`:`top`,align:e?`start`:`center`,className:`w-40`,children:(0,R.jsxs)(Qa,{value:a,onValueChange:e=>o(e),children:[(0,R.jsxs)($a,{value:`light`,children:[(0,R.jsx)(Vi,{className:`size-4 mr-2`}),`Light`]}),(0,R.jsxs)($a,{value:`dark`,children:[(0,R.jsx)(bi,{className:`size-4 mr-2`}),`Dark`]}),(0,R.jsxs)($a,{value:`system`,children:[(0,R.jsx)(yi,{className:`size-4 mr-2`}),`System`]})]})})]}),(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`button`,{type:`button`,onClick:r,className:BB,"aria-label":`Command Palette`,"data-testid":`command-palette-trigger-button`,children:(0,R.jsx)(Ur,{className:`size-4`})}),nativeButton:!0}),(0,R.jsxs)(Et,{side:e?`right`:`top`,children:[`Command Palette (`,`⌘`,`K)`]})]})]})]})})}function GB(e,t){let n=0,r=0,i=e;for(;i&&i!==t;)n+=i.offsetTop,r+=i.offsetLeft,i=i.offsetParent;if(i!==t){let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();return{top:r.top-n.top,left:r.left-n.left,width:r.width,height:r.height}}return{top:n,left:r,width:e.offsetWidth,height:e.offsetHeight}}function KB(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.top!==i.top||n.left!==i.left||n.width!==i.width||n.height!==i.height)return!1}return!0}function qB(e,t={}){let{axis:n=`y`}=t,r=(0,z.useRef)(new Map),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)({}),c=(0,z.useRef)({}),l=(0,z.useRef)(0),u=(0,z.useRef)(null),d=(0,z.useRef)(null),f=(0,z.useCallback)(()=>{let t=e.current;if(!t)return;let n={};r.current.forEach((e,r)=>{n[r]=GB(e,t)}),!KB(c.current,n)&&(c.current=n,s(n))},[e]),p=(0,z.useCallback)((e,t)=>{t?r.current.set(e,t):r.current.delete(e),d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null,f()})},[f]),m=(0,z.useCallback)(t=>{let r=t.clientX,i=t.clientY;u.current!==null&&cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{u.current=null;let t=e.current;if(!t)return;let o=t.getBoundingClientRect(),s=n===`x`?r:i,l=null,d=1/0,f=null,p=c.current,m=n===`x`?t.scrollLeft:t.scrollTop,h=n===`x`?t.clientLeft:t.clientTop,g=n===`x`?o.left:o.top,_=n===`x`?t.offsetWidth:t.offsetHeight,v=n===`x`?o.width:o.height,y=_>0?v/_:1;for(let[e,t]of Object.entries(p)){let r=g+(h+(n===`x`?t.left:t.top)-m)*y,i=(n===`x`?t.width:t.height)*y,a=r+i;s>=r&&s<=a&&(f=e);let o=r+i/2,c=Math.abs(s-o);c<d&&(d=c,l=e)}a(f??l)})},[n,e]),h=(0,z.useCallback)(()=>{l.current+=1},[]),g=(0,z.useCallback)(()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),a(null)},[]);return(0,z.useEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>{d.current!==null&&cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{d.current=null,f()})});return n.observe(t),()=>n.disconnect()},[e,f]),(0,z.useEffect)(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current),d.current!==null&&cancelAnimationFrame(d.current)},[]),{activeKey:i,itemRects:o,sessionRef:l,handlers:{onMouseMove:m,onMouseEnter:h,onMouseLeave:g},registerItem:p,measureItems:f}}function JB(e){if(!e)return{left:0,right:0};let t=getComputedStyle(e),n=Number.parseFloat(t.getPropertyValue(`--sidebar-nav-pill-bleed`))||0,r=Number.parseFloat(t.getPropertyValue(`--sidebar-nav-scrollbar-width`))||0,i=Number.parseFloat(t.getPropertyValue(`--sidebar-nav-pill-outer-trim-right`))||0;return{left:n,right:n+r+i}}function YB(e,t){return{...e,left:e.left-t.left,width:e.width+t.left+t.right}}var XB=(0,z.createContext)(null);function ZB(){let e=(0,z.useContext)(XB),t=(0,z.useRef)(e?.registerItem);t.current=e?.registerItem;let n=(0,z.useRef)(new Map);return(0,z.useCallback)(e=>{let r=n.current,i=r.get(e);return i||(i=n=>t.current?.(e,n),r.set(e,i)),i},[])}function QB({children:e,isActiveKey:t,className:n}){let r=(0,z.useRef)(null),{activeKey:i,itemRects:a,sessionRef:o,handlers:s,registerItem:c,measureItems:l}=qB(r),u=(0,z.useMemo)(()=>({registerItem:c}),[c]),d=Object.keys(a).find(e=>t(e))??null;(0,z.useLayoutEffect)(()=>{l()},[l,e,d]);let f=JB(r.current),p=i?a[i]:null,m=d?a[d]:null,h=p?YB(p,f):null,g=m?YB(m,f):null,_=i!==null&&i!==d;return(0,R.jsx)(XB.Provider,{value:u,children:(0,R.jsxs)(`div`,{ref:r,onMouseEnter:s.onMouseEnter,onMouseMove:s.onMouseMove,onMouseLeave:s.onMouseLeave,className:A(`relative isolate`,n),children:[(0,R.jsx)(en,{initial:!1,children:g&&d?(0,R.jsx)(qe.div,{"aria-hidden":!0,className:`pointer-events-none absolute -z-20 rounded-full bg-sidebar-accent`,initial:{opacity:0,top:g.top,left:g.left,width:g.width,height:g.height},animate:{opacity:_?.85:1,top:g.top,left:g.left,width:g.width,height:g.height},exit:{opacity:0,transition:At.fast.exit},transition:{opacity:{duration:.08},top:{duration:0},left:{duration:0},width:{duration:0},height:{duration:0}}},d):null}),(0,R.jsx)(en,{children:h?(0,R.jsx)(qe.div,{"aria-hidden":!0,className:`pointer-events-none absolute -z-10 rounded-full bg-sidebar-accent`,initial:{opacity:0,top:g?.top??h.top,left:g?.left??h.left,width:g?.width??h.width,height:g?.height??h.height},animate:{opacity:1,top:h.top,left:h.left,width:h.width,height:h.height},exit:{opacity:0,transition:At.fast.exit},transition:{...At.fast,opacity:{duration:.08}}},o.current):null}),e]})})}var $B=A(`pointer-events-auto absolute right-(--sidebar-nav-trailing-right) top-1/2 z-10 flex h-(--sidebar-nav-trailing-size) min-w-(--sidebar-nav-trailing-size) -translate-y-1/2 items-center justify-center`,A(`transition-[opacity,filter] duration-200 ease-out`,`opacity-100 blur-0`,`group-data-[collapsible=icon]:opacity-0 group-data-[collapsible=icon]:blur-[3px] group-data-[collapsible=icon]:pointer-events-none`,`group-data-[collapsed=true]:opacity-0 group-data-[collapsed=true]:blur-[3px] group-data-[collapsed=true]:pointer-events-none`)),eV=A(`truncate transition-[opacity,filter,margin] duration-200 ease-out`,`group-data-[collapsible=icon]:hidden`,`group-data-[collapsed=true]:hidden`),tV=A(`peer/menu-button flex cursor-pointer items-center gap-2 overflow-hidden rounded-full py-2 text-left text-sm outline-hidden ring-sidebar-ring hover:text-sidebar-accent-foreground group-hover/menu-item:text-sidebar-accent-foreground focus-visible:ring-2 active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:font-medium data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,`transition-[width,max-width,height,padding,border-radius] duration-200 ease-out`,`h-8 text-sm`);function nV({count:e}){return(0,R.jsx)(`span`,{className:A(`inline-flex h-5 shrink-0 items-center justify-center border border-border bg-zinc-200 px-1 text-[10px] font-medium tabular-nums leading-none text-foreground dark:bg-zinc-700`,String(e).length>=3?`min-w-5 rounded-md`:`size-5 min-w-5 rounded-full`),children:e})}function rV(e){return e.id!==`separator`}function iV({activeTab:e,onTabChange:t,selectedServer:n,visibleTabs:r,collapsed:i}){let a=ZB();return(0,R.jsx)(`ul`,{className:`flex w-full min-w-0 flex-col gap-1 px-(--sidebar-nav-inset-x) group`,"data-collapsed":i,"aria-label":`Inspector tabs`,children:(r?Az.filter(e=>rV(e)&&r.includes(e.id)):Az.filter(rV)).map((r,o)=>{let s=Oz(r.id,n),c=kz(r.id,s,i),l=r.icon,u=e===r.id,d=s>0||c,f=(0,R.jsxs)(`button`,{ref:a(r.id),type:`button`,"data-testid":`tab-${r.id}`,"data-active":u?!0:void 0,onClick:()=>t(r.id),className:A(tV,i?`size-8! w-8! max-w-8! shrink-0 justify-center gap-0 p-0!`:`w-full max-w-full sidebar-nav-pill-bleed-x pl-(--sidebar-nav-icon-pl-bleed) pr-(--sidebar-nav-pr-bleed)`,d&&!i&&`pr-[calc(var(--sidebar-nav-trailing-right)+var(--sidebar-nav-trailing-size))]`),children:[(0,R.jsx)(l,{className:`size-4 shrink-0`}),(0,R.jsx)(`span`,{className:eV,children:r.label})]});return(0,R.jsxs)(`li`,{className:A(`group/menu-item relative`,o===0&&`mt-4`),children:[i?(0,R.jsxs)(gt,{delayDuration:0,children:[(0,R.jsx)(Ie,{render:f,nativeButton:!0}),(0,R.jsx)(Et,{side:`right`,children:s>0?`${r.label} (${s})`:r.label})]}):f,d&&!i?(0,R.jsx)(`div`,{className:$B,children:s>0?(0,R.jsx)(nV,{count:s}):c?(0,R.jsx)(`span`,{className:`inline-flex h-2 w-2 shrink-0 rounded-full bg-yellow-500 animate-status-pulse-yellow`}):null}):null]},r.id)})})}function aV({activeTab:e,onTabChange:t,selectedServer:n,visibleTabs:r,collapsed:i,onCollapsedChange:a,rpcLoggerOpen:o,onRpcLoggerOpenChange:s,onCommandPaletteOpen:c}){return(0,R.jsxs)(`aside`,{className:A(`group/sidebar relative hidden lg:flex flex-col shrink-0 text-sidebar-foreground transition-[width] duration-200 ease-out @container/sidebar`,i?`w-(--sidebar-width-icon)`:`w-(--sidebar-width)`),"data-collapsed":i,"data-collapsible":i?`icon`:`expanded`,children:[(0,R.jsx)(`div`,{className:`sidebar-nav-scroll flex-1 overflow-y-auto overflow-x-hidden min-h-0`,children:(0,R.jsx)(QB,{isActiveKey:t=>t===e,className:`pb-2`,children:(0,R.jsx)(iV,{activeTab:e,onTabChange:t,selectedServer:n,visibleTabs:r,collapsed:i})})}),(0,R.jsx)(WB,{collapsed:i,rpcLoggerOpen:o,onRpcLoggerOpenChange:s,onCommandPaletteOpen:c}),(0,R.jsx)(vB,{collapsed:i,onToggle:()=>a(!i)})]})}function oV(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/t**r*100)/100+` `+n[r]}function sV(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(1))} ${n[r]}`}var cV=100*1024,lV=1024*20;function uV(e,t){if(e==null)return e;if(typeof e==`string`)return e.length>t?e.substring(0,t)+`... (truncated)`:e;if(Array.isArray(e))return e.map(e=>uV(e,t));if(typeof e==`object`){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=uV(e[r],t));return n}return e}function dV(e){let t=JSON.stringify(e,null,2);return new TextEncoder().encode(t).length>cV?uV(e,lV):e}function fV(e){let t=JSON.stringify(e,null,2),n=new TextEncoder().encode(t).length,r=n>cV,i;if(r){let t=uV(e,lV);i=JSON.stringify(t,null,2)}else i=t;return{isLarge:r,size:n,sizeFormatted:oV(n),preview:i,full:t}}function pV(e,t){try{let n=JSON.stringify(e,null,2),r=globalThis.Blob,i=new r([n],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=t||`data-${Date.now()}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a)}catch(e){throw console.error(`Failed to download JSON:`,e),e}}var mV={key:`text-sky-600 dark:text-sky-400`,string:`text-emerald-600 dark:text-emerald-400`,number:`text-amber-600 dark:text-amber-400`,boolean:`text-violet-600 dark:text-violet-400`,null:`text-zinc-500 dark:text-zinc-400`,punctuation:`text-muted-foreground`};function hV(e){let t=[],n=0,r=(e,n)=>{n&&t.push({kind:e,text:n})};for(;n<e.length;){let t=e[n];if(t===`"`){let t=n;for(n++;n<e.length;){if(e[n]===`\\`){n+=2;continue}if(e[n]===`"`){n++;break}n++}let i=e.slice(t,n),a=n;for(;a<e.length&&/[ \t]/.test(e[a]);)a++;r(e[a]===`:`?`key`:`string`,i);continue}if(/[0-9-]/.test(t)){let t=n;for(e[n]===`-`&&n++;n<e.length&&/[0-9.eE+-]/.test(e[n]);)n++;r(`number`,e.slice(t,n));continue}if(e.startsWith(`true`,n)||e.startsWith(`false`,n)){let t=e.startsWith(`true`,n)?`true`:`false`;r(`boolean`,t),n+=t.length;continue}if(e.startsWith(`null`,n)){r(`null`,`null`),n+=4;continue}if(/[{}[\],:]/.test(t)){r(`punctuation`,t),n++;continue}r(`punctuation`,t),n++}return t}function gV(e){return hV(e).map((e,t)=>(0,R.jsx)(`span`,{className:mV[e.kind],children:e.text},t))}var _V={string:`text-emerald-600 dark:text-emerald-400`,number:`text-amber-600 dark:text-amber-400`,boolean:`text-violet-600 dark:text-violet-400`,null:`text-zinc-500 dark:text-zinc-400`,key:`text-sky-600 dark:text-sky-400`,punctuation:`text-muted-foreground`};function vV(e){return e===null?(0,R.jsx)(`span`,{className:_V.null,children:`null`}):typeof e==`string`?(0,R.jsx)(`span`,{className:_V.string,children:JSON.stringify(e)}):typeof e==`number`?(0,R.jsx)(`span`,{className:_V.number,children:String(e)}):typeof e==`boolean`?(0,R.jsx)(`span`,{className:_V.boolean,children:String(e)}):(0,R.jsx)(`span`,{className:_V.string,children:JSON.stringify(e)})}function yV(e){return Array.isArray(e)?`[${e.length}]`:`{${Object.keys(e).length}}`}function bV({label:e,value:t,depth:n,defaultExpanded:r}){let i=typeof t==`object`&&t&&!Array.isArray(t)?Object.keys(t).length>0:Array.isArray(t)?t.length>0:!1,[a,o]=(0,z.useState)(i&&(r||n===0));if(!i){let r=Array.isArray(t)?`[]`:`{}`;return typeof t==`object`&&t?(0,R.jsxs)(`div`,{className:`font-mono text-[0.8rem] leading-relaxed`,style:{paddingLeft:n*12},children:[e!=null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:_V.key,children:JSON.stringify(e)}),(0,R.jsx)(`span`,{className:_V.punctuation,children:`: `})]}),(0,R.jsx)(`span`,{className:_V.punctuation,children:r})]}):(0,R.jsxs)(`div`,{className:`font-mono text-[0.8rem] leading-relaxed`,style:{paddingLeft:n*12},children:[e!=null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:_V.key,children:JSON.stringify(e)}),(0,R.jsx)(`span`,{className:_V.punctuation,children:`: `})]}),vV(t)]})}let s=Array.isArray(t)?t.map((e,t)=>[String(t),e]):Object.entries(t),c=Array.isArray(t),l=c?`[`:`{`,u=c?`]`:`}`;return(0,R.jsxs)(`div`,{className:`font-mono text-[0.8rem] leading-relaxed`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-0.5`,style:{paddingLeft:n*12},children:[(0,R.jsx)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>o(e=>!e),className:`mt-0.5 inline-flex shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground`,children:(0,R.jsx)(O,{className:A(`h-3.5 w-3.5 transition-transform`,a&&`rotate-90`)})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[e!=null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:_V.key,children:JSON.stringify(e)}),(0,R.jsx)(`span`,{className:_V.punctuation,children:`: `})]}),(0,R.jsx)(`span`,{className:_V.punctuation,children:l}),!a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>o(!0),className:`mx-1 text-xs text-muted-foreground hover:text-foreground`,children:yV(t)}),(0,R.jsx)(`span`,{className:_V.punctuation,children:u})]})]})]}),a&&(0,R.jsxs)(`div`,{children:[s.map(([e,t])=>(0,R.jsx)(bV,{label:e,value:t,depth:n+1,defaultExpanded:r},`${n}-${e}`)),(0,R.jsx)(`div`,{style:{paddingLeft:n*12},children:(0,R.jsx)(`span`,{className:_V.punctuation,children:u})})]})]})}function xV({data:e,defaultExpanded:t=!0,className:n}){return(0,R.jsx)(`div`,{className:A(`text-gray-900 dark:text-gray-100 [overflow-wrap:anywhere]`,n),"data-testid":`collapsible-json`,children:(0,R.jsx)(bV,{value:e,depth:0,defaultExpanded:t})})}var SV=`font-mono text-[0.8rem] text-gray-900 dark:text-gray-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`;function CV({data:e,filename:t,className:n,collapsible:r=!1,defaultExpanded:i=!0,...a}){let o=fV(e),s=dV(e),c=o.isLarge?(0,R.jsx)(`div`,{className:`mb-3 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex-1`,children:[(0,R.jsxs)(`p`,{className:`text-sm font-medium text-yellow-800 dark:text-yellow-300 mb-1`,children:[`JSON is too large (`,o.sizeFormatted,`)`]}),(0,R.jsx)(`p`,{className:`text-xs text-yellow-700 dark:text-yellow-400`,children:`Showing full structure with truncated values. Download the full JSON file to see complete values.`})]}),(0,R.jsxs)(jt,{variant:`outline`,size:`sm`,onClick:()=>{pV(e,t)},className:`shrink-0`,children:[(0,R.jsx)(qr,{className:`h-4 w-4 mr-1`}),`Download`]})]})}):null;return r?(0,R.jsxs)(`div`,{className:n,...a,children:[c,(0,R.jsx)(xV,{data:s,defaultExpanded:i})]}):o.isLarge?(0,R.jsxs)(`div`,{className:n,...a,children:[c,(0,R.jsx)(`pre`,{className:SV,children:(0,R.jsx)(`code`,{children:gV(o.preview)})})]}):(0,R.jsx)(`div`,{className:n,...a,children:(0,R.jsx)(`pre`,{className:SV,children:(0,R.jsx)(`code`,{children:gV(o.preview)})})})}function wV(e){if(!e)return null;for(let t of e.elements){let e=t.tagName;if(e===`BUTTON`||e===`INPUT`){let e=t;if(e.type===`submit`)return e}}return null}var TV=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.indeterminate=`data-indeterminate`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({});function EV(e){return z.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[TV.checked]:``}:{[TV.unchecked]:``}},...Tn}),[e.indeterminate])}var DV=z.createContext({disabled:!1});function OV(){return z.useContext(DV)}var kV=z.createContext(void 0);function AV(e=!0){let t=z.useContext(kV);if(t===void 0&&!e)throw Error(Ve(3));return t}var jV=z.createContext(void 0);function MV(){let e=z.useContext(jV);if(e===void 0)throw Error(Ve(14));return e}var NV=`data-parent`,PV=z.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,"aria-labelledby":a,disabled:o=!1,form:s,id:c,indeterminate:l=!1,inputRef:u,name:d,onCheckedChange:f,parent:p=!1,readOnly:m=!1,render:h,required:g=!1,uncheckedValue:_,value:y,nativeButton:b=!1,style:x,...S}=e,{clearErrors:C}=An(),{disabled:w,name:T,setDirty:ee,setFilled:E,setFocused:D,setTouched:te,state:ne,validationMode:O,validityData:re,validation:k}=On(),ie=OV(),{labelId:A,controlId:j,registerControlId:M,getDescriptionProps:oe}=kn(),se=AV(),P=se?.parent,ce=P&&se.allValues,le=w||ie.disabled||se?.disabled||o,ue=T??d,de=y??ue,fe=N(),pe=N(),me=j;ce?me=p?pe:`${P.id}-${de}`:c&&(me=c);let he={};ce&&(p?he=se.parent.getParentProps():de&&(he=se.parent.getChildProps(de)));let{checked:ge=n,indeterminate:_e=l,onCheckedChange:ve,...ye}=he,F=se?.value,xe=se?.setValue,Se=se?.defaultValue,Ce=z.useRef(null),we=Bt(()=>Symbol(`checkbox-control`)),Te=z.useRef(!1),{getButtonProps:Ee,buttonRef:De}=Pe({disabled:le,native:b}),Oe=se?.validation??k,[ke,je]=Yt({controlled:de&&F&&!p?F.includes(de):ge,default:de&&Se&&!p?Se.includes(de):i,name:`Checkbox`,state:`checked`}),Me=ce?!!ge:ke,Ne=ce&&_e||l;be(()=>{M!==mt&&(Te.current=!0,M(we.current,me))},[me,M,we]),z.useEffect(()=>{let e=we.current;return()=>{!Te.current||M===mt||(Te.current=!1,M(e,void 0))}},[M,we]),En(Ce,fe,ke,void 0,!se&&!le,d);let Fe=z.useRef(null),Ie=Ze(u,Fe,Oe.inputRef,Oe.registerInput),Re=wB(a,A,Fe,!b,me??void 0);be(()=>{Fe.current&&(Fe.current.indeterminate=Ne,ke&&E(!0))},[ke,Ne,E]),Dn(ke,()=>{se||(C(ue),E(ke),ee(ke!==re.initialValue),Oe.change(ke))});let ze=Ut({checked:ke,disabled:le,form:s,name:p?void 0:ue,id:b?void 0:me??void 0,required:g,ref:Ie,style:ue?Le:rt,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(m){e.preventDefault();return}let t=e.currentTarget.checked,n=ae(Ae,e.nativeEvent);f?.(t,n),!n.isCanceled&&(ve?.(t,n),!n.isCanceled&&(je(t),de&&F&&xe&&!p&&!ce&&xe(t?[...F,de]:F.filter(e=>e!==de),n)))},onFocus(){Ce.current?.focus()}},y===void 0?St:{value:(se?ke&&y:y)||``},oe,e=>Oe.getValidationProps(le,e));z.useEffect(()=>{if(!P||!de)return;let e=P.disabledStatesRef.current;return e.set(de,le),()=>{e.delete(de)}},[P,le,de]);let Be=z.useMemo(()=>({...ne,checked:Me,disabled:le,readOnly:m,required:g,indeterminate:Ne}),[ne,Me,le,m,g,Ne]),Ve=EV(Be),He=We(`span`,e,{state:Be,ref:[De,Ce,t,se?.registerControlRef],props:[{id:b?me??void 0:fe,role:`checkbox`,"aria-checked":Ne?`mixed`:Me,"aria-readonly":m||void 0,"aria-required":g||void 0,"aria-labelledby":Re,[NV]:p?``:void 0,onFocus(){le||D(!0)},onBlur(){let e=Fe.current;e&&(te(!0),D(!1),O===`onBlur`&&Oe.commit(se?F:e.checked))},onKeyDown(e){if(e.key!==`Enter`||(e.preventBaseUIHandler(),e.defaultPrevented))return;let t=Fe.current?.form??null,n=e.currentTarget,r=e.nativeEvent,i=e.preventDefault,a=r.preventDefault,o=!1;e.preventDefault=()=>{o=!0,i.call(e)},r.preventDefault=()=>{o=!0,a.call(r)},a.call(r),v(n).queueMicrotask(()=>{e.preventDefault=i,r.preventDefault=a,o||wV(t)?.click()})},onClick(e){if(m||le)return;e.preventDefault();let t=Fe.current;t&&t.dispatchEvent(new(v(t)).PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey}))}},S,ye,Ee,oe,e=>Oe.getValidationProps(le,e)],stateAttributesMapping:Ve});return(0,R.jsxs)(jV.Provider,{value:Be,children:[He,!ke&&!se&&ue&&!p&&_!==void 0&&(0,R.jsx)(`input`,{type:`hidden`,form:s,name:ue,value:_,disabled:le}),(0,R.jsx)(`input`,{...ze,suppressHydrationWarning:!0})]})}),FV=z.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=MV(),c=s.checked||s.indeterminate,{mounted:l,transitionStatus:u,setMounted:d}=lt(c),f=z.useRef(null),p={...s,transitionStatus:u};x({open:c,ref:f,onComplete(){c||d(!1)}});let m={...EV(s),...bt,...Tn},h=a||l,g=We(`span`,e,{ref:[t,f],state:p,stateAttributesMapping:m,props:o});return h?g:null}),IV=(0,z.createContext)(null);function LV(){let e=(0,z.useContext)(IV);if(!e)throw Error(`useCheckboxGroup must be used within a CheckboxGroup`);return e}var RV=(0,z.forwardRef)(({children:e,checkedIndices:t,orientation:n=`vertical`,className:r,...i},a)=>{let o=(0,z.useRef)(null),s=n===`horizontal`,{activeIndex:c,setActiveIndex:l,handlers:u,registerItem:d,measureItems:f}=_n(o,{axis:s?`x`:`y`});(0,z.useEffect)(()=>{f()},[f,e]);let p=s?`ArrowLeft`:`ArrowUp`,m=s?`ArrowRight`:`ArrowDown`;return(0,R.jsx)(IV.Provider,{value:{registerItem:d,activeIndex:c},children:(0,R.jsx)(`div`,{ref:e=>{o.current=e,typeof a==`function`?a(e):a&&(a.current=e)},onMouseEnter:u.onMouseEnter,onMouseMove:u.onMouseMove,onMouseLeave:u.onMouseLeave,onFocus:e=>{let t=e.target.closest(`[data-proximity-index]`)?.getAttribute(`data-proximity-index`);t!=null&&l(Number(t))},onBlur:e=>{o.current?.contains(e.relatedTarget)||l(null)},onKeyDown:e=>{let t=Array.from(o.current?.querySelectorAll(`[data-proximity-index]`)??[]),n=t.indexOf(e.target);n!==-1&&([p,m].includes(e.key)?(e.preventDefault(),t[e.key===m?(n+1)%t.length:(n-1+t.length)%t.length]?.focus()):e.key===`Home`?(e.preventDefault(),t[0]?.focus()):e.key===`End`&&(e.preventDefault(),t[t.length-1]?.focus()))},role:`group`,className:A(`relative flex max-w-full select-none`,s?`w-auto flex-row`:`w-72 flex-col`,r),...i,children:e})})});RV.displayName=`CheckboxGroup`;var zV=(0,z.forwardRef)(({label:e,index:t,checked:n,onToggle:r,size:i=`default`,className:a,...o},s)=>{let c=(0,z.useRef)(null),l=(0,z.useRef)(!1),{registerItem:u,activeIndex:d}=LV();(0,z.useEffect)(()=>(u(t,c.current),()=>u(t,null)),[t,u]),(0,z.useEffect)(()=>{l.current=!0},[]);let f=d===t,p=!l.current,m=D(),h=i===`sm`;return(0,R.jsxs)(`div`,{ref:e=>{c.current=e,typeof s==`function`?s(e):s&&(s.current=e)},"data-proximity-index":t,tabIndex:0,role:`checkbox`,"aria-checked":n,"aria-label":e,onClick:r,onMouseDown:e=>{let t=e.target.closest(`button:not([tabindex="-1"]), a[href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);t&&t!==e.currentTarget||(e.preventDefault(),e.currentTarget.focus())},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),r())},className:A(`relative z-10 flex items-center cursor-pointer outline-none`,h?`h-7 gap-1.5 px-2`:`h-8 gap-2.5 px-3`,m.item,`focus-visible:ring-1 focus-visible:ring-[color:var(--focus-ring,#6B97FF)]`,a),...o,children:[(0,R.jsxs)(PV,{checked:n,tabIndex:-1,"aria-hidden":!0,className:A(`pointer-events-none relative shrink-0 appearance-none bg-transparent p-0 border-0 outline-none`,h?`size-[13px]`:`size-[15px]`),children:[(0,R.jsx)(`div`,{className:A(`absolute inset-0 rounded-[5px] border-solid transition-all duration-80 border-[1.5px]`,n?`border-border`:f?`border-neutral-400 dark:border-neutral-500`:`border-border`)}),(0,R.jsx)(en,{children:n&&(0,R.jsx)(FV,{keepMounted:!0,render:e=>{let{style:t,onDrag:n,onDragStart:r,onDragEnd:i,onAnimationStart:a,onAnimationEnd:o,onAnimationIteration:s,...c}=e;return(0,R.jsx)(qe.svg,{...c,width:h?14:18,height:h?14:18,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 text-foreground`,initial:{opacity:1},animate:{opacity:1},exit:{opacity:1},children:(0,R.jsx)(qe.path,{d:`M6 12L10 16L18 8`,initial:{pathLength:+!!p},animate:{pathLength:1,transition:{duration:.08,ease:`easeOut`}},exit:{pathLength:0,transition:{duration:.04,ease:`easeIn`}}})})}})})]}),(0,R.jsxs)(`span`,{className:`inline-grid items-center self-center leading-none`,children:[(0,R.jsx)(`span`,{className:`col-start-1 row-start-1 invisible leading-none`,style:{fontVariationSettings:He.semibold},"aria-hidden":`true`,children:e}),(0,R.jsx)(`span`,{className:A(`col-start-1 row-start-1 leading-none transition-[color,font-variation-settings] duration-80`,h?`text-[11px]`:`text-[13px]`,n||f?`text-foreground`:`text-muted-foreground`),style:{fontVariationSettings:n?He.semibold:He.normal},children:e})]})]})});zV.displayName=`CheckboxItem`;var BV=36,VV=188,HV=6;function UV(e,t,n){let[r,i]=(0,z.useState)(0),[a,o]=(0,z.useState)(0),s=(0,z.useMemo)(()=>{let n=[],r=[],i=0;for(let a of e){n.push(i);let e=BV+(t.has(a.id)?VV:0);r.push(e),i+=e}return{offsets:n,heights:r,totalHeight:i}},[t,e]),c=(0,z.useMemo)(()=>{if(e.length===0)return{totalHeight:0,visibleItems:[]};let{offsets:t,heights:n,totalHeight:i}=s,o=r+a,c=0;for(;c<e.length&&t[c]+n[c]<r;)c++;c=Math.max(0,c-HV);let l=c;for(;l<e.length&&t[l]<o;)l++;l=Math.min(e.length,l+HV);let u=[];for(let r=c;r<l;r++)u.push({index:r,item:e[r],top:t[r],height:n[r]});return{totalHeight:i,visibleItems:u}},[e,s,r,a]),l=(0,z.useCallback)(()=>{let e=n.current;e&&i(e.scrollTop)},[n]);return(0,z.useEffect)(()=>{let e=n.current;if(!e)return;let t=()=>{o(e.clientHeight),i(e.scrollTop)};t();let r=new ResizeObserver(t);return r.observe(e),e.addEventListener(`scroll`,l,{passive:!0}),()=>{r.disconnect(),e.removeEventListener(`scroll`,l)}},[l,n,e.length]),c}var WV=300,GV=/(?:^|\/)notifications\//;function KV(e){let t=e;return typeof t?.method==`string`?t.method:null}function qV(e){let t=e.message;if(t?.id!==void 0&&t.id!==null||t?.result!==void 0||t?.error!==void 0)return null;let n=KV(e.message);return!n||!GV.test(n)?null:[e.source,e.serverId,e.widgetId??``,e.direction,n].join(`|`)}function JV(e,t,n=Date.now()){let r=qV(e),i=qV(t);if(!r||r!==i)return!1;let a=Date.parse(e.timestamp);return Number.isNaN(a)?!1:n-a<=WV}function YV(e,t){return{...e,timestamp:t.timestamp,message:t.message,repeatCount:(e.repeatCount??1)+1}}var XV=new class{maxEntries;entries=[];listeners=new Set;nextId=0;emitFrame=null;constructor(e=1e3){this.maxEntries=e}publish(e){let t=this.entries[this.entries.length-1];if(t&&JV(t,e,Date.parse(e.timestamp))){this.entries[this.entries.length-1]=YV(t,e),this.scheduleEmit();return}this.entries.push({...e,id:`rpc-${++this.nextId}`}),this.entries.length>this.maxEntries&&this.entries.splice(0,this.entries.length-this.maxEntries),this.scheduleEmit()}getSnapshot=()=>this.entries;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));clear(e={}){let t=new Set(e.serverIds??[]),n=new Set(e.sources??[]);t.size===0&&n.size===0?this.entries=[]:this.entries=this.entries.filter(e=>!((t.size===0||t.has(e.serverId))&&(n.size===0||n.has(e.source)))),this.scheduleEmit()}peekCoalesceKey(e){return qV(e)}scheduleEmit(){if(this.emitFrame===null){if(typeof requestAnimationFrame>`u`){this.emit();return}this.emitFrame=requestAnimationFrame(()=>{this.emitFrame=null,this.emit()})}}emit(){this.listeners.forEach(e=>e())}},ZV;function QV(e){XV.publish({source:`mcp`,serverId:e.serverId,direction:e.direction,timestamp:e.timestamp,message:e.message})}function $V(){ZV||=(rk().forEach(QV),ik(QV))}$V();function eH({serverIds:e,onCountChange:t,onClearRef:n,onExportRef:r}={}){let i=(0,z.useRef)(null),[a,o]=(0,z.useState)(new Set),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(()=>new Set([`mcp`,`widget`])),p=(0,z.useSyncExternalStore)(XV.subscribe,XV.getSnapshot,XV.getSnapshot),m=async e=>{try{await Qj(JSON.stringify(e,null,2)),GF.success(`Message copied to clipboard`)}catch(e){console.error(`Failed to copy message:`,e),GF.error(`Failed to copy to clipboard`)}},h=(0,z.useMemo)(()=>{if(!e?.length)return p;let t=new Set(e);return p.filter(e=>t.has(e.serverId))},[p,e]),g=(0,z.useMemo)(()=>{let e=new Set;return d.has(`mcp`)&&e.add(0),d.has(`widget`)&&e.add(1),e},[d]),_=(0,z.useCallback)(e=>{f(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),v=(0,z.useMemo)(()=>{let e=h;d.size>0&&(e=e.filter(e=>d.has(e.source)));let t=s.trim().toLowerCase();return t&&(e=e.filter(e=>{let n=nH(e);return e.serverId.toLowerCase().includes(t)||e.widgetId?.toLowerCase().includes(t)||e.source.includes(t)||n.toLowerCase().includes(t)||e.direction.toLowerCase().includes(t)||JSON.stringify(e.message).toLowerCase().includes(t)})),[...e].reverse()},[h,s,d]),{totalHeight:y,visibleItems:b}=UV(v,a,i),x=(0,z.useCallback)(e=>{o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),S=(0,z.useCallback)(async()=>{let t=d.size===0||d.size===2?void 0:[...d];(!t||t.includes(`mcp`))&&(e?.length?e.forEach(e=>ak(e)):ak()),XV.clear({serverIds:e,sources:t}),o(new Set)},[e,d]),C=(0,z.useCallback)(async()=>{try{await Qj(JSON.stringify(v,null,2)),GF.success(`Copied ${v.length} messages`)}catch(e){console.error(`Failed to copy messages:`,e),GF.error(`Failed to copy to clipboard`)}},[v]),w=(0,z.useCallback)(()=>{let e=new Blob([JSON.stringify(v,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`mcp-rpc-traffic-${new Date().toISOString().replaceAll(`:`,`-`)}.json`,n.click(),URL.revokeObjectURL(t)},[v]);return(0,z.useEffect)(()=>{t?.(v.length)},[v.length,t]),(0,z.useEffect)(()=>(n&&(n.current=S),()=>{n&&(n.current=null)}),[S,n]),(0,z.useEffect)(()=>(r&&(r.current=C),()=>{r&&(r.current=null)}),[C,r]),(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 pr-2 pt-2 pl-1`,children:[(0,R.jsx)(`h2`,{className:`text-xs font-medium text-foreground`,children:`RPC Logs`}),(0,R.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`size-7 p-0`,onClick:C,disabled:v.length===0,"aria-label":`Copy filtered RPC traffic`,title:`Copy filtered`,children:(0,R.jsx)(Wr,{className:`size-3.5`})}),(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`size-7 p-0`,onClick:w,disabled:v.length===0,"aria-label":`Download filtered RPC traffic as JSON`,title:`Download JSON`,children:(0,R.jsx)(qr,{className:`size-3.5`})}),(0,R.jsx)(jt,{variant:`ghost`,size:`sm`,className:`size-7 p-0`,onClick:S,disabled:p.length===0,"aria-label":`Clear RPC traffic`,title:`Clear`,children:(0,R.jsx)(Ui,{className:`size-3.5`})})]})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center pr-2 pb-2 pt-1 pl-1`,children:[(0,R.jsxs)(`div`,{className:`relative min-w-0 flex-1 transition-[flex-grow] duration-200 ease-out`,children:[(0,R.jsx)(T,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,R.jsx)(Nt,{value:s,onChange:e=>c(e.target.value),onFocus:()=>u(!0),onBlur:()=>u(!1),placeholder:`Search`,"aria-label":`Search RPC traffic`,className:`h-8 w-full pl-7 text-xs shadow-none transition-[width] duration-200 ease-out`})]}),(0,R.jsx)(`div`,{"aria-hidden":l,className:A(`shrink-0 overflow-hidden transition-[max-width,opacity,margin] duration-200 ease-out`,l?`pointer-events-none ml-0 max-w-0 opacity-0`:`ml-2 max-w-32 opacity-100`),children:(0,R.jsxs)(RV,{checkedIndices:g,orientation:`horizontal`,"aria-label":`Filter RPC traffic by source`,className:`w-auto shrink-0`,children:[(0,R.jsx)(zV,{index:0,label:`MCP`,size:`sm`,checked:d.has(`mcp`),onToggle:()=>_(`mcp`)}),(0,R.jsx)(zV,{index:1,label:`UI`,size:`sm`,checked:d.has(`widget`),onToggle:()=>_(`widget`)})]})})]}),(0,R.jsx)(`div`,{ref:i,className:`min-h-0 flex-1 overflow-y-auto pb-10`,style:{maskImage:`linear-gradient(to bottom, black 0, black calc(100% - 3rem), transparent 100%)`,WebkitMaskImage:`linear-gradient(to bottom, black 0, black calc(100% - 3rem), transparent 100%)`},children:v.length===0?(0,R.jsxs)(`div`,{className:`text-center py-8`,children:[(0,R.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No messages yet`}),(0,R.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:`JSON-RPC messages will appear here`})]}):(0,R.jsx)(`div`,{className:`relative w-full`,style:{height:y},children:b.map(({item:e,top:t,height:n})=>(0,R.jsx)(tH,{item:e,top:t,height:n,expanded:a.has(e.id),onToggle:()=>x(e.id),onCopy:()=>m(e.message)},e.id))})})]})}function tH({item:e,top:t,height:n,expanded:r,onToggle:i,onCopy:a}){let o=nH(e),s=rH(e),c=e.repeatCount&&e.repeatCount>1?` ×${e.repeatCount}`:``;return(0,R.jsxs)(`div`,{className:`absolute inset-x-0 overflow-hidden`,style:{top:t,height:n},"data-testid":`rpc-message-${o.replace(/\//g,`-`)}`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":r,onClick:i,className:`flex h-9 w-full cursor-pointer items-center gap-2 py-2 pr-3 pl-1 text-left text-muted-foreground transition-colors hover:text-foreground`,children:[(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center`,children:e.direction===`receive`?(0,R.jsx)(Dr,{className:`size-3.5 text-blue-500`}):(0,R.jsx)(Ar,{className:`size-3.5 text-emerald-500`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:`left`,children:s})]}),(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`span`,{className:`flex size-3.5 shrink-0 items-center justify-center`,children:e.source===`mcp`?(0,R.jsx)(AL,{className:`size-3`}):(0,R.jsx)(wi,{className:`size-3`})}),nativeButton:!1}),(0,R.jsx)(Et,{side:`left`,children:e.source===`mcp`?`MCP server`:`UI widget`})]}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:[o,c?(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:c}):null]}),(0,R.jsxs)(gt,{children:[(0,R.jsx)(Ie,{render:(0,R.jsx)(`time`,{dateTime:e.timestamp,className:`shrink-0 cursor-default font-mono text-[10px] tabular-nums text-muted-foreground underline decoration-dotted underline-offset-2`,children:new Date(e.timestamp).toLocaleTimeString()}),nativeButton:!1}),(0,R.jsx)(Et,{side:`left`,children:new Date(e.timestamp).toLocaleString()})]})]}),r?(0,R.jsxs)(`div`,{className:`relative mx-3 mb-2 max-h-44 overflow-auto rounded-lg p-2 pr-8`,children:[(0,R.jsx)(CV,{data:e.message,className:`[&_pre]:!text-[10px] [&_pre]:!leading-4`}),(0,R.jsx)(jt,{variant:`secondary`,size:`icon-sm`,onClick:a,className:`absolute right-1 top-1 size-6 rounded-full p-0`,title:`Copy message`,"aria-label":`Copy message`,children:(0,R.jsx)(Wr,{className:`size-3`})})]}):null]})}function nH(e){let t=KV(e.message);if(t)return t;let n=e.message;return n?.result===void 0?n?.error===void 0?`unknown`:`error`:`result`}function rH(e){return e.source===`widget`?e.direction===`send`?`Host → Widget`:`Widget → Host`:e.direction===`send`?`Inspector → MCP`:`MCP → Inspector`}function iH({serverId:e,open:t}){return(0,R.jsx)(`aside`,{"aria-label":`RPC Panel`,"aria-hidden":!t,className:A(`relative hidden min-h-0 shrink-0 flex-col overflow-hidden transition-[width,margin] duration-200 ease-out lg:flex`,t?`w-(--rpc-panel-width) lg:mr-[18px]`:`w-0 lg:mr-0`),children:(0,R.jsx)(`div`,{className:A(`flex h-full min-h-0 w-(--rpc-panel-width) flex-col transition-opacity duration-200 ease-out`,t?`opacity-100`:`pointer-events-none opacity-0`),children:(0,R.jsx)(eH,{serverIds:[e]})})})}function aH(e){return`${e.replace(/\/+$/,``)}${nM()}`}function oH({tunnelUrl:e,tunnelMcpUrl:t,selectedServerId:n,selectedServer:r,configLoaded:i,removeConnection:a,updateConnection:o,connections:s}){let c=(0,z.useRef)(null),l=(0,z.useRef)(!1),u=(0,z.useRef)(null),[d,f]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{!d||r?.url!==u.current||r.state!==`ready`&&r.state!==`failed`||(f(!1),l.current=!1,u.current=null)},[d,r]),(0,z.useEffect)(()=>{n&&oM(n)?c.current=n:r?.url&&oM(r.url)&&(c.current=r.url)},[r?.url,n]),(0,z.useEffect)(()=>{if(!i||!n||!r||l.current)return;let d=r.url??``,p=oM(d),m=sM(d),h=t??(e?aH(e):null),g=null;e&&h&&p?g=h:!e&&m&&c.current&&(g=c.current),!(!g||g===d)&&(l.current=!0,u.current=g,f(!0),(async()=>{try{g!==n&&s.some(e=>e.id===g)&&await a(g),await o(n,yM({...xM(n)??bM(r),url:g}))}catch{f(!1),u.current=null,l.current=!1}})())},[i,s,a,r,n,t,e,o]),(0,z.useEffect)(()=>{d||(l.current=!1)},[d]),d}function sH({children:e}){let t=KN(),n=UN(),{servers:r,addServer:i,removeServer:a,updateServerMetadata:o,updateServer:s,storageLoaded:c}=Sj(),l=(0,z.useCallback)(async(e,t)=>{try{await s(e,yM(t)),hM(e,t)}catch(t){console.error(`[Layout] Failed to update connection ${e}:`,t)}},[s]),u=(0,z.useCallback)(async(e,t)=>{try{await o(e,t)}catch(t){console.error(`[Layout] Failed to update connection metadata for ${e}:`,t)}},[o]),{selectedServerId:d,setSelectedServerId:f,activeTab:p,setActiveTab:m,navigateToItem:h,setTunnelUrl:g,tunnelUrl:_,isEmbedded:v,embeddedConfig:y,setEmbeddedMode:b}=fL(),[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(()=>{try{return localStorage.getItem(`inspector-sidebar-collapsed`)===`true`}catch{return!1}}),[T,ee]=(0,z.useState)(()=>{try{return localStorage.getItem(`inspector-rpc-logger-open`)===`true`}catch{return!1}});(0,z.useEffect)(()=>{try{localStorage.setItem(`inspector-sidebar-collapsed`,C?`true`:`false`)}catch{}},[C]),(0,z.useEffect)(()=>{try{localStorage.setItem(`inspector-rpc-logger-open`,String(T))}catch{}},[T]);let{savedRequests:E}=hL();(0,z.useEffect)(()=>{let e=new URLSearchParams(n.search),t=e.get(`embedded`)===`true`,r=e.get(`embeddedConfig`);if(t){let e={};if(r)try{e=JSON.parse(r)}catch(e){console.error(`Failed to parse embeddedConfig:`,e)}b(!0,e),e.defaultTab&&m(e.defaultTab)}},[]),(0,z.useEffect)(()=>{let e=new URLSearchParams(n.search).get(`tunnelUrl`);e!==null&&g(e)},[n.search,g]),(0,z.useEffect)(()=>{let e=new URLSearchParams(n.search).get(`tab`);e&&[`tools`,`prompts`,`resources`,`chat`,`sampling`,`elicitation`,`notifications`,`server-metadata`,`connection-settings`].includes(e)&&m(e)},[n.search,m]);let D=(0,z.useRef)(null),te=(0,z.useRef)(Date.now()),ne=(0,z.useRef)(new Set),O=(0,z.useRef)(0);(0,z.useEffect)(()=>{let e=()=>{O.current++};return window.addEventListener(`mcp-tool-executed`,e),()=>window.removeEventListener(`mcp-tool-executed`,e)},[]),(0,z.useEffect)(()=>{let e=()=>{try{ET(new Oo({durationSeconds:Math.round((Date.now()-te.current)/1e3),tabsVisited:ne.current.size,toolsExecuted:O.current})).catch(()=>{})}catch{}};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[]);let re=(0,z.useCallback)(e=>{try{ET(new Eo({tab:e,previousTab:D.current})).catch(()=>{})}catch{}D.current=e,ne.current.add(e),m(e);let r=new URLSearchParams(n.search);r.set(`tab`,e),t(`/?${r.toString()}`,{replace:!0})},[m,t,n.search]);(0,z.useEffect)(()=>{let e=e=>{let t=e.detail.requestId;d&&h(d,`sampling`,t)},t=e=>{let t=e.detail.requestId;d&&h(d,`elicitation`,t)},n=e=>{let t=e.detail.toolName;d&&t?h(d,`tools`,t):d&&re(`tools`)};return window.addEventListener(`navigate-to-sampling`,e),window.addEventListener(`navigate-to-elicitation`,t),window.addEventListener(`navigate-to-tool-result`,n),()=>{window.removeEventListener(`navigate-to-sampling`,e),window.removeEventListener(`navigate-to-elicitation`,t),window.removeEventListener(`navigate-to-tool-result`,n)}},[d,re,h]);let k=(0,z.useRef)(null),ie=(0,z.useRef)(null),j=(0,z.useRef)(null),{isAutoConnecting:M}=dI({connections:r,addServer:i,removeConnection:a,configLoaded:c,embedded:v});(0,z.useEffect)(()=>{let e=()=>{let e=document.documentElement.classList.contains(`dark`)?`#000000`:`#f3f3f3`;document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e};e();let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>t.disconnect()},[]);let ae=(0,z.useCallback)(e=>{ET(new xo({trigger:e})).catch(()=>{}),S(!0)},[]),oe=e=>{if(!r.find(t=>t.id===e))return;f(e);let i=new URLSearchParams(n.search),a=i.get(`tunnelUrl`),o=i.get(`tab`),s=new URLSearchParams;s.set(`server`,e),a&&s.set(`tunnelUrl`,a),o&&s.set(`tab`,o),t(`/?${s.toString()}`)},se=(0,z.useCallback)(e=>{if(!d)return;let t=xM(d)||r.find(e=>e.id===d);e.url===d?t&&wM(t,e)?(u(d,{name:e.name||e.url}),hM(d,e)):l(d,e):(a(d),i(e.url,yM(e))),GF.success(`Connection settings updated`)},[d,r,a,i,u,l]),N=(e,i,a)=>{if(fetch(`http://127.0.0.1:7371/ingest/4e7482c5-571f-4071-bd09-762c357289f4`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Debug-Session-Id":`831b88`},body:JSON.stringify({sessionId:`831b88`,location:`Layout.tsx:handleCommandPaletteNavigate`,message:`layout navigate entry`,data:{tab:e,itemName:i??null,serverId:a??null,hasServerId:!!a},timestamp:Date.now(),hypothesisId:`H1`})}).catch(()=>{}),console.warn(`[Layout] handleCommandPaletteNavigate called:`,{tab:e,itemName:i,serverId:a}),a){let o=r.find(e=>e.id===a);if(console.warn(`[Layout] Server lookup:`,{serverId:a,serverFound:!!o,serverState:o?.state}),!o||o.state!==`ready`){console.warn(`[Layout] Server not ready, showing error`),GF.error(`Server is not connected and cannot be inspected`);return}console.warn(`[Layout] Calling navigateToItem:`,{serverId:a,tab:e,itemName:i}),fetch(`http://127.0.0.1:7371/ingest/4e7482c5-571f-4071-bd09-762c357289f4`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-Debug-Session-Id":`831b88`},body:JSON.stringify({sessionId:`831b88`,location:`Layout.tsx:navigateToItem-call`,message:`calling navigateToItem`,data:{serverId:a,tab:e,itemName:i??null,serverState:o?.state??null},timestamp:Date.now(),hypothesisId:`H1`})}).catch(()=>{}),h(a,e,i);let s=new URLSearchParams(n.search),c=s.get(`tunnelUrl`),l=s.get(`tab`),u=new URLSearchParams;u.set(`server`,a),c&&u.set(`tunnelUrl`,c),e?u.set(`tab`,e):l&&u.set(`tab`,l);let d=`/?${u.toString()}`;console.warn(`[Layout] Navigating to:`,d),t(d)}else console.warn(`[Layout] No serverId, just updating tab to:`,e),re(e)},P=r.find(e=>e.id===d),ce=oH({tunnelUrl:_,selectedServerId:d,selectedServer:P,configLoaded:c,removeConnection:a,updateConnection:s,connections:r}),le=P?P.tools.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.tools.map(t=>({...t,_serverId:e.id,_serverName:lM(e)})):[]),ue=P?P.prompts.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.prompts.map(t=>({...t,_serverId:e.id,_serverName:lM(e)})):[]),de=P?P.resources.map(e=>({...e,_serverId:P.id})):r.flatMap(e=>e.state===`ready`?e.resources.map(t=>({...t,_serverId:e.id,_serverName:lM(e)})):[]);(0,z.useEffect)(()=>{if(ce)return;let e=new URLSearchParams(n.search),i=e.get(`server`);if(i&&(i.startsWith(`http://`)||i.startsWith(`https://`))&&!r.find(e=>e.id===i)){let n=new URLSearchParams(e);n.delete(`server`),n.set(`autoConnect`,i),t(`/?${n.toString()}`,{replace:!0});return}i!==d&&f(i)},[n.search,d,f,r,t,ce]),(0,z.useEffect)(()=>{if(ce)return;let e=new URLSearchParams(n.search).get(`server`);if(e&&!r.find(t=>t.id===e)){let e=setTimeout(()=>t(`/`),3e3);return()=>clearTimeout(e)}},[n.search,t,r,ce]),(0,z.useEffect)(()=>{if(!v)return;let e=e=>{if(!e.data||typeof e.data!=`object`||e.data.type!==`mcp-inspector:connect_servers`)return;let t=e.data.servers;if(!Array.isArray(t)||t.length===0)return;let n=null;for(let e of t){if(!e.url||typeof e.url!=`string`)continue;let t=e.url,a=e.name??`Server`,o={...e.headers??{}};if(e.auth?.access_token){let t=e.auth.token_type||`bearer`;o.Authorization=`${t.charAt(0).toUpperCase()+t.slice(1)} ${e.auth.access_token}`}let s=typeof e.proxyConfig?.proxyAddress==`string`?e.proxyConfig.proxyAddress.trim():``,c=``;try{new URL(t).origin!==window.location.origin&&(c=uM())}catch{c=uM()}let l=s||c,u=dM(e.connectionMode,e.connectionType,!!s),d=yM({url:t,name:a,transportType:`http`,connectionMode:u,connectionType:u===`proxy`?`Via Proxy`:`Direct`,proxyConfig:u===`proxy`&&l?{proxyAddress:l,...Object.keys(o).length>0?{headers:o}:{}}:void 0,headers:o,autoProxyFallback:u===`auto`&&l?{enabled:!0,proxyAddress:l}:!1});r.find(e=>e.url===t)||i(t,d),n||=t}window.parent!==window&&window.parent.postMessage({type:`mcp-inspector:servers_connected`,count:t.length},`*`)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[v,r,i]);let fe=(0,z.useRef)(!1);(0,z.useEffect)(()=>{if(!v||fe.current||d)return;let e=r.find(e=>e.state===`ready`);if(e){fe.current=!0,f(e.id);let r=new URLSearchParams(n.search);r.set(`server`,e.id),t(`/?${r.toString()}`,{replace:!0})}},[v,r,d,f,t,n.search]),pL({onCommandPalette:()=>ae(`keyboard`),onToolsTab:()=>{P&&re(`tools`)},onPromptsTab:()=>{P&&re(`prompts`)},onResourcesTab:()=>{P&&re(`resources`)},onChatTab:()=>{P&&re(`chat`)},onHome:()=>{t(`/`)},onFocusSearch:()=>{p===`tools`&&k.current?k.current.focusSearch():p===`prompts`&&ie.current?ie.current.focusSearch():p===`resources`&&j.current&&j.current.focusSearch()},onBlurSearch:()=>{p===`tools`&&k.current?k.current.blurSearch():p===`prompts`&&ie.current?ie.current.blurSearch():p===`resources`&&j.current&&j.current.blurSearch()}});let pe=new URLSearchParams(n.search).get(`server`),me=!c&&!!pe&&!pe.startsWith(`http://`)&&!pe.startsWith(`https://`),he=M||me||ce,ge=P?.id??`home`,_e=he?`boot`:ge,[ve,ye]=(0,z.useState)(_e);(0,z.useLayoutEffect)(()=>{if(_e===ve)return;let e=()=>(0,br.flushSync)(()=>ye(_e));typeof document.startViewTransition==`function`?document.startViewTransition(e):e()},[_e,ve]);let be=ve===`boot`,F=be||ve===`home`?void 0:r.find(e=>e.id===ve),xe=v&&y.singleTab,Se=v?{backgroundColor:y.backgroundColor||`#f3f3f3`,padding:xe?`0`:y.padding||`0.5rem`}:{},Ce=v?xe?`h-screen flex flex-col`:`h-screen flex flex-col gap-2 sm:gap-4`:`h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-4 lg:px-0 pb-4`,we=xe?`flex-1 w-full bg-white dark:bg-black p-0 overflow-auto`:A(`flex-1 min-h-0 w-full bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 overflow-auto`,!F&&`lg:mx-4`,F&&`lg:mr-4`);return(0,R.jsxs)(nt,{children:[(0,R.jsx)(`div`,{className:`inspector-view-transition h-screen bg-[#f3f3f3] dark:bg-black`,children:be?(0,R.jsx)(`div`,{className:`flex h-full items-center justify-center bg-[#f3f3f3] dark:bg-black`,children:(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,R.jsx)(aL,{className:`h-8 w-8 text-zinc-600 dark:text-zinc-400`}),(0,R.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Connecting to MCP server...`})]})}):(0,R.jsxs)(`div`,{className:Ce,style:Se,children:[!xe&&(0,R.jsx)(_B,{connections:r,selectedServer:F,activeTab:p,onServerSelect:oe,onTabChange:re,embedded:v,sidebarCollapsed:C}),(0,R.jsxs)(`div`,{className:xe?`flex-1 min-h-0`:`flex flex-1 min-h-0 min-w-0`,children:[F&&!xe&&(0,R.jsx)(aV,{activeTab:p,onTabChange:re,selectedServer:F,visibleTabs:y.visibleTabs,collapsed:C,onCollapsedChange:w,rpcLoggerOpen:T,onRpcLoggerOpenChange:ee,onCommandPaletteOpen:()=>ae(`button`)}),(0,R.jsx)(`main`,{className:we,children:(0,R.jsx)(VR,{selectedServer:F,activeTab:p,toolsSearchRef:k,promptsSearchRef:ie,resourcesSearchRef:j,onUpdateConnection:se,children:e})}),F&&!xe&&(0,R.jsx)(iH,{serverId:F.id,open:T})]})]})}),(0,R.jsx)(ML,{isOpen:x,onOpenChange:S,tools:le,prompts:ue,resources:de,savedRequests:E,connections:r,selectedServer:P,tunnelUrl:_,onNavigate:N,onServerSelect:oe})]})}function cH({...e}){let{resolvedTheme:t}=_z();return(0,R.jsx)(oI,{theme:t,className:`toaster group`,style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`},...e})}var lH=(0,z.createContext)(void 0),uH={deviceType:`desktop`,customViewport:{width:768,height:1024},cspMode:`permissive`,displayModeOverride:null,capabilities:{hover:!0,touch:!1},safeAreaInsets:{top:0,right:0,bottom:0,left:0},locale:`en-US`,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`};function dH({children:e}){let[t,n]=(0,z.useState)({activeWidgetId:null,widgets:new Map,playground:uH}),r=(0,z.useCallback)(e=>{n(t=>({...t,activeWidgetId:e}))},[]),i=(0,z.useCallback)((e,t)=>{n(n=>{if(n.widgets.has(e))return n;let r=new Map(n.widgets);return r.set(e,{...t,cspViolations:[]}),{...n,widgets:r}})},[]),a=(0,z.useCallback)(e=>{n(t=>{let n=new Map(t.widgets);return n.delete(e),{...t,widgets:n,activeWidgetId:t.activeWidgetId===e?null:t.activeWidgetId}})},[]),o=(0,z.useRef)(t);o.current=t;let s=(0,z.useCallback)(e=>o.current.widgets.get(e),[]),c=(0,z.useCallback)((e,t)=>{n(n=>{let r=n.widgets.get(e);if(!r)return n;let i={cspViolations:[...r.cspViolations,t]};t.originalPolicy&&r.effectivePolicy===void 0&&(i.effectivePolicy=t.originalPolicy);let a=new Map(n.widgets);return a.set(e,{...r,...i}),{...n,widgets:a}})},[]),l=(0,z.useCallback)(e=>{n(t=>{let n=t.widgets.get(e);if(!n)return t;let r=new Map(t.widgets);return r.set(e,{...n,cspViolations:[]}),{...t,widgets:r}})},[]),u=(0,z.useCallback)((e,t)=>{n(n=>{let r=n.widgets.get(e);if(!r)return n;let i=new Map(n.widgets);return i.set(e,{...r,modelContext:t}),{...n,widgets:i}})},[]),d=(0,z.useCallback)((e,t)=>{n(n=>{let r=n.widgets.get(e);if(!r)return n;let i=new Map(n.widgets);return i.set(e,{...r,widgetState:t}),{...n,widgets:i}})},[]),f=(0,z.useCallback)((e,t,r)=>{n(n=>{let i=n.widgets.get(e);if(!i)return n;let a=new Map(n.widgets);return a.set(e,{...i,declaredCsp:t,...r!==void 0&&{effectivePolicy:r}}),{...n,widgets:a}})},[]),p=(0,z.useCallback)(e=>{n(t=>({...t,playground:{...t.playground,...e}}))},[]),m=(0,z.useCallback)(()=>{n(e=>({...e,widgets:new Map,activeWidgetId:null}))},[]),h=(0,z.useCallback)(()=>{let e=new Map;for(let[n,r]of t.widgets)r.modelContext&&e.set(n,r.modelContext);return e},[t.widgets]);return(0,R.jsx)(lH,{value:(0,z.useMemo)(()=>({...t,setActiveWidget:r,addWidget:i,removeWidget:a,getWidget:s,addCspViolation:c,clearCspViolations:l,setWidgetModelContext:u,setWidgetState:d,setWidgetDeclaredCsp:f,updatePlaygroundSettings:p,clearAllWidgets:m,getAllModelContexts:h}),[t,r,i,a,s,c,l,u,d,f,p,m,h]),children:e})}function fH(){let e=(0,z.use)(lH);if(!e)throw Error(`useWidgetDebug must be used within WidgetDebugProvider`);return e}var pH={mobile:{width:390,height:844,name:`iPhone 14`},tablet:{width:820,height:1180,name:`iPad Air`},desktop:{width:1440,height:900,name:`Desktop`},custom:{width:768,height:1024,name:`Custom`}},mH=(0,z.lazy)(()=>tS(()=>import(`./OAuthCallback-BjcRxLh5.js`).then(e=>({default:e.OAuthCallback})),__vite__mapDeps([40,1,5]))),hH=(0,z.lazy)(()=>tS(()=>import(`./ManufactOAuthCallback-DCLbW-mz.js`).then(e=>({default:e.ManufactOAuthCallback})),__vite__mapDeps([41,1,5]))),gH=(0,z.lazy)(()=>tS(()=>import(`./ViewPreview-jgeU7bY9.js`).then(e=>({default:e.ViewPreview})),__vite__mapDeps([42,1,5,19])));function _H({activeTabRef:e}){let{activeTab:t}=fL();return(0,z.useEffect)(()=>{e.current=t},[t,e]),null}function vH(){let e=(0,z.useRef)(`tools`),t=new URLSearchParams(window.location.search),n=t.get(`embedded`)===`true`,r=t.get(`theme`),i=(0,z.useMemo)(()=>n?void 0:new TM(`mcp-inspector-connections`),[n]),a=uM(),o=a?.replace(/\/proxy\/?$/,`/oauth`),s=rM();return(0,z.useEffect)(()=>{wT()},[]),(0,z.useEffect)(()=>{let e=t.get(`auth_error`);if(!e)return;let n=t.get(`auth_error_description`);GF.error(`OAuth authentication failed: ${n||e}`,{duration:1/0,closeButton:!0});let r=new URLSearchParams(t);r.delete(`auth_error`),r.delete(`auth_error_description`);let i=r.toString();window.history.replaceState({},``,`${window.location.pathname}${i?`?${i}`:``}`)},[]),(0,R.jsx)(vz,{forcedTheme:r||void 0,children:(0,R.jsx)(pe,{defaultShape:`pill`,children:(0,R.jsx)(dH,{children:(0,R.jsx)(xj,{storageProvider:i,enableRpcLogging:!0,defaultCallbackUrl:`${window.location.origin}${s}/oauth/callback`,defaultOAuthProxyUrl:o,defaultAutoProxyFallback:a?{enabled:!0,proxyAddress:a}:!1,defaultServerConfig:{preventAutoAuth:!0,useRedirectFlow:!0},clientInfo:{name:`mcp-use Inspector`,version:ko(),websiteUrl:`https://mcp-use.com`,icons:[{src:`https://mcp-use.com/logo.png`}],capabilities:{extensions:{"io.modelcontextprotocol/ui":{mimeTypes:[`text/html;profile=mcp-app`]}}}},onServerAdded:(e,t)=>{console.log(`[Inspector] Server added:`,e,t.state)},onServerRemoved:e=>{console.log(`[Inspector] Server removed:`,e)},onServerStateChange:(e,t)=>{console.log(`[Inspector] Server state changed:`,e,t)},onSamplingRequest:(e,t,n,r,i)=>{let a=GF((0,R.jsx)(Fn,{title:`Sampling Request Received`,description:`New request from ${n}`,actions:[{label:`View Details`,testId:`sampling-toast-view-details`,onClick:()=>{let t=new CustomEvent(`navigate-to-sampling`,{detail:{requestId:e.id}});window.dispatchEvent(t),GF.dismiss(a)}},{label:`Approve`,testId:`sampling-toast-approve`,onClick:()=>{r(e.id,In),GF.success(`Sampling request approved`),GF.dismiss(a)}},{label:`Deny`,testId:`sampling-toast-deny`,onClick:()=>{i(e.id,`User denied from toast`),GF.dismiss(a)}}]}),{duration:1/0})},onElicitationRequest:(t,n,r,i,a)=>{if(e.current===`chat`)return;let o=t.request.mode||`form`,s=t.request.message,c=o===`url`&&`url`in t.request?t.request.url:void 0,l=GF((0,R.jsx)(Fn,{title:`Elicitation Request Received`,description:`From ${r}: ${s}`,extra:o===`url`&&c?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 font-mono`,children:c}):void 0,actions:[{label:`View Details`,testId:`elicitation-toast-view-details`,onClick:()=>{let e=new CustomEvent(`navigate-to-elicitation`,{detail:{requestId:t.id}});window.dispatchEvent(e),GF.dismiss(l)}},...o===`url`&&c?[{label:`Open URL`,testId:`elicitation-toast-open-url`,onClick:()=>{window.open(c,`_blank`),GF.dismiss(l)}}]:[],{label:`Cancel`,testId:`elicitation-toast-cancel`,onClick:()=>{a(t.id,`User cancelled from toast`),GF.dismiss(l)}}]}),{duration:1/0})},children:(0,R.jsxs)(dL,{children:[(0,R.jsx)(_H,{activeTabRef:e}),(0,R.jsx)(lF,{basename:s,children:(0,R.jsxs)(bP,{children:[(0,R.jsx)(vP,{path:`/oauth/callback`,element:(0,R.jsx)(kR,{children:(0,R.jsx)(mH,{})})}),(0,R.jsx)(vP,{path:`/auth/callback`,element:(0,R.jsx)(kR,{children:(0,R.jsx)(hH,{})})}),(0,R.jsx)(vP,{path:`/preview/:view`,element:(0,R.jsx)(kR,{children:(0,R.jsx)(gH,{})})}),(0,R.jsx)(vP,{path:`/`,element:(0,R.jsx)(sH,{children:(0,R.jsx)(lL,{})})})]})}),(0,R.jsx)(cH,{position:`top-center`})]})})})})})}var yH=document.getElementById(`root`);yH?Pn.createRoot(yH).render((0,R.jsx)(vH,{})):console.error(`[inspector] Root element not found`);export{JN as $,Zr as $t,YI as A,qa as At,zI as B,Pi as Bt,pL as C,To as Ct,rL as D,mo as Dt,iL as E,ho as Et,eL as F,Ji as Ft,wI as G,yi as Gt,MI as H,Oi as Ht,JI as I,qi as It,gI as J,si as Jt,yI as K,vi as Kt,HI as L,Ui as Lt,$I as M,Za as Mt,XI as N,Ja as Nt,qI as O,So as Ot,QI as P,Pa as Pt,GF as Q,$r as Qt,VI as R,Hi as Rt,hL as S,hf as St,aL as T,go as Tt,EI as U,wi as Ut,NI as V,ki as Vt,TI as W,bi as Wt,pI as X,ri as Xt,hI as Y,ai as Yt,mI as Z,ti as Zt,Qz as _,ET as _t,PV as a,Ir as an,cM as at,jR as b,tS as bt,OV as c,jr as cn,iM as ct,pV as d,Yj as dt,Xr as en,bF as et,sV as f,Lj as ft,$z as g,Sj as gt,Zz as h,cj as ht,FV as i,Vr as in,bM as it,tL as j,Ya as jt,ZI as k,to as kt,CV as l,vr as ln,Qj as lt,wB as m,Rj as mt,fH as n,qr as nn,uM as nt,NV as o,Fr as on,lM as ot,RB as p,zj as pt,fI as q,di as qt,XV as r,Wr as rn,xM as rt,kV as s,Mr as sn,nM as st,pH as t,Yr as tn,gM as tt,fV as u,_r as un,$j as ut,_z as v,RC as vt,fL as w,vo as wt,mR as x,Mb as xt,XR as y,Q as yt,BI as z,Li as zt};
|