@mcp-use/inspector 1.0.0 → 1.0.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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rpc-logger-TPNV75J4-CMVlzCN7.js","assets/chunk-JU7W27UC-CMTI_w7A.js","assets/chunk-3GQAWCBQ-ntjTDD_C.js","assets/chunk-zsgVPwQN.js","assets/chunk-QWQYAQCK-BR4V0xsV.js","assets/core-GZZnkE26.js","assets/core-CsUyNVs5.js","assets/1c-AGlpZ3Bo.js","assets/abnf-CY04oKOo.js","assets/accesslog-BW-XYbZ-.js","assets/actionscript-CyrdwIe8.js","assets/ada-C-TrrrBy.js","assets/angelscript-CRTYantF.js","assets/apache-BtWb7jui.js","assets/applescript-B5uiivcX.js","assets/arcade-CKXflcFV.js","assets/arduino-9WdEHP7F.js","assets/armasm-B1n3-9gm.js","assets/asciidoc-DnpyabXI.js","assets/aspectj-DHfRYIO6.js","assets/autohotkey-D4kyAzbx.js","assets/autoit-Dkm5j0Id.js","assets/avrasm-DDWyveTc.js","assets/awk-0C9tJhw5.js","assets/axapta-7WyvVgTr.js","assets/bash-BU3h1nvY.js","assets/basic-cvnVWdBh.js","assets/bnf-DqQP6RvA.js","assets/brainfuck-9Gnm7MFh.js","assets/c-like-DQRMjEeJ.js","assets/c-CR0xII_C.js","assets/cal-BupHjSW7.js","assets/capnproto-BJz3QcqE.js","assets/ceylon-Cm5BiqjN.js","assets/clean-yd5cdwwQ.js","assets/clojure-repl-4mYnspW8.js","assets/clojure-BEy8uY0S.js","assets/cmake-D6UxhUeW.js","assets/coffeescript-BKMS6sen.js","assets/coq-ByIcAboL.js","assets/cos-WtGXvK46.js","assets/cpp-7GTPyvMa.js","assets/crmsh-C5mOafXq.js","assets/crystal-CDkEXhx-.js","assets/csharp-BB5evbyJ.js","assets/csp-C5gCtA0-.js","assets/css-BxJzVbPg.js","assets/d-pa4_Cp7t.js","assets/dart-BX2VLXw3.js","assets/delphi-DdHGjuIZ.js","assets/diff-CBEZzUzk.js","assets/django-D4YuT7a9.js","assets/dns-r4HMRPCv.js","assets/dockerfile-ZfcC6nOD.js","assets/dos-CIXc_2yf.js","assets/dsconfig-DlugHtUP.js","assets/dts-DaEIYGjQ.js","assets/dust-D5BPeLmO.js","assets/ebnf-FDSeI3Uq.js","assets/elixir-BW6MO0JC.js","assets/elm-DlEB7oVS.js","assets/erb-Cfqar-lN.js","assets/erlang-repl-ynjzGTyJ.js","assets/erlang-CAmVwVgE.js","assets/excel-B4xDzPh0.js","assets/fix-DrIaqPya.js","assets/flix-C1QBAYX7.js","assets/fortran-13hn1qLz.js","assets/fsharp-DsthWJmP.js","assets/gams-CCIHfrc2.js","assets/gauss-DPE0fKXo.js","assets/gcode-Cnu_Eke-.js","assets/gherkin-6DphholZ.js","assets/glsl-bxnyXALN.js","assets/gml-CNHkNLih.js","assets/go-CNn2XrbH.js","assets/golo-DiSoln2k.js","assets/gradle-DwRwgn-A.js","assets/groovy-B5vHRPUi.js","assets/haml-DyyQV85z.js","assets/handlebars-BAEJweq7.js","assets/haskell-ChxeibtB.js","assets/haxe-Bnvb8PoO.js","assets/hsp-BdBjqG0g.js","assets/htmlbars-Dco0ls0x.js","assets/http-BQrDnbm9.js","assets/hy-j_gy-_-v.js","assets/inform7-4lpsdkpY.js","assets/ini-CyoU_M9N.js","assets/irpf90-CA5ICZkt.js","assets/isbl-D5MCB9gL.js","assets/java-C_cNvtw0.js","assets/javascript-Cx9Fh-yC.js","assets/jboss-cli-n0a6upZq.js","assets/json-pS218i2Y.js","assets/julia-repl-DoKEpX79.js","assets/julia-ByIGgcyj.js","assets/kotlin-D7EVUsdH.js","assets/lasso-CfHzza_u.js","assets/latex-DEpVEzU4.js","assets/ldif-CztKIlXq.js","assets/leaf-BeXHCQvG.js","assets/less-BYuoMNFC.js","assets/lisp-DENj9Gb0.js","assets/livecodeserver-DzZuZBA6.js","assets/livescript-Dcoaf4MP.js","assets/llvm-B_NkXFs1.js","assets/lsl-sr9xRjsv.js","assets/lua-DOwApfze.js","assets/makefile-Dnbo7dYF.js","assets/markdown-DGgwjJWS.js","assets/mathematica-DvU9l120.js","assets/matlab-flr6798G.js","assets/maxima-DCd2nSGc.js","assets/mel-NmXTNXHL.js","assets/mercury-PVmYLiQ2.js","assets/mipsasm-LHYPiOXU.js","assets/mizar-BbJKfTOL.js","assets/mojolicious-Dw8SBiyk.js","assets/monkey-CYCsHKco.js","assets/moonscript-BndWJdyg.js","assets/n1ql-p64i6r1f.js","assets/nginx-Clg11n23.js","assets/nim-BF6erjkH.js","assets/nix-aqHU_7Cj.js","assets/node-repl-DuuOln4U.js","assets/nsis-BZNwabo3.js","assets/objectivec-BD-A2eRS.js","assets/ocaml-Dtfm3HD8.js","assets/openscad-3uP221Jx.js","assets/oxygene-DBIMAfJO.js","assets/parser3-C9bjRYvd.js","assets/perl-Be1CLDbh.js","assets/pf-BEYn9RX1.js","assets/pgsql-Bp-7Jjz8.js","assets/php-template-5wDTa_KR.js","assets/php-D8HtobZG.js","assets/plaintext-DF3cBN5Y.js","assets/pony-CA_LuLTd.js","assets/powershell-CfylS3qM.js","assets/processing-BOdw1uey.js","assets/profile-BMNLdTbz.js","assets/prolog-wnuVaQNI.js","assets/properties-BY2UjzIx.js","assets/protobuf-W4tuiDUG.js","assets/puppet-CcAPsi7F.js","assets/purebasic-Cx_iSilj.js","assets/python-repl-B1V7zIpU.js","assets/python-DtGc5unX.js","assets/q-DwgFecwj.js","assets/qml-CxtqwNEV.js","assets/r-Vyl1b83h.js","assets/reasonml-D1BWml10.js","assets/rib-WKK4Jb_l.js","assets/roboconf-DD9St8Le.js","assets/routeros-DIyDrw3W.js","assets/rsl-CfigMFVZ.js","assets/ruby-YHScF8rv.js","assets/ruleslanguage-BYwdQsZF.js","assets/rust-B5YXnMyV.js","assets/sas-CCTr8w16.js","assets/scala-Cbxd3VFS.js","assets/scheme-BsN3DINT.js","assets/scilab-DPKVNXPG.js","assets/scss-DbQAKOek.js","assets/shell-DWzkAqOf.js","assets/smali-BftjeLb5.js","assets/smalltalk-CRiQmXNN.js","assets/sml-StzcQc9I.js","assets/sqf-DD5HJChz.js","assets/sql-DPgh6LFW.js","assets/sql_more-CtzXbTQc.js","assets/stan-r2rUHRuO.js","assets/stata-BVbnRiot.js","assets/step21-Dq-6Zq9y.js","assets/stylus-BBnpEkBq.js","assets/subunit-ELCErEkQ.js","assets/swift-DaAs7qTh.js","assets/taggerscript-1FPav-0a.js","assets/tap-EToQ4lhN.js","assets/tcl-D3o49C6L.js","assets/thrift-CWhyiqPB.js","assets/tp-B6O9yM_7.js","assets/twig-CtXlonbL.js","assets/typescript-CCrKHjvE.js","assets/vala-DqTbJvZE.js","assets/vbnet-BIMC8kyn.js","assets/vbscript-html-6BIOjkqb.js","assets/vbscript-CwHfrTEX.js","assets/verilog-Br3eYmwZ.js","assets/vhdl-CDlnDphM.js","assets/vim-BOZojkV6.js","assets/x86asm-Br9iqCtX.js","assets/xl-eSTclZWH.js","assets/xml-C775tW_n.js","assets/xquery-DimlVJ6h.js","assets/yaml-Dnhus5cp.js","assets/zephir-j3mL6he_.js","assets/messages-D4_mH1tk.js","assets/json-schema-processors-DNSjFPrk.js","assets/dist-JsQmV3pO.js","assets/function_calling-kK7um7Ye.js","assets/chunk_array-Bw1lTtex.js","assets/llms-ByyTYk2T.js","assets/tools-kLe9X8V8.js","assets/schemas-BrqAD_Qo.js","assets/dist-t5Yo0YiG.js","assets/dist-BZmXa__p.js","assets/browser-BwHKNEau.js","assets/preload-helper-ckxxtgMM.js","assets/client-z1GrRUEs.js","assets/chunk-ECXMLUNG-CSRGaMIB.js","assets/chunk-BBSBHVGK-D4wCPq_w.js","assets/chunk-RPN2XO5I-Cr13Miz-.js","assets/chunk-UJPHRNQP-B14ZPq5a.js"])))=>i.map(i=>d[i]);
2
- import{a as e,n as t,o as n,r,t as i}from"./chunk-zsgVPwQN.js";import{t as a}from"./chunk-3GQAWCBQ-ntjTDD_C.js";import{n as o,t as s}from"./chunk-QWQYAQCK-BR4V0xsV.js";import{Xt as c,dn as l,gn as u}from"./messages-D4_mH1tk.js";import{A as d,C as f,D as p,E as m,M as h,O as g,S as _,T as v,b as y,c as b,d as x,f as S,h as C,i as w,j as T,k as E,m as D,p as O,u as k,v as A,w as j,x as M,y as N}from"./client-z1GrRUEs.js";import{c as P,d as F,l as I,s as L,u as R}from"./chunk-ECXMLUNG-CSRGaMIB.js";import{t as z}from"./preload-helper-ckxxtgMM.js";import{i as B,n as V,t as ee}from"./chunk-BBSBHVGK-D4wCPq_w.js";import{i as te,n as ne,t as H}from"./chunk-JU7W27UC-CMTI_w7A.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 re=i((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,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){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&&E());){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&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),ie=i(((e,t)=>{t.exports=re()})),ae=i((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),oe=i(((e,t)=>{t.exports=ae()})),se=i((e=>{var t=oe();function n(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 r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),ce=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=se()})),le=i((e=>{var t=ie(),n=oe(),r=ce();function i(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 a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(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 s(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 c(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 l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function z(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var V=R(null),ee=R(null),te=R(null),ne=R(null);function H(e,t){switch(B(te,t),B(ee,e),B(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?qd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=qd(t),e=Jd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(V),B(V,e)}function re(){z(V),z(ee),z(te)}function ae(e){e.memoizedState!==null&&B(ne,e);var t=V.current,n=Jd(t,e.type);t!==n&&(B(ee,e),B(V,n))}function se(e){ee.current===e&&(z(V),z(ee)),ne.current===e&&(z(ne),ip._currentValue=F)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rpc-logger-TPNV75J4-CMVlzCN7.js","assets/chunk-JU7W27UC-CMTI_w7A.js","assets/chunk-3GQAWCBQ-ntjTDD_C.js","assets/chunk-zsgVPwQN.js","assets/chunk-QWQYAQCK-BR4V0xsV.js","assets/core-GZZnkE26.js","assets/core-CsUyNVs5.js","assets/1c-AGlpZ3Bo.js","assets/abnf-CY04oKOo.js","assets/accesslog-BW-XYbZ-.js","assets/actionscript-CyrdwIe8.js","assets/ada-C-TrrrBy.js","assets/angelscript-CRTYantF.js","assets/apache-BtWb7jui.js","assets/applescript-B5uiivcX.js","assets/arcade-CKXflcFV.js","assets/arduino-9WdEHP7F.js","assets/armasm-B1n3-9gm.js","assets/asciidoc-DnpyabXI.js","assets/aspectj-DHfRYIO6.js","assets/autohotkey-D4kyAzbx.js","assets/autoit-Dkm5j0Id.js","assets/avrasm-DDWyveTc.js","assets/awk-0C9tJhw5.js","assets/axapta-7WyvVgTr.js","assets/bash-BU3h1nvY.js","assets/basic-cvnVWdBh.js","assets/bnf-DqQP6RvA.js","assets/brainfuck-9Gnm7MFh.js","assets/c-like-DQRMjEeJ.js","assets/c-CR0xII_C.js","assets/cal-BupHjSW7.js","assets/capnproto-BJz3QcqE.js","assets/ceylon-Cm5BiqjN.js","assets/clean-yd5cdwwQ.js","assets/clojure-repl-4mYnspW8.js","assets/clojure-BEy8uY0S.js","assets/cmake-D6UxhUeW.js","assets/coffeescript-BKMS6sen.js","assets/coq-ByIcAboL.js","assets/cos-WtGXvK46.js","assets/cpp-7GTPyvMa.js","assets/crmsh-C5mOafXq.js","assets/crystal-CDkEXhx-.js","assets/csharp-BB5evbyJ.js","assets/csp-C5gCtA0-.js","assets/css-BxJzVbPg.js","assets/d-pa4_Cp7t.js","assets/dart-BX2VLXw3.js","assets/delphi-DdHGjuIZ.js","assets/diff-CBEZzUzk.js","assets/django-D4YuT7a9.js","assets/dns-r4HMRPCv.js","assets/dockerfile-ZfcC6nOD.js","assets/dos-CIXc_2yf.js","assets/dsconfig-DlugHtUP.js","assets/dts-DaEIYGjQ.js","assets/dust-D5BPeLmO.js","assets/ebnf-FDSeI3Uq.js","assets/elixir-BW6MO0JC.js","assets/elm-DlEB7oVS.js","assets/erb-Cfqar-lN.js","assets/erlang-repl-ynjzGTyJ.js","assets/erlang-CAmVwVgE.js","assets/excel-B4xDzPh0.js","assets/fix-DrIaqPya.js","assets/flix-C1QBAYX7.js","assets/fortran-13hn1qLz.js","assets/fsharp-DsthWJmP.js","assets/gams-CCIHfrc2.js","assets/gauss-DPE0fKXo.js","assets/gcode-Cnu_Eke-.js","assets/gherkin-6DphholZ.js","assets/glsl-bxnyXALN.js","assets/gml-CNHkNLih.js","assets/go-CNn2XrbH.js","assets/golo-DiSoln2k.js","assets/gradle-DwRwgn-A.js","assets/groovy-B5vHRPUi.js","assets/haml-DyyQV85z.js","assets/handlebars-BAEJweq7.js","assets/haskell-ChxeibtB.js","assets/haxe-Bnvb8PoO.js","assets/hsp-BdBjqG0g.js","assets/htmlbars-Dco0ls0x.js","assets/http-BQrDnbm9.js","assets/hy-j_gy-_-v.js","assets/inform7-4lpsdkpY.js","assets/ini-CyoU_M9N.js","assets/irpf90-CA5ICZkt.js","assets/isbl-D5MCB9gL.js","assets/java-C_cNvtw0.js","assets/javascript-Cx9Fh-yC.js","assets/jboss-cli-n0a6upZq.js","assets/json-pS218i2Y.js","assets/julia-repl-DoKEpX79.js","assets/julia-ByIGgcyj.js","assets/kotlin-D7EVUsdH.js","assets/lasso-CfHzza_u.js","assets/latex-DEpVEzU4.js","assets/ldif-CztKIlXq.js","assets/leaf-BeXHCQvG.js","assets/less-BYuoMNFC.js","assets/lisp-DENj9Gb0.js","assets/livecodeserver-DzZuZBA6.js","assets/livescript-Dcoaf4MP.js","assets/llvm-B_NkXFs1.js","assets/lsl-sr9xRjsv.js","assets/lua-DOwApfze.js","assets/makefile-Dnbo7dYF.js","assets/markdown-DGgwjJWS.js","assets/mathematica-DvU9l120.js","assets/matlab-flr6798G.js","assets/maxima-DCd2nSGc.js","assets/mel-NmXTNXHL.js","assets/mercury-PVmYLiQ2.js","assets/mipsasm-LHYPiOXU.js","assets/mizar-BbJKfTOL.js","assets/mojolicious-Dw8SBiyk.js","assets/monkey-CYCsHKco.js","assets/moonscript-BndWJdyg.js","assets/n1ql-p64i6r1f.js","assets/nginx-Clg11n23.js","assets/nim-BF6erjkH.js","assets/nix-aqHU_7Cj.js","assets/node-repl-DuuOln4U.js","assets/nsis-BZNwabo3.js","assets/objectivec-BD-A2eRS.js","assets/ocaml-Dtfm3HD8.js","assets/openscad-3uP221Jx.js","assets/oxygene-DBIMAfJO.js","assets/parser3-C9bjRYvd.js","assets/perl-Be1CLDbh.js","assets/pf-BEYn9RX1.js","assets/pgsql-Bp-7Jjz8.js","assets/php-template-5wDTa_KR.js","assets/php-D8HtobZG.js","assets/plaintext-DF3cBN5Y.js","assets/pony-CA_LuLTd.js","assets/powershell-CfylS3qM.js","assets/processing-BOdw1uey.js","assets/profile-BMNLdTbz.js","assets/prolog-wnuVaQNI.js","assets/properties-BY2UjzIx.js","assets/protobuf-W4tuiDUG.js","assets/puppet-CcAPsi7F.js","assets/purebasic-Cx_iSilj.js","assets/python-repl-B1V7zIpU.js","assets/python-DtGc5unX.js","assets/q-DwgFecwj.js","assets/qml-CxtqwNEV.js","assets/r-Vyl1b83h.js","assets/reasonml-D1BWml10.js","assets/rib-WKK4Jb_l.js","assets/roboconf-DD9St8Le.js","assets/routeros-DIyDrw3W.js","assets/rsl-CfigMFVZ.js","assets/ruby-YHScF8rv.js","assets/ruleslanguage-BYwdQsZF.js","assets/rust-B5YXnMyV.js","assets/sas-CCTr8w16.js","assets/scala-Cbxd3VFS.js","assets/scheme-BsN3DINT.js","assets/scilab-DPKVNXPG.js","assets/scss-DbQAKOek.js","assets/shell-DWzkAqOf.js","assets/smali-BftjeLb5.js","assets/smalltalk-CRiQmXNN.js","assets/sml-StzcQc9I.js","assets/sqf-DD5HJChz.js","assets/sql-DPgh6LFW.js","assets/sql_more-CtzXbTQc.js","assets/stan-r2rUHRuO.js","assets/stata-BVbnRiot.js","assets/step21-Dq-6Zq9y.js","assets/stylus-BBnpEkBq.js","assets/subunit-ELCErEkQ.js","assets/swift-DaAs7qTh.js","assets/taggerscript-1FPav-0a.js","assets/tap-EToQ4lhN.js","assets/tcl-D3o49C6L.js","assets/thrift-CWhyiqPB.js","assets/tp-B6O9yM_7.js","assets/twig-CtXlonbL.js","assets/typescript-CCrKHjvE.js","assets/vala-DqTbJvZE.js","assets/vbnet-BIMC8kyn.js","assets/vbscript-html-6BIOjkqb.js","assets/vbscript-CwHfrTEX.js","assets/verilog-Br3eYmwZ.js","assets/vhdl-CDlnDphM.js","assets/vim-BOZojkV6.js","assets/x86asm-Br9iqCtX.js","assets/xl-eSTclZWH.js","assets/xml-C775tW_n.js","assets/xquery-DimlVJ6h.js","assets/yaml-Dnhus5cp.js","assets/zephir-j3mL6he_.js","assets/messages-D4_mH1tk.js","assets/json-schema-processors-DNSjFPrk.js","assets/dist-JsQmV3pO.js","assets/function_calling-kK7um7Ye.js","assets/chunk_array-Bw1lTtex.js","assets/llms-ByyTYk2T.js","assets/tools-kLe9X8V8.js","assets/schemas-BrqAD_Qo.js","assets/dist-t5Yo0YiG.js","assets/dist-BZmXa__p.js","assets/browser-BNpsOGG_.js","assets/preload-helper-ckxxtgMM.js","assets/client-5vpOfDX8.js","assets/chunk-BNC5K56L-B1_Oxlux.js","assets/chunk-QIWRSADU-B2_7Bv-j.js","assets/chunk-RPN2XO5I-UsVhKRmv.js","assets/chunk-UJPHRNQP-B14ZPq5a.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,n as t,o as n,r,t as i}from"./chunk-zsgVPwQN.js";import{t as a}from"./chunk-3GQAWCBQ-ntjTDD_C.js";import{n as o,t as s}from"./chunk-QWQYAQCK-BR4V0xsV.js";import{Xt as c,dn as l,gn as u}from"./messages-D4_mH1tk.js";import{A as d,C as f,D as p,E as m,M as h,O as g,S as _,T as v,b as y,c as b,d as x,f as S,h as C,i as w,j as T,k as E,m as D,p as O,u as k,v as A,w as j,x as M,y as N}from"./client-5vpOfDX8.js";import{c as P,d as F,l as I,s as L,u as R}from"./chunk-BNC5K56L-B1_Oxlux.js";import{t as z}from"./preload-helper-ckxxtgMM.js";import{i as B,n as V,t as ee}from"./chunk-QIWRSADU-B2_7Bv-j.js";import{i as te,n as ne,t as H}from"./chunk-JU7W27UC-CMTI_w7A.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 re=i((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,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){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&&E());){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&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),ie=i(((e,t)=>{t.exports=re()})),ae=i((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.4`})),oe=i(((e,t)=>{t.exports=ae()})),se=i((e=>{var t=oe();function n(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 r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.4`})),ce=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=se()})),le=i((e=>{var t=ie(),n=oe(),r=ce();function i(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 a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(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 s(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 c(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 l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),m=Symbol.for(`react.transitional.element`),h=Symbol.for(`react.portal`),g=Symbol.for(`react.fragment`),_=Symbol.for(`react.strict_mode`),v=Symbol.for(`react.profiler`),y=Symbol.for(`react.consumer`),b=Symbol.for(`react.context`),x=Symbol.for(`react.forward_ref`),S=Symbol.for(`react.suspense`),C=Symbol.for(`react.suspense_list`),w=Symbol.for(`react.memo`),T=Symbol.for(`react.lazy`),E=Symbol.for(`react.activity`),D=Symbol.for(`react.memo_cache_sentinel`),O=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=O&&e[O]||e[`@@iterator`],typeof e==`function`?e:null)}var A=Symbol.for(`react.client.reference`);function j(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===A?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case g:return`Fragment`;case v:return`Profiler`;case _:return`StrictMode`;case S:return`Suspense`;case C:return`SuspenseList`;case E:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case h:return`Portal`;case b:return e.displayName||`Context`;case y:return(e._context.displayName||`Context`)+`.Consumer`;case x:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case w:return t=e.displayName||null,t===null?j(e.type)||`Memo`:t;case T:t=e._payload,e=e._init;try{return j(e(t))}catch{}}return null}var M=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},I=[],L=-1;function R(e){return{current:e}}function z(e){0>L||(e.current=I[L],I[L]=null,L--)}function B(e,t){L++,I[L]=e.current,e.current=t}var V=R(null),ee=R(null),te=R(null),ne=R(null);function H(e,t){switch(B(te,t),B(ee,e),B(V,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?qd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=qd(t),e=Jd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(V),B(V,e)}function re(){z(V),z(ee),z(te)}function ae(e){e.memoizedState!==null&&B(ne,e);var t=V.current,n=Jd(t,e.type);t!==n&&(B(ee,e),B(V,n))}function se(e){ee.current===e&&(z(V),z(ee)),ne.current===e&&(z(ne),ip._currentValue=F)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+le+e+ue}var fe=!1;function pe(e,t){if(!e||fe)return``;fe=!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(`
5
5
  `),l=s.split(`
@@ -337,7 +337,7 @@ void main() {
337
337
 
338
338
  fragColor = vec4(color, opacity);
339
339
  }
340
- `;function id(e){if(Array.isArray(e))return e.length===4?e:e.length===3?[...e,1]:ud;if(typeof e!=`string`)return ud;let t,n,r,i=1;if(e.startsWith(`#`))[t,n,r,i]=ad(e);else if(e.startsWith(`rgb`))[t,n,r,i]=od(e);else if(e.startsWith(`hsl`))[t,n,r,i]=cd(sd(e));else return console.error(`Unsupported color format`,e),ud;return[ld(t,0,1),ld(n,0,1),ld(r,0,1),ld(i,0,1)]}function ad(e){return e=e.replace(/^#/,``),e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),e.length===6&&(e+=`ff`),[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255,parseInt(e.slice(6,8),16)/255]}function od(e){let t=e.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??`0`)/255,parseInt(t[2]??`0`)/255,parseInt(t[3]??`0`)/255,t[4]===void 0?1:parseFloat(t[4])]:[0,0,0,1]}function sd(e){let t=e.match(/^hsla?\s*\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??`0`),parseInt(t[2]??`0`),parseInt(t[3]??`0`),t[4]===void 0?1:parseFloat(t[4])]:[0,0,0,1]}function cd(e){let[t,n,r,i]=e,a=t/360,o=n/100,s=r/100,c,l,u;if(n===0)c=l=u=s;else{let e=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),t=s<.5?s*(1+o):s+o-s*o,n=2*s-t;c=e(n,t,a+1/3),l=e(n,t,a),u=e(n,t,a-1/3)}return[c,l,u,i]}var ld=(e,t,n)=>Math.min(Math.max(e,t),n),ud=[0,0,0,1];function dd(e){let t=W.useRef(void 0),n=W.useCallback(t=>{let n=e.map(e=>{if(e!=null){if(typeof e==`function`){let n=e,r=n(t);return typeof r==`function`?r:()=>{n(null)}}return e.current=t,()=>{e.current=null}}});return()=>{n.forEach(e=>e?.())}},e);return W.useMemo(()=>e.every(e=>e==null)?null:e=>{t.current&&=(t.current(),void 0),e!=null&&(t.current=n(e))},e)}function fd(e){if(e.naturalWidth<1024&&e.naturalHeight<1024){if(e.naturalWidth<1||e.naturalHeight<1)return;let t=e.naturalWidth/e.naturalHeight;e.width=Math.round(t>1?1024*t:1024),e.height=Math.round(t>1?1024:1024/t)}}async function pd(e){let t={},n=[],r=e=>{try{return e.startsWith(`/`)||new URL(e),!0}catch{return!1}},i=e=>{try{return e.startsWith(`/`)?!1:new URL(e,window.location.origin).origin!==window.location.origin}catch{return!1}};return Object.entries(e).forEach(([e,a])=>{if(typeof a==`string`){let o=a||`data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==`;if(!r(o)){console.warn(`Uniform "${e}" has invalid URL "${o}". Skipping image loading.`);return}let s=new Promise((n,r)=>{let a=new Image;i(o)&&(a.crossOrigin=`anonymous`),a.onload=()=>{fd(a),t[e]=a,n()},a.onerror=()=>{console.error(`Could not set uniforms. Failed to load image at ${o}`),r()},a.src=o});n.push(s)}else a instanceof HTMLImageElement&&fd(a),t[e]=a}),await Promise.all(n),t}var md=(0,W.forwardRef)(function({fragmentShader:e,uniforms:t,webGlContextAttributes:n,speed:r=0,frame:i=0,width:a,height:o,minPixelRatio:s,maxPixelCount:c,mipmaps:l,style:u,...d},f){let[p,m]=(0,W.useState)(!1),h=(0,W.useRef)(null),g=(0,W.useRef)(null),_=(0,W.useRef)(n);return(0,W.useEffect)(()=>((async()=>{let n=await pd(t);h.current&&!g.current&&(g.current=new Gu(h.current,e,n,_.current,r,i,s,c,l),m(!0))})(),()=>{g.current?.dispose(),g.current=null}),[e]),(0,W.useEffect)(()=>{let e=!1;return(async()=>{let n=await pd(t);e||g.current?.setUniforms(n)})(),()=>{e=!0}},[t,p]),(0,W.useEffect)(()=>{g.current?.setSpeed(r)},[r,p]),(0,W.useEffect)(()=>{g.current?.setMaxPixelCount(c)},[c,p]),(0,W.useEffect)(()=>{g.current?.setMinPixelRatio(s)},[s,p]),(0,W.useEffect)(()=>{g.current?.setFrame(i)},[i,p]),(0,U.jsx)(`div`,{ref:dd([h,f]),style:a!==void 0||o!==void 0?{width:typeof a==`string`&&isNaN(+a)===!1?+a:a,height:typeof o==`string`&&isNaN(+o)===!1?+o:o,...u}:u,...d})});md.displayName=`ShaderMount`;function hd(e,t){for(let n in e){if(n===`colors`){let n=Array.isArray(e.colors),r=Array.isArray(t.colors);if(!n||!r){if(Object.is(e.colors,t.colors)===!1)return!1;continue}if(e.colors?.length!==t.colors?.length||!e.colors?.every((e,n)=>e===t.colors?.[n]))return!1;continue}if(Object.is(e[n],t[n])===!1)return!1}return!0}var gd={name:`Default`,params:{...Zu,speed:1,frame:0,colors:[`#e0eaff`,`#241d9a`,`#f75092`,`#9f50d3`],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:0}};({...Zu}),{...Zu},{...Zu};var _d=(0,W.memo)(function({speed:e=gd.params.speed,frame:t=gd.params.frame,colors:n=gd.params.colors,distortion:r=gd.params.distortion,swirl:i=gd.params.swirl,grainMixer:a=gd.params.grainMixer,grainOverlay:o=gd.params.grainOverlay,fit:s=gd.params.fit,rotation:c=gd.params.rotation,scale:l=gd.params.scale,originX:u=gd.params.originX,originY:d=gd.params.originY,offsetX:f=gd.params.offsetX,offsetY:p=gd.params.offsetY,worldWidth:m=gd.params.worldWidth,worldHeight:h=gd.params.worldHeight,...g}){let _={u_colors:n.map(id),u_colorsCount:n.length,u_distortion:r,u_swirl:i,u_grainMixer:a,u_grainOverlay:o,u_fit:Qu[s],u_rotation:c,u_scale:l,u_offsetX:f,u_offsetY:p,u_originX:u,u_originY:d,u_worldWidth:m,u_worldHeight:h};return(0,U.jsx)(md,{...g,speed:e,frame:t,fragmentShader:rd,uniforms:_})},hd),vd=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),yd=`VisuallyHidden`,bd=W.forwardRef((e,t)=>(0,U.jsx)(En.span,{...e,ref:t,style:{...vd,...e.style}}));bd.displayName=yd;var xd=bd,[Sd,Cd]=dn(`Tooltip`,[La]),wd=La(),Td=`TooltipProvider`,Ed=700,Dd=`tooltip.open`,[Od,kd]=Sd(Td),Ad=e=>{let{__scopeTooltip:t,delayDuration:n=Ed,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=W.useRef(!0),s=W.useRef(!1),c=W.useRef(0);return W.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,U.jsx)(Od,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:W.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:W.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:W.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Ad.displayName=Td;var jd=`Tooltip`,[Md,Nd]=Sd(jd),Pd=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=kd(jd,e.__scopeTooltip),l=wd(t),[u,d]=W.useState(null),f=pr(),p=W.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=W.useRef(!1),[_,v]=hn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Dd))):c.onClose(),a?.(e)},caller:jd}),y=W.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=W.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=W.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=W.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return W.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,U.jsx)($a,{...l,children:(0,U.jsx)(Md,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:W.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:W.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Pd.displayName=jd;var Fd=`TooltipTrigger`,Id=W.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Nd(Fd,n),a=kd(Fd,n),o=wd(n),s=_e(t,W.useRef(null),i.onTriggerChange),c=W.useRef(!1),l=W.useRef(!1),u=W.useCallback(()=>c.current=!1,[]);return W.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,U.jsx)(eo,{asChild:!0,...o,children:(0,U.jsx)(En.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:ln(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:ln(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:ln(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:ln(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:ln(e.onBlur,i.onClose),onClick:ln(e.onClick,i.onClose)})})});Id.displayName=Fd;var Ld=`TooltipPortal`,[Rd,zd]=Sd(Ld,{forceMount:void 0}),Bd=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Nd(Ld,t);return(0,U.jsx)(Rd,{scope:t,forceMount:n,children:(0,U.jsx)(oo,{present:n||a.open,children:(0,U.jsx)(io,{asChild:!0,container:i,children:r})})})};Bd.displayName=Ld;var Vd=`TooltipContent`,Hd=W.forwardRef((e,t)=>{let n=zd(Vd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Nd(Vd,e.__scopeTooltip);return(0,U.jsx)(oo,{present:r||o.open,children:o.disableHoverableContent?(0,U.jsx)(qd,{side:i,...a,ref:t}):(0,U.jsx)(Ud,{side:i,...a,ref:t})})}),Ud=W.forwardRef((e,t)=>{let n=Nd(Vd,e.__scopeTooltip),r=kd(Vd,e.__scopeTooltip),i=W.useRef(null),a=_e(t,i),[o,s]=W.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=W.useCallback(()=>{s(null),d(!1)},[d]),p=W.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Zd(r,Xd(r,n.getBoundingClientRect())),a=Qd(t.getBoundingClientRect());s(ef([...i,...a])),d(!0)},[d]);return W.useEffect(()=>()=>f(),[f]),W.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),W.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!$d(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,U.jsx)(qd,{...e,ref:a})}),[Wd,Gd]=Sd(jd,{isInside:!1}),Kd=Sn(`TooltipContent`),qd=W.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Nd(Vd,n),l=wd(n),{onClose:u}=c;return W.useEffect(()=>(document.addEventListener(Dd,u),()=>document.removeEventListener(Dd,u)),[u]),W.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,U.jsx)(zn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,U.jsxs)(to,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,U.jsx)(Kd,{children:r}),(0,U.jsx)(Wd,{scope:n,isInside:!0,children:(0,U.jsx)(xd,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Hd.displayName=Vd;var Jd=`TooltipArrow`,Yd=W.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=wd(n);return Gd(Jd,n).isInside?null:(0,U.jsx)(no,{...i,...r,ref:t})});Yd.displayName=Jd;function Xd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Zd(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Qd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function $d(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function ef(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),tf(t)}function tf(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var nf=Ad,rf=Pd,af=Id,of=Bd,sf=Hd,cf=Yd;function lf({delayDuration:e=0,...t}){return(0,U.jsx)(nf,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function uf({...e}){return(0,U.jsx)(lf,{children:(0,U.jsx)(rf,{"data-slot":`tooltip`,...e})})}function df({...e}){return(0,U.jsx)(af,{"data-slot":`tooltip-trigger`,...e})}function ff({className:e,sideOffset:t=0,children:n,...r}){return(0,U.jsx)(of,{children:(0,U.jsxs)(sf,{"data-slot":`tooltip-content`,sideOffset:t,className:K(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,U.jsx)(cf,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var pf=class{name=`mcp_inspector_open`;properties;constructor(e){this.properties={server_url:e.serverUrl,connection_count:e.connectionCount}}},mf=class{name=`mcp_tool_execution`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId,success:e.success,duration:e.duration,error:e.error}}},hf=class{name=`mcp_resource_read`;properties;constructor(e){this.properties={resource_uri:e.resourceUri,server_id:e.serverId,success:e.success,error:e.error}}},gf=class{name=`mcp_prompt_call`;properties;constructor(e){this.properties={prompt_name:e.promptName,server_id:e.serverId,success:e.success,error:e.error}}},_f=class{name=`mcp_chat_message`;properties;constructor(e){this.properties={server_id:e.serverId,provider:e.provider,model:e.model,message_count:e.messageCount,tool_calls_count:e.toolCallsCount,success:e.success,execution_mode:e.executionMode,duration:e.duration,error:e.error}}},vf=class{name=`mcp_server_added`;properties;constructor(e){this.properties={server_id:e.serverId,server_url:e.serverUrl,connection_type:e.connectionType,via_proxy:e.viaProxy}}},yf=class{name=`mcp_command_palette_open`;properties;constructor(e){this.properties={trigger:e.trigger}}},bf=class{name=`mcp_tool_saved`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId}}};function xf(){try{return`1.0.0`}catch{return`0.0.0`}}function Sf(){try{return typeof window<`u`&&typeof document<`u`}catch{return!1}}var Cf=class{endpoint;timeout;constructor(e,t=3e3){this.endpoint=e,this.timeout=t}async logEvent(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout),r=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(clearTimeout(n),!r.ok)throw Error(`HTTP error! status: ${r.status}`)}catch{}}};function wf(e){return`mcp_inspector_telemetry_${e}`}function Tf(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`}var Ef=class e{static instance=null;POSTHOG_PROXY_URL=`/inspector/api/tel/posthog`;SCARF_PROXY_URL=`/inspector/api/tel/scarf`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogClient=null;_scarfClient=null;_source=`inspector`;constructor(){let e=Sf(),t=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||`inspector`,t)this._posthogClient=null,this._scarfClient=null;else if(!e)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new Cf(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new Cf(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return!!(Tf()&&localStorage.getItem(wf(`disabled`))===`true`||typeof process<`u`&&{}?.MCP_USE_ANONYMIZED_TELEMETRY===`false`)}getStoredSource(){return Tf()?localStorage.getItem(wf(`source`)):null}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e,Tf()&&localStorage.setItem(wf(`source`),e)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!Sf())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{if(!Tf())throw Error(`localStorage is not available or not functional`);let e=localStorage.getItem(wf(`user_id`));if(e)this._currUserId=e;else{let e=this.generateUserId();localStorage.setItem(wf(`user_id`),e),this._currUserId=e}this.trackPackageDownload({triggered_by:`user_id_property`}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){let e=window.crypto;if(e){let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);return n.slice(0,8)+`-`+n.slice(8,12)+`-`+n.slice(12,16)+`-`+n.slice(16,20)+`-`+n.slice(20,32)}else return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}async capture(e){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{let t={event:e.name,user_id:this.userId,properties:{...e.properties,mcp_use_version:xf(),language:`typescript`,source:this._source,package:`inspector`}};await this._posthogClient.logEvent(t)}catch{}if(this._scarfClient)try{let t={};t.mcp_use_version=xf(),t.user_id=this.userId,t.event=e.name,t.language=`typescript`,t.source=this._source,t.package=`inspector`,await this._scarfClient.logEvent(t)}catch{}}}async trackPackageDownload(e){if(this._scarfClient&&Sf())try{if(!Tf())throw Error(`localStorage is not available or not functional`);let t=xf(),n=!1,r=!1,i=localStorage.getItem(wf(`download_version`));if(i?t>i&&(n=!0,r=!1,localStorage.setItem(wf(`download_version`),t)):(n=!0,r=!0,localStorage.setItem(wf(`download_version`),t)),n){let n={...e||{}};n.mcp_use_version=t,n.user_id=this.userId,n.event=`package_download`,n.first_download=r,n.language=`typescript`,n.source=this._source,n.package=`inspector`,await this._scarfClient.logEvent(n)}}catch{}}async trackInspectorOpen(e){let t=new pf(e);await this.capture(t)}},Df=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Of=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),kf=e=>{let t=Of(e);return t.charAt(0).toUpperCase()+t.slice(1)},Af=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),jf=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0},Mf={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`},Nf=(0,W.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,W.createElement)(`svg`,{ref:c,...Mf,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Af(`lucide`,i),...!a&&!jf(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,W.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Pf=(e,t)=>{let n=(0,W.forwardRef)(({className:n,...r},i)=>(0,W.createElement)(Nf,{ref:i,iconNode:t,className:Af(`lucide-${Df(kf(e))}`,`lucide-${e}`,n),...r}));return n.displayName=kf(e),n},Ff=Pf(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),If=Pf(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Lf=Pf(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Rf=Pf(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),zf=Pf(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Bf=Pf(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Vf=Pf(`brush-cleaning`,[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]),Hf=Pf(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]),Uf=Pf(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Wf=Pf(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Gf=Pf(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Kf=Pf(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),qf=Pf(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Jf=Pf(`chevrons-left-right-ellipsis`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`m17 7 5 5-5 5`,key:`1xlxn0`}],[`path`,{d:`m7 7-5 5 5 5`,key:`19njba`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}]]),Yf=Pf(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Xf=Pf(`circle-minus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),Zf=Pf(`clock`,[[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Qf=Pf(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),$f=Pf(`cog`,[[`path`,{d:`M11 10.27 7 3.34`,key:`16pf9h`}],[`path`,{d:`m11 13.73-4 6.93`,key:`794ttg`}],[`path`,{d:`M12 22v-2`,key:`1osdcq`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14 12h8`,key:`4f43i9`}],[`path`,{d:`m17 20.66-1-1.73`,key:`eq3orb`}],[`path`,{d:`m17 3.34-1 1.73`,key:`2wel8s`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`m20.66 17-1.73-1`,key:`sg0v6f`}],[`path`,{d:`m20.66 7-1.73 1`,key:`1ow05n`}],[`path`,{d:`m3.34 17 1.73-1`,key:`nuk764`}],[`path`,{d:`m3.34 7 1.73 1`,key:`1ulond`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}]]),ep=Pf(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),tp=Pf(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),np=Pf(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),rp=Pf(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),ip=Pf(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ap=Pf(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),op=Pf(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),sp=Pf(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),cp=Pf(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),lp=Pf(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),up=Pf(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),dp=Pf(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),fp=Pf(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),pp=Pf(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),mp=Pf(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),hp=Pf(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),gp=Pf(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),_p=Pf(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),vp=Pf(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),yp=Pf(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),bp=Pf(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),xp=Pf(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),Sp=Pf(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),Cp=Pf(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),wp=Pf(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Tp=Pf(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),Ep=Pf(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Dp=Pf(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Op=Pf(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),kp=Pf(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Ap=Pf(`picture-in-picture`,[[`path`,{d:`M2 10h6V4`,key:`zwrco`}],[`path`,{d:`m2 4 6 6`,key:`ug085t`}],[`path`,{d:`M21 10V7a2 2 0 0 0-2-2h-7`,key:`git5jr`}],[`path`,{d:`M3 14v2a2 2 0 0 0 2 2h3`,key:`1f7fh3`}],[`rect`,{x:`12`,y:`14`,width:`10`,height:`7`,rx:`1`,key:`1wjs3o`}]]),jp=Pf(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Mp=Pf(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Np=Pf(`pointer`,[[`path`,{d:`M22 14a8 8 0 0 1-8 8`,key:`56vcr3`}],[`path`,{d:`M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1agjmk`}],[`path`,{d:`M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1`,key:`wdbh2u`}],[`path`,{d:`M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10`,key:`1ibuk9`}],[`path`,{d:`M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`g6ys72`}]]),Pp=Pf(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Fp=Pf(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Ip=Pf(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Lp=Pf(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Rp=Pf(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),zp=Pf(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Bp=Pf(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Vp=Pf(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Hp=Pf(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Up=Pf(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Wp=Pf(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Gp=Pf(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Kp=Pf(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),qp=Pf(`square-dashed-mouse-pointer`,[[`path`,{d:`M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z`,key:`xwnzip`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h2`,key:`1qve2z`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v2`,key:`p14lih`}],[`path`,{d:`M3 14v1`,key:`vnatye`}]]),Jp=Pf(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Yp=Pf(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Xp=Pf(`sun-dim`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 4h.01`,key:`1ujb9j`}],[`path`,{d:`M20 12h.01`,key:`1ykeid`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M4 12h.01`,key:`158zrr`}],[`path`,{d:`M17.657 6.343h.01`,key:`31pqzk`}],[`path`,{d:`M17.657 17.657h.01`,key:`jehnf4`}],[`path`,{d:`M6.343 17.657h.01`,key:`gdk6ow`}],[`path`,{d:`M6.343 6.343h.01`,key:`1uurf0`}]]),Zp=Pf(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Qp=Pf(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),$p=Pf(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),em=Pf(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),tm=Pf(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),nm=Pf(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),rm=Pf(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]);async function im(e,t=fetch){let n=e.replace(/\/$/,``),r=await t(n.endsWith(`/mcp`)?n:`${n}/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jsonrpc:`2.0`,method:`initialize`,id:1,params:{}})});if(r.status!==401)return{};let{resourceMetadataUrl:i,scope:a}=R(r);return{resourceMetadataUrl:i,scope:a}}a(im,`probeAuthParams`);function am(e,t){if(!e)throw Error(t)}a(am,`assert`);function om(e){return e===`localhost`||e===`127.0.0.1`||e.startsWith(`127.`)||e.startsWith(`192.168.`)||e.startsWith(`10.`)||e.startsWith(`172.`)}a(om,`isLocalServer`);function sm(e){let t=e.split(`.`),n=[];for(let e=0;e<t.length-1;e++)n.push(t.slice(e).join(`.`));return n}a(sm,`getSubdomainLevels`);function cm(e){return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>{t(r.result)},r.onerror=n,r.readAsDataURL(e)})}a(cm,`blobToBase64`);async function lm(e){console.debug(`[favicon-detector] Starting favicon detection for:`,e);try{let t;if(t=e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e.includes(`://`)?e.split(`://`)[1].split(`/`)[0]:e.split(`/`)[0],console.debug(`[favicon-detector] Extracted domain:`,t),om(t))return console.debug(`[favicon-detector] Skipping local server:`,t),null;let n=sm(t);console.debug(`[favicon-detector] Domains to try:`,n);for(let e of n)try{let t=`https://favicon.tools.mcp-use.com/${e}?response=json`;console.debug(`[favicon-detector] Attempting to fetch favicon metadata for:`,e,`from:`,t);let n=new AbortController,r=setTimeout(()=>n.abort(),2e3);try{let i=await fetch(t,{signal:n.signal});if(clearTimeout(r),!i.ok){console.debug(`[favicon-detector] Fetch failed for`,e,`with status:`,i.status);continue}let a=await i.json();console.debug(`[favicon-detector] Retrieved favicon metadata for:`,e,`source:`,a.source);let o=a.url.replace(/^http:\/\//,`https://`),s=await fetch(o);if(!s.ok){console.debug(`[favicon-detector] Failed to fetch favicon image for`,e,`status:`,s.status);continue}let c=await s.blob(),l=await cm(c);if(a.source===`default`){console.debug(`[favicon-detector] Found default favicon for:`,e,`skipping and continuing to search for non-default`);continue}return console.debug(`[favicon-detector] Successfully retrieved non-default favicon for:`,e,`source:`,a.source,`size:`,c.size,`bytes`),l}catch(t){clearTimeout(r),console.debug(`[favicon-detector] Fetch error for`,e,`:`,t instanceof Error?t.message:String(t));continue}}catch(t){console.debug(`[favicon-detector] Error processing domain`,e,`:`,t instanceof Error?t.message:String(t));continue}return console.debug(`[favicon-detector] No non-default favicon found for:`,e,`returning null to show gradient fallback`),null}catch(e){return console.warn(`[favicon-detector] Error detecting favicon:`,e),null}}a(lm,`detectFavicon`);function um(e,t){let n=t?.headers??t?.customHeaders??{};if(t?.customHeaders&&!t?.headers&&console.warn(`[applyProxyConfig] The "customHeaders" option in proxyConfig is deprecated. Use "headers" instead.`),!t?.proxyAddress)return{url:e,headers:n};let r=new URL(t.proxyAddress),i=new URL(e);return{url:`${r.origin}${r.pathname}${i.pathname}${i.search}`,headers:{"X-Target-URL":e,...n}}}a(um,`applyProxyConfig`);var dm=`inspector-server`;function fm(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}a(fm,`deriveOAuthClientConfigFromClientInfo`);function pm(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`)}a(pm,`isOAuthDiscoveryFailure`);function mm(e){if(!e)return;let t=new URL(e),n=t.pathname.replace(/\/proxy\/?$/,``);return`${t.origin}${n}/oauth`}a(mm,`deriveOAuthProxyUrl`);function hm(e){let t=mm(e.gatewayUrl),n=new V(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});return t&&e.installFetchInterceptor&&n.installFetchInterceptor(),{provider:n,oauthProxyUrl:t}}a(hm,`createBrowserOAuthProvider`);function gm(e){let t=null,n=Date.now(),r=e.healthCheckIntervalMs??1e4,i=e.healthCheckTimeoutMs??3e4;return t=setInterval(a(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)))}},`checkConnectionHealth`),r),()=>{t&&=(clearInterval(t),null)}}a(gm,`startConnectionHealthMonitoring`);var _m=3e3,vm=5e3;function ym(e){let{url:t,enabled:n=!0,callbackUrl:r=typeof window<`u`?B(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:i=`mcp:auth`,clientConfig:c={},authProvider:l,headers:u,customHeaders:d,proxyConfig:f,autoProxyFallback:p=!0,debug:m=!1,logLevel:h,autoRetry:g=!1,autoReconnect:_=_m,reconnectionOptions:v,transportType:y=`auto`,preventAutoAuth:x=!0,useRedirectFlow:S=!1,onPopupWindow:C,timeout:T=3e4,sseReadTimeout:E=3e5,wrapTransport:D,fetch:O,clientOptions:k,onNotification:A,onSampling:j,samplingCallback:M,onElicitation:N,elicitationCallback:P}=e,F=(0,W.useMemo)(()=>{let e=`useMcp:${t||`no-url`}`,n=s.get(e);return h?n.level=h:m&&(n.level=`debug`),n},[t,h,m]),I=u??d??{};d&&!u&&F.warn(`[useMcp] The "customHeaders" option is deprecated. Use "headers" instead.`);let R=j??M;M&&!j&&F.warn(`[useMcp] The "samplingCallback" option is deprecated. Use "onSampling" instead.`);let z=N??P;P&&!N&&o.warn(`[useMcp] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`);let V=(0,W.useMemo)(()=>({name:`mcp-use`,title:`mcp-use`,version:b(),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`}),[]),te=(0,W.useMemo)(()=>e.clientInfo?{...V,...e.clientInfo}:V,[e.clientInfo,V]),ne=(0,W.useMemo)(()=>fm(te),[te]),H=(0,W.useMemo)(()=>c&&Object.keys(c).length>0?(F.warn(`[useMcp] The 'clientConfig' option is deprecated and will be removed in a future version. Use 'clientInfo' instead. The clientConfig will be automatically derived from clientInfo.`),{...ne,...c}):ne,[c,ne]),re=(0,W.useMemo)(()=>p?typeof p==`boolean`?{enabled:p,proxyAddress:`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:p.enabled!==!1,proxyAddress:p.proxyAddress||`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:!1,proxyAddress:void 0},[p]),ie=(0,W.useMemo)(()=>_===!1?{enabled:!1,initialDelay:0,healthCheckInterval:!1,healthCheckTimeout:3e4}:_===!0?{enabled:!0,initialDelay:_m,healthCheckInterval:1e4,healthCheckTimeout:3e4}:typeof _==`number`?{enabled:!0,initialDelay:_,healthCheckInterval:1e4,healthCheckTimeout:3e4}:{enabled:_.enabled!==!1,initialDelay:_.initialDelay??_m,healthCheckInterval:_.healthCheckInterval??1e4,healthCheckTimeout:_.healthCheckTimeout??3e4},[_]),ae=(0,W.useRef)(!1),[oe,se]=(0,W.useState)(f);(0,W.useEffect)(()=>{se(f)},[f]);let{gatewayUrl:ce,proxyHeaders:le}=(0,W.useMemo)(()=>{let e=um(t||``,f);return{gatewayUrl:f?.proxyAddress,proxyHeaders:e.headers}},[t,f]),ue=(0,W.useMemo)(()=>t||``,[t]),de=(0,W.useMemo)(()=>({...le,...I}),[le,I]),[fe,pe]=(0,W.useState)(`discovering`),[U,me]=(0,W.useState)([]),[he,ge]=(0,W.useState)([]),[_e,ve]=(0,W.useState)([]),[ye,be]=(0,W.useState)([]),[xe,Se]=(0,W.useState)(e._initialServerInfo?.name?e._initialServerInfo:void 0),[Ce,we]=(0,W.useState)(),[Te,Ee]=(0,W.useState)(void 0),[De,Oe]=(0,W.useState)([]),[ke,Ae]=(0,W.useState)(void 0),[je,Me]=(0,W.useState)(void 0),Ne=(0,W.useRef)(null),Pe=(0,W.useRef)(l??null),Fe=(0,W.useRef)(null),Ie=(0,W.useRef)(!1),Le=(0,W.useRef)(!0),Re=(0,W.useRef)(0),ze=(0,W.useRef)(null),Be=(0,W.useRef)(!1),Ve=(0,W.useRef)(fe),He=(0,W.useRef)(_),Ue=(0,W.useRef)(null),We=(0,W.useRef)(null),Ge=(0,W.useRef)(null);(0,W.useEffect)(()=>{Ve.current=fe,He.current=_},[fe,_]),(0,W.useEffect)(()=>{Pe.current=l??null},[l]);let G=(0,W.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`:F.error(i);break;case`warn`:F.warn(i);break;case`info`:F.info(i);break;case`debug`:F.debug(i);break;default:F.info(i)}Le.current&&Oe(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[F]),Ke=(0,W.useCallback)(async(e=!1)=>{if(e||G(`info`,`Disconnecting...`),Ie.current=!1,ze.current&&clearTimeout(ze.current),ze.current=null,Ne.current)try{let e=dm,t=Ne.current.getSession(e);t&&t._healthCheckCleanup&&(t._healthCheckCleanup(),t._healthCheckCleanup=null),t&&await Ne.current.closeSession(e)}catch(t){e||G(`warn`,`Error closing session:`,t)}Ne.current=null,Le.current&&!e&&(pe(`discovering`),me([]),ge([]),ve([]),be([]),Ee(void 0),Ae(void 0))},[G]),qe=(0,W.useCallback)((e,n)=>{G(`error`,e,n??``);let r=n&&`code`in n?n.code:void 0,i=re.enabled&&!oe?.proxyAddress,a=e.includes(`CORS`)||e.includes(`blocked by CORS policy`)||e.includes(`Failed to fetch`),o=r===400;if(i&&(a||o||typeof r==`number`&&r>=404&&r<500)&&!(r===401||r===403))return G(`info`,`Direct connection failed with ${a?`CORS error`:o?`HTTP 400 (Bad Request)`:`HTTP 4xx error`}. Trying with proxy...`),Ne.current=null,l||(Pe.current=null),G(`debug`,`Cleared client and auth provider for proxy fallback`),se({proxyAddress:re.proxyAddress}),Le.current&&pe(`discovering`),setTimeout(()=>{Le.current&&We.current?.()},1e3),!0;if(Le.current){G(`info`,`Setting state to FAILED:`,e),pe(`failed`),Ee(e);let t=Pe.current?.getLastAttemptedAuthUrl?.();t&&(Ae(t),G(`info`,`Manual authentication URL may be available.`,t))}return Ie.current=!1,t&&w.getInstance().trackUseMcpConnection({url:t,transportType:y,success:!1,errorType:n?.name||`UnknownError`,hasOAuth:!!Pe.current,hasSampling:!!R,hasElicitation:!!z}).catch(()=>{}),!1},[G,t,y,R,z,re,oe,l]),Je=(0,W.useCallback)(async()=>{if(!n||!t){G(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`);return}if(Ie.current){G(`debug`,`Connection attempt already in progress.`);return}if(!Le.current){G(`debug`,`Connect called after unmount, aborting.`);return}if(Ie.current=!0,Re.current+=1,Ee(void 0),Ae(void 0),Ue.current=null,pe(`discovering`),G(`info`,`Connecting attempt #${Re.current} to ${t}...`),!Pe.current){let{provider:e,oauthProxyUrl:t}=hm({effectiveOAuthUrl:ue,storageKeyPrefix:i,oauthClientConfig:H,callbackUrl:r,preventAutoAuth:x,useRedirectFlow:S,gatewayUrl:ce,onPopupWindow:C,installFetchInterceptor:!0});Pe.current=e,t&&G(`debug`,`OAuth proxy URL derived from gateway: ${t}`),G(`debug`,`BrowserOAuthClientProvider initialized with URL: ${ue}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ce?`enabled`:`disabled`}`)}Ne.current?G(`debug`,`BrowserMCPClient already exists, reusing.`):(Ne.current=new ee,G(`debug`,`BrowserMCPClient initialized in connect.`));let e=a(async n=>{if(!Le.current)return G(`debug`,`Connection attempt aborted - component unmounted`),`failed`;G(`info`,`Attempting connection with transport: ${n}`),G(`debug`,`Client ref status at start of tryConnectWithTransport: ${Ne.current?`initialized`:`NULL`}`);try{let e=dm,r={url:t,transport:n===`sse`?`http`:n,timeout:T,sseReadTimeout:E,disableSseFallback:y===`http`,preferSse:n===`sse`,clientInfo:te,...O&&{fetch:O},...k&&{clientOptions:k},...v?{reconnectionOptions:v}:_===!1?{reconnectionOptions:{maxRetries:0}}:{}};if(ce&&(r.gatewayUrl=ce,G(`debug`,`Using proxy gateway: ${ce} for target: ${t}`)),de&&Object.keys(de).length>0&&(r.headers=de),!Ne.current){if(!Le.current)return G(`debug`,`Connection aborted - component unmounted, client cleaned up`),`failed`;let e=Error(`Client not initialized - this is a bug in the connection flow`);throw G(`error`,`Client ref is null in tryConnectWithTransport but component is still mounted`),e}Ne.current.addServer(e,{...r,authProvider:Pe.current,onSampling:R,onElicitation:z,wrapTransport:D?n=>(G(`debug`,`Applying transport wrapper for server:`,e,`url:`,t),D(n,t)):void 0});let i=await Ne.current.createSession(e,!1);if(!Le.current)return G(`debug`,`Connection aborted after session creation - component unmounted`),`failed`;if(i.on(`notification`,e=>{G(`debug`,`Notification received:`,e.method,e),A?.(e),e.method===`notifications/tools/list_changed`?(G(`info`,`Tools list changed, auto-refreshing...`),nt().catch(e=>{G(`warn`,`Auto-refresh tools failed:`,e)})):e.method===`notifications/resources/list_changed`?(G(`info`,`Resources list changed, auto-refreshing...`),rt().catch(e=>G(`warn`,`Auto-refresh resources failed:`,e))):e.method===`notifications/prompts/list_changed`&&(G(`info`,`Prompts list changed, auto-refreshing...`),it().catch(e=>G(`warn`,`Auto-refresh prompts failed:`,e)))}),await i.initialize(),!Le.current)return G(`debug`,`Connection completed but component unmounted, aborting`),`failed`;if(G(`info`,`✅ Successfully connected to MCP server`),G(`info`,`Server info:`,i.connector.serverInfo),G(`info`,`Server capabilities:`,i.connector.serverCapabilities),!Le.current)return G(`debug`,`Skipping state update - component unmounted`),`failed`;pe(`ready`),Ue.current=n,ie.enabled&&ie.healthCheckInterval!==!1&&(i._healthCheckCleanup=gm({gatewayUrl:ce,url:t,allHeaders:de,getAuthHeaders:a(async()=>{try{let e=await Pe.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{}},`getAuthHeaders`),isMountedRef:Le,stateRef:Ve,autoReconnectRef:He,setState:pe,addLog:G,connect:Je,defaultReconnectDelay:ie.initialDelay,healthCheckIntervalMs:ie.healthCheckInterval,healthCheckTimeoutMs:ie.healthCheckTimeout})),w.getInstance().trackUseMcpConnection({url:t,transportType:n,success:!0,hasOAuth:!!Pe.current,hasSampling:!!R,hasElicitation:!!z}).catch(()=>{}),me(i.connector.tools||[]);let o=await i.connector.listAllResources();if(!Le.current)return G(`debug`,`Connection aborted after listing resources - component unmounted`),`failed`;ge(o.resources||[]);let s=await i.connector.listPrompts();if(!Le.current)return G(`debug`,`Connection aborted after listing prompts - component unmounted`),`failed`;if(be(s.prompts||[]),i.connector.serverCapabilities?.resourceTemplates){let e=await i.connector.listResourceTemplates();if(!Le.current)return G(`debug`,`Connection aborted after listing resource templates - component unmounted`),`failed`;ve(e.resourceTemplates||[])}else ve([]);let c=i.connector.serverInfo,l=i.connector.serverCapabilities;if(c){if(G(`debug`,`Server info:`,c),!Le.current)return G(`debug`,`Skipping state update - component unmounted`),`failed`;Se(c),Fe.current=(async()=>{try{let e=c.icons;if(e&&Array.isArray(e)&&e.length>0){let t=e[0].src||e[0].url;if(t){G(`info`,`Server provided icon:`,t);let e=await(await fetch(t)).blob(),n=await new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)});return Le.current&&(Se(e=>e?{...e,icon:n}:void 0),G(`debug`,`Server icon converted to base64`)),n}}if(t){let e=await lm(t);if(!Le.current)return G(`debug`,`Connection aborted after favicon detection - component unmounted`),null;if(e)return Se(t=>t?{...t,icon:e}:void 0),G(`debug`,`Favicon detected and added to serverInfo`),e}return null}catch(e){return G(`debug`,`Icon loading failed (non-critical):`,e),null}})()}if(l){if(G(`debug`,`Server capabilities:`,l),!Le.current)return G(`debug`,`Skipping state update - component unmounted`),`failed`;we(l)}if(Pe.current){let e=await Pe.current.tokens?.();if(!Le.current)return G(`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;if(!Le.current)return G(`debug`,`Skipping state update - component unmounted`),`failed`;Me({access_token:e.access_token,token_type:e.token_type||`Bearer`,expires_at:t,refresh_token:e.refresh_token,scope:e.scope})}}return`success`}catch(r){let i=r,a=i?.message||String(r),o=pm(r),s=i.code===401||a.includes(`401`)||a.includes(`Unauthorized`);if(o&&I&&Object.keys(I).length>0)return qe(`Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct.`),`failed`;if(o&&(!I||Object.keys(I).length===0))return qe(`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(s){if(o)return qe(`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(Pe.current)if(G(`info`,`Authentication required. OAuth provider available.`),x){if(G(`info`,`Waiting for user to initiate authentication flow...`),Le.current){pe(`pending_auth`);let e=Pe.current?.getLastAttemptedAuthUrl?.();e&&(Ae(e),G(`info`,`Retrieved stored auth URL for manual authentication`))}return Ie.current=!1,`auth_redirect`}else{G(`info`,`Triggering automatic OAuth authentication flow...`);try{let{resourceMetadataUrl:r,scope:i}=await im(t);if(await L(Pe.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i}})===`REDIRECT`){let e=await Pe.current.getAuthorizationCode?.();if(!e)throw Error(`Authorization code not captured by headless provider`);await L(Pe.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i},authorizationCode:e})}return G(`info`,`OAuth flow completed, reconnecting...`),await e(n)}catch(e){return qe(`Automatic OAuth authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:Error(String(e))),`failed`}}return I&&Object.keys(I).length>0?(qe(`Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct.`),`failed`):(qe(`Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`)}return qe(a,i instanceof Error?i:Error(String(i)))?`auth_redirect`:`failed`}},`tryConnectWithTransport`),o=`failed`;if(y===`sse`)G(`debug`,`Using SSE-only transport mode`),o=await e(`sse`);else if(y===`http`)G(`debug`,`Using HTTP-only transport mode`),o=await e(`http`);else{G(`debug`,`Using auto transport mode (HTTP with SSE fallback)`);let t=await e(`http`);t===`fallback`&&Le.current&&Ve.current!==`authenticating`?(G(`info`,`HTTP failed, attempting SSE fallback...`),o=await e(`sse`)):o=t}(o===`success`||o===`failed`||o===`auth_redirect`)&&(Ie.current=!1),G(`debug`,`Connection sequence finished with status: ${o}`)},[G,qe,Ke,t,i,r,H.name,H.version,H.uri,H.logo_uri,I,y,x,S,C,n,T,E,te,ce,de,ue]);(0,W.useEffect)(()=>{We.current=Je,Ge.current=qe},[Je,qe]);let Ye=(0,W.useCallback)(async(e,t,n)=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot call tool "${e}".`);G(`info`,`Calling tool: ${e}`,t);let r=Date.now();try{let i=dm,a=Ne.current.getSession(i);if(!a)throw Error(`No active session found`);let o=await a.connector.callTool(e,t||{},n);return G(`info`,`Tool "${e}" call successful:`,o),w.getInstance().trackUseMcpToolCall({toolName:e,success:!0,executionTimeMs:Date.now()-r}).catch(()=>{}),o}catch(t){throw G(`error`,`Tool "${e}" call failed:`,t),w.getInstance().trackUseMcpToolCall({toolName:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`,executionTimeMs:Date.now()-r}).catch(()=>{}),t}},[fe]),Xe=(0,W.useCallback)(()=>{Ve.current===`failed`?(G(`info`,`Retry requested...`),We.current?.()):G(`warn`,`Retry called but state is not 'failed' (state: ${Ve.current}). Ignoring.`)},[G]),Ze=(0,W.useCallback)(async()=>{G(`info`,`Manual authentication requested...`);let e=Ve.current;if(e===`failed`)G(`info`,`Attempting to reconnect and authenticate via retry...`),Xe();else if(e===`pending_auth`){G(`info`,`Proceeding with authentication from pending state...`);try{if(am(Pe.current,`Auth Provider not available for manual auth`),am(t,`Server URL is required for authentication`),l){G(`info`,`Using provided authProvider for manual authentication`);let e=new URL(t).origin;await L(Pe.current,{serverUrl:e}),We.current?.();return}G(`info`,`Cleared ${Pe.current.clearStorage?.()??0} OAuth storage item(s) for fresh authentication`),pe(`authenticating`);let{provider:e,oauthProxyUrl:n}=hm({effectiveOAuthUrl:ue,storageKeyPrefix:i,oauthClientConfig:H,callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:S,gatewayUrl:ce,onPopupWindow:C,installFetchInterceptor:!ce});n&&!ce?G(`info`,`Installed OAuth fetch interceptor for manual auth`):n&&ce&&G(`info`,`Using MCP gateway proxy for OAuth (no fetch interceptor needed)`),Pe.current=e,G(`info`,`Triggering fresh OAuth authorization...`);let a=new URL(t).origin;try{await L(e,{serverUrl:a}),G(`info`,`OAuth flow completed (tokens obtained)`)}catch(e){G(`info`,`OAuth flow initiated (popup/redirect):`,e instanceof Error?e.message:`Redirecting...`)}let o=e.getLastAttemptedAuthUrl?.();o&&(Ae(o),G(`info`,`Updated auth URL for fallback:`,o))}catch(e){if(!Le.current)return;pe(`pending_auth`),G(`error`,`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`)}}else if(e===`authenticating`){G(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=Pe.current?.getLastAttemptedAuthUrl?.();e&&!ke&&(Ae(e),G(`info`,`Manual authentication URL retrieved:`,e))}else G(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[G,Xe,ke,t,S,C,i,H.name,H.uri,H.logo_uri,r,te,l]),Qe=(0,W.useCallback)(()=>{Pe.current?.clearStorage?(G(`info`,`Cleared ${Pe.current.clearStorage()} item(s) from localStorage for ${t}.`),Ae(void 0),Ke()):G(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,G,Ke]),$e=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot list resources.`);G(`info`,`Listing resources`);try{let e=dm,t=Ne.current.getSession(e);if(!t)throw Error(`No active session found`);ge((await t.connector.listAllResources()).resources||[]),G(`info`,`Resources listed successfully`)}catch(e){throw G(`error`,`List resources failed:`,e),e}},[fe]),et=(0,W.useCallback)(async e=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot read resource.`);G(`info`,`Reading resource: ${e}`);try{let t=dm,n=Ne.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.connector.readResource(e);return G(`info`,`Resource read successful:`,r),w.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!0}).catch(()=>{}),r}catch(t){throw G(`error`,`Resource read failed:`,t),w.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`}).catch(()=>{}),t}},[fe]),tt=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot list prompts.`);G(`info`,`Listing prompts`);try{let e=dm,t=Ne.current.getSession(e);if(!t)throw Error(`No active session found`);be((await t.connector.listPrompts()).prompts||[]),G(`info`,`Prompts listed successfully`)}catch(e){throw G(`error`,`List prompts failed:`,e),e}},[fe]),nt=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current){G(`debug`,`Cannot refresh tools - client not ready. State:`,Ve.current);return}G(`debug`,`Refreshing tools list`);try{let e=dm,t=Ne.current.getSession(e);if(!t){G(`warn`,`No active session found for tools refresh`);return}G(`debug`,`Calling listTools...`);let n=await t.connector.listTools();G(`debug`,`listTools returned:`,n?.length,`tools`),me(n||[]),G(`info`,`Tools list refreshed successfully`)}catch(e){G(`error`,`Failed to refresh tools:`,e)}},[G]),rt=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current){G(`debug`,`Cannot refresh resources - client not ready`);return}G(`debug`,`Refreshing resources list`);try{let e=dm,t=Ne.current.getSession(e);if(!t){G(`warn`,`No active session found for resources refresh`);return}ge((await t.connector.listAllResources()).resources||[]),G(`info`,`Resources list refreshed successfully`)}catch(e){G(`warn`,`Failed to refresh resources:`,e)}},[G]),it=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current){G(`debug`,`Cannot refresh prompts - client not ready`);return}G(`debug`,`Refreshing prompts list`);try{let e=dm,t=Ne.current.getSession(e);if(!t){G(`warn`,`No active session found for prompts refresh`);return}be((await t.connector.listPrompts()).prompts||[]),G(`info`,`Prompts list refreshed successfully`)}catch(e){G(`warn`,`Failed to refresh prompts:`,e)}},[G]),at=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current){G(`debug`,`Cannot refresh resource templates - client not ready`);return}G(`debug`,`Refreshing resource templates list`);try{let e=dm,t=Ne.current.getSession(e);if(!t)throw Error(`No active session found`);let n=await t.connector.listResourceTemplates();Le.current&&(ve(n.resourceTemplates||[]),G(`info`,`Resource templates refreshed: ${n.resourceTemplates?.length||0} templates`))}catch(e){throw G(`error`,`Failed to refresh resource templates:`,e),e}},[G]),ot=(0,W.useCallback)(async()=>{G(`info`,`Refreshing all lists (tools, resources, resource templates, prompts)`),await Promise.all([nt(),rt(),at(),it()])},[nt,rt,at,it,G]),st=(0,W.useCallback)(async(e,t)=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot get prompt.`);G(`info`,`Getting prompt: ${e}`,t);try{let n=dm,r=Ne.current.getSession(n);if(!r)throw Error(`No active session found`);let i=await r.connector.getPrompt(e,t||{});return G(`info`,`Prompt "${e}" retrieved successfully:`,i),i}catch(t){throw G(`error`,`Prompt "${e}" retrieval failed:`,t),t}},[fe,G]),ct=(0,W.useCallback)(async e=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot request completion.`);G(`info`,`Requesting completions for ${e.ref.type===`ref/prompt`?`prompt`:`resource template`} "${e.ref.type===`ref/prompt`?e.ref.name:e.ref.uri}"`);try{let t=dm,n=Ne.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.complete(e);return G(`info`,`Received ${r.completion.values.length} completion suggestions`),r}catch(e){throw G(`error`,`Completion request failed:`,e),e}},[fe,G]);(0,W.useEffect)(()=>{let e=a(e=>{e.origin===window.location.origin&&e.data?.type===`mcp_auth_callback`&&(G(`info`,`Received auth callback message.`,e.data),ze.current&&clearTimeout(ze.current),ze.current=null,e.data.success?(G(`info`,`Authentication successful via popup. Reconnecting client...`),Ie.current&&G(`debug`,`Connection attempt already in progress, resetting flag to allow reconnection.`),Ie.current=!1,setTimeout(()=>{Le.current&&(G(`debug`,`Initiating reconnection after successful auth callback.`),We.current?.())},100)):Ge.current?.(`Authentication failed in callback: ${e.data.error||`Unknown reason.`}`))},`messageHandler`);return window.addEventListener(`message`,e),G(`debug`,`Auth callback message listener added.`),()=>{window.removeEventListener(`message`,e),G(`debug`,`Auth callback message listener removed.`),ze.current&&clearTimeout(ze.current)}},[G]),(0,W.useEffect)(()=>{ae.current=!1,se(f)},[t,f]),(0,W.useEffect)(()=>{if(Le.current=!0,!n||!t)return G(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`),pe(`discovering`),()=>{Le.current=!1};if(G(`debug`,`useMcp mounted, initiating connection.`),Re.current=0,l)Pe.current=l,G(`debug`,`Using externally provided authProvider`);else if(!Pe.current||Pe.current.serverUrl!==ue){let{provider:e,oauthProxyUrl:t}=hm({effectiveOAuthUrl:ue,storageKeyPrefix:i,oauthClientConfig:H,callbackUrl:r,preventAutoAuth:x,useRedirectFlow:S,gatewayUrl:ce,onPopupWindow:C,installFetchInterceptor:!0});Pe.current=e,t&&G(`debug`,`OAuth proxy URL derived from gateway: ${t}`),G(`debug`,`BrowserOAuthClientProvider initialized/updated with URL: ${ue}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ce?`enabled`:`disabled`}`)}return Je(),()=>{if(Le.current=!1,G(`debug`,`useMcp unmounting, disconnecting.`),(Ve.current===`authenticating`||Ve.current===`pending_auth`)&&Pe.current)try{let e=Pe.current.clearStorage?.()??0;e>0&&G(`debug`,`Cleared ${e} OAuth state item(s) during unmount to prevent corruption`)}catch(e){G(`debug`,`Error clearing OAuth state during unmount:`,e)}Ke(!0)}},[t,n,i,r,H.name,H.version,H.uri,H.logo_uri,S,te,ue,f,l]);let lt=(0,W.useRef)(Xe),ut=(0,W.useRef)(G);(0,W.useEffect)(()=>{lt.current=Xe,ut.current=G},[Xe,G]),(0,W.useEffect)(()=>{let e=null;if(fe===`failed`&&g&&Re.current>0){if(!Be.current){Be.current=!0;let t=typeof g==`number`?g:vm;ut.current(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{Be.current=!1,Le.current&&Ve.current===`failed`&&lt.current()},t)}}else fe!==`failed`&&(Be.current=!1);return()=>{e&&(clearTimeout(e),Be.current=!1)}},[fe,g]);let dt=(0,W.useCallback)(async()=>Ve.current===`ready`?xe?.icon?xe.icon:Fe.current?(G(`debug`,`Waiting for icon to finish loading...`),await Fe.current):(G(`debug`,`No icon available and no loading in progress`),null):(G(`warn`,`Cannot ensure icon loaded - not connected`),null),[xe,G]);return{state:fe,name:xe?.name||t||``,tools:U,resources:he,resourceTemplates:_e,prompts:ye,serverInfo:xe,capabilities:Ce,error:Te,log:De,authUrl:ke,authTokens:je,client:Ne.current,callTool:Ye,readResource:et,listResources:$e,listPrompts:tt,getPrompt:st,complete:ct,refreshTools:nt,refreshResources:rt,refreshResourceTemplates:at,refreshPrompts:it,refreshAll:ot,retry:Xe,disconnect:Ke,authenticate:Ze,clearStorage:Qe,ensureIconLoaded:dt}}a(ym,`useMcp`);var bm=`__model_context`,xm=new Map;function Sm(e){xm.set(e.id,e),Tm()}a(Sm,`setNode`);function Cm(e){xm.delete(e),Tm()}a(Cm,`removeNode`);var wm=!1;function Tm(){wm||(wm=!0,queueMicrotask(Em))}a(Tm,`scheduleFlush`);function Em(){wm=!1,Am(Dm())}a(Em,`flush`);function Dm(){let e=new Map;for(let t of xm.values()){let n=t.parentId??null;e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let t of e.values())t.sort((e,t)=>e.id.localeCompare(t.id));let t=[];function n(r,i){let a=e.get(r);if(a)for(let e of a)e.content.trim()&&t.push(`${` `.repeat(i)}- ${e.content.trim()}`),n(e.id,i+1)}return a(n,`traverseTree`),n(null,0),t.join(`
340
+ `;function id(e){if(Array.isArray(e))return e.length===4?e:e.length===3?[...e,1]:ud;if(typeof e!=`string`)return ud;let t,n,r,i=1;if(e.startsWith(`#`))[t,n,r,i]=ad(e);else if(e.startsWith(`rgb`))[t,n,r,i]=od(e);else if(e.startsWith(`hsl`))[t,n,r,i]=cd(sd(e));else return console.error(`Unsupported color format`,e),ud;return[ld(t,0,1),ld(n,0,1),ld(r,0,1),ld(i,0,1)]}function ad(e){return e=e.replace(/^#/,``),e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),e.length===6&&(e+=`ff`),[parseInt(e.slice(0,2),16)/255,parseInt(e.slice(2,4),16)/255,parseInt(e.slice(4,6),16)/255,parseInt(e.slice(6,8),16)/255]}function od(e){let t=e.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??`0`)/255,parseInt(t[2]??`0`)/255,parseInt(t[3]??`0`)/255,t[4]===void 0?1:parseFloat(t[4])]:[0,0,0,1]}function sd(e){let t=e.match(/^hsla?\s*\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([0-9.]+))?\s*\)$/i);return t?[parseInt(t[1]??`0`),parseInt(t[2]??`0`),parseInt(t[3]??`0`),t[4]===void 0?1:parseFloat(t[4])]:[0,0,0,1]}function cd(e){let[t,n,r,i]=e,a=t/360,o=n/100,s=r/100,c,l,u;if(n===0)c=l=u=s;else{let e=(e,t,n)=>(n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e),t=s<.5?s*(1+o):s+o-s*o,n=2*s-t;c=e(n,t,a+1/3),l=e(n,t,a),u=e(n,t,a-1/3)}return[c,l,u,i]}var ld=(e,t,n)=>Math.min(Math.max(e,t),n),ud=[0,0,0,1];function dd(e){let t=W.useRef(void 0),n=W.useCallback(t=>{let n=e.map(e=>{if(e!=null){if(typeof e==`function`){let n=e,r=n(t);return typeof r==`function`?r:()=>{n(null)}}return e.current=t,()=>{e.current=null}}});return()=>{n.forEach(e=>e?.())}},e);return W.useMemo(()=>e.every(e=>e==null)?null:e=>{t.current&&=(t.current(),void 0),e!=null&&(t.current=n(e))},e)}function fd(e){if(e.naturalWidth<1024&&e.naturalHeight<1024){if(e.naturalWidth<1||e.naturalHeight<1)return;let t=e.naturalWidth/e.naturalHeight;e.width=Math.round(t>1?1024*t:1024),e.height=Math.round(t>1?1024:1024/t)}}async function pd(e){let t={},n=[],r=e=>{try{return e.startsWith(`/`)||new URL(e),!0}catch{return!1}},i=e=>{try{return e.startsWith(`/`)?!1:new URL(e,window.location.origin).origin!==window.location.origin}catch{return!1}};return Object.entries(e).forEach(([e,a])=>{if(typeof a==`string`){let o=a||`data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==`;if(!r(o)){console.warn(`Uniform "${e}" has invalid URL "${o}". Skipping image loading.`);return}let s=new Promise((n,r)=>{let a=new Image;i(o)&&(a.crossOrigin=`anonymous`),a.onload=()=>{fd(a),t[e]=a,n()},a.onerror=()=>{console.error(`Could not set uniforms. Failed to load image at ${o}`),r()},a.src=o});n.push(s)}else a instanceof HTMLImageElement&&fd(a),t[e]=a}),await Promise.all(n),t}var md=(0,W.forwardRef)(function({fragmentShader:e,uniforms:t,webGlContextAttributes:n,speed:r=0,frame:i=0,width:a,height:o,minPixelRatio:s,maxPixelCount:c,mipmaps:l,style:u,...d},f){let[p,m]=(0,W.useState)(!1),h=(0,W.useRef)(null),g=(0,W.useRef)(null),_=(0,W.useRef)(n);return(0,W.useEffect)(()=>((async()=>{let n=await pd(t);h.current&&!g.current&&(g.current=new Gu(h.current,e,n,_.current,r,i,s,c,l),m(!0))})(),()=>{g.current?.dispose(),g.current=null}),[e]),(0,W.useEffect)(()=>{let e=!1;return(async()=>{let n=await pd(t);e||g.current?.setUniforms(n)})(),()=>{e=!0}},[t,p]),(0,W.useEffect)(()=>{g.current?.setSpeed(r)},[r,p]),(0,W.useEffect)(()=>{g.current?.setMaxPixelCount(c)},[c,p]),(0,W.useEffect)(()=>{g.current?.setMinPixelRatio(s)},[s,p]),(0,W.useEffect)(()=>{g.current?.setFrame(i)},[i,p]),(0,U.jsx)(`div`,{ref:dd([h,f]),style:a!==void 0||o!==void 0?{width:typeof a==`string`&&isNaN(+a)===!1?+a:a,height:typeof o==`string`&&isNaN(+o)===!1?+o:o,...u}:u,...d})});md.displayName=`ShaderMount`;function hd(e,t){for(let n in e){if(n===`colors`){let n=Array.isArray(e.colors),r=Array.isArray(t.colors);if(!n||!r){if(Object.is(e.colors,t.colors)===!1)return!1;continue}if(e.colors?.length!==t.colors?.length||!e.colors?.every((e,n)=>e===t.colors?.[n]))return!1;continue}if(Object.is(e[n],t[n])===!1)return!1}return!0}var gd={name:`Default`,params:{...Zu,speed:1,frame:0,colors:[`#e0eaff`,`#241d9a`,`#f75092`,`#9f50d3`],distortion:.8,swirl:.1,grainMixer:0,grainOverlay:0}};({...Zu}),{...Zu},{...Zu};var _d=(0,W.memo)(function({speed:e=gd.params.speed,frame:t=gd.params.frame,colors:n=gd.params.colors,distortion:r=gd.params.distortion,swirl:i=gd.params.swirl,grainMixer:a=gd.params.grainMixer,grainOverlay:o=gd.params.grainOverlay,fit:s=gd.params.fit,rotation:c=gd.params.rotation,scale:l=gd.params.scale,originX:u=gd.params.originX,originY:d=gd.params.originY,offsetX:f=gd.params.offsetX,offsetY:p=gd.params.offsetY,worldWidth:m=gd.params.worldWidth,worldHeight:h=gd.params.worldHeight,...g}){let _={u_colors:n.map(id),u_colorsCount:n.length,u_distortion:r,u_swirl:i,u_grainMixer:a,u_grainOverlay:o,u_fit:Qu[s],u_rotation:c,u_scale:l,u_offsetX:f,u_offsetY:p,u_originX:u,u_originY:d,u_worldWidth:m,u_worldHeight:h};return(0,U.jsx)(md,{...g,speed:e,frame:t,fragmentShader:rd,uniforms:_})},hd),vd=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),yd=`VisuallyHidden`,bd=W.forwardRef((e,t)=>(0,U.jsx)(En.span,{...e,ref:t,style:{...vd,...e.style}}));bd.displayName=yd;var xd=bd,[Sd,Cd]=dn(`Tooltip`,[La]),wd=La(),Td=`TooltipProvider`,Ed=700,Dd=`tooltip.open`,[Od,kd]=Sd(Td),Ad=e=>{let{__scopeTooltip:t,delayDuration:n=Ed,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=W.useRef(!0),s=W.useRef(!1),c=W.useRef(0);return W.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,U.jsx)(Od,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:W.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:W.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:W.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Ad.displayName=Td;var jd=`Tooltip`,[Md,Nd]=Sd(jd),Pd=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=kd(jd,e.__scopeTooltip),l=wd(t),[u,d]=W.useState(null),f=pr(),p=W.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=W.useRef(!1),[_,v]=hn({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Dd))):c.onClose(),a?.(e)},caller:jd}),y=W.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=W.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=W.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=W.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return W.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,U.jsx)($a,{...l,children:(0,U.jsx)(Md,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:W.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:W.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Pd.displayName=jd;var Fd=`TooltipTrigger`,Id=W.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Nd(Fd,n),a=kd(Fd,n),o=wd(n),s=_e(t,W.useRef(null),i.onTriggerChange),c=W.useRef(!1),l=W.useRef(!1),u=W.useCallback(()=>c.current=!1,[]);return W.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,U.jsx)(eo,{asChild:!0,...o,children:(0,U.jsx)(En.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:ln(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:ln(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:ln(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:ln(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:ln(e.onBlur,i.onClose),onClick:ln(e.onClick,i.onClose)})})});Id.displayName=Fd;var Ld=`TooltipPortal`,[Rd,zd]=Sd(Ld,{forceMount:void 0}),Bd=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Nd(Ld,t);return(0,U.jsx)(Rd,{scope:t,forceMount:n,children:(0,U.jsx)(oo,{present:n||a.open,children:(0,U.jsx)(io,{asChild:!0,container:i,children:r})})})};Bd.displayName=Ld;var Vd=`TooltipContent`,Hd=W.forwardRef((e,t)=>{let n=zd(Vd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Nd(Vd,e.__scopeTooltip);return(0,U.jsx)(oo,{present:r||o.open,children:o.disableHoverableContent?(0,U.jsx)(qd,{side:i,...a,ref:t}):(0,U.jsx)(Ud,{side:i,...a,ref:t})})}),Ud=W.forwardRef((e,t)=>{let n=Nd(Vd,e.__scopeTooltip),r=kd(Vd,e.__scopeTooltip),i=W.useRef(null),a=_e(t,i),[o,s]=W.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=W.useCallback(()=>{s(null),d(!1)},[d]),p=W.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Zd(r,Xd(r,n.getBoundingClientRect())),a=Qd(t.getBoundingClientRect());s(ef([...i,...a])),d(!0)},[d]);return W.useEffect(()=>()=>f(),[f]),W.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),W.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!$d(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,U.jsx)(qd,{...e,ref:a})}),[Wd,Gd]=Sd(jd,{isInside:!1}),Kd=Sn(`TooltipContent`),qd=W.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Nd(Vd,n),l=wd(n),{onClose:u}=c;return W.useEffect(()=>(document.addEventListener(Dd,u),()=>document.removeEventListener(Dd,u)),[u]),W.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,U.jsx)(zn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,U.jsxs)(to,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,U.jsx)(Kd,{children:r}),(0,U.jsx)(Wd,{scope:n,isInside:!0,children:(0,U.jsx)(xd,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Hd.displayName=Vd;var Jd=`TooltipArrow`,Yd=W.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=wd(n);return Gd(Jd,n).isInside?null:(0,U.jsx)(no,{...i,...r,ref:t})});Yd.displayName=Jd;function Xd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Zd(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Qd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function $d(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function ef(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),tf(t)}function tf(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var nf=Ad,rf=Pd,af=Id,of=Bd,sf=Hd,cf=Yd;function lf({delayDuration:e=0,...t}){return(0,U.jsx)(nf,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function uf({...e}){return(0,U.jsx)(lf,{children:(0,U.jsx)(rf,{"data-slot":`tooltip`,...e})})}function df({...e}){return(0,U.jsx)(af,{"data-slot":`tooltip-trigger`,...e})}function ff({className:e,sideOffset:t=0,children:n,...r}){return(0,U.jsx)(of,{children:(0,U.jsxs)(sf,{"data-slot":`tooltip-content`,sideOffset:t,className:K(`bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance`,e),...r,children:[n,(0,U.jsx)(cf,{className:`bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]`})]})})}var pf=class{name=`mcp_inspector_open`;properties;constructor(e){this.properties={server_url:e.serverUrl,connection_count:e.connectionCount}}},mf=class{name=`mcp_tool_execution`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId,success:e.success,duration:e.duration,error:e.error}}},hf=class{name=`mcp_resource_read`;properties;constructor(e){this.properties={resource_uri:e.resourceUri,server_id:e.serverId,success:e.success,error:e.error}}},gf=class{name=`mcp_prompt_call`;properties;constructor(e){this.properties={prompt_name:e.promptName,server_id:e.serverId,success:e.success,error:e.error}}},_f=class{name=`mcp_chat_message`;properties;constructor(e){this.properties={server_id:e.serverId,provider:e.provider,model:e.model,message_count:e.messageCount,tool_calls_count:e.toolCallsCount,success:e.success,execution_mode:e.executionMode,duration:e.duration,error:e.error}}},vf=class{name=`mcp_server_added`;properties;constructor(e){this.properties={server_id:e.serverId,server_url:e.serverUrl,connection_type:e.connectionType,via_proxy:e.viaProxy}}},yf=class{name=`mcp_command_palette_open`;properties;constructor(e){this.properties={trigger:e.trigger}}},bf=class{name=`mcp_tool_saved`;properties;constructor(e){this.properties={tool_name:e.toolName,server_id:e.serverId}}};function xf(){try{return`1.0.1`}catch{return`0.0.0`}}function Sf(){try{return typeof window<`u`&&typeof document<`u`}catch{return!1}}var Cf=class{endpoint;timeout;constructor(e,t=3e3){this.endpoint=e,this.timeout=t}async logEvent(e){try{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout),r=await fetch(this.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(clearTimeout(n),!r.ok)throw Error(`HTTP error! status: ${r.status}`)}catch{}}};function wf(e){return`mcp_inspector_telemetry_${e}`}function Tf(){return typeof localStorage<`u`&&typeof localStorage.getItem==`function`&&typeof localStorage.setItem==`function`}var Ef=class e{static instance=null;POSTHOG_PROXY_URL=`/inspector/api/tel/posthog`;SCARF_PROXY_URL=`/inspector/api/tel/scarf`;UNKNOWN_USER_ID=`UNKNOWN_USER_ID`;_currUserId=null;_posthogClient=null;_scarfClient=null;_source=`inspector`;constructor(){let e=Sf(),t=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||`inspector`,t)this._posthogClient=null,this._scarfClient=null;else if(!e)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new Cf(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new Cf(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return!!(Tf()&&localStorage.getItem(wf(`disabled`))===`true`||typeof process<`u`&&{}?.MCP_USE_ANONYMIZED_TELEMETRY===`false`)}getStoredSource(){return Tf()?localStorage.getItem(wf(`source`)):null}static getInstance(){return e.instance||=new e,e.instance}setSource(e){this._source=e,Tf()&&localStorage.setItem(wf(`source`),e)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!Sf())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{if(!Tf())throw Error(`localStorage is not available or not functional`);let e=localStorage.getItem(wf(`user_id`));if(e)this._currUserId=e;else{let e=this.generateUserId();localStorage.setItem(wf(`user_id`),e),this._currUserId=e}this.trackPackageDownload({triggered_by:`user_id_property`}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){let e=window.crypto;if(e){let t=new Uint8Array(16);e.getRandomValues(t),t[6]=t[6]&15|64,t[8]=t[8]&63|128;let n=Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``);return n.slice(0,8)+`-`+n.slice(8,12)+`-`+n.slice(12,16)+`-`+n.slice(16,20)+`-`+n.slice(20,32)}else return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}async capture(e){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{let t={event:e.name,user_id:this.userId,properties:{...e.properties,mcp_use_version:xf(),language:`typescript`,source:this._source,package:`inspector`}};await this._posthogClient.logEvent(t)}catch{}if(this._scarfClient)try{let t={};t.mcp_use_version=xf(),t.user_id=this.userId,t.event=e.name,t.language=`typescript`,t.source=this._source,t.package=`inspector`,await this._scarfClient.logEvent(t)}catch{}}}async trackPackageDownload(e){if(this._scarfClient&&Sf())try{if(!Tf())throw Error(`localStorage is not available or not functional`);let t=xf(),n=!1,r=!1,i=localStorage.getItem(wf(`download_version`));if(i?t>i&&(n=!0,r=!1,localStorage.setItem(wf(`download_version`),t)):(n=!0,r=!0,localStorage.setItem(wf(`download_version`),t)),n){let n={...e||{}};n.mcp_use_version=t,n.user_id=this.userId,n.event=`package_download`,n.first_download=r,n.language=`typescript`,n.source=this._source,n.package=`inspector`,await this._scarfClient.logEvent(n)}}catch{}}async trackInspectorOpen(e){let t=new pf(e);await this.capture(t)}},Df=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Of=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),kf=e=>{let t=Of(e);return t.charAt(0).toUpperCase()+t.slice(1)},Af=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),jf=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0},Mf={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`},Nf=(0,W.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,W.createElement)(`svg`,{ref:c,...Mf,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Af(`lucide`,i),...!a&&!jf(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,W.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Pf=(e,t)=>{let n=(0,W.forwardRef)(({className:n,...r},i)=>(0,W.createElement)(Nf,{ref:i,iconNode:t,className:Af(`lucide-${Df(kf(e))}`,`lucide-${e}`,n),...r}));return n.displayName=kf(e),n},Ff=Pf(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),If=Pf(`arrow-up-from-line`,[[`path`,{d:`m18 9-6-6-6 6`,key:`kcunyi`}],[`path`,{d:`M12 3v14`,key:`7cf3v8`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),Lf=Pf(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),Rf=Pf(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),zf=Pf(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Bf=Pf(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Vf=Pf(`brush-cleaning`,[[`path`,{d:`m16 22-1-4`,key:`1ow2iv`}],[`path`,{d:`M19 14a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2h-3a1 1 0 0 1-1-1V4a2 2 0 0 0-4 0v5a1 1 0 0 1-1 1H6a2 2 0 0 0-2 2v1a1 1 0 0 0 1 1`,key:`11gii7`}],[`path`,{d:`M19 14H5l-1.973 6.767A1 1 0 0 0 4 22h16a1 1 0 0 0 .973-1.233z`,key:`bju7h4`}],[`path`,{d:`m8 22 1-4`,key:`s3unb`}]]),Hf=Pf(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]),Uf=Pf(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Wf=Pf(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),Gf=Pf(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Kf=Pf(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),qf=Pf(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Jf=Pf(`chevrons-left-right-ellipsis`,[[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`m17 7 5 5-5 5`,key:`1xlxn0`}],[`path`,{d:`m7 7-5 5 5 5`,key:`19njba`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}]]),Yf=Pf(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Xf=Pf(`circle-minus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),Zf=Pf(`clock`,[[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Qf=Pf(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),$f=Pf(`cog`,[[`path`,{d:`M11 10.27 7 3.34`,key:`16pf9h`}],[`path`,{d:`m11 13.73-4 6.93`,key:`794ttg`}],[`path`,{d:`M12 22v-2`,key:`1osdcq`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M14 12h8`,key:`4f43i9`}],[`path`,{d:`m17 20.66-1-1.73`,key:`eq3orb`}],[`path`,{d:`m17 3.34-1 1.73`,key:`2wel8s`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`m20.66 17-1.73-1`,key:`sg0v6f`}],[`path`,{d:`m20.66 7-1.73 1`,key:`1ow05n`}],[`path`,{d:`m3.34 17 1.73-1`,key:`nuk764`}],[`path`,{d:`m3.34 7 1.73 1`,key:`1ulond`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`circle`,{cx:`12`,cy:`12`,r:`8`,key:`46899m`}]]),ep=Pf(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),tp=Pf(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),np=Pf(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),rp=Pf(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),ip=Pf(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ap=Pf(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),op=Pf(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),sp=Pf(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),cp=Pf(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),lp=Pf(`file-image`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]),up=Pf(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),dp=Pf(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),fp=Pf(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),pp=Pf(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),mp=Pf(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),hp=Pf(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),gp=Pf(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),_p=Pf(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),vp=Pf(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),yp=Pf(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),bp=Pf(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),xp=Pf(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),Sp=Pf(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),Cp=Pf(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),wp=Pf(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),Tp=Pf(`minimize`,[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]),Ep=Pf(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Dp=Pf(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),Op=Pf(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),kp=Pf(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Ap=Pf(`picture-in-picture`,[[`path`,{d:`M2 10h6V4`,key:`zwrco`}],[`path`,{d:`m2 4 6 6`,key:`ug085t`}],[`path`,{d:`M21 10V7a2 2 0 0 0-2-2h-7`,key:`git5jr`}],[`path`,{d:`M3 14v2a2 2 0 0 0 2 2h3`,key:`1f7fh3`}],[`rect`,{x:`12`,y:`14`,width:`10`,height:`7`,rx:`1`,key:`1wjs3o`}]]),jp=Pf(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),Mp=Pf(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Np=Pf(`pointer`,[[`path`,{d:`M22 14a8 8 0 0 1-8 8`,key:`56vcr3`}],[`path`,{d:`M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1agjmk`}],[`path`,{d:`M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1`,key:`wdbh2u`}],[`path`,{d:`M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10`,key:`1ibuk9`}],[`path`,{d:`M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`g6ys72`}]]),Pp=Pf(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Fp=Pf(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Ip=Pf(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Lp=Pf(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),Rp=Pf(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),zp=Pf(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Bp=Pf(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Vp=Pf(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Hp=Pf(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Up=Pf(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),Wp=Pf(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),Gp=Pf(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Kp=Pf(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),qp=Pf(`square-dashed-mouse-pointer`,[[`path`,{d:`M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z`,key:`xwnzip`}],[`path`,{d:`M5 3a2 2 0 0 0-2 2`,key:`y57alp`}],[`path`,{d:`M19 3a2 2 0 0 1 2 2`,key:`18rm91`}],[`path`,{d:`M5 21a2 2 0 0 1-2-2`,key:`sbafld`}],[`path`,{d:`M9 3h1`,key:`1yesri`}],[`path`,{d:`M9 21h2`,key:`1qve2z`}],[`path`,{d:`M14 3h1`,key:`1ec4yj`}],[`path`,{d:`M3 9v1`,key:`1r0deq`}],[`path`,{d:`M21 9v2`,key:`p14lih`}],[`path`,{d:`M3 14v1`,key:`vnatye`}]]),Jp=Pf(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Yp=Pf(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Xp=Pf(`sun-dim`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 4h.01`,key:`1ujb9j`}],[`path`,{d:`M20 12h.01`,key:`1ykeid`}],[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M4 12h.01`,key:`158zrr`}],[`path`,{d:`M17.657 6.343h.01`,key:`31pqzk`}],[`path`,{d:`M17.657 17.657h.01`,key:`jehnf4`}],[`path`,{d:`M6.343 17.657h.01`,key:`gdk6ow`}],[`path`,{d:`M6.343 6.343h.01`,key:`1uurf0`}]]),Zp=Pf(`tablet`,[[`rect`,{width:`16`,height:`20`,x:`4`,y:`2`,rx:`2`,ry:`2`,key:`76otgf`}],[`line`,{x1:`12`,x2:`12.01`,y1:`18`,y2:`18`,key:`1dp563`}]]),Qp=Pf(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),$p=Pf(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),em=Pf(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),tm=Pf(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),nm=Pf(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),rm=Pf(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]);async function im(e,t=fetch){let n=e.replace(/\/$/,``),r=await t(n.endsWith(`/mcp`)?n:`${n}/mcp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jsonrpc:`2.0`,method:`initialize`,id:1,params:{}})});if(r.status!==401)return{};let{resourceMetadataUrl:i,scope:a}=R(r);return{resourceMetadataUrl:i,scope:a}}a(im,`probeAuthParams`);function am(e,t){if(!e)throw Error(t)}a(am,`assert`);function om(e){return e===`localhost`||e===`127.0.0.1`||e.startsWith(`127.`)||e.startsWith(`192.168.`)||e.startsWith(`10.`)||e.startsWith(`172.`)}a(om,`isLocalServer`);function sm(e){let t=e.split(`.`),n=[];for(let e=0;e<t.length-1;e++)n.push(t.slice(e).join(`.`));return n}a(sm,`getSubdomainLevels`);function cm(e){return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>{t(r.result)},r.onerror=n,r.readAsDataURL(e)})}a(cm,`blobToBase64`);async function lm(e){console.debug(`[favicon-detector] Starting favicon detection for:`,e);try{let t;if(t=e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e.includes(`://`)?e.split(`://`)[1].split(`/`)[0]:e.split(`/`)[0],console.debug(`[favicon-detector] Extracted domain:`,t),om(t))return console.debug(`[favicon-detector] Skipping local server:`,t),null;let n=sm(t);console.debug(`[favicon-detector] Domains to try:`,n);for(let e of n)try{let t=`https://favicon.tools.mcp-use.com/${e}?response=json`;console.debug(`[favicon-detector] Attempting to fetch favicon metadata for:`,e,`from:`,t);let n=new AbortController,r=setTimeout(()=>n.abort(),2e3);try{let i=await fetch(t,{signal:n.signal});if(clearTimeout(r),!i.ok){console.debug(`[favicon-detector] Fetch failed for`,e,`with status:`,i.status);continue}let a=await i.json();console.debug(`[favicon-detector] Retrieved favicon metadata for:`,e,`source:`,a.source);let o=a.url.replace(/^http:\/\//,`https://`),s=await fetch(o);if(!s.ok){console.debug(`[favicon-detector] Failed to fetch favicon image for`,e,`status:`,s.status);continue}let c=await s.blob(),l=await cm(c);if(a.source===`default`){console.debug(`[favicon-detector] Found default favicon for:`,e,`skipping and continuing to search for non-default`);continue}return console.debug(`[favicon-detector] Successfully retrieved non-default favicon for:`,e,`source:`,a.source,`size:`,c.size,`bytes`),l}catch(t){clearTimeout(r),console.debug(`[favicon-detector] Fetch error for`,e,`:`,t instanceof Error?t.message:String(t));continue}}catch(t){console.debug(`[favicon-detector] Error processing domain`,e,`:`,t instanceof Error?t.message:String(t));continue}return console.debug(`[favicon-detector] No non-default favicon found for:`,e,`returning null to show gradient fallback`),null}catch(e){return console.warn(`[favicon-detector] Error detecting favicon:`,e),null}}a(lm,`detectFavicon`);function um(e,t){let n=t?.headers??t?.customHeaders??{};if(t?.customHeaders&&!t?.headers&&console.warn(`[applyProxyConfig] The "customHeaders" option in proxyConfig is deprecated. Use "headers" instead.`),!t?.proxyAddress)return{url:e,headers:n};let r=new URL(t.proxyAddress),i=new URL(e);return{url:`${r.origin}${r.pathname}${i.pathname}${i.search}`,headers:{"X-Target-URL":e,...n}}}a(um,`applyProxyConfig`);var dm=`inspector-server`;function fm(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}a(fm,`deriveOAuthClientConfigFromClientInfo`);function pm(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`)}a(pm,`isOAuthDiscoveryFailure`);function mm(e){if(!e)return;let t=new URL(e),n=t.pathname.replace(/\/proxy\/?$/,``);return`${t.origin}${n}/oauth`}a(mm,`deriveOAuthProxyUrl`);function hm(e){let t=mm(e.gatewayUrl),n=new V(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});return t&&e.installFetchInterceptor&&n.installFetchInterceptor(),{provider:n,oauthProxyUrl:t}}a(hm,`createBrowserOAuthProvider`);function gm(e){let t=null,n=Date.now(),r=e.healthCheckIntervalMs??1e4,i=e.healthCheckTimeoutMs??3e4;return t=setInterval(a(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)))}},`checkConnectionHealth`),r),()=>{t&&=(clearInterval(t),null)}}a(gm,`startConnectionHealthMonitoring`);var _m=3e3,vm=5e3;function ym(e){let{url:t,enabled:n=!0,callbackUrl:r=typeof window<`u`?B(new URL(`/oauth/callback`,window.location.origin).toString()):`/oauth/callback`,storageKeyPrefix:i=`mcp:auth`,clientConfig:c={},authProvider:l,headers:u,customHeaders:d,proxyConfig:f,autoProxyFallback:p=!0,debug:m=!1,logLevel:h,autoRetry:g=!1,autoReconnect:_=_m,reconnectionOptions:v,transportType:y=`auto`,preventAutoAuth:x=!0,useRedirectFlow:S=!1,onPopupWindow:C,timeout:T=3e4,sseReadTimeout:E=3e5,wrapTransport:D,fetch:O,clientOptions:k,onNotification:A,onSampling:j,samplingCallback:M,onElicitation:N,elicitationCallback:P}=e,F=(0,W.useMemo)(()=>{let e=`useMcp:${t||`no-url`}`,n=s.get(e);return h?n.level=h:m&&(n.level=`debug`),n},[t,h,m]),I=u??d??{};d&&!u&&F.warn(`[useMcp] The "customHeaders" option is deprecated. Use "headers" instead.`);let R=j??M;M&&!j&&F.warn(`[useMcp] The "samplingCallback" option is deprecated. Use "onSampling" instead.`);let z=N??P;P&&!N&&o.warn(`[useMcp] The "elicitationCallback" option is deprecated. Use "onElicitation" instead.`);let V=(0,W.useMemo)(()=>({name:`mcp-use`,title:`mcp-use`,version:b(),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`}),[]),te=(0,W.useMemo)(()=>e.clientInfo?{...V,...e.clientInfo}:V,[e.clientInfo,V]),ne=(0,W.useMemo)(()=>fm(te),[te]),H=(0,W.useMemo)(()=>c&&Object.keys(c).length>0?(F.warn(`[useMcp] The 'clientConfig' option is deprecated and will be removed in a future version. Use 'clientInfo' instead. The clientConfig will be automatically derived from clientInfo.`),{...ne,...c}):ne,[c,ne]),re=(0,W.useMemo)(()=>p?typeof p==`boolean`?{enabled:p,proxyAddress:`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:p.enabled!==!1,proxyAddress:p.proxyAddress||`https://inspector.mcp-use.com/inspector/api/proxy`}:{enabled:!1,proxyAddress:void 0},[p]),ie=(0,W.useMemo)(()=>_===!1?{enabled:!1,initialDelay:0,healthCheckInterval:!1,healthCheckTimeout:3e4}:_===!0?{enabled:!0,initialDelay:_m,healthCheckInterval:1e4,healthCheckTimeout:3e4}:typeof _==`number`?{enabled:!0,initialDelay:_,healthCheckInterval:1e4,healthCheckTimeout:3e4}:{enabled:_.enabled!==!1,initialDelay:_.initialDelay??_m,healthCheckInterval:_.healthCheckInterval??1e4,healthCheckTimeout:_.healthCheckTimeout??3e4},[_]),ae=(0,W.useRef)(!1),[oe,se]=(0,W.useState)(f);(0,W.useEffect)(()=>{se(f)},[f]);let{gatewayUrl:ce,proxyHeaders:le}=(0,W.useMemo)(()=>{let e=um(t||``,f);return{gatewayUrl:f?.proxyAddress,proxyHeaders:e.headers}},[t,f]),ue=(0,W.useMemo)(()=>t||``,[t]),de=(0,W.useMemo)(()=>({...le,...I}),[le,I]),[fe,pe]=(0,W.useState)(`discovering`),[U,me]=(0,W.useState)([]),[he,ge]=(0,W.useState)([]),[_e,ve]=(0,W.useState)([]),[ye,be]=(0,W.useState)([]),[xe,Se]=(0,W.useState)(e._initialServerInfo?.name?e._initialServerInfo:void 0),[Ce,we]=(0,W.useState)(),[Te,Ee]=(0,W.useState)(void 0),[De,Oe]=(0,W.useState)([]),[ke,Ae]=(0,W.useState)(void 0),[je,Me]=(0,W.useState)(void 0),Ne=(0,W.useRef)(null),Pe=(0,W.useRef)(l??null),Fe=(0,W.useRef)(null),Ie=(0,W.useRef)(!1),Le=(0,W.useRef)(!0),Re=(0,W.useRef)(0),ze=(0,W.useRef)(null),Be=(0,W.useRef)(!1),Ve=(0,W.useRef)(fe),He=(0,W.useRef)(_),Ue=(0,W.useRef)(null),We=(0,W.useRef)(null),Ge=(0,W.useRef)(null);(0,W.useEffect)(()=>{Ve.current=fe,He.current=_},[fe,_]),(0,W.useEffect)(()=>{Pe.current=l??null},[l]);let G=(0,W.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`:F.error(i);break;case`warn`:F.warn(i);break;case`info`:F.info(i);break;case`debug`:F.debug(i);break;default:F.info(i)}Le.current&&Oe(t=>[...t.slice(-100),{level:e,message:r,timestamp:Date.now()}])},[F]),Ke=(0,W.useCallback)(async(e=!1)=>{if(e||G(`info`,`Disconnecting...`),Ie.current=!1,ze.current&&clearTimeout(ze.current),ze.current=null,Ne.current)try{let e=dm,t=Ne.current.getSession(e);t&&t._healthCheckCleanup&&(t._healthCheckCleanup(),t._healthCheckCleanup=null),t&&await Ne.current.closeSession(e)}catch(t){e||G(`warn`,`Error closing session:`,t)}Ne.current=null,Le.current&&!e&&(pe(`discovering`),me([]),ge([]),ve([]),be([]),Ee(void 0),Ae(void 0))},[G]),qe=(0,W.useCallback)((e,n)=>{G(`error`,e,n??``);let r=n&&`code`in n?n.code:void 0,i=re.enabled&&!oe?.proxyAddress,a=e.includes(`CORS`)||e.includes(`blocked by CORS policy`)||e.includes(`Failed to fetch`),o=r===400;if(i&&(a||o||typeof r==`number`&&r>=404&&r<500)&&!(r===401||r===403))return G(`info`,`Direct connection failed with ${a?`CORS error`:o?`HTTP 400 (Bad Request)`:`HTTP 4xx error`}. Trying with proxy...`),Ne.current=null,l||(Pe.current=null),G(`debug`,`Cleared client and auth provider for proxy fallback`),se({proxyAddress:re.proxyAddress}),Le.current&&pe(`discovering`),setTimeout(()=>{Le.current&&We.current?.()},1e3),!0;if(Le.current){G(`info`,`Setting state to FAILED:`,e),pe(`failed`),Ee(e);let t=Pe.current?.getLastAttemptedAuthUrl?.();t&&(Ae(t),G(`info`,`Manual authentication URL may be available.`,t))}return Ie.current=!1,t&&w.getInstance().trackUseMcpConnection({url:t,transportType:y,success:!1,errorType:n?.name||`UnknownError`,hasOAuth:!!Pe.current,hasSampling:!!R,hasElicitation:!!z}).catch(()=>{}),!1},[G,t,y,R,z,re,oe,l]),Je=(0,W.useCallback)(async()=>{if(!n||!t){G(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`);return}if(Ie.current){G(`debug`,`Connection attempt already in progress.`);return}if(!Le.current){G(`debug`,`Connect called after unmount, aborting.`);return}if(Ie.current=!0,Re.current+=1,Ee(void 0),Ae(void 0),Ue.current=null,pe(`discovering`),G(`info`,`Connecting attempt #${Re.current} to ${t}...`),!Pe.current){let{provider:e,oauthProxyUrl:t}=hm({effectiveOAuthUrl:ue,storageKeyPrefix:i,oauthClientConfig:H,callbackUrl:r,preventAutoAuth:x,useRedirectFlow:S,gatewayUrl:ce,onPopupWindow:C,installFetchInterceptor:!0});Pe.current=e,t&&G(`debug`,`OAuth proxy URL derived from gateway: ${t}`),G(`debug`,`BrowserOAuthClientProvider initialized with URL: ${ue}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ce?`enabled`:`disabled`}`)}Ne.current?G(`debug`,`BrowserMCPClient already exists, reusing.`):(Ne.current=new ee,G(`debug`,`BrowserMCPClient initialized in connect.`));let e=a(async n=>{if(!Le.current)return G(`debug`,`Connection attempt aborted - component unmounted`),`failed`;G(`info`,`Attempting connection with transport: ${n}`),G(`debug`,`Client ref status at start of tryConnectWithTransport: ${Ne.current?`initialized`:`NULL`}`);try{let e=dm,r={url:t,transport:n===`sse`?`http`:n,timeout:T,sseReadTimeout:E,disableSseFallback:y===`http`,preferSse:n===`sse`,clientInfo:te,...O&&{fetch:O},...k&&{clientOptions:k},...v?{reconnectionOptions:v}:_===!1?{reconnectionOptions:{maxRetries:0}}:{}};if(ce&&(r.gatewayUrl=ce,G(`debug`,`Using proxy gateway: ${ce} for target: ${t}`)),de&&Object.keys(de).length>0&&(r.headers=de),!Ne.current){if(!Le.current)return G(`debug`,`Connection aborted - component unmounted, client cleaned up`),`failed`;let e=Error(`Client not initialized - this is a bug in the connection flow`);throw G(`error`,`Client ref is null in tryConnectWithTransport but component is still mounted`),e}Ne.current.addServer(e,{...r,authProvider:Pe.current,onSampling:R,onElicitation:z,wrapTransport:D?n=>(G(`debug`,`Applying transport wrapper for server:`,e,`url:`,t),D(n,t)):void 0});let i=await Ne.current.createSession(e,!1);if(!Le.current)return G(`debug`,`Connection aborted after session creation - component unmounted`),`failed`;if(i.on(`notification`,e=>{G(`debug`,`Notification received:`,e.method,e),A?.(e),e.method===`notifications/tools/list_changed`?(G(`info`,`Tools list changed, auto-refreshing...`),nt().catch(e=>{G(`warn`,`Auto-refresh tools failed:`,e)})):e.method===`notifications/resources/list_changed`?(G(`info`,`Resources list changed, auto-refreshing...`),rt().catch(e=>G(`warn`,`Auto-refresh resources failed:`,e))):e.method===`notifications/prompts/list_changed`&&(G(`info`,`Prompts list changed, auto-refreshing...`),it().catch(e=>G(`warn`,`Auto-refresh prompts failed:`,e)))}),await i.initialize(),!Le.current)return G(`debug`,`Connection completed but component unmounted, aborting`),`failed`;if(G(`info`,`✅ Successfully connected to MCP server`),G(`info`,`Server info:`,i.connector.serverInfo),G(`info`,`Server capabilities:`,i.connector.serverCapabilities),!Le.current)return G(`debug`,`Skipping state update - component unmounted`),`failed`;pe(`ready`),Ue.current=n,ie.enabled&&ie.healthCheckInterval!==!1&&(i._healthCheckCleanup=gm({gatewayUrl:ce,url:t,allHeaders:de,getAuthHeaders:a(async()=>{try{let e=await Pe.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{}},`getAuthHeaders`),isMountedRef:Le,stateRef:Ve,autoReconnectRef:He,setState:pe,addLog:G,connect:Je,defaultReconnectDelay:ie.initialDelay,healthCheckIntervalMs:ie.healthCheckInterval,healthCheckTimeoutMs:ie.healthCheckTimeout})),w.getInstance().trackUseMcpConnection({url:t,transportType:n,success:!0,hasOAuth:!!Pe.current,hasSampling:!!R,hasElicitation:!!z}).catch(()=>{}),me(i.connector.tools||[]);let o=await i.connector.listAllResources();if(!Le.current)return G(`debug`,`Connection aborted after listing resources - component unmounted`),`failed`;ge(o.resources||[]);let s=await i.connector.listPrompts();if(!Le.current)return G(`debug`,`Connection aborted after listing prompts - component unmounted`),`failed`;if(be(s.prompts||[]),i.connector.serverCapabilities?.resourceTemplates){let e=await i.connector.listResourceTemplates();if(!Le.current)return G(`debug`,`Connection aborted after listing resource templates - component unmounted`),`failed`;ve(e.resourceTemplates||[])}else ve([]);let c=i.connector.serverInfo,l=i.connector.serverCapabilities;if(c){if(G(`debug`,`Server info:`,c),!Le.current)return G(`debug`,`Skipping state update - component unmounted`),`failed`;Se(c),Fe.current=(async()=>{try{let e=c.icons;if(e&&Array.isArray(e)&&e.length>0){let t=e[0].src||e[0].url;if(t){G(`info`,`Server provided icon:`,t);let e=await(await fetch(t)).blob(),n=await new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)});return Le.current&&(Se(e=>e?{...e,icon:n}:void 0),G(`debug`,`Server icon converted to base64`)),n}}if(t){let e=await lm(t);if(!Le.current)return G(`debug`,`Connection aborted after favicon detection - component unmounted`),null;if(e)return Se(t=>t?{...t,icon:e}:void 0),G(`debug`,`Favicon detected and added to serverInfo`),e}return null}catch(e){return G(`debug`,`Icon loading failed (non-critical):`,e),null}})()}if(l){if(G(`debug`,`Server capabilities:`,l),!Le.current)return G(`debug`,`Skipping state update - component unmounted`),`failed`;we(l)}if(Pe.current){let e=await Pe.current.tokens?.();if(!Le.current)return G(`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;if(!Le.current)return G(`debug`,`Skipping state update - component unmounted`),`failed`;Me({access_token:e.access_token,token_type:e.token_type||`Bearer`,expires_at:t,refresh_token:e.refresh_token,scope:e.scope})}}return`success`}catch(r){let i=r,a=i?.message||String(r),o=pm(r),s=i.code===401||a.includes(`401`)||a.includes(`Unauthorized`);if(o&&I&&Object.keys(I).length>0)return qe(`Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct.`),`failed`;if(o&&(!I||Object.keys(I).length===0))return qe(`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(s){if(o)return qe(`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(Pe.current)if(G(`info`,`Authentication required. OAuth provider available.`),x){if(G(`info`,`Waiting for user to initiate authentication flow...`),Le.current){pe(`pending_auth`);let e=Pe.current?.getLastAttemptedAuthUrl?.();e&&(Ae(e),G(`info`,`Retrieved stored auth URL for manual authentication`))}return Ie.current=!1,`auth_redirect`}else{G(`info`,`Triggering automatic OAuth authentication flow...`);try{let{resourceMetadataUrl:r,scope:i}=await im(t);if(await L(Pe.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i}})===`REDIRECT`){let e=await Pe.current.getAuthorizationCode?.();if(!e)throw Error(`Authorization code not captured by headless provider`);await L(Pe.current,{serverUrl:t,...r&&{resourceMetadataUrl:r},...i&&{scope:i},authorizationCode:e})}return G(`info`,`OAuth flow completed, reconnecting...`),await e(n)}catch(e){return qe(`Automatic OAuth authentication failed: ${e instanceof Error?e.message:String(e)}`,e instanceof Error?e:Error(String(e))),`failed`}}return I&&Object.keys(I).length>0?(qe(`Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct.`),`failed`):(qe(`Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY).`),`failed`)}return qe(a,i instanceof Error?i:Error(String(i)))?`auth_redirect`:`failed`}},`tryConnectWithTransport`),o=`failed`;if(y===`sse`)G(`debug`,`Using SSE-only transport mode`),o=await e(`sse`);else if(y===`http`)G(`debug`,`Using HTTP-only transport mode`),o=await e(`http`);else{G(`debug`,`Using auto transport mode (HTTP with SSE fallback)`);let t=await e(`http`);t===`fallback`&&Le.current&&Ve.current!==`authenticating`?(G(`info`,`HTTP failed, attempting SSE fallback...`),o=await e(`sse`)):o=t}(o===`success`||o===`failed`||o===`auth_redirect`)&&(Ie.current=!1),G(`debug`,`Connection sequence finished with status: ${o}`)},[G,qe,Ke,t,i,r,H.name,H.version,H.uri,H.logo_uri,I,y,x,S,C,n,T,E,te,ce,de,ue]);(0,W.useEffect)(()=>{We.current=Je,Ge.current=qe},[Je,qe]);let Ye=(0,W.useCallback)(async(e,t,n)=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot call tool "${e}".`);G(`info`,`Calling tool: ${e}`,t);let r=Date.now();try{let i=dm,a=Ne.current.getSession(i);if(!a)throw Error(`No active session found`);let o=await a.connector.callTool(e,t||{},n);return G(`info`,`Tool "${e}" call successful:`,o),w.getInstance().trackUseMcpToolCall({toolName:e,success:!0,executionTimeMs:Date.now()-r}).catch(()=>{}),o}catch(t){throw G(`error`,`Tool "${e}" call failed:`,t),w.getInstance().trackUseMcpToolCall({toolName:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`,executionTimeMs:Date.now()-r}).catch(()=>{}),t}},[fe]),Xe=(0,W.useCallback)(()=>{Ve.current===`failed`?(G(`info`,`Retry requested...`),We.current?.()):G(`warn`,`Retry called but state is not 'failed' (state: ${Ve.current}). Ignoring.`)},[G]),Ze=(0,W.useCallback)(async()=>{G(`info`,`Manual authentication requested...`);let e=Ve.current;if(e===`failed`)G(`info`,`Attempting to reconnect and authenticate via retry...`),Xe();else if(e===`pending_auth`){G(`info`,`Proceeding with authentication from pending state...`);try{if(am(Pe.current,`Auth Provider not available for manual auth`),am(t,`Server URL is required for authentication`),l){G(`info`,`Using provided authProvider for manual authentication`);let e=new URL(t).origin;await L(Pe.current,{serverUrl:e}),We.current?.();return}G(`info`,`Cleared ${Pe.current.clearStorage?.()??0} OAuth storage item(s) for fresh authentication`),pe(`authenticating`);let{provider:e,oauthProxyUrl:n}=hm({effectiveOAuthUrl:ue,storageKeyPrefix:i,oauthClientConfig:H,callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:S,gatewayUrl:ce,onPopupWindow:C,installFetchInterceptor:!ce});n&&!ce?G(`info`,`Installed OAuth fetch interceptor for manual auth`):n&&ce&&G(`info`,`Using MCP gateway proxy for OAuth (no fetch interceptor needed)`),Pe.current=e,G(`info`,`Triggering fresh OAuth authorization...`);let a=new URL(t).origin;try{await L(e,{serverUrl:a}),G(`info`,`OAuth flow completed (tokens obtained)`)}catch(e){G(`info`,`OAuth flow initiated (popup/redirect):`,e instanceof Error?e.message:`Redirecting...`)}let o=e.getLastAttemptedAuthUrl?.();o&&(Ae(o),G(`info`,`Updated auth URL for fallback:`,o))}catch(e){if(!Le.current)return;pe(`pending_auth`),G(`error`,`Manual authentication failed: ${e instanceof Error?e.message:String(e)}`)}}else if(e===`authenticating`){G(`warn`,`Already attempting authentication. Check for blocked popups or wait for timeout.`);let e=Pe.current?.getLastAttemptedAuthUrl?.();e&&!ke&&(Ae(e),G(`info`,`Manual authentication URL retrieved:`,e))}else G(`info`,`Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`)},[G,Xe,ke,t,S,C,i,H.name,H.uri,H.logo_uri,r,te,l]),Qe=(0,W.useCallback)(()=>{Pe.current?.clearStorage?(G(`info`,`Cleared ${Pe.current.clearStorage()} item(s) from localStorage for ${t}.`),Ae(void 0),Ke()):G(`warn`,`Auth provider not initialized, cannot clear storage.`)},[t,G,Ke]),$e=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot list resources.`);G(`info`,`Listing resources`);try{let e=dm,t=Ne.current.getSession(e);if(!t)throw Error(`No active session found`);ge((await t.connector.listAllResources()).resources||[]),G(`info`,`Resources listed successfully`)}catch(e){throw G(`error`,`List resources failed:`,e),e}},[fe]),et=(0,W.useCallback)(async e=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot read resource.`);G(`info`,`Reading resource: ${e}`);try{let t=dm,n=Ne.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.connector.readResource(e);return G(`info`,`Resource read successful:`,r),w.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!0}).catch(()=>{}),r}catch(t){throw G(`error`,`Resource read failed:`,t),w.getInstance().trackUseMcpResourceRead({resourceUri:e,success:!1,errorType:t instanceof Error?t.name:`UnknownError`}).catch(()=>{}),t}},[fe]),tt=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot list prompts.`);G(`info`,`Listing prompts`);try{let e=dm,t=Ne.current.getSession(e);if(!t)throw Error(`No active session found`);be((await t.connector.listPrompts()).prompts||[]),G(`info`,`Prompts listed successfully`)}catch(e){throw G(`error`,`List prompts failed:`,e),e}},[fe]),nt=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current){G(`debug`,`Cannot refresh tools - client not ready. State:`,Ve.current);return}G(`debug`,`Refreshing tools list`);try{let e=dm,t=Ne.current.getSession(e);if(!t){G(`warn`,`No active session found for tools refresh`);return}G(`debug`,`Calling listTools...`);let n=await t.connector.listTools();G(`debug`,`listTools returned:`,n?.length,`tools`),me(n||[]),G(`info`,`Tools list refreshed successfully`)}catch(e){G(`error`,`Failed to refresh tools:`,e)}},[G]),rt=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current){G(`debug`,`Cannot refresh resources - client not ready`);return}G(`debug`,`Refreshing resources list`);try{let e=dm,t=Ne.current.getSession(e);if(!t){G(`warn`,`No active session found for resources refresh`);return}ge((await t.connector.listAllResources()).resources||[]),G(`info`,`Resources list refreshed successfully`)}catch(e){G(`warn`,`Failed to refresh resources:`,e)}},[G]),it=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current){G(`debug`,`Cannot refresh prompts - client not ready`);return}G(`debug`,`Refreshing prompts list`);try{let e=dm,t=Ne.current.getSession(e);if(!t){G(`warn`,`No active session found for prompts refresh`);return}be((await t.connector.listPrompts()).prompts||[]),G(`info`,`Prompts list refreshed successfully`)}catch(e){G(`warn`,`Failed to refresh prompts:`,e)}},[G]),at=(0,W.useCallback)(async()=>{if(Ve.current!==`ready`||!Ne.current){G(`debug`,`Cannot refresh resource templates - client not ready`);return}G(`debug`,`Refreshing resource templates list`);try{let e=dm,t=Ne.current.getSession(e);if(!t)throw Error(`No active session found`);let n=await t.connector.listResourceTemplates();Le.current&&(ve(n.resourceTemplates||[]),G(`info`,`Resource templates refreshed: ${n.resourceTemplates?.length||0} templates`))}catch(e){throw G(`error`,`Failed to refresh resource templates:`,e),e}},[G]),ot=(0,W.useCallback)(async()=>{G(`info`,`Refreshing all lists (tools, resources, resource templates, prompts)`),await Promise.all([nt(),rt(),at(),it()])},[nt,rt,at,it,G]),st=(0,W.useCallback)(async(e,t)=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot get prompt.`);G(`info`,`Getting prompt: ${e}`,t);try{let n=dm,r=Ne.current.getSession(n);if(!r)throw Error(`No active session found`);let i=await r.connector.getPrompt(e,t||{});return G(`info`,`Prompt "${e}" retrieved successfully:`,i),i}catch(t){throw G(`error`,`Prompt "${e}" retrieval failed:`,t),t}},[fe,G]),ct=(0,W.useCallback)(async e=>{if(Ve.current!==`ready`||!Ne.current)throw Error(`MCP client is not ready (current state: ${fe}). Cannot request completion.`);G(`info`,`Requesting completions for ${e.ref.type===`ref/prompt`?`prompt`:`resource template`} "${e.ref.type===`ref/prompt`?e.ref.name:e.ref.uri}"`);try{let t=dm,n=Ne.current.getSession(t);if(!n)throw Error(`No active session found`);let r=await n.complete(e);return G(`info`,`Received ${r.completion.values.length} completion suggestions`),r}catch(e){throw G(`error`,`Completion request failed:`,e),e}},[fe,G]);(0,W.useEffect)(()=>{let e=a(e=>{e.origin===window.location.origin&&e.data?.type===`mcp_auth_callback`&&(G(`info`,`Received auth callback message.`,e.data),ze.current&&clearTimeout(ze.current),ze.current=null,e.data.success?(G(`info`,`Authentication successful via popup. Reconnecting client...`),Ie.current&&G(`debug`,`Connection attempt already in progress, resetting flag to allow reconnection.`),Ie.current=!1,setTimeout(()=>{Le.current&&(G(`debug`,`Initiating reconnection after successful auth callback.`),We.current?.())},100)):Ge.current?.(`Authentication failed in callback: ${e.data.error||`Unknown reason.`}`))},`messageHandler`);return window.addEventListener(`message`,e),G(`debug`,`Auth callback message listener added.`),()=>{window.removeEventListener(`message`,e),G(`debug`,`Auth callback message listener removed.`),ze.current&&clearTimeout(ze.current)}},[G]),(0,W.useEffect)(()=>{ae.current=!1,se(f)},[t,f]),(0,W.useEffect)(()=>{if(Le.current=!0,!n||!t)return G(`debug`,n?`No server URL provided, skipping connection.`:`Connection disabled via enabled flag.`),pe(`discovering`),()=>{Le.current=!1};if(G(`debug`,`useMcp mounted, initiating connection.`),Re.current=0,l)Pe.current=l,G(`debug`,`Using externally provided authProvider`);else if(!Pe.current||Pe.current.serverUrl!==ue){let{provider:e,oauthProxyUrl:t}=hm({effectiveOAuthUrl:ue,storageKeyPrefix:i,oauthClientConfig:H,callbackUrl:r,preventAutoAuth:x,useRedirectFlow:S,gatewayUrl:ce,onPopupWindow:C,installFetchInterceptor:!0});Pe.current=e,t&&G(`debug`,`OAuth proxy URL derived from gateway: ${t}`),G(`debug`,`BrowserOAuthClientProvider initialized/updated with URL: ${ue}, proxy: ${t?`enabled`:`disabled`}, gateway: ${ce?`enabled`:`disabled`}`)}return Je(),()=>{if(Le.current=!1,G(`debug`,`useMcp unmounting, disconnecting.`),(Ve.current===`authenticating`||Ve.current===`pending_auth`)&&Pe.current)try{let e=Pe.current.clearStorage?.()??0;e>0&&G(`debug`,`Cleared ${e} OAuth state item(s) during unmount to prevent corruption`)}catch(e){G(`debug`,`Error clearing OAuth state during unmount:`,e)}Ke(!0)}},[t,n,i,r,H.name,H.version,H.uri,H.logo_uri,S,te,ue,f,l]);let lt=(0,W.useRef)(Xe),ut=(0,W.useRef)(G);(0,W.useEffect)(()=>{lt.current=Xe,ut.current=G},[Xe,G]),(0,W.useEffect)(()=>{let e=null;if(fe===`failed`&&g&&Re.current>0){if(!Be.current){Be.current=!0;let t=typeof g==`number`?g:vm;ut.current(`info`,`Connection failed, auto-retrying in ${t}ms...`),e=setTimeout(()=>{Be.current=!1,Le.current&&Ve.current===`failed`&&lt.current()},t)}}else fe!==`failed`&&(Be.current=!1);return()=>{e&&(clearTimeout(e),Be.current=!1)}},[fe,g]);let dt=(0,W.useCallback)(async()=>Ve.current===`ready`?xe?.icon?xe.icon:Fe.current?(G(`debug`,`Waiting for icon to finish loading...`),await Fe.current):(G(`debug`,`No icon available and no loading in progress`),null):(G(`warn`,`Cannot ensure icon loaded - not connected`),null),[xe,G]);return{state:fe,name:xe?.name||t||``,tools:U,resources:he,resourceTemplates:_e,prompts:ye,serverInfo:xe,capabilities:Ce,error:Te,log:De,authUrl:ke,authTokens:je,client:Ne.current,callTool:Ye,readResource:et,listResources:$e,listPrompts:tt,getPrompt:st,complete:ct,refreshTools:nt,refreshResources:rt,refreshResourceTemplates:at,refreshPrompts:it,refreshAll:ot,retry:Xe,disconnect:Ke,authenticate:Ze,clearStorage:Qe,ensureIconLoaded:dt}}a(ym,`useMcp`);var bm=`__model_context`,xm=new Map;function Sm(e){xm.set(e.id,e),Tm()}a(Sm,`setNode`);function Cm(e){xm.delete(e),Tm()}a(Cm,`removeNode`);var wm=!1;function Tm(){wm||(wm=!0,queueMicrotask(Em))}a(Tm,`scheduleFlush`);function Em(){wm=!1,Am(Dm())}a(Em,`flush`);function Dm(){let e=new Map;for(let t of xm.values()){let n=t.parentId??null;e.has(n)||e.set(n,[]),e.get(n).push(t)}for(let t of e.values())t.sort((e,t)=>e.id.localeCompare(t.id));let t=[];function n(r,i){let a=e.get(r);if(a)for(let e of a)e.content.trim()&&t.push(`${` `.repeat(i)}- ${e.content.trim()}`),n(e.id,i+1)}return a(n,`traverseTree`),n(null,0),t.join(`
341
341
  `)}a(Dm,`buildDescriptionString`);var Om=null;function km(e){return Om=e,e(Dm()),()=>{Om===e&&(Om=null)}}a(km,`registerModelContextFlush`);function Am(e){Om?.(e)}a(Am,`notifyHost`);var jm=(0,W.createContext)(null);function Mm({content:e,children:t}){let n=(0,W.useContext)(jm),r=(0,W.useId)();return(0,W.useEffect)(()=>(e.trim()&&Sm({id:r,parentId:n,content:e}),()=>{Cm(r)}),[r,n,e]),t==null?null:W.createElement(jm.Provider,{value:r},t)}a(Mm,`ModelContext`);var Nm=s.get(`ErrorBoundary`),Pm=class extends W.Component{static{a(this,`ErrorBoundary`)}constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){Nm.error(`Widget Error:`,e,t),this.props.onError?.(e,t)}render(){return this.state.hasError&&this.state.error?this.props.fallback===void 0?W.createElement(`div`,{className:`p-4 border border-red-500 bg-red-50 text-red-900 rounded-md dark:bg-red-900/20 dark:text-red-100`},W.createElement(`h3`,{className:`font-bold mb-2`},`Widget Error`),W.createElement(`pre`,{className:`text-sm whitespace-pre-wrap`},this.state.error.message)):typeof this.props.fallback==`function`?this.props.fallback(this.state.error):this.props.fallback:this.props.children}};function Fm(e,t){return{jsonrpc:`2.0`,method:e,...t&&{params:t}}}a(Fm,`createNotification`);function Im(e,t,n){return{jsonrpc:`2.0`,id:e,method:t,...n&&{params:n}}}a(Im,`createRequest`);var Lm={POLL_INTERVAL:100,MAX_TIMEOUT:5e3,MAX_HEIGHT:600,LOCALE:`en`},Rm={REQUEST_TIMEOUT:3e4,APP_NAME:`mcp-use-widget`,APP_VERSION:`1.0.0`,PROTOCOL_VERSION:`2025-06-18`},zm=class{static{a(this,`McpAppsBridge`)}connected=!1;connectPromise=null;requestId=1;pendingRequests=new Map;listeners=new Set;toolInput=null;partialToolInput=null;toolOutput=null;toolResponseMetadata=null;hostContext=null;hostInfo=null;hostCapabilities=null;initialized=!1;toolInputHandlers=new Set;toolInputPartialHandlers=new Set;toolResultHandlers=new Set;hostContextHandlers=new Set;constructor(){if(typeof window>`u`)return;let e=a(e=>{let t=e.data;if(!(!t||t.jsonrpc!==`2.0`)){if(`result`in t||`error`in t){let e=t;if(e.id!==null&&e.id!==void 0){let t=this.pendingRequests.get(e.id);t&&(this.pendingRequests.delete(e.id),`error`in e&&e.error?t.reject(Error(e.error.message)):t.resolve(e.result))}return}`method`in t&&!(`id`in t)&&this.handleNotification(t)}},`handleMessage`);window.addEventListener(`message`,e),this.listeners.add(e),this.interceptConsole()}interceptConsole(){if(typeof window>`u`||typeof console>`u`)return;let e={log:console.log.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),info:console.info.bind(console),debug:console.debug.bind(console)},t={log:`info`,warn:`warning`,error:`error`,info:`info`,debug:`debug`},n=a((e,t=new WeakSet)=>{if(typeof e!=`object`||!e)return e;if(t.has(e))return`[Circular]`;if(e instanceof Response)return{__type:`Response`,status:e.status,statusText:e.statusText,ok:e.ok,url:e.url,headers:Object.fromEntries(e.headers.entries())};if(e instanceof Request)return{__type:`Request`,method:e.method,url:e.url,headers:Object.fromEntries(e.headers.entries())};if(e instanceof Error)return{__type:`Error`,name:e.name,message:e.message,stack:e.stack};if(e instanceof Event)return{__type:`Event`,type:e.type,target:e.target?.constructor?.name};if(typeof HTMLElement<`u`&&e instanceof HTMLElement)return{__type:`HTMLElement`,tagName:e.tagName,id:e.id,className:e.className};if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;if(Array.isArray(e))return t.add(e),e.map(e=>n(e,t));try{t.add(e);let r={};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i))try{r[i]=n(e[i],t)}catch{r[i]=`[Unserializable]`}return r}catch{return`[Object]`}},`serializeForPostMessage`),r=a((r,i)=>{try{let e=i.map(e=>n(e));this.sendNotification(`notifications/message`,{level:t[r]||`info`,logger:`console`,data:e.length===1?e[0]:e})}catch(t){e.warn(`[MCP Apps Bridge] Failed to forward console message:`,t)}},`sendLog`);console.log=(...t)=>{r(`log`,t),e.log(...t)},console.warn=(...t)=>{r(`warn`,t),e.warn(...t)},console.error=(...t)=>{r(`error`,t),e.error(...t)},console.info=(...t)=>{r(`info`,t),e.info(...t)},console.debug=(...t)=>{r(`debug`,t),e.debug(...t)}}handleNotification(e){switch(console.log(`[MCP Apps Bridge] Received notification:`,e.method,e.params),e.method){case`ui/notifications/tool-input`:{let t=e.params;console.log(`[MCP Apps Bridge] Tool input received:`,t.arguments),this.toolInput=t.arguments,this.toolInputHandlers.forEach(e=>e(t.arguments));break}case`ui/notifications/tool-input-partial`:{let t=e.params;console.log(`[MCP Apps Bridge] Partial tool input received:`,t.arguments),this.partialToolInput=t.arguments,this.toolInputPartialHandlers.forEach(e=>e(t.arguments));break}case`ui/notifications/tool-result`:{let t=e.params,n=t.structuredContent||this.parseTextContent(t),r=t._meta||null;this.toolOutput=n,this.toolResponseMetadata=r,this.partialToolInput=null,this.toolResultHandlers.forEach(e=>e(n));break}case`ui/notifications/host-context-changed`:{let t=e.params;console.log(`[MCP Apps Bridge] Host context changed:`,t),this.hostContext={...this.hostContext,...t},console.log(`[MCP Apps Bridge] Merged hostContext:`,this.hostContext),console.log(`[MCP Apps Bridge] Calling handlers:`,this.hostContextHandlers.size),this.hostContextHandlers.forEach(e=>e(this.hostContext));break}case`ui/notifications/initialized`:this.initialized=!0;break;default:break}}parseTextContent(e){if(e.content&&Array.isArray(e.content)){for(let t of e.content)if(t.type===`text`&&t.text)try{let e=JSON.parse(t.text);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{}}return{}}sendRequest(e,t){if(typeof window>`u`||!window.parent)return Promise.reject(Error(`Not in iframe context`));let n=this.requestId++,r=Im(n,e,t);return new Promise((t,i)=>{this.pendingRequests.set(n,{resolve:t,reject:i}),window.parent.postMessage(r,`*`),setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),i(Error(`Request timeout: ${e}`)))},Rm.REQUEST_TIMEOUT)})}sendNotification(e,t){if(typeof window>`u`||!window.parent)return;let n=Fm(e,t);window.parent.postMessage(n,`*`)}async connect(){if(!this.connected){if(typeof window>`u`||window===window.parent){console.log(`[MCP Apps Bridge] Not in iframe, skipping connection`);return}return this.connectPromise||(this.connectPromise=this.doConnect(),this.connectPromise.catch(()=>{this.connectPromise=null})),this.connectPromise}}async doConnect(){console.log(`[MCP Apps Bridge] Connecting to MCP Apps host...`);try{let e=await this.sendRequest(`ui/initialize`,{appCapabilities:{},appInfo:{name:Rm.APP_NAME,version:Rm.APP_VERSION},protocolVersion:Rm.PROTOCOL_VERSION});console.log(`[MCP Apps Bridge] Initialize result:`,e),e.hostContext&&(this.hostContext=e.hostContext,console.log(`[MCP Apps Bridge] Host context:`,this.hostContext)),e.hostInfo&&(this.hostInfo=e.hostInfo),e.hostCapabilities&&(this.hostCapabilities=e.hostCapabilities),this.sendNotification(`ui/notifications/initialized`,{}),this.connected=!0,console.log(`[MCP Apps Bridge] Successfully connected`)}catch(e){throw console.error(`[MCP Apps Bridge] Failed to connect:`,e),e}}isConnected(){return this.connected}getToolInput(){return this.toolInput}getPartialToolInput(){return this.partialToolInput}getToolOutput(){return this.toolOutput}getToolResponseMetadata(){return this.toolResponseMetadata}getHostContext(){return this.hostContext}getHostInfo(){return this.hostInfo}getHostCapabilities(){return this.hostCapabilities}onToolInput(e){return this.toolInputHandlers.add(e),()=>this.toolInputHandlers.delete(e)}onToolInputPartial(e){return this.toolInputPartialHandlers.add(e),()=>this.toolInputPartialHandlers.delete(e)}onToolResult(e){return this.toolResultHandlers.add(e),()=>this.toolResultHandlers.delete(e)}onHostContextChange(e){return this.hostContextHandlers.add(e),()=>this.hostContextHandlers.delete(e)}async callTool(e,t){return this.sendRequest(`tools/call`,{name:e,arguments:t})}async sendMessage(e){let t=Array.isArray(e)?e:[e];await this.sendRequest(`ui/message`,{role:`user`,content:t})}async openLink(e){await this.sendRequest(`ui/open-link`,{url:e})}async requestDisplayMode(e){return await this.sendRequest(`ui/request-display-mode`,{mode:e})}async updateModelContext(e){await this.sendRequest(`ui/update-model-context`,e)}sendSizeChanged(e){this.sendNotification(`ui/notifications/size-changed`,e)}disconnect(){this.listeners.forEach(e=>{typeof window<`u`&&window.removeEventListener(`message`,e)}),this.listeners.clear(),this.pendingRequests.clear(),this.toolInputHandlers.clear(),this.toolInputPartialHandlers.clear(),this.toolResultHandlers.clear(),this.hostContextHandlers.clear(),this.connected=!1,this.connectPromise=null}},Bm=null;function Vm(){return Bm||=new zm,Bm}a(Vm,`getMcpAppsBridge`);function Hm(e){if(e&&typeof e==`object`&&`result`in e)return e;let t=e?.content||[],n=e?.structuredContent||{},r=t.filter(e=>e.type===`text`&&e.text).map(e=>e.text).join(`
342
342
  `);return{content:t,structuredContent:n,isError:e?.isError??!1,result:r,_meta:e?._meta}}a(Hm,`normalizeCallToolResponse`);var Um=`openai:set_globals`;function Wm(e){return(0,W.useSyncExternalStore)(t=>{let n=typeof window<`u`&&window.openai?window.openai[e]:void 0,r=a(r=>{let i=r.detail.globals[e];i!==void 0&&i!==n&&(n=i,t())},`handleSetGlobal`);return typeof window<`u`&&window.addEventListener(Um,r),()=>{typeof window<`u`&&window.removeEventListener(Um,r)}},()=>typeof window<`u`&&window.openai?window.openai[e]:void 0)}a(Wm,`useOpenAiGlobal`);function Gm(e){let[t,n]=(0,W.useState)(()=>typeof window<`u`&&!!window.openai),[r,i]=(0,W.useState)(!1),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(typeof window<`u`&&window.openai){n(!0);return}let e=setInterval(()=>{typeof window<`u`&&window.openai&&(n(!0),clearInterval(e))},100),t=a(()=>{typeof window<`u`&&window.openai&&(n(!0),clearInterval(e))},`handleSetGlobals`);typeof window<`u`&&window.addEventListener(Um,t);let r=setTimeout(()=>{clearInterval(e),typeof window<`u`&&window.removeEventListener(Um,t)},5e3);return()=>{clearInterval(e),clearTimeout(r),typeof window<`u`&&window.removeEventListener(Um,t)}},[]),(0,W.useEffect)(()=>{if(typeof window>`u`||window.openai||window===window.parent)return;let e=Vm();e.connect().then(()=>{i(!0);let t=e.getToolInput(),n=e.getToolOutput(),r=e.getToolResponseMetadata(),a=e.getHostContext(),o=e.getPartialToolInput();t&&s(t),n&&l(n),r&&d(r),o&&p(o),a&&h(a);let c=e.getHostInfo(),u=e.getHostCapabilities();c&&_(c),u&&y(u)}).catch(e=>{console.warn(`[useWidget] Failed to connect to MCP Apps host:`,e)});let t=e.onToolInput(e=>{s(e)}),n=e.onToolInputPartial(e=>{p(e)}),r=e.onToolResult(t=>{l(t),d(e.getToolResponseMetadata()),p(null)}),a=e.onHostContextChange(e=>{console.log(`[useWidget] Host context change received:`,e),h(e)});return()=>{t(),n(),r(),a()}},[]);let b=(0,W.useMemo)(()=>t?`openai`:r?`mcp-apps`:`mcp-ui`,[t,r]),x=typeof window<`u`?window.location.search:``,S=(0,W.useMemo)(()=>{let e=new URLSearchParams(x);return e.has(`mcpUseParams`)?JSON.parse(e.get(`mcpUseParams`)):{toolInput:{},toolOutput:{},toolId:``}},[x]),C=Wm(`toolInput`),w=Wm(`toolOutput`),T=Wm(`toolResponseMetadata`),E=Wm(`widgetState`),D=Wm(`theme`),O=Wm(`displayMode`),k=Wm(`safeArea`),A=Wm(`maxHeight`),j=Wm(`userAgent`),M=Wm(`locale`),N=(0,W.useMemo)(()=>b===`openai`?C:b===`mcp-apps`?o:S.toolInput,[b,C,o,S.toolInput]),P=(0,W.useMemo)(()=>{if(b===`openai`){let e=w;return e&&e.structuredContent&&typeof e.structuredContent==`object`?e.structuredContent:w}return b===`mcp-apps`?c:S.toolOutput},[b,w,c,S.toolOutput]),F=(0,W.useMemo)(()=>{let t=N||{},n=e||{},r;if(b===`openai`&&w){let e=w;r=e.structuredContent&&typeof e.structuredContent==`object`?e.structuredContent:e}else b===`mcp-apps`&&c?r=c:b===`mcp-ui`&&S.toolOutput&&(r=S.toolOutput);return{...n,...t,...r||{}}},[b,N,w,c,S.toolOutput,e]),I=(0,W.useMemo)(()=>{if(b===`openai`)return D;if(b===`mcp-apps`&&m)return m.theme},[b,D,m]),L=(0,W.useMemo)(()=>{if(b===`openai`)return O;if(b===`mcp-apps`&&m)return m.displayMode},[b,O,m]),R=(0,W.useMemo)(()=>{if(b===`openai`)return k;if(b===`mcp-apps`&&m?.safeAreaInsets)return{insets:m.safeAreaInsets}},[b,k,m]),z=(0,W.useMemo)(()=>{if(b===`openai`)return A;if(b===`mcp-apps`&&m?.containerDimensions)return m.containerDimensions.maxHeight},[b,A,m]),B=(0,W.useMemo)(()=>{if(b!==`openai`&&b===`mcp-apps`&&m?.containerDimensions)return m.containerDimensions.maxWidth},[b,m]),V=(0,W.useMemo)(()=>{if(b===`openai`)return j;if(b===`mcp-apps`&&m)return{device:{type:m.platform===`mobile`?`mobile`:`desktop`},capabilities:{hover:m.deviceCapabilities?.hover??!1,touch:m.deviceCapabilities?.touch??!1}}},[b,j,m]),ee=(0,W.useMemo)(()=>{if(b===`openai`)return M;if(b===`mcp-apps`&&m)return m.locale},[b,M,m]),te=(0,W.useMemo)(()=>{if(b===`openai`)return typeof window<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0;if(b===`mcp-apps`&&m)return m.timeZone},[b,m]),ne=(0,W.useMemo)(()=>typeof window<`u`&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,``):``,[]),[H,re]=(0,W.useState)(null);(0,W.useEffect)(()=>{E!==void 0&&re(E)},[E]);let ie=(0,W.useRef)(b);ie.current=b;let ae=(0,W.useRef)(H);ae.current=H,(0,W.useEffect)(()=>km(e=>{let t=ie.current;if(t===`mcp-apps`){let t=Vm();t.isConnected()&&t.updateModelContext({structuredContent:{[bm]:e},content:[{type:`text`,text:e}]}).catch(e=>{console.warn(`[ModelContext] Failed to update model context:`,e)});return}if(t===`openai`&&window.openai?.setWidgetState){let t=window.openai.widgetState??ae.current??{};window.openai.setWidgetState({...t,[bm]:e}).catch(e=>{console.warn(`[ModelContext] Failed to set widget state:`,e)})}}),[]);let oe=(0,W.useCallback)(async(e,t)=>{if(b===`mcp-apps`)return Hm(await Vm().callTool(e,t));if(!window.openai?.callTool)throw Error(`window.openai.callTool is not available`);return Hm(await window.openai.callTool(e,t))},[b]),se=(0,W.useCallback)(async e=>{let t=typeof e==`string`?[{type:`text`,text:e}]:e;if(b===`mcp-apps`){await Vm().sendMessage(t);return}if(!window.openai?.sendFollowUpMessage)throw Error(`window.openai.sendFollowUpMessage is not available`);let n=typeof e==`string`?e:t.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
343
343
  `);return window.openai.sendFollowUpMessage({prompt:n})},[b]),ce=(0,W.useCallback)(e=>{if(b===`mcp-apps`){Vm().openLink(e).catch(e=>{console.error(`Failed to open link:`,e)});return}if(!window.openai?.openExternal)throw Error(`window.openai.openExternal is not available`);window.openai.openExternal({href:e})},[b]),le=(0,W.useCallback)(async e=>{if(b===`mcp-apps`)return await Vm().requestDisplayMode(e);if(!window.openai?.requestDisplayMode)throw Error(`window.openai.requestDisplayMode is not available`);return window.openai.requestDisplayMode({mode:e})},[b]),ue=(0,W.useCallback)(async e=>{if(b===`mcp-apps`){let t=typeof e==`function`?e(H):e;re(t);let n=Vm(),r=t;n.updateModelContext({structuredContent:r,content:[{type:`text`,text:JSON.stringify(Object.fromEntries(Object.entries(r).filter(([e])=>e!==bm)))}]}).catch(e=>{console.warn(`[useWidget] Failed to update model context:`,e)});return}if(!window.openai?.setWidgetState)throw Error(`window.openai.setWidgetState is not available`);let t=typeof e==`function`?e(E===void 0?H:E):e,n=(window.openai.widgetState??{})[bm];return re(t),window.openai.setWidgetState(n===void 0?t:{...t,[bm]:n})},[b,E,H]),de=(0,W.useMemo)(()=>b===`openai`?w===null&&T===null:b===`mcp-apps`?c===null:b===`mcp-ui`?typeof window<`u`&&window!==window.parent&&!S.toolId?!0:P==null:!1,[b,w,T,c,P,S.toolId]),fe=(0,W.useMemo)(()=>b===`mcp-apps`&&f?f:null,[b,f]),pe=(0,W.useMemo)(()=>b===`mcp-apps`?f!==null:!1,[b,f]);return{props:F,toolInput:N||{},output:P??null,metadata:b===`mcp-apps`?u??null:T??null,state:H?Object.fromEntries(Object.entries(H).filter(([e])=>e!==bm)):null,setState:ue,theme:I||`light`,displayMode:L||`inline`,safeArea:R||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:z||600,maxWidth:B,userAgent:V||{device:{type:`desktop`},capabilities:{hover:!0,touch:!1}},locale:ee||Lm.LOCALE,timeZone:te||(typeof window<`u`?Intl.DateTimeFormat().resolvedOptions().timeZone:`UTC`),mcp_url:ne,callTool:oe,sendFollowUpMessage:se,openExternal:ce,requestDisplayMode:le,isAvailable:t||r,isPending:de,partialToolInput:fe,isStreaming:pe,hostInfo:g??void 0,hostCapabilities:v??void 0}}a(Gm,`useWidget`);function Km(e){let{props:t}=Gm(e);return t}a(Km,`useWidgetProps`);function qm(){let{theme:e}=Gm();return e}a(qm,`useWidgetTheme`);function eee(e){let{state:t,setState:n}=Gm();return(0,W.useEffect)(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}a(eee,`useWidgetState`);var tee=a(({children:e})=>{let{theme:t,isAvailable:n}=Gm(),[r,i]=(0,W.useState)(()=>typeof window>`u`?`light`:window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`);(0,W.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=a(e=>{i(e.matches?`dark`:`light`)},`handleChange`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let o=n?t:r;return(0,W.useLayoutEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement;e.classList.remove(`light`,`dark`),e.classList.add(o===`dark`?`dark`:`light`),e.setAttribute(`data-theme`,o===`dark`?`dark`:`light`),e.style.colorScheme=o===`dark`?`dark`:`light`},[o]),W.createElement(W.Fragment,null,e)},`ThemeProvider`);function Jm({children:e,className:t=``,position:n=`top-right`,attachTo:r,showLabels:i=!0,debugger:o=!1,viewControls:s=!1}){let{props:c,output:l,metadata:u,state:d,theme:f,displayMode:p,safeArea:m,maxHeight:h,userAgent:g,locale:_,isAvailable:v,callTool:y,sendFollowUpMessage:b,openExternal:x,requestDisplayMode:S,setState:C}=Gm(),[w,T]=(0,W.useState)(!1),[E,D]=(0,W.useState)(!1),O=(0,W.useRef)(null),k=(0,W.useRef)(null),[A,j]=(0,W.useState)([]),[M,N]=(0,W.useState)(``),[P,F]=(0,W.useState)(`get-my-city`),[I,L]=(0,W.useState)(`{}`),[R,z]=(0,W.useState)(`Test follow-up message`),[B,V]=(0,W.useState)(`https://mcp-use.com/docs`),ee=p===`fullscreen`&&v,te=p===`pip`&&v,ne=typeof window<`u`&&window.location.pathname.includes(`/inspector/api/`);(0,W.useEffect)(()=>{let e=setTimeout(()=>{if(typeof window<`u`&&window.openai)try{j(Object.keys(window.openai))}catch{j([])}else j([])},100);return()=>{clearTimeout(e)}},[]);let H=f===`dark`,re=a(()=>{let e=[`absolute`,`z-[1000]`,`flex`,`gap-2`,`transition-opacity`,`duration-200`,`ease-in-out`,w?`opacity-100`:`opacity-0`,w?`pointer-events-auto`:`pointer-events-none`];switch(n){case`top-left`:return[...e,`top-4`,`left-4`];case`top-center`:return[...e,`top-4`,`left-1/2`,`-translate-x-1/2`];case`top-right`:return[...e,`top-4`,`right-4`];case`center-left`:return[...e,`top-1/2`,`left-4`,`-translate-y-1/2`];case`center-right`:return[...e,`top-1/2`,`right-4`,`-translate-y-1/2`];case`bottom-left`:return[...e,`bottom-4`,`left-4`];case`bottom-center`:return[...e,`bottom-4`,`left-1/2`,`-translate-x-1/2`];case`bottom-right`:return[...e,`bottom-4`,`right-4`];default:return[...e,`top-4`,`right-4`]}},`getPositionClasses`),ie=a(()=>{let e=m?.insets?.top?Math.max(16,m.insets.top+8):16,t=m?.insets?.right?Math.max(16,m.insets.right+8):16,r=m?.insets?.bottom?Math.max(16,m.insets.bottom+8):16,i=m?.insets?.left?Math.max(16,m.insets.left+8):16,a={};switch(n){case`top-left`:a.top=`${e}px`,a.left=`${i}px`;break;case`top-center`:a.top=`${e}px`;break;case`top-right`:a.top=`${e}px`,a.right=`${t}px`;break;case`center-left`:a.left=`${i}px`;break;case`center-right`:a.right=`${t}px`;break;case`bottom-left`:a.bottom=`${r}px`,a.left=`${i}px`;break;case`bottom-center`:a.bottom=`${r}px`;break;case`bottom-right`:a.bottom=`${r}px`,a.right=`${t}px`;break;default:a.top=`${e}px`,a.right=`${t}px`;break}return a},`getPositionOffsetStyles`);(0,W.useEffect)(()=>{if(!r)return;let e=a(()=>T(!0),`handleMouseEnter`),t=a(()=>T(!1),`handleMouseLeave`);return r.addEventListener(`mouseenter`,e),r.addEventListener(`mouseleave`,t),()=>{r.removeEventListener(`mouseenter`,e),r.removeEventListener(`mouseleave`,t)}},[r]),(0,W.useEffect)(()=>{if(!E)return;let e=a(e=>{k.current&&!k.current.contains(e.target)&&D(!1)},`handleClickOutside`);return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[E]),(0,W.useEffect)(()=>(E?document.body.style.overflow=`hidden`:document.body.style.overflow=``,()=>{document.body.style.overflow=``}),[E]);let ae=a(()=>{D(!E)},`handleToggleOverlay`),oe=a(async()=>{try{N(`Calling tool...`);let e=await y(P,I.trim()?JSON.parse(I):{});N(`Success: ${JSON.stringify(e,null,2)}`)}catch(e){N(`Error: ${e.message}`)}},`handleCallTool`),se=a(async()=>{try{N(`Sending follow-up message...`),await b(R),N(`Follow-up message sent successfully`)}catch(e){N(`Error: ${e.message}`)}},`handleSendFollowUpMessage`),ce=a(()=>{try{x(B),N(`Opened external link: ${B}`)}catch(e){N(`Error: ${e.message}`)}},`handleOpenExternal`),le=a(async e=>{try{N(`Requesting display mode: ${e}...`),N(`Display mode granted: ${(await S(e)).mode}`)}catch(e){N(`Error: ${e.message}`)}},`handleRequestDisplayMode`),ue=a(async()=>{try{let e=d?{...d,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};N(`Setting state...`),await C(e),N(`State updated: ${JSON.stringify(e,null,2)}`)}catch(e){N(`Error: ${e.message}`)}},`handleSetState`),de=a(async()=>{try{await S(`fullscreen`)}catch(e){console.error(`Failed to go fullscreen:`,e)}},`handleFullscreen`),fe=a(async()=>{try{await S(`pip`)}catch(e){console.error(`Failed to go pip:`,e)}},`handlePip`),pe=a(()=>{let e=[`absolute`,`px-2`,`py-1`,`bg-black/90`,`text-white`,`rounded`,`text-xs`,`whitespace-nowrap`,`pointer-events-none`,`transition-opacity`,`duration-200`,`ease-in-out`];switch(n){case`top-right`:return[...e,`top-full`,`right-0`,`mt-2`];case`top-left`:return[...e,`top-full`,`left-0`,`mt-2`];case`top-center`:return[...e,`top-full`,`left-1/2`,`-translate-x-1/2`,`mt-2`];case`bottom-right`:return[...e,`bottom-full`,`right-0`,`mb-2`];case`bottom-left`:return[...e,`bottom-full`,`left-0`,`mb-2`];case`bottom-center`:return[...e,`bottom-full`,`left-1/2`,`-translate-x-1/2`,`mb-2`];case`center-left`:return[...e,`left-full`,`top-1/2`,`-translate-y-1/2`,`ml-2`];case`center-right`:return[...e,`right-full`,`top-1/2`,`-translate-y-1/2`,`mr-2`];default:return[...e,`top-full`,`right-0`,`mt-2`]}},`getTooltipClasses`),U=a(({onClick:e,label:t,children:n})=>{let[r,a]=(0,W.useState)(!1),o=pe();return W.createElement(`button`,{className:`p-2 ${H?`bg-white/10 hover:bg-white/20`:`bg-black/70 hover:bg-black/90`} text-white border-none rounded-lg cursor-pointer flex items-center justify-center w-8 h-8 transition-colors duration-200 backdrop-blur-md ${H?`shadow-[0_2px_8px_rgba(0,0,0,0.3)]`:`shadow-[0_2px_8px_rgba(0,0,0,0.2)]`} relative`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),onClick:e,"aria-label":t},W.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`block`},n),i&&W.createElement(`span`,{className:`${o.join(` `)} ${r?`opacity-100`:`opacity-0`}`},t))},`IconButton`),me=a(e=>{if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)},`formatValue`),he=a(e=>e?`${e.device?.type||`unknown`}`:`N/A`,`formatUserAgent`),ge=a(e=>{if(!e?.insets)return`N/A`;let{top:t,bottom:n,left:r,right:i}=e.insets;return`T:${t} B:${n} L:${r} R:${i}`},`formatSafeArea`);return W.createElement(W.Fragment,null,W.createElement(`div`,{ref:O,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&T(!0),onMouseLeave:()=>!r&&T(!1)},W.createElement(`div`,{className:re().join(` `),style:ie()},!ne&&W.createElement(W.Fragment,null,!ee&&!te&&W.createElement(W.Fragment,null,(s===!0||s===`fullscreen`)&&W.createElement(U,{onClick:de,label:`Fullscreen`},W.createElement(`path`,{d:`M15 3h6v6`}),W.createElement(`path`,{d:`m21 3-7 7`}),W.createElement(`path`,{d:`m3 21 7-7`}),W.createElement(`path`,{d:`M9 21H3v-6`})),(s===!0||s===`pip`)&&W.createElement(U,{onClick:fe,label:`Picture in Picture`},W.createElement(`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`}),W.createElement(`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`}))),o&&W.createElement(U,{onClick:ae,label:`Debug Info`},W.createElement(`path`,{d:`M12 20v-9`}),W.createElement(`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`}),W.createElement(`path`,{d:`M14.12 3.88 16 2`}),W.createElement(`path`,{d:`M21 21a4 4 0 0 0-3.81-4`}),W.createElement(`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`}),W.createElement(`path`,{d:`M22 13h-4`}),W.createElement(`path`,{d:`M3 21a4 4 0 0 1 3.81-4`}),W.createElement(`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`}),W.createElement(`path`,{d:`M6 13H2`}),W.createElement(`path`,{d:`m8 2 1.88 1.88`}),W.createElement(`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`})))),e),E&&o&&W.createElement(`div`,{ref:k,className:`fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4`,onClick:e=>{e.target===k.current&&D(!1)}},W.createElement(`button`,{onClick:()=>D(!1),className:`absolute top-4 right-4 bg-white/10 text-white border-none rounded w-8 h-8 cursor-pointer flex items-center justify-center text-lg leading-none`,"aria-label":`Close`},`×`),W.createElement(`div`,{className:`max-w-[1200px] mx-auto pt-10`},W.createElement(`h1`,{className:`text-lg font-bold mb-4 border-b border-gray-700 pb-2`},`Debug Info`),W.createElement(`table`,{className:`w-full border-collapse border-spacing-0`},W.createElement(`tbody`,null,W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Props`),W.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},me(c))),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Output`),W.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},me(l))),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Metadata`),W.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},me(u))),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`State`),W.createElement(`td`,{className:`p-2 whitespace-pre-wrap break-all`},me(d))),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Theme`),W.createElement(`td`,{className:`p-2`},f)),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Display Mode`),W.createElement(`td`,{className:`p-2`},p)),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Locale`),W.createElement(`td`,{className:`p-2`},_)),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Max Height`),W.createElement(`td`,{className:`p-2`},h,`px`)),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`User Agent`),W.createElement(`td`,{className:`p-2`},he(g))),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`Safe Area`),W.createElement(`td`,{className:`p-2`},ge(m))),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`API Available`),W.createElement(`td`,{className:`p-2`},v?`Yes`:`No`)),W.createElement(`tr`,{className:`border-b border-gray-700`},W.createElement(`td`,{className:`p-2 font-bold w-[200px] align-top`},`window.openai Keys`),W.createElement(`td`,{className:`p-2`},A.length>0?A.join(`, `):`N/A`)))),W.createElement(`h2`,{className:`text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2`},`Actions`),W.createElement(`div`,{className:`flex flex-col gap-3`},W.createElement(`div`,{className:`flex gap-2 items-center`},W.createElement(`input`,{type:`text`,value:P,onChange:e=>F(e.target.value),placeholder:`Tool name`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]`}),W.createElement(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:`{"key": "value"}`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),W.createElement(`button`,{onClick:oe,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Call Tool`)),W.createElement(`div`,{className:`flex gap-2 items-center`},W.createElement(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:`Follow-up message`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),W.createElement(`button`,{onClick:se,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Send Follow-Up`)),W.createElement(`div`,{className:`flex gap-2 items-center`},W.createElement(`input`,{type:`text`,value:B,onChange:e=>V(e.target.value),placeholder:`External URL`,className:`py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1`}),W.createElement(`button`,{onClick:ce,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Open Link`)),W.createElement(`div`,{className:`flex gap-2 items-center`},W.createElement(`span`,{className:`w-[150px] text-xs`},`Display Mode:`),W.createElement(`button`,{onClick:()=>le(`inline`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Inline`),W.createElement(`button`,{onClick:()=>le(`pip`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`PiP`),W.createElement(`button`,{onClick:()=>le(`fullscreen`),className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1`},`Fullscreen`)),W.createElement(`div`,{className:`flex gap-2 items-center`},W.createElement(`button`,{onClick:ue,className:`py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs`},`Set State (Add Timestamp)`)),M&&W.createElement(`div`,{className:`mt-2 p-2 bg-[#1a1a1a] border border-gray-700 rounded whitespace-pre-wrap break-all text-[11px] max-h-[200px] overflow-auto`},W.createElement(`div`,{className:`font-bold mb-1 text-gray-400`},`Result:`),M,W.createElement(`button`,{onClick:()=>N(``),className:`mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]`},`Clear`))))))}a(Jm,`WidgetControls`);var nee=150,ree=5;function iee({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!0}){let[i,a]=(0,W.useState)(null),o=(0,W.useRef)(0),s=(0,W.useRef)(null),c=(0,W.useRef)(!1),l=(0,W.useCallback)(e=>{if(!(typeof window>`u`)){if(c.current=!0,window.openai?.notifyIntrinsicHeight){window.openai.notifyIntrinsicHeight(e).then(()=>{c.current=!1}).catch(e=>{c.current=!1,console.error(`[McpUseProvider] Failed to notify intrinsic height (ChatGPT):`,e)});return}try{Vm().sendSizeChanged({height:e}),console.log(`[McpUseProvider] Sent size-changed notification:`,e),c.current=!1}catch(e){c.current=!1,console.error(`[McpUseProvider] Failed to notify size change (MCP Apps):`,e)}}},[]),u=(0,W.useCallback)(e=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{Math.abs(e-o.current)>=ree&&e>0&&(o.current=e,l(e))},nee)},[l]);(0,W.useEffect)(()=>{if(!r){console.log(`[McpUseProvider] autoSize is disabled`);return}if(!i){console.log(`[McpUseProvider] No container element found for autoSize`);return}if(typeof ResizeObserver>`u`){console.log(`[McpUseProvider] ResizeObserver not available`);return}console.log(`[McpUseProvider] Setting up ResizeObserver for autoSize`);let e=new ResizeObserver(e=>{if(c.current){console.log(`[McpUseProvider] Skipping resize - notification in progress`);return}for(let t of e){let e=t.contentRect.height,n=t.target.scrollHeight,r=Math.max(e,n);console.log(`[McpUseProvider] ResizeObserver fired:`,{height:e,scrollHeight:n,intrinsicHeight:r}),u(r)}});e.observe(i);let t=Math.max(i.offsetHeight,i.scrollHeight);return console.log(`[McpUseProvider] Initial height measurement:`,t),t>0&&u(t),()=>{console.log(`[McpUseProvider] Cleaning up ResizeObserver`),e.disconnect(),s.current&&=(clearTimeout(s.current),null),c.current=!1}},[r,i,u]);let d=e;return d=W.createElement(Pm,null,d),(t||n)&&(d=W.createElement(Jm,{debugger:t,viewControls:n},d)),d=W.createElement(tee,null,d),r&&(d=W.createElement(`div`,{ref:a,style:{width:`100%`,minHeight:0}},d)),W.createElement(W.StrictMode,null,d)}a(iee,`McpUseProvider`);function aee(){let e=(0,W.useMemo)(()=>typeof window>`u`?!1:typeof window.openai?.uploadFile==`function`&&typeof window.openai?.getFileDownloadUrl==`function`,[]);return{isSupported:e,upload:(0,W.useMemo)(()=>async(t,n={})=>{if(!e)throw Error("[useFiles] File upload is not supported in this host. Check `isSupported` before calling `upload`. File operations are only available in the ChatGPT Apps SDK environment.");let r=await window.openai.uploadFile(t),{modelVisible:i=!0}=n;if(i&&window.openai?.setWidgetState){let e=window.openai.widgetState??{},t=[...e.imageIds??[],r.fileId];window.openai.setWidgetState({...e,imageIds:t}).catch(e=>{console.warn(`[useFiles] Failed to track imageId:`,e)})}return r},[e]),getDownloadUrl:(0,W.useMemo)(()=>async t=>{if(!e)throw Error("[useFiles] File download is not supported in this host. Check `isSupported` before calling `getDownloadUrl`. File operations are only available in the ChatGPT Apps SDK environment.");return window.openai.getFileDownloadUrl(t)},[e])}}a(aee,`useFiles`);function Ym(e){let[{status:t,data:n,error:r},i]=(0,W.useState)({status:`idle`,data:void 0,error:void 0}),o=(0,W.useRef)(0),s=a(async t=>{let n=++o.current;i({status:`pending`,data:void 0,error:void 0});try{let r;if(typeof window<`u`)if(window.openai?.callTool)r=await window.openai.callTool(e,t);else if(window!==window.parent)r=await Vm().callTool(e,t);else throw Error(`No tool calling interface available`);else throw Error(`useCallTool can only be used in browser environment`);let a=Hm(r);return n===o.current&&i({status:`success`,data:a,error:void 0}),a}catch(e){throw n===o.current&&i({status:`error`,data:void 0,error:e}),e}},`execute`),c=(0,W.useCallback)((e=>s(e===void 0?null:e)),[e]),l=(0,W.useCallback)(((e,t)=>{let n;e&&typeof e==`object`&&(`onSuccess`in e||`onError`in e||`onSettled`in e)?(n=null,t=e):n=e===void 0?null:e,s(n).then(e=>{t?.onSuccess?.(e,n),t?.onSettled?.(e,void 0,n)}).catch(e=>{t?.onError?.(e,n),t?.onSettled?.(void 0,e,n)})}),[e]);return{status:t,data:n,error:r,isIdle:t===`idle`,isPending:t===`pending`,isSuccess:t===`success`,isError:t===`error`,callTool:l,callToolAsync:c}}a(Ym,`useCallTool`);function oee(){return{useCallTool:a(e=>Ym(e),`useCallTool`),useToolInfo:a(()=>Gm(),`useToolInfo`)}}a(oee,`generateHelpers`);var Xm=s.get(`McpClientProvider`),Zm=(0,W.createContext)(null),Qm=500;function $m({id:e,options:t,defaultProxyConfig:n,defaultAutoProxyFallback:r,clientInfo:i,cachedMetadata:a,onUpdate:o,rpcWrapTransport:s,onGlobalSamplingRequest:c,onGlobalElicitationRequest:l}){let{name:u,onSamplingRequest:d,onElicitationRequest:f,onNotificationReceived:p,wrapTransport:m}=t,h=(0,W.useMemo)(()=>{let{name:e,onSamplingRequest:o,onElicitationRequest:s,onNotificationReceived:c,wrapTransport:l,...u}=t;return{...u,proxyConfig:u.proxyConfig||n,autoProxyFallback:u.autoProxyFallback===void 0?r:u.autoProxyFallback,clientInfo:u.clientInfo?i?{...i,...u.clientInfo}:u.clientInfo:i,_initialServerInfo:a}},[t,n,r,i,a]),g=(0,W.useMemo)(()=>{if(!(!s&&!m))return t=>{let n=t;return s&&(n=s(n,e)),m&&(n=m(n,e)),n}},[s,m,e]),[_,v]=(0,W.useState)([]),[y,b]=(0,W.useState)([]),x=(0,W.useRef)(0),[S,C]=(0,W.useState)([]),w=(0,W.useRef)(0),T=(0,W.useCallback)(e=>{v(t=>t.map(t=>t.id===e?{...t,read:!0}:t))},[]),E=(0,W.useCallback)(()=>{v(e=>e.map(e=>({...e,read:!0})))},[]),D=(0,W.useCallback)(()=>{v([])},[]),O=(0,W.useCallback)(e=>{let t={id:globalThis.crypto?.randomUUID?.()||`${Date.now()}-${Math.random()}`,method:e.method,params:e.params,timestamp:Date.now(),read:!1};v(e=>{let n=[t,...e];return n.length>Qm?n.slice(0,Qm):n}),p?.(t)},[p]),k=(0,W.useCallback)((e,t)=>{b(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),A=(0,W.useCallback)((e,t)=>{b(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected sampling request`)),n.filter(t=>t.id!==e)):n})},[]),j=(0,W.useCallback)(async t=>new Promise((n,r)=>{let i={id:`sampling-${x.current++}`,request:{method:`sampling/createMessage`,params:t},timestamp:Date.now(),serverName:u||e},a={...i,resolve:n,reject:r};b(e=>[...e,a]),d?.(i),c?.(i,e,u||e,k,A)}),[e,u,d,c,k,A]),M=(0,W.useCallback)((e,t)=>{C(n=>{let r=n.find(t=>t.id===e);return r?(r.resolve(t),n.filter(t=>t.id!==e)):n})},[]),N=(0,W.useCallback)((e,t)=>{C(n=>{let r=n.find(t=>t.id===e);return r?(r.reject(Error(t||`User rejected elicitation request`)),n.filter(t=>t.id!==e)):n})},[]),P=(0,W.useCallback)(async t=>new Promise((n,r)=>{let i={id:`elicitation-${w.current++}`,request:t,timestamp:Date.now(),serverName:u||e},a={...i,resolve:n,reject:r};C(e=>[...e,a]),f?.(i),l?.(i,e,u||e,M,N)}),[e,u,f,l,M,N]),F=ym({...h,onNotification:O,onSampling:j,onElicitation:P,wrapTransport:g}),I=(0,W.useMemo)(()=>y.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[y]),L=(0,W.useMemo)(()=>S.map(e=>({id:e.id,request:e.request,timestamp:e.timestamp,serverName:e.serverName})),[S]),R=(0,W.useMemo)(()=>_.filter(e=>!e.read).length,[_]),z=(0,W.useMemo)(()=>JSON.stringify(F.tools.map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,_meta:e._meta})).sort((e,t)=>e.name.localeCompare(t.name))),[F.tools,e]),B=(0,W.useMemo)(()=>JSON.stringify(F.resources.map(e=>({uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType})).sort((e,t)=>e.uri.localeCompare(t.uri))),[F.resources]),V=(0,W.useMemo)(()=>JSON.stringify(F.prompts.map(e=>({name:e.name,description:e.description,arguments:e.arguments})).sort((e,t)=>e.name.localeCompare(t.name))),[F.prompts]),ee=(0,W.useRef)(o),te=(0,W.useRef)(null),ne=(0,W.useRef)({tools:``,resources:``,prompts:``});return(0,W.useEffect)(()=>{ee.current=o},[o]),(0,W.useEffect)(()=>{let n={...F,id:e,url:t.url||``,name:u||e,notifications:_,unreadNotificationCount:R,markNotificationRead:T,markAllNotificationsRead:E,clearNotifications:D,pendingSamplingRequests:I,approveSampling:k,rejectSampling:A,pendingElicitationRequests:L,approveElicitation:M,rejectElicitation:N},r=te.current,i=ne.current,a=i.tools!==z,o=i.resources!==B,s=i.prompts!==V;!r||r.state!==n.state||r.error!==n.error||r.authUrl!==n.authUrl||a||o||s||r.serverInfo!==n.serverInfo||r.capabilities!==n.capabilities||r.notifications.length!==n.notifications.length||r.unreadNotificationCount!==n.unreadNotificationCount||r.pendingSamplingRequests.length!==n.pendingSamplingRequests.length||r.pendingElicitationRequests.length!==n.pendingElicitationRequests.length||!r.client?(te.current=n,ne.current={tools:z,resources:B,prompts:V},ee.current(n)):Xm.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`)},[e,u,t.url,F.state,F.error,F.authUrl,z,B,V,F.serverInfo,F.capabilities,_.length,R,I.length,L.length,T,E,D,k,A,M,N]),null}a($m,`McpServerWrapper`);function eh({children:e,mcpServers:t,defaultProxyConfig:n,defaultAutoProxyFallback:r=!0,clientInfo:i,storageProvider:o,enableRpcLogging:s=!1,onServerAdded:c,onServerRemoved:l,onServerStateChange:u,onSamplingRequest:d,onElicitationRequest:f}){let[p,m]=(0,W.useState)([]),[h,g]=(0,W.useState)([]),[_,v]=(0,W.useState)(!1),y=(0,W.useRef)({}),[b,x]=(0,W.useState)(void 0),[S,C]=(0,W.useState)(!1);(0,W.useEffect)(()=>{if(!s||typeof window>`u`){x(void 0),C(!0);return}z(()=>import(`./rpc-logger-TPNV75J4-CMVlzCN7.js`).then(e=>{Xm.debug(`[McpClientProvider] RPC logger loaded`),x(()=>e.wrapTransportForLogging),C(!0)}),__vite__mapDeps([0,1,2,3,4])).catch(e=>{Xm.error(`[McpClientProvider] Failed to load RPC logger:`,e),x(void 0),C(!0)})},[s]),(0,W.useEffect)(()=>{if(!S){Xm.debug(`[McpClientProvider] Waiting for RPC logging to be ready before loading servers`);return}a(async()=>{if(Xm.debug(`[McpClientProvider] Loading servers, storageProvider:`,!!o,`mcpServers:`,t),!o){if(t){let e=Object.entries(t).map(([e,t])=>({id:e,options:t}));Xm.debug(`[McpClientProvider] Loaded from mcpServers prop:`,e.length),m(e)}v(!0);return}try{let e=await Promise.resolve(o.getServers());if(Xm.debug(`[McpClientProvider] Loaded from storage:`,Object.keys(e).length),o.getServerMetadata)try{let t=Object.keys(e).map(async e=>[e,await Promise.resolve(o.getServerMetadata(e))]),n=await Promise.all(t);y.current=Object.fromEntries(n.filter(e=>e[1]!==void 0)),Xm.debug(`[McpClientProvider] Loaded cached metadata for`,Object.keys(y.current).length,`servers`)}catch(e){Xm.warn(`[McpClientProvider] Failed to load cached metadata:`,e)}let n={...e,...t},r=Object.entries(n).map(([e,t])=>({id:e,options:t}));Xm.debug(`[McpClientProvider] Total servers after merge:`,r.length),m(r),v(!0)}catch(e){Xm.error(`[McpClientProvider] Failed to load from storage:`,e),t&&m(Object.entries(t).map(([e,t])=>({id:e,options:t}))),v(!0)}},`loadServers`)()},[o,t,S]),(0,W.useEffect)(()=>{!o||!_||a(async()=>{try{let e=p.reduce((e,t)=>(e[t.id]=t.options,e),{});await Promise.resolve(o.setServers(e))}catch(e){Xm.error(`[McpClientProvider] Failed to save to storage:`,e)}},`saveServers`)()},[p,o,_]);let w=(0,W.useCallback)(e=>{Xm.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`,{toolCount:e.tools.length,state:e.state});let t=[];g(n=>{let r=n.findIndex(t=>t.id===e.id);if(r===-1)return Xm.debug(`[McpClientProvider] Adding new server ${e.id} to state`),t.push(()=>c?.(e.id,e)),[...n,e];let i=n[r],a=i.state!==e.state,s=i.serverInfo!==e.serverInfo;if(Xm.debug(`[McpClientProvider] Comparing server ${e.id}:`,{toolsChanged:i.tools!==e.tools,currentToolCount:i.tools.length,updatedToolCount:e.tools.length,stateChanged:a}),i.name===e.name&&i.url===e.url&&i.state===e.state&&i.tools===e.tools&&i.resources===e.resources&&i.prompts===e.prompts&&i.error===e.error&&i.serverInfo===e.serverInfo&&i.client===e.client&&i.notifications===e.notifications&&i.unreadNotificationCount===e.unreadNotificationCount&&i.pendingSamplingRequests.length===e.pendingSamplingRequests.length&&i.pendingElicitationRequests.length===e.pendingElicitationRequests.length)return Xm.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`),n;if(Xm.debug(`[McpClientProvider] Updating server ${e.id} in state`),a&&t.push(()=>u?.(e.id,e.state)),s&&e.serverInfo&&o?.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};y.current[e.id]=t,Promise.resolve(o.setServerMetadata(e.id,t)).catch(e=>{Xm.error(`[McpClientProvider] Failed to save server metadata:`,e)})}let l=[...n];return l[r]=e,l}),t.length>0&&queueMicrotask(()=>{t.forEach(e=>e())})},[c,u,o]),T=(0,W.useCallback)((e,t)=>{m(n=>n.find(t=>t.id===e)?n:(Xm.debug(`[McpClientProvider] Adding new server to configs:`,e),[...n,{id:e,options:t}]))},[]),E=(0,W.useCallback)(e=>{g(t=>{let n=t.find(t=>t.id===e);return n?.disconnect&&n.disconnect(),n?.clearStorage&&n.clearStorage(),t.filter(t=>t.id!==e)}),m(t=>t.filter(t=>t.id!==e)),l?.(e)},[l]),D=(0,W.useCallback)(async(e,t)=>new Promise(n=>{let r=p.find(t=>t.id===e);if(!r){Xm.warn(`[McpClientProvider] Cannot update server "${e}" - not found`),n();return}let i={...r.options,...t,_updateVersion:(r.options._updateVersion||0)+1};g(t=>{let n=t.find(t=>t.id===e);return n?.disconnect&&n.disconnect(),n?.clearStorage&&n.clearStorage(),t.filter(t=>t.id!==e)}),m(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r})}),[p]),O=(0,W.useCallback)(async(e,t)=>new Promise(n=>{let r=p.find(t=>t.id===e);if(!r){Xm.warn(`[McpClientProvider] Cannot update server metadata for "${e}" - not found`),n();return}let i={...r.options,...t};g(n=>n.map(n=>n.id===e?{...n,name:t.name}:n)),m(t=>{let r=t.map(t=>t.id===e?{id:e,options:i}:t);return setTimeout(()=>n(),0),r})}),[p]),k=(0,W.useCallback)(e=>h.find(t=>t.id===e),[h]),A=(0,W.useMemo)(()=>({servers:h,addServer:T,removeServer:E,updateServerMetadata:O,updateServer:D,getServer:k,storageLoaded:_}),[h,T,E,O,D,k,_]),{capabilities:j,...M}=i||{},N=(0,W.useMemo)(()=>Object.keys(M).length?M:void 0,[i]),P=(0,W.useMemo)(()=>p.map(e=>({id:e.id,options:j?{...e.options,clientOptions:{...e.options.clientOptions,capabilities:{...j,...e.options.clientOptions?.capabilities}}}:e.options})),[p,j]);return W.createElement(Zm.Provider,{value:A},e,P.map(e=>W.createElement($m,{key:`${e.id}-v${e.options._updateVersion||0}`,id:e.id,options:e.options,defaultProxyConfig:n,defaultAutoProxyFallback:r,clientInfo:N,cachedMetadata:y.current[e.id],onUpdate:w,rpcWrapTransport:b,onGlobalSamplingRequest:d,onGlobalElicitationRequest:f})))}a(eh,`McpClientProvider`);function th(){let e=(0,W.useContext)(Zm);if(!e)throw Error(`useMcpClient must be used within a McpClientProvider`);return e}a(th,`useMcpClient`);function nh(e){let{getServer:t}=th();return t(e)}a(nh,`useMcpServer`);var rh=class{constructor(e=`mcp-client-servers`){this.storageKey=e,this.metadataKey=`${e}-metadata`}static{a(this,`LocalStorageProvider`)}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)}};(class{static{a(this,`MemoryStorageProvider`)}storage={};metadata={};getServers(){return{...this.storage}}setServers(e){this.storage={...e}}setServer(e,t){this.storage[e]=t}removeServer(e){delete this.storage[e],this.removeServerMetadata(e)}clear(){this.storage={},this.metadata={}}getServerMetadata(e){return this.metadata[e]}setServerMetadata(e,t){this.metadata[e]={...t,cachedAt:Date.now()}}removeServerMetadata(e){delete this.metadata[e]}});async function ih(e){if(navigator.clipboard?.writeText)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);if(t.value=e,t.style.cssText=`position:fixed;top:-9999px;left:-9999px;opacity:0`,document.body.appendChild(t),t.focus(),t.select(),!document.execCommand(`copy`))throw Error(`execCommand copy failed`);document.body.removeChild(t)}function ah(e){try{let t=localStorage.getItem(`mcp-inspector-connections`);return t&&JSON.parse(t)[e]||null}catch{return null}}function oh(e){let t=e.proxyConfig?.headers||e.proxyConfig?.customHeaders||e.headers||e.customHeaders||{};return Object.fromEntries(Object.entries(t).filter(([e,t])=>e&&t).map(([e,t])=>[e,String(t)]).sort(([e],[t])=>e.localeCompare(t)))}function sh(e){let t=e.url?.trim()||``;return{url:t,name:e.name?.trim()||t,transportType:e.transportType||`http`,proxyAddress:e.proxyConfig?.proxyAddress?.trim()||``,headers:oh(e)}}function ch(e,t){let n=sh(e),r=sh(t);return n.url===r.url&&n.transportType===r.transportType&&n.proxyAddress===r.proxyAddress&&JSON.stringify(n.headers)===JSON.stringify(r.headers)&&n.name!==r.name}function lh(e){let t=e.name?.trim(),n=e.url?.trim();return t?t===n?``:t:``}function uh(e){return lh(e)||e.serverInfo?.title?.trim()||e.serverInfo?.name?.trim()||e.name?.trim()||e.url?.trim()||`Unknown server`}var dh=`popstate`;function fh(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return _h(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:vh(t)}return bh(t,n,null,e)}function ph(e,t){if(e===!1||e==null)throw Error(t)}function mh(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function hh(){return Math.random().toString(36).substring(2,10)}function gh(e,t){return{usr:e.state,key:e.key,idx:t}}function _h(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?yh(t):t,state:n,key:t&&t.key||r||hh()}}function vh({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function yh(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function bh(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=_h(h.location,e,t);n&&n(r,e),l=u()+1;let d=gh(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=_h(h.location,e,t);n&&n(r,e),l=u();let i=gh(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return xh(e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(dh,d),c=e,()=>{i.removeEventListener(dh,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function xh(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),ph(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:vh(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function Sh(e,t,n=`/`){return Ch(e,t,n,!1)}function Ch(e,t,n,r){let i=Mh((typeof t==`string`?yh(t):t).pathname||`/`,n);if(i==null)return null;let a=Th(e);Dh(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=hee(i);o=pee(a[e],t,r)}return o}function wh(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function Th(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;ph(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=Lh([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(ph(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),Th(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:dee(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of Eh(e.path))a(e,t,!0,n)}),t}function Eh(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=Eh(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function Dh(e){e.sort((e,t)=>e.score===t.score?fee(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var Oh=/^:[\w-]+$/,kh=3,see=2,cee=1,lee=10,uee=-2,Ah=e=>e===`*`;function dee(e,t){let n=e.split(`/`),r=n.length;return n.some(Ah)&&(r+=uee),t&&(r+=see),n.filter(e=>!Ah(e)).reduce((e,t)=>e+(Oh.test(t)?kh:t===``?cee:lee),r)}function fee(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function pee(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=jh({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=jh({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:Lh([a,u.pathname]),pathnameBase:yee(Lh([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=Lh([a,u.pathnameBase]))}return o}function jh(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=mee(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function mee(e,t=!1,n=!0){mh(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function hee(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return mh(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Mh(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var gee=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function _ee(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?yh(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?Nh(n.substring(1),`/`):Nh(n,t)):a=t,{pathname:a,search:bee(r),hash:xee(i)}}function Nh(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Ph(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function vee(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Fh(e){let t=vee(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Ih(e,t,n,r=!1){let i;typeof e==`string`?i=yh(e):(i={...e},ph(!i.pathname||!i.pathname.includes(`?`),Ph(`?`,`pathname`,`search`,i)),ph(!i.pathname||!i.pathname.includes(`#`),Ph(`#`,`pathname`,`hash`,i)),ph(!i.search||!i.search.includes(`#`),Ph(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=_ee(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var Lh=e=>e.join(`/`).replace(/\/\/+/g,`/`),yee=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),bee=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,xee=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,See=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Cee(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function wee(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var Rh=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function zh(e,t){let n=e;if(typeof n!=`string`||!gee.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Rh)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=Mh(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{mh(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Bh=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Bh);var Vh=[`GET`,...Bh];new Set(Vh);var Hh=W.createContext(null);Hh.displayName=`DataRouter`;var Uh=W.createContext(null);Uh.displayName=`DataRouterState`;var Wh=W.createContext(!1),Gh=W.createContext({isTransitioning:!1});Gh.displayName=`ViewTransition`;var Kh=W.createContext(new Map);Kh.displayName=`Fetchers`;var qh=W.createContext(null);qh.displayName=`Await`;var Jh=W.createContext(null);Jh.displayName=`Navigation`;var Yh=W.createContext(null);Yh.displayName=`Location`;var Xh=W.createContext({outlet:null,matches:[],isDataRoute:!1});Xh.displayName=`Route`;var Zh=W.createContext(null);Zh.displayName=`RouteError`;var Qh=`REACT_ROUTER_ERROR`,$h=`REDIRECT`,eg=`ROUTE_ERROR_RESPONSE`;function tg(e){if(e.startsWith(`${Qh}:${$h}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function ng(e){if(e.startsWith(`${Qh}:${eg}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new See(t.status,t.statusText,t.data)}catch{}}function rg(e,{relative:t}={}){ph(ig(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=W.useContext(Jh),{hash:i,pathname:a,search:o}=ug(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Lh([n,a])),r.createHref({pathname:s,search:o,hash:i})}function ig(){return W.useContext(Yh)!=null}function ag(){return ph(ig(),`useLocation() may be used only in the context of a <Router> component.`),W.useContext(Yh).location}var og=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function sg(e){W.useContext(Jh).static||W.useLayoutEffect(e)}function cg(){let{isDataRoute:e}=W.useContext(Xh);return e?kg():lg()}function lg(){ph(ig(),`useNavigate() may be used only in the context of a <Router> component.`);let e=W.useContext(Hh),{basename:t,navigator:n}=W.useContext(Jh),{matches:r}=W.useContext(Xh),{pathname:i}=ag(),a=JSON.stringify(Fh(r)),o=W.useRef(!1);return sg(()=>{o.current=!0}),W.useCallback((r,s={})=>{if(mh(o.current,og),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Ih(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Lh([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}W.createContext(null);function ug(e,{relative:t}={}){let{matches:n}=W.useContext(Xh),{pathname:r}=ag(),i=JSON.stringify(Fh(n));return W.useMemo(()=>Ih(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function dg(e,t){return fg(e,t)}function fg(e,t,n,r,i){ph(ig(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:a}=W.useContext(Jh),{matches:o}=W.useContext(Xh),s=o[o.length-1],c=s?s.params:{},l=s?s.pathname:`/`,u=s?s.pathnameBase:`/`,d=s&&s.route;{let e=d&&d.path||``;jg(l,!d||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${l}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
@@ -678,9 +678,9 @@ Example format: {"theme": "dark", "width": "400", "title": "My Widget"}`),new d(
678
678
  `)}else r.content&&typeof r.content==`object`&&(r.content.type===`text`&&r.content.text?e=r.content.text:r.content.type===`image`&&r.content.data?i.push({type:`image`,data:r.content.data,mimeType:r.content.mimeType||`image/png`}):e=JSON.stringify(r.content));!e&&i.length===0&&(e=`[no content]`);let a={id:`prompt-${n.promptName}-${n.timestamp}-${t.length}`,role:r.role,content:e||``,timestamp:n.timestamp,attachments:i.length>0?i:void 0};t.push(a)}}return t};function Kie({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:r,chatApiUrl:i,waitForChatApiUrl:a,widgetModelContexts:o,initialMessages:s,disabledTools:c,streamProtocol:l=`sse`,credentials:u,extraHeaders:d,body:f}){let[p,m]=(0,W.useState)(s??[]),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)([]),y=(0,W.useRef)(null);return{messages:p,isLoading:h,attachments:_,sendMessage:(0,W.useCallback)(async(s,h,b)=>{let x=[..._,...b??[]];if(!(s.trim()||h.length>0||x.length>0)||!t||!r)return;let S=[...d5(h)];if(s.trim()||x.length>0){let e={id:`user-${Date.now()}`,role:`user`,content:s.trim(),timestamp:Date.now(),attachments:x.length>0?x:void 0};S.push(e)}m(e=>[...e,...S]),g(!0),v([]),y.current=new AbortController;try{let r=n;if(n?.type===`oauth`)try{let t=`mcp:auth_${fU(e)}_tokens`,i=localStorage.getItem(t);if(i){let e=JSON.parse(i);r={...n,oauthTokens:e}}else console.warn(`No OAuth tokens found in localStorage for key:`,t)}catch(e){console.warn(`Failed to retrieve OAuth tokens:`,e)}let s=[];if(o&&o.size>0){let e=[];for(let[,t]of o)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
679
679
  `)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&s.push({role:`user`,content:`[Current Widget State]\n${e.join(`
680
680
  `)}`})}let h=i??(a?await a():void 0)??`/inspector/api/chat/stream`,g=[...[...p,...S].map(e=>({role:e.role,content:e.content||(e.parts?.filter(e=>e.type===`text`).map(e=>e.text).join(``)??``),attachments:e.attachments})),...s],_=await fetch(h,{method:`POST`,headers:{"Content-Type":`application/json`,...d},signal:y.current.signal,...u?{credentials:u}:{},body:JSON.stringify(f?f(g):{mcpServerUrl:e,llmConfig:t,authConfig:r,messages:g,...c&&c.size>0?{disabledTools:[...c]}:{}})});if(!_.ok)throw Error(`HTTP error! status: ${_.status}`);let v=`assistant-${Date.now()}`,b=``,x=[];m(e=>[...e,{id:v,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]);let C=_.body?.getReader(),w=new TextDecoder;if(!C)throw Error(`No response body`);let T=()=>{m(e=>e.map(e=>e.id===v?{...e,parts:[...x]}:e))},E=()=>{m(e=>e.map(e=>e.id===v?{...e,parts:[...x],content:``}:e))},D=e=>{b+=e;let t=x[x.length-1];t&&t.type===`text`?t.text=b:x.push({type:`text`,text:b}),T()},O=(e,t)=>{b&&=``,x.push({type:`tool-invocation`,toolInvocation:{toolName:e,args:t,state:`pending`}}),T()},k=(e,t)=>{let n;n=e.by===`toolName`?x.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.toolName===e.toolName&&!t.toolInvocation?.result):x[e.index],n?.toolInvocation&&(n.toolInvocation.result=t,n.toolInvocation.state=t?.isError?`error`:`result`,T())},A=new Map,j=``;for(;;){if(y.current?.signal.aborted){await C.cancel();break}let{done:e,value:t}=await C.read();if(e)break;j+=w.decode(t,{stream:!0});let n=j.split(`
681
- `);j=n.pop()||``;for(let e of n)if(e.trim())try{if(l===`data-stream`){let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t),r=e.slice(t+1),i;try{i=JSON.parse(r)}catch{continue}switch(n){case`0`:D(typeof i==`string`?i:String(i));break;case`9`:{let e=i,t=e.args??{};if(typeof t.input==`string`&&Object.keys(t).length===1)try{let e=JSON.parse(t.input);typeof e==`object`&&e&&(t=e)}catch{}O(String(e.toolName??``),t),e.toolCallId&&A.set(e.toolCallId,x.length-1);break}case`a`:{let e=i,t=A.get(e.toolCallId),n=e.result,r=n;if(r?.lc===1&&r?.type===`constructor`&&r?.kwargs?.content){let e=r.kwargs.content;if(typeof e==`string`)try{n=JSON.parse(e)}catch{n=e}}t!==void 0&&k({by:`index`,index:t},n);break}case`d`:E();break;case`3`:throw Error(typeof i==`string`?i:JSON.stringify(i));default:break}}else{if(!e.startsWith(`data: `))continue;let t=JSON.parse(e.slice(6));if(t.type!==`message`){if(t.type===`text`)D(t.content);else if(t.type===`tool-call`)O(t.toolName,t.args);else if(t.type===`tool-result`)k({by:`toolName`,toolName:t.toolName},t.result);else if(t.type===`done`)E();else if(t.type===`error`)throw Error(t.message||`Streaming error`)}}}catch(t){if(t instanceof Error&&t.message!==`Streaming error`)console.error(`Failed to parse streaming event:`,t,e);else throw t}}if(y.current?.signal.aborted){for(let e of x)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);m(e=>e.map(e=>e.id===v?{...e,parts:[...x],content:``}:e))}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;let t=`Unknown error occurred`;if(e instanceof Error){t=e.message;let n=e;n.status&&(t=`HTTP ${n.status}: ${t}`),(n.code===401||t.includes(`401`)||t.includes(`Unauthorized`))&&(t=`Authentication failed (401). Check your Authorization header in the connection settings.`)}let n={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${t}`,timestamp:Date.now()};m(e=>[...e,n])}finally{g(!1),y.current=null}},[t,r,e,p,n,_,i,a,o,c,l,u,d,f]),clearMessages:(0,W.useCallback)(()=>{m([])},[]),setMessages:m,stop:(0,W.useCallback)(()=>{y.current&&y.current.abort()},[]),addAttachment:(0,W.useCallback)(async e=>{try{let t=await bU(e);v(e=>{let n=[...e,t];return vU(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,W.useCallback)(e=>{v(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,W.useCallback)(()=>{v([])},[])}}function qie({connection:e,llmConfig:t,isConnected:n,readResource:r,widgetModelContexts:i,disabledTools:a}){let[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)([]),f=(0,W.useRef)(null),p=(0,W.useRef)(null),m=(0,W.useRef)(null),h=(0,W.useRef)(``);return{messages:o,isLoading:c,attachments:u,sendMessage:(0,W.useCallback)(async(c,g,_)=>{let v=[...u,..._??[]];if(!(c.trim()||g.length>0||v.length>0)||!t||!n)return;let y=d5(g),b={id:`user-${Date.now()}`,role:`user`,content:c.trim(),timestamp:Date.now(),attachments:v.length>0?v:void 0},x=[...y];(c.trim()||v.length>0)&&x.push(b),s(e=>[...e,...x]),l(!0),d([]),f.current=new AbortController;let S=Date.now(),C=0;try{let n=`assistant-${Date.now()}`,l=``,u=[],d=new Map,g=0,_=async()=>{let e=Date.now();e-g>=80&&(g=e,await new Promise(e=>setTimeout(e,0)))};if(s(e=>[...e,{id:n,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let e;if(t.provider===`openai`){let{ChatOpenAI:n}=await z(async()=>{let{ChatOpenAI:e}=await import(`./dist-JsQmV3pO.js`);return{ChatOpenAI:e}},__vite__mapDeps([200,198,3,199,201,202,203,204,205]));e=new n({model:t.model,apiKey:t.apiKey})}else if(t.provider===`anthropic`){let{ChatAnthropic:n}=await z(async()=>{let{ChatAnthropic:e}=await import(`./dist-t5Yo0YiG.js`);return{ChatAnthropic:e}},__vite__mapDeps([206,198,3,199,201,204,205]));e=new n({model:t.model,apiKey:t.apiKey})}else if(t.provider===`google`){let{ChatGoogleGenerativeAI:n}=await z(async()=>{let{ChatGoogleGenerativeAI:e}=await import(`./dist-BZmXa__p.js`);return{ChatGoogleGenerativeAI:e}},__vite__mapDeps([207,198,3,199,201,202]));e=new n({model:t.model,apiKey:t.apiKey})}else throw Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:e,provider:t.provider,model:t.model,apiKey:t.apiKey}}let v=a?[...a].sort():[],x=v.join(`,`);if(!p.current||p.current.llm!==m.current.instance||h.current!==x){let{MCPAgent:t}=await z(async()=>{let{MCPAgent:e}=await import(`./browser-BwHKNEau.js`);return{MCPAgent:e}},__vite__mapDeps([208,209,198,3,199,201,202,203,204,210,205,2,4,211,212,213,214]));p.current=new t({llm:m.current.instance,client:e.client??void 0,memoryEnabled:!1,exposeResourcesAsTools:!1,exposePromptsAsTools:!1,disallowedTools:v.length>0?v:void 0,systemPrompt:`You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.`}),await p.current.initialize(),h.current=x}let w=[];if(i&&i.size>0){let e=[];for(let[,t]of i)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
681
+ `);j=n.pop()||``;for(let e of n)if(e.trim())try{if(l===`data-stream`){let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t),r=e.slice(t+1),i;try{i=JSON.parse(r)}catch{continue}switch(n){case`0`:D(typeof i==`string`?i:String(i));break;case`9`:{let e=i,t=e.args??{};if(typeof t.input==`string`&&Object.keys(t).length===1)try{let e=JSON.parse(t.input);typeof e==`object`&&e&&(t=e)}catch{}O(String(e.toolName??``),t),e.toolCallId&&A.set(e.toolCallId,x.length-1);break}case`a`:{let e=i,t=A.get(e.toolCallId),n=e.result,r=n;if(r?.lc===1&&r?.type===`constructor`&&r?.kwargs?.content){let e=r.kwargs.content;if(typeof e==`string`)try{n=JSON.parse(e)}catch{n=e}}t!==void 0&&k({by:`index`,index:t},n);break}case`d`:E();break;case`3`:throw Error(typeof i==`string`?i:JSON.stringify(i));default:break}}else{if(!e.startsWith(`data: `))continue;let t=JSON.parse(e.slice(6));if(t.type!==`message`){if(t.type===`text`)D(t.content);else if(t.type===`tool-call`)O(t.toolName,t.args);else if(t.type===`tool-result`)k({by:`toolName`,toolName:t.toolName},t.result);else if(t.type===`done`)E();else if(t.type===`error`)throw Error(t.message||`Streaming error`)}}}catch(t){if(t instanceof Error&&t.message!==`Streaming error`)console.error(`Failed to parse streaming event:`,t,e);else throw t}}if(y.current?.signal.aborted){for(let e of x)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);m(e=>e.map(e=>e.id===v?{...e,parts:[...x],content:``}:e))}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;let t=`Unknown error occurred`;if(e instanceof Error){t=e.message;let n=e;n.status&&(t=`HTTP ${n.status}: ${t}`),(n.code===401||t.includes(`401`)||t.includes(`Unauthorized`))&&(t=`Authentication failed (401). Check your Authorization header in the connection settings.`)}let n={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${t}`,timestamp:Date.now()};m(e=>[...e,n])}finally{g(!1),y.current=null}},[t,r,e,p,n,_,i,a,o,c,l,u,d,f]),clearMessages:(0,W.useCallback)(()=>{m([])},[]),setMessages:m,stop:(0,W.useCallback)(()=>{y.current&&y.current.abort()},[]),addAttachment:(0,W.useCallback)(async e=>{try{let t=await bU(e);v(e=>{let n=[...e,t];return vU(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,W.useCallback)(e=>{v(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,W.useCallback)(()=>{v([])},[])}}function qie({connection:e,llmConfig:t,isConnected:n,readResource:r,widgetModelContexts:i,disabledTools:a}){let[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)([]),f=(0,W.useRef)(null),p=(0,W.useRef)(null),m=(0,W.useRef)(null),h=(0,W.useRef)(``);return{messages:o,isLoading:c,attachments:u,sendMessage:(0,W.useCallback)(async(c,g,_)=>{let v=[...u,..._??[]];if(!(c.trim()||g.length>0||v.length>0)||!t||!n)return;let y=d5(g),b={id:`user-${Date.now()}`,role:`user`,content:c.trim(),timestamp:Date.now(),attachments:v.length>0?v:void 0},x=[...y];(c.trim()||v.length>0)&&x.push(b),s(e=>[...e,...x]),l(!0),d([]),f.current=new AbortController;let S=Date.now(),C=0;try{let n=`assistant-${Date.now()}`,l=``,u=[],d=new Map,g=0,_=async()=>{let e=Date.now();e-g>=80&&(g=e,await new Promise(e=>setTimeout(e,0)))};if(s(e=>[...e,{id:n,role:`assistant`,content:``,timestamp:Date.now(),parts:[]}]),!m.current||m.current.provider!==t.provider||m.current.model!==t.model||m.current.apiKey!==t.apiKey){let e;if(t.provider===`openai`){let{ChatOpenAI:n}=await z(async()=>{let{ChatOpenAI:e}=await import(`./dist-JsQmV3pO.js`);return{ChatOpenAI:e}},__vite__mapDeps([200,198,3,199,201,202,203,204,205]));e=new n({model:t.model,apiKey:t.apiKey})}else if(t.provider===`anthropic`){let{ChatAnthropic:n}=await z(async()=>{let{ChatAnthropic:e}=await import(`./dist-t5Yo0YiG.js`);return{ChatAnthropic:e}},__vite__mapDeps([206,198,3,199,201,204,205]));e=new n({model:t.model,apiKey:t.apiKey})}else if(t.provider===`google`){let{ChatGoogleGenerativeAI:n}=await z(async()=>{let{ChatGoogleGenerativeAI:e}=await import(`./dist-BZmXa__p.js`);return{ChatGoogleGenerativeAI:e}},__vite__mapDeps([207,198,3,199,201,202]));e=new n({model:t.model,apiKey:t.apiKey})}else throw Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:e,provider:t.provider,model:t.model,apiKey:t.apiKey}}let v=a?[...a].sort():[],x=v.join(`,`);if(!p.current||p.current.llm!==m.current.instance||h.current!==x){let{MCPAgent:t}=await z(async()=>{let{MCPAgent:e}=await import(`./browser-BNpsOGG_.js`);return{MCPAgent:e}},__vite__mapDeps([208,209,198,3,199,201,202,203,204,210,205,2,4,211,212,213,214]));p.current=new t({llm:m.current.instance,client:e.client??void 0,memoryEnabled:!1,exposeResourcesAsTools:!1,exposePromptsAsTools:!1,disallowedTools:v.length>0?v:void 0,systemPrompt:`You are a helpful assistant with access to MCP tools. Help users interact with the MCP server.`}),await p.current.initialize(),h.current=x}let w=[];if(i&&i.size>0){let e=[];for(let[,t]of i)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
682
682
  `)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&w.push({id:`widget-context-${Date.now()}`,role:`user`,content:`[Current Widget State]\n${e.join(`
683
- `)}`,timestamp:Date.now()})}let T=(b.attachments?.length??0)>0,E=Gie([...o,...y,...w,...T?[b]:[]]),D=T?``:c;for await(let e of p.current.streamEvents(D,10,!1,E,void 0,f.current?.signal)){if(f.current?.signal.aborted)break;if(e.event===`on_chat_model_stream`){let t=e.data?.chunk;if(t?.text){let e=t.text;if(typeof e==`string`&&e.length>0){l+=e;let t=u[u.length-1];t&&t.type===`text`?t.text=l:u.push({type:`text`,text:l}),s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}}let r=t?.tool_call_chunks||t?.kwargs?.tool_call_chunks||t?.lc_kwargs?.tool_call_chunks||t?.additional_kwargs?.tool_calls||t?.tool_calls;if(r&&Array.isArray(r)&&r.length>0){l&&=``;for(let e of r){let t=e.index??0,r=e.name||``,i=e.args||``,a=d.get(t);a||(a={name:r||`unknown`,accumulatedJson:``},d.set(t,a)),r&&a.name===`unknown`&&(a.name=r);let o;if(typeof i==`object`&&i)o=i;else if(typeof i==`string`&&i){a.accumulatedJson+=i;try{o=JSON.parse(a.accumulatedJson)}catch{let e=[()=>{let e=a.accumulatedJson;(e.match(/(?<!\\)"/g)||[]).length%2!=0&&(e+=`"`);let t=(e.match(/{/g)||[]).length-(e.match(/}/g)||[]).length,n=(e.match(/\[/g)||[]).length-(e.match(/]/g)||[]).length;for(let t=0;t<n;t++)e+=`]`;for(let n=0;n<t;n++)e+=`}`;return JSON.parse(e)},()=>{let e=a.accumulatedJson;e=e.replace(/,\s*"[^"]*"?\s*:\s*("([^"\\]|\\.)*)?$/,``),e=e.replace(/,\s*"[^"]*$/,``),(e.match(/(?<!\\)"/g)||[]).length%2!=0&&(e+=`"`);let t=(e.match(/{/g)||[]).length-(e.match(/}/g)||[]).length,n=(e.match(/\[/g)||[]).length-(e.match(/]/g)||[]).length;for(let t=0;t<n;t++)e+=`]`;for(let n=0;n<t;n++)e+=`}`;return JSON.parse(e)}];for(let t of e)try{o=t();break}catch{}}}if(o){let e=u.find(e=>e.type===`tool-invocation`&&e.toolInvocation?.state===`streaming`&&e.toolInvocation?.toolName===a.name);if(e&&e.toolInvocation){let t=e.toolInvocation.partialArgs,n=t?Object.keys(t):[],r=Object.keys(o),i=n.reduce((e,n)=>e+String(t[n]??``).length,0),a=r.reduce((e,t)=>e+String(o[t]??``).length,0);(r.length>n.length||a>=i)&&(e.toolInvocation.partialArgs=o)}else u.push({type:`tool-invocation`,toolInvocation:{toolName:a.name,args:{},state:`streaming`,partialArgs:o}});s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e)),await _()}}}}else if(e.event===`on_tool_start`){l&&=``;let t={};e.data?.input?t=e.data.input:e.data?.tool_input?t=e.data.tool_input:e.data&&(t=e.data),console.log(`[useChatMessagesClientSide] on_tool_start:`,{toolName:e.name,eventData:e.data,extractedArgs:t}),C++;let r=u.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.state===`streaming`&&t.toolInvocation?.toolName===(e.name||`unknown`));r&&r.toolInvocation?(r.toolInvocation.args=t,r.toolInvocation.state=`pending`):u.push({type:`tool-invocation`,toolInvocation:{toolName:e.name||`unknown`,args:t,state:`pending`}}),d.clear(),s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}else if(e.event===`on_tool_end`){let t=u.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.toolName===e.name&&!t.toolInvocation?.result);if(console.log(`[useChatMessagesClientSide] on_tool_end event:`,{toolName:e.name,hasToolPart:!!t,output:e.data?.output}),t&&t.toolInvocation){let i=e.data?.output;if(i?.kwargs?.content&&typeof i.kwargs.content==`string`)try{i=JSON.parse(i.kwargs.content)}catch(e){console.warn(`[useChatMessagesClientSide] Failed to parse kwargs.content:`,e),i=i.kwargs.content}else if(i?.content&&typeof i.content==`string`)try{i=JSON.parse(i.content)}catch{i=i.content}t.toolInvocation.result=i,t.toolInvocation.state=i?.isError?`error`:`result`;let a=i?._meta?.[`openai/outputTemplate`];if(console.log(`[useChatMessagesClientSide] Tool result:`,{toolName:e.name,hasMeta:!!i?._meta,hasStructuredContent:!!i?.structuredContent,appsSdkUri:a}),a&&typeof a==`string`&&r){console.log(`[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:`,a);try{let e=await r(a);console.log(`[useChatMessagesClientSide] Resource fetched:`,e);let n=i?.structuredContent||null;if(e?.contents&&Array.isArray(e.contents)){let r=e.contents.map(e=>({type:`resource`,resource:e}));console.log(`[useChatMessagesClientSide] Created MCP resources:`,r);let a={...i,content:[...i.content||[],...r],structuredContent:n};t.toolInvocation.result=a,console.log(`[useChatMessagesClientSide] Updated result with resources`)}else console.warn(`[useChatMessagesClientSide] No contents in resourceData:`,e)}catch(e){console.error(`Failed to fetch Apps SDK resource:`,e)}}s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}}}if(f.current?.signal.aborted)for(let e of u)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);s(e=>e.map(e=>e.id===n?{...e,parts:[...u],content:``}:e)),t&&Ef.getInstance().capture(new _f({serverId:e.url,provider:t.provider,model:t.model,messageCount:o.length+1,toolCallsCount:C,success:!0,executionMode:`client-side`,duration:Date.now()-S})).catch(()=>{})}catch(n){if(n instanceof DOMException&&n.name===`AbortError`)return;console.error(`Client-side agent error:`,n);let r=`Unknown error occurred`;if(n instanceof Error){r=n.message;let e=n;e.status&&(r=`HTTP ${e.status}: ${r}`),(e.code===401||r.includes(`401`)||r.includes(`Unauthorized`))&&(r=`Authentication failed (401). Check your Authorization header in the connection settings.`)}t&&Ef.getInstance().capture(new _f({serverId:e.url,provider:t.provider,model:t.model,messageCount:o.length+1,toolCallsCount:C,success:!1,executionMode:`client-side`,duration:Date.now()-S,error:r})).catch(()=>{});let i={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${r}`,timestamp:Date.now()};s(e=>[...e,i])}finally{l(!1),f.current=null}},[e,t,n,o,r,u,a]),clearMessages:(0,W.useCallback)(()=>{s([]),p.current&&p.current.clearConversationHistory()},[]),setMessages:s,stop:(0,W.useCallback)(()=>{f.current&&f.current.abort()},[]),addAttachment:(0,W.useCallback)(async e=>{try{let t=await bU(e);d(e=>{let n=[...e,t];return vU(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,W.useCallback)(e=>{d(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,W.useCallback)(()=>{d([])},[])}}var f5={openai:`gpt-4o`,anthropic:`claude-haiku-4-5-20251001`,google:`gemini-2.5-flash`};function p5({mcpServerUrl:e}){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(`openai`),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(f5.openai),p=(0,W.useCallback)(()=>{let e=localStorage.getItem(`mcp-inspector-api-keys`);if(e)try{return JSON.parse(e)}catch(e){return console.error(`Failed to load API keys:`,e),{}}return{}},[]),m=(0,W.useCallback)(e=>{localStorage.setItem(`mcp-inspector-api-keys`,JSON.stringify(e))},[]),[h,g]=(0,W.useState)(`none`),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(``);return(0,W.useEffect)(()=>{let e=()=>{let e=localStorage.getItem(`mcp-inspector-llm-config`),t=p();if(e)try{let r=JSON.parse(e);n(r),c(r.provider),u(t[r.provider]||r.apiKey||``),f(r.model)}catch(e){console.error(`Failed to load LLM config:`,e)}};e();let t=()=>{e()},r=t=>{(t.key===`mcp-inspector-llm-config`||t.key===`mcp-inspector-api-keys`)&&e()};return window.addEventListener(`llm-config-updated`,t),window.addEventListener(`storage`,r),()=>{window.removeEventListener(`llm-config-updated`,t),window.removeEventListener(`storage`,r)}},[p]),(0,W.useEffect)(()=>{let t=localStorage.getItem(`mcp-inspector-auth-config`);if(t)try{let e=JSON.parse(t);i(e),g(e.type),e.username&&v(e.username),e.password&&b(e.password),e.token&&S(e.token)}catch(e){console.error(`Failed to load auth config:`,e)}else try{let t=`mcp:auth_${fU(e)}_tokens`;localStorage.getItem(t)&&(i({type:`oauth`}),g(`oauth`))}catch(e){console.error(`Failed to check for OAuth tokens:`,e)}},[e]),(0,W.useEffect)(()=>{f(f5[s]),u(p()[s]||``)},[s,p]),{llmConfig:t,authConfig:r,configDialogOpen:a,setConfigDialogOpen:o,tempProvider:s,setTempProvider:c,tempApiKey:l,setTempApiKey:u,tempModel:d,setTempModel:f,tempAuthType:h,saveLLMConfig:(0,W.useCallback)(()=>{if(!l.trim())return;let e=p();e[s]=l,m(e);let t={provider:s,apiKey:l,model:d},r={type:h,...h===`basic`&&{username:_.trim(),password:y.trim()},...h===`bearer`&&{token:x.trim()}};n(t),i(r),localStorage.setItem(`mcp-inspector-llm-config`,JSON.stringify(t)),localStorage.setItem(`mcp-inspector-auth-config`,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(`llm-config-updated`)),o(!1)},[s,l,d,h,_,y,x,p,m]),clearConfig:(0,W.useCallback)(()=>{n(null),i(null);let e=p();delete e[s],m(e),u(``),v(``),b(``),S(``),g(`none`),localStorage.removeItem(`mcp-inspector-llm-config`),localStorage.removeItem(`mcp-inspector-auth-config`)},[s,p,m])}}var Jie=/(?:^\/$|\s+\/$)/,Yie=[`ArrowDown`,`ArrowUp`,`Escape`,`Enter`];function m5({connection:e,isConnected:t,useClientSide:n=!0,enableKeyboardShortcuts:r=!0,prompts:i,serverId:a,callPrompt:o,readResource:s,chatApiUrl:c,waitForChatApiUrl:l,initialMessages:u,managedLlmConfig:d,clearButtonLabel:f,hideTitle:p,hideModelBadge:m,hideServerUrl:h,clearButtonHideIcon:g,clearButtonHideShortcut:_,clearButtonVariant:v,hideClearButton:y,hideToolSelector:b,chatQuickQuestions:x=[],chatFollowups:S=[],streamProtocol:C,credentials:w,extraHeaders:T,body:E}){let[D,O]=(0,W.useState)(``),[k,A]=(0,W.useState)(!1),[j,M]=(0,W.useState)(-1),[N,P]=(0,W.useState)(x),[F,I]=(0,W.useState)(S),[L,R]=(0,W.useState)(new Set),B=(0,W.useRef)(null),V=(0,W.useRef)(null),ee=(0,W.useRef)(null),te=(0,W.useMemo)(()=>(e.tools??[]).map(e=>({name:e.name,description:e.description})),[e.tools]),{llmConfig:ne,authConfig:H,configDialogOpen:re,setConfigDialogOpen:ie,tempProvider:ae,setTempProvider:oe,tempApiKey:se,setTempApiKey:ce,tempModel:le,setTempModel:ue,saveLLMConfig:de,clearConfig:fe}=p5({mcpServerUrl:e.url}),pe=d??ne,me=!!d,{getAllModelContexts:he}=DK(),ge=he(),_e={connection:e,llmConfig:pe,isConnected:t,readResource:s,widgetModelContexts:ge,disabledTools:L},ve=Kie({mcpServerUrl:e.url,llmConfig:pe,authConfig:H,isConnected:t,chatApiUrl:c,waitForChatApiUrl:l,widgetModelContexts:ge,initialMessages:u,disabledTools:L,streamProtocol:C,credentials:w,extraHeaders:T,body:E}),ye=qie(_e),{messages:be,isLoading:xe,attachments:Se,sendMessage:Ce,clearMessages:we,setMessages:Te,stop:Ee,addAttachment:De,removeAttachment:Oe}=n?ye:ve,{filteredPrompts:ke,setSelectedPrompt:Ae,selectedPrompt:je,setPromptArgs:Me,executePrompt:Ne,results:Pe,handleDeleteResult:Fe,clearPromptResults:Ie}=$V({prompts:i,callPrompt:o,serverId:a}),Le=(0,W.useCallback)(e=>Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean).slice(0,8):[],[]),Re=(0,W.useCallback)(e=>typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e.text??``).join(``):``,[]),ze=(0,W.useCallback)(()=>be.map(e=>{let t=Re(e),n=e.parts?.filter(e=>e.type===`tool-invocation`&&e.toolInvocation).map(e=>({toolName:e.toolInvocation.toolName,args:e.toolInvocation.args,state:e.toolInvocation.state,result:typeof e.toolInvocation.result==`string`?e.toolInvocation.result.slice(0,2e3):e.toolInvocation.result==null?void 0:JSON.stringify(e.toolInvocation.result).slice(0,2e3)})),r=t||(n?.length?`[Tool calls: ${n.map(e=>`${e.toolName}(${e.state})`).join(`, `)}]`:``);return{id:e.id,role:e.role,content:r,timestamp:e.timestamp,toolInvocations:n?.length?n:void 0}}),[be,Re]),Be=(0,W.useCallback)((e,t={})=>{typeof window>`u`||window.parent===window||window.parent.postMessage({type:e,serverId:a,...t},`*`)},[a]);(0,W.useEffect)(()=>{Be(`mcp-inspector:chat:ready`,{capabilities:{send:!0,clear:!0,getState:!0,setQuickQuestions:!0,setFollowups:!0,loadMessages:!0}})},[Be]),(0,W.useEffect)(()=>{Be(`mcp-inspector:chat:state_changed`,{isLoading:xe,messageCount:be.length,messages:ze(),quickQuestions:N,followups:F})},[F,ze,xe,be.length,Be,N]),(0,W.useEffect)(()=>{let e=e=>{if(!e.data||typeof e.data!=`object`)return;let n=e.data;if(!n.type?.startsWith(`mcp-inspector:chat:`)||n.serverId&&n.serverId!==a)return;let r=n.requestId,i=(e,t={})=>{Be(`mcp-inspector:chat:command_result`,{requestId:r,ok:e,...t})};if(n.type===`mcp-inspector:chat:send`){let e=(n.message??n.prompt??``).trim();if(!e){i(!1,{error:`Missing message`});return}if(!pe||!t){i(!1,{error:`Chat is not ready to send messages`});return}Ce(e,[]).then(()=>{Be(`mcp-inspector:chat:message_sent`,{requestId:r,message:e,source:`bridge`}),i(!0)}).catch(e=>{i(!1,{error:e instanceof Error?e.message:String(e)})});return}if(n.type===`mcp-inspector:chat:clear`){we(),Be(`mcp-inspector:chat:cleared`,{requestId:r}),i(!0);return}if(n.type===`mcp-inspector:chat:get_state`){Be(`mcp-inspector:chat:state`,{requestId:r,isLoading:xe,messageCount:be.length,messages:ze(),quickQuestions:N,followups:F}),i(!0);return}if(n.type===`mcp-inspector:chat:set_quick_questions`){let e=Le(n.questions);P(e),i(!0,{quickQuestions:e});return}if(n.type===`mcp-inspector:chat:set_followups`){let e=Le(n.followups);I(e),i(!0,{followups:e});return}if(n.type===`mcp-inspector:chat:load_messages`){let e=n.messages;if(!Array.isArray(e)){i(!1,{error:`messages must be an array`});return}Te(e),i(!0,{count:e.length});return}if(n.type===`mcp-inspector:chat:screenshot`){let e=n.toolCallId;(async()=>{try{let t=null;if(e&&(t=document.querySelector(`[data-tool-call-id="${e}"]`)),!t){let e=document.querySelectorAll(`[data-tool-call-id]`);e.length>0&&(t=e[e.length-1])}if(!t&&V.current&&(t=V.current),!t){i(!1,{error:`No screenshot target found`});return}let n=1e4,a=null,o=``,s=``;try{let e=await z(()=>import(`https://esm.sh/html-to-image@1.11.13`),[]);e?.toPng?a=await Promise.race([e.toPng(t,{pixelRatio:1,backgroundColor:`#ffffff`,includeQueryParams:!0}),new Promise((e,t)=>setTimeout(()=>t(Error(`html-to-image timed out`)),n))]):o=`toPng not found on module`}catch(e){o=e instanceof Error?e.message:String(e)}if(!a)try{if(!window.html2canvas){let e=document.createElement(`script`);e.src=`https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js`,document.head.appendChild(e),await new Promise((t,n)=>{e.onload=()=>t(),e.onerror=()=>n(Error(`Failed to load html2canvas`))})}let e=window.html2canvas;a=(await Promise.race([e(t,{useCORS:!0,allowTaint:!0,backgroundColor:`#ffffff`,scale:1,logging:!1,foreignObjectRendering:!1}),new Promise((e,t)=>setTimeout(()=>t(Error(`html2canvas timed out`)),n))])).toDataURL(`image/png`)}catch(e){s=e instanceof Error?e.message:String(e)}if(a)Be(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:a,timestamp:Date.now()}),i(!0);else{let t=V.current||document.body,n=t.innerText?.substring(0,5e3)||``,a=t.innerHTML?.substring(0,1e4)||``;Be(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:``,domText:n,domHtml:a,error:`html-to-image: ${o||`ok`}; html2canvas: ${s||`ok`}`,timestamp:Date.now()}),i(!1,{error:`html-to-image: ${o}; html2canvas: ${s}`})}}catch(t){let n=(V.current||document.body).innerText?.substring(0,5e3)||``;Be(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:``,domText:n,error:t instanceof Error?t.message:`Screenshot capture failed`,timestamp:Date.now()}),i(!1,{error:t instanceof Error?t.message:`Screenshot failed`})}})();return}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[we,Te,F,ze,xe,be.length,Be,N,Le,Ce,a,pe,t]),FB(r?{onNewChat:we}:{});let Ve=(0,W.useCallback)(()=>{M(-1),A(!1),ee.current=null},[]),He=(0,W.useCallback)(()=>{if(!B.current)return;let e=B.current.selectionStart,t=D.slice(0,e),n=Jie.test(t);A(n),n?(ee.current={start:e-1,end:e},M(0)):Ve()},[D,Ve]);(0,W.useEffect)(()=>{pe&&be.length===0&&B.current&&B.current.focus()},[pe,be.length]),(0,W.useEffect)(()=>{!xe&&be.length>0&&B.current&&B.current.focus()},[xe,be.length]),(0,W.useEffect)(()=>{B.current&&He()},[D,He]);let Ue=(0,W.useCallback)(()=>{Ae(null),Me({}),Ve()},[Ve]),We=(0,W.useCallback)(async e=>{if(Ae(e),e.arguments&&e.arguments.length>0){Ae(null),nv.error(`Prompts with arguments are not supported`,{description:`This prompt requires arguments which are not yet supported in chat mode.`});return}try{await Ne(e,{})}catch(e){console.error(`Error executing prompt`,e)}finally{if(B.current&&ee.current){let{start:e,end:t}=ee.current;O(D.slice(0,e)+D.slice(t)),requestAnimationFrame(()=>{B.current?.focus(),B.current?.setSelectionRange(e,e)})}Ue()}},[Ne,Ue,D]),Ge=(0,W.useCallback)(()=>{(D.trim()||Pe.length>0||Se.length>0)&&(Ce(D,Pe),O(``),Ie())},[D,Pe,Ce,Ie,Se]),G=(0,W.useCallback)(e=>{if(e.key===`ArrowDown`)M(e=>ke.length===0?-1:(e+1)%ke.length);else if(e.key===`ArrowUp`)M(e=>ke.length===0?-1:(e-1+ke.length)%ke.length);else if(e.key===`Escape`)e.stopPropagation(),Ve();else if(e.key===`Enter`&&j>=0){let e=ke[j];e&&We(e)}},[ke,j,We,Ve]),Ke=(0,W.useCallback)(e=>{Yie.includes(e.key)&&k?(e.preventDefault(),G(e)):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ge())},[Ge,G,k]),qe=(0,W.useCallback)(e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&He()},[He]),Je=(0,W.useCallback)(()=>{fe(),we()},[fe,we]),Ye=(0,W.useCallback)(e=>{e.trim()&&(!pe||!t||Ce(e,[]).then(()=>{Be(`mcp-inspector:chat:message_sent`,{message:e,source:`quick_question`})}))},[Be,Ce,pe,t]),Xe=(0,W.useCallback)(e=>{e.trim()&&(!pe||!t||Ce(e,[]).then(()=>{Be(`mcp-inspector:chat:message_sent`,{message:e,source:`followup`})}))},[Be,Ce,pe,t]);return pe&&be.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[!me&&(0,U.jsx)(`div`,{className:`absolute top-4 right-4 z-10`,children:(0,U.jsx)(KH,{open:re,onOpenChange:ie,tempProvider:ae,tempModel:le,tempApiKey:se,onProviderChange:oe,onModelChange:ue,onApiKeyChange:ce,onSave:de,onClear:Je,showClearButton:!0,buttonLabel:`Change API Key`})}),(0,U.jsx)(DU,{mcpServerUrl:e.url,inputValue:D,isConnected:t,isLoading:xe,textareaRef:B,llmConfig:pe,promptsDropdownOpen:k,promptFocusedIndex:j,prompts:ke,selectedPrompt:je,promptResults:Pe,attachments:Se,tools:b?void 0:te,disabledTools:b?void 0:L,onDisabledToolsChange:b?void 0:R,onDeletePromptResult:Fe,onPromptSelect:We,onInputChange:O,onKeyDown:Ke,onKeyUp:qe,onClick:He,onSubmit:e=>{e.preventDefault(),Ge()},onConfigDialogOpenChange:ie,onAttachmentAdd:De,onAttachmentRemove:Oe,hideModelBadge:m,hideServerUrl:h,quickQuestions:N,onQuickQuestionSelect:Ye})]}):(0,U.jsxs)(`div`,{className:`flex flex-col h-full relative`,children:[(0,U.jsx)(qH,{llmConfig:pe,hasMessages:be.length>0,configDialogOpen:me?!1:re,onConfigDialogOpenChange:me?()=>{}:ie,onClearChat:we,tempProvider:ae,tempModel:le,tempApiKey:se,onProviderChange:oe,onModelChange:ue,onApiKeyChange:ce,onSaveConfig:de,onClearConfig:Je,hideConfigButton:me,clearButtonLabel:f,hideTitle:p,clearButtonHideIcon:g,clearButtonHideShortcut:_,clearButtonVariant:v,hideClearButton:y}),(0,U.jsx)(`div`,{ref:V,className:`flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]`,children:pe?(0,U.jsx)(Uie,{messages:be,isLoading:xe,serverId:e.url,readResource:s,tools:e.tools,sendMessage:(e,t)=>Ce(e,[],t),serverBaseUrl:e.url}):(0,U.jsx)(OU,{onConfigureClick:()=>ie(!0)})}),pe&&(0,U.jsx)(TU,{inputValue:D,isConnected:t,isLoading:xe,textareaRef:B,promptsDropdownOpen:k,promptFocusedIndex:j,prompts:ke,promptResults:Pe,selectedPrompt:je,attachments:Se,tools:b?void 0:te,disabledTools:b?void 0:L,onDisabledToolsChange:b?void 0:R,onDeletePromptResult:Fe,onPromptSelect:We,onInputChange:O,onKeyDown:Ke,onKeyUp:qe,onClick:He,onSendMessage:Ge,onStopStreaming:Ee,onAttachmentAdd:De,onAttachmentRemove:Oe,followups:F,onFollowupSelect:Xe})]})}var Xie=r({Group:()=>y7,Panel:()=>S7,Separator:()=>C7,isCoarsePointer:()=>w5,useDefaultLayout:()=>Cae,useGroupCallbackRef:()=>Tae,useGroupRef:()=>Eae,usePanelCallbackRef:()=>kae,usePanelRef:()=>Aae});function Zie(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Qie(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function $ie(e){return e/100*window.innerHeight}function eae(e){return e/100*window.innerWidth}function tae(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function h5({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=tae(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Qie(t,i);break;case`em`:r=Zie(t,i);break;case`vh`:r=$ie(i);break;case`vw`:r=eae(i);break}return r}function g5(e){return parseFloat(e.toFixed(3))}function _5({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function v5(e){let{panels:t}=e,n=_5({group:e});return n===0?t.map(e=>({collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=g5(h5({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=g5(h5({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=g5(h5({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=g5(h5({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function y5(e,t=`Assertion error`){if(!e)throw Error(t)}function b5(e,t){return Array.from(t).sort(e===`horizontal`?nae:rae)}function nae(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function rae(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function x5(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function S5(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function iae({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=S5(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return y5(i,`No rect found`),i}var C5;function w5(){return C5===void 0&&(C5=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),C5}function T5(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=b5(n,Array.from(t.children).filter(x5).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.ariaDisabled===null&&(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,iae({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=w5()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:_5({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var aae=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}};function E5(e,t,n=0){return Math.abs(g5(e)-g5(t))<=n}var D5={cursorFlags:0,interactionState:{state:`inactive`},mountedGroups:new Map},O5=new aae;function k5(){return D5}function A5(e){let t=typeof e==`function`?e(D5):e;if(D5===t)return D5;let n=D5;return D5={...D5,...t},t.cursorFlags!==void 0&&O5.emit(`cursorFlagsChange`,D5.cursorFlags),t.interactionState!==void 0&&O5.emit(`interactionStateChange`,D5.interactionState),t.mountedGroups!==void 0&&(D5.mountedGroups.forEach((e,t)=>{e.derivedPanelConstraints.forEach(r=>{if(r.collapsible){let{layout:i}=n.mountedGroups.get(t)??{};if(i){let n=E5(r.collapsedSize,e.layout[r.panelId]),a=E5(r.collapsedSize,i[r.panelId]);n&&!a&&(t.inMemoryLastExpandedPanelSizes[r.panelId]=i[r.panelId])}}})}),O5.emit(`mountedGroupsChange`,D5.mountedGroups)),D5}function oae(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=S5(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function sae(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function cae(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:N5(e),b:N5(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();y5(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:M5(j5(n.a)),b:M5(j5(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var lae=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function uae(e){let t=getComputedStyle(P5(e)??e).display;return t===`flex`||t===`inline-flex`}function dae(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||uae(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||lae.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function j5(e){let t=e.length;for(;t--;){let n=e[t];if(y5(n,`Missing node`),dae(n))return n}return null}function M5(e){return e&&Number(getComputedStyle(e).zIndex)||0}function N5(e){let t=[];for(;e;)t.push(e),e=P5(e);return t}function P5(e){let{parentNode:t}=e;return sae(t)?t.host:t}function fae(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function pae({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!x5(n)||n.contains(e)||e.contains(n))return!0;if(cae(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(fae(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function F5(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=T5(r),a=oae(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&pae({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function mae(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function I5(e,t){return E5(e,t)?0:e>t?1:-1}function L5({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(I5(r,c)<0)if(a){let e=(i+c)/2;r=I5(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=g5(r),r}function R5({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(E5(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;y5(u!=null,`Invalid first pivot index`),y5(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];y5(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(y5(n!=null,`Previous layout not found for panel index ${t}`),E5(n,i)){let t=o-n;I5(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];y5(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(y5(n!=null,`Previous layout not found for panel index ${t}`),E5(n,o)){let t=n-i;I5(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];y5(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&I5(i,c)<0)if(e>0){let t=c-o,n=t/2;I5(i+e,c)<0&&(e=I5(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;I5(i-e,c)<0&&(e=I5(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];y5(e!=null,`Previous layout not found for panel index ${r}`);let a=L5({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];y5(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=L5({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!E5(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(mae(c,l))return i;{let t=e<0?d:u,r=s[t];y5(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=L5({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!E5(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];y5(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=L5({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(E5(i,s)||(t-=s-i,l[r]=s),E5(t,0))break;e>0?r--:r++}}}if(!E5(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function z5(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||I5(e[n],t[n])!==0)return!1;return!0}function B5({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!E5(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];y5(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];y5(i!=null,`No layout data found for index ${e}`);let o=r[e];y5(o!=null,`No layout data found for index ${e}`);let s=L5({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!E5(a,0))for(let e=0;e<t.length;e++){let n=r[e];y5(n!=null,`No layout data found for index ${e}`);let i=n+a,o=L5({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,E5(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function V5({groupId:e,panelId:t}){let n=()=>{let{mountedGroups:t}=k5();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,separatorToPanels:o}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,layout:a,separatorToPanels:o};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,layout:c,separatorToPanels:l}=n(),u=s.panels.findIndex(e=>e.id===t),d=u===s.panels.length-1,f=B5({layout:R5({delta:d?r-e:e-r,initialLayout:c,panelConstraints:o,pivotIndices:d?[u-1,u]:[u,u+1],prevLayout:c,trigger:`imperative-api`}),panelConstraints:o});z5(c,f)||A5(e=>({mountedGroups:new Map(e.mountedGroups).set(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,layout:f,separatorToPanels:l})}))};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&E5(t,n)},resize:e=>{if(a()!==e){let t;switch(typeof e){case`number`:{let{group:r}=n();t=g5(e/_5({group:r})*100);break}case`string`:t=parseFloat(e);break}o(t)}}}}function H5(e){if(e.defaultPrevented)return;let{mountedGroups:t}=k5();F5(e,t).forEach(t=>{if(t.separator){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=V5({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function U5(e){let{mountedGroups:t}=k5();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function W5({groupId:e}){let t=()=>{let{mountedGroups:t}=k5();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,layout:a,separatorToPanels:o}=t(),s=B5({layout:e,panelConstraints:r});if(n)return a;if(!z5(a,s)){A5(e=>({mountedGroups:new Map(e.mountedGroups).set(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,layout:s,separatorToPanels:o})}));let e=i.panels.map(({id:e})=>e).join(`,`);i.inMemoryLayouts[e]=s}return s}}}function G5(e){let{mountedGroups:t}=k5(),n=t.get(e);return y5(n,`Mounted Group ${e.id} not found`),n}function K5(e,t){let n=U5(e),r=G5(n),i=n.separators.find(t=>t.element===e);y5(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);y5(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=W5({groupId:n.id}).getLayout(),c=B5({layout:R5({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});z5(s,c)||A5(e=>({mountedGroups:new Map(e.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:c,separatorToPanels:r.separatorToPanels})}))}function q5(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=U5(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&K5(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&K5(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&K5(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&K5(t,-5);break;case`End`:e.preventDefault(),K5(t,100);break;case`Enter`:{e.preventDefault();let n=U5(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=G5(n),o=n.separators.find(e=>e.element===t);y5(o,`Matching separator not found`);let s=a.get(o);y5(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(y5(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];K5(t,(l.collapsedSize===e?n.inMemoryLastExpandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=U5(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);y5(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus();break}case`Home`:e.preventDefault(),K5(t,-100);break}}function J5(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let{mountedGroups:t}=k5(),n=F5(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus()));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),A5({interactionState:{hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}}),n.length&&e.preventDefault()}var hae=e=>e,Y5=()=>{},X5=1,Z5=2,Q5=4,$5=8,e7=3,t7=12,n7;function r7(){return n7===void 0&&(n7=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(n7=!0)),n7}function gae({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&r7()){let t=(e&X5)!==0,n=(e&Z5)!==0,r=(e&Q5)!==0,i=(e&$5)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return r7()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var i7=new WeakMap;function a7(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=i7.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets.push(n));let{cursorFlags:r,interactionState:i}=k5();switch(i.state){case`active`:case`hover`:{let e=gae({cursorFlags:r,groups:i.hitRegions.map(e=>e.group),state:i.state}),a=`*, *:hover {cursor: ${e} !important; }`;if(t===a)return;t=a,e?n.cssRules.length===0?n.insertRule(a):n.replaceSync(a):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}i7.set(e,{prevStyle:t,styleSheet:n})}function o7({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0,c=new Map(i);n.forEach(e=>{let{group:n,groupSize:o}=e,{disableCursor:l,orientation:u,panels:d}=n,f=0;f=a?u===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:u===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let p=r.get(n),{defaultLayoutDeferred:m,derivedPanelConstraints:h,layout:g,separatorToPanels:_}=i.get(n)??{defaultLayoutDeferred:!1};if(h&&p&&g&&_){let t=R5({delta:f,initialLayout:p,panelConstraints:h,pivotIndices:e.panels.map(e=>d.indexOf(e)),prevLayout:g,trigger:`mouse-or-touch`});if(z5(t,g)){if(f!==0&&!l)switch(u){case`horizontal`:s|=f<0?X5:Z5;break;case`vertical`:s|=f<0?Q5:$5;break}}else{c.set(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,layout:t,separatorToPanels:_});let n=e.group.panels.map(({id:e})=>e).join(`,`);e.group.inMemoryLayouts[n]=t}}});let l=0;t.movementX===0?l|=o&e7:l|=s&e7,t.movementY===0?l|=o&t7:l|=s&t7,A5({cursorFlags:l,mountedGroups:c}),a7(e)}function s7(e){let{cursorFlags:t,interactionState:n,mountedGroups:r}=k5();switch(n.state){case`active`:o7({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:r,prevCursorFlags:t})}}function c7(e){if(e.defaultPrevented)return;let{cursorFlags:t,interactionState:n,mountedGroups:r}=k5();switch(n.state){case`active`:if(e.buttons===0){A5(e=>e.interactionState.state===`inactive`?e:{cursorFlags:0,interactionState:{state:`inactive`}}),A5(e=>({mountedGroups:new Map(e.mountedGroups)}));return}o7({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:t});break;default:{let t=F5(e,r);t.length===0?n.state!==`inactive`&&A5({interactionState:{state:`inactive`}}):A5({interactionState:{hitRegions:t,state:`hover`}}),a7(e.currentTarget);break}}}function l7(e){if(e.relatedTarget instanceof HTMLIFrameElement){let{interactionState:e}=k5();switch(e.state){case`hover`:A5({interactionState:{state:`inactive`}})}}}function u7(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let{interactionState:t}=k5();switch(t.state){case`active`:A5({cursorFlags:0,interactionState:{state:`inactive`}}),t.hitRegions.length>0&&(a7(e.currentTarget),A5(e=>({mountedGroups:new Map(e.mountedGroups)})),e.preventDefault())}}function d7(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=g5(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=g5((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function _ae(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=_5({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:g5(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function vae(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function yae(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var f7=new Map;function bae(e){let t=!0;y5(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){if(_5({group:e})===0)return;A5(t=>{let n=t.mountedGroups.get(e);if(n){let r=v5(e),i=n.defaultLayoutDeferred?d7(r):n.layout,a=B5({layout:i,panelConstraints:r});return!n.defaultLayoutDeferred&&z5(i,a)&&vae(n.derivedPanelConstraints,r)?t:{mountedGroups:new Map(t.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,layout:a,separatorToPanels:n.separatorToPanels})}}return t})}}else _ae(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{y5(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=_5({group:e}),s=v5(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.defaultLayout;l&&(yae(e.panels,l)||(l=void 0));let u=B5({layout:e.inMemoryLayouts[c]??l??d7(s),panelConstraints:s}),d=T5(e),f=e.element.ownerDocument;return A5(t=>{let n=new Map;return f7.set(f,(f7.get(f)??0)+1),d.forEach(e=>{e.separator&&n.set(e.separator,e.panels)}),{mountedGroups:new Map(t.mountedGroups).set(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,layout:u,separatorToPanels:n})}}),e.separators.forEach(e=>{y5(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,q5)}),f7.get(f)===1&&(f.addEventListener(`dblclick`,H5,!0),f.addEventListener(`pointerdown`,J5,!0),f.addEventListener(`pointerleave`,s7),f.addEventListener(`pointermove`,c7),f.addEventListener(`pointerout`,l7),f.addEventListener(`pointerup`,u7,!0)),function(){t=!1,f7.set(f,Math.max(0,(f7.get(f)??0)-1)),A5(t=>{let n=new Map(t.mountedGroups);return n.delete(e),{mountedGroups:n}}),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,q5)}),f7.get(f)||(f.removeEventListener(`dblclick`,H5,!0),f.removeEventListener(`pointerdown`,J5,!0),f.removeEventListener(`pointerleave`,s7),f.removeEventListener(`pointermove`,c7),f.removeEventListener(`pointerout`,l7),f.removeEventListener(`pointerup`,u7,!0)),a.disconnect()}}function xae(){let[e,t]=(0,W.useState)({});return[e,(0,W.useCallback)(()=>t({}),[])]}function p7(e){let t=(0,W.useId)();return`${e??t}`}var m7=typeof window<`u`?W.useLayoutEffect:W.useEffect;function h7(e){let t=(0,W.useRef)(e);return m7(()=>{t.current=e},[e]),(0,W.useCallback)((...e)=>t.current?.(...e),[t])}function g7(...e){return h7(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function _7(e){let t=(0,W.useRef)({...e});return m7(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var v7=(0,W.createContext)(null);function Sae(e,t){let n=(0,W.useRef)({getLayout:()=>({}),setLayout:hae});(0,W.useImperativeHandle)(t,()=>n.current,[]),m7(()=>{Object.assign(n.current,W5({groupId:e}))})}function y7({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,W.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=h7(e=>{z5(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=h7(e=>{z5(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=p7(s),v=(0,W.useRef)(null),[y,b]=xae(),x=(0,W.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=g7(v,a);Sae(_,o);let C=h7((e,t)=>{let{interactionState:r,mountedGroups:i}=k5();for(let n of i.keys())if(n.id===e){let e=i.get(n);if(e){let i=!1;switch(r.state){case`active`:i=r.hitRegions.some(e=>e.group===n);break}return{flexGrow:e.layout[t]??1,pointerEvents:i?`none`:void 0}}}return{flexGrow:n?.[t]??1}}),w=_7({defaultLayout:n,disableCursor:r}),T=(0,W.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=b5(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=b5(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},togglePanelDisabled:(e,t)=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let{mountedGroups:r}=k5();for(let e of r.keys())if(e.id===_){let t=r.get(e);t&&(t.derivedPanelConstraints=v5(e))}},toggleSeparatorDisabled:(e,t)=>{let n=x.current.separators.find(t=>t.id===e);n&&(n.disabled=t)}}),[C,_,b,u,w]),E=(0,W.useRef)(null);return m7(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={defaultLayout:n,disableCursor:!!w.disableCursor,disabled:!!i,element:e,id:_,inMemoryLastExpandedPanelSizes:x.current.lastExpandedPanelSizes,inMemoryLayouts:x.current.layouts,orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=bae(r),o=k5().mountedGroups.get(r);if(o){let{defaultLayoutDeferred:e,derivedPanelConstraints:t,layout:n}=o;!e&&t.length>0&&(h(n),g(n))}let s=O5.addListener(`interactionStateChange`,e=>{e.state}),c=O5.addListener(`mountedGroupsChange`,e=>{let t=e.get(r);if(t){let{defaultLayoutDeferred:e,derivedPanelConstraints:n,layout:r}=t;if(e||n.length===0)return;let{interactionState:i}=k5(),a=i.state!==`active`;h(r),a&&g(r)}});return()=>{E.current=null,a(),s(),c()}},[i,_,g,h,u,y,w]),(0,W.useEffect)(()=>{let e=E.current;e&&(e.defaultLayout=n,e.disableCursor=!!r)}),(0,U.jsx)(v7.Provider,{value:T,children:(0,U.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}y7.displayName=`Group`;function b7(e,t){return`react-resizable-panels:${[e,...t].join(`:`)}`}function Cae({debounceSaveMs:e=100,panelIds:t,storage:n=localStorage,...r}){let i=t!==void 0,a=`id`in r?r.id:r.groupId,o=b7(a,t??[]),s=(0,W.useSyncExternalStore)(wae,()=>n.getItem(o),()=>n.getItem(o)),c=(0,W.useMemo)(()=>s?JSON.parse(s):void 0,[s]),l=(0,W.useRef)(null),u=(0,W.useCallback)(()=>{let e=l.current;e&&(l.current=null,clearTimeout(e))},[]);(0,W.useLayoutEffect)(()=>()=>{u()},[u]);let d=(0,W.useCallback)(e=>{u();let t;t=i?b7(a,Object.keys(e)):b7(a,[]);try{n.setItem(t,JSON.stringify(e))}catch(e){console.error(e)}},[u,i,a,n]);return{defaultLayout:c,onLayoutChange:(0,W.useCallback)(t=>{u(),e===0?d(t):l.current=setTimeout(()=>{d(t)},e)},[u,e,d]),onLayoutChanged:d}}function wae(){return function(){}}function Tae(){return(0,W.useState)(null)}function Eae(){return(0,W.useRef)(null)}function x7(){let e=(0,W.useContext)(v7);return y5(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Dae(e,t){let{id:n}=x7(),r=(0,W.useRef)({collapse:Y5,expand:Y5,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Y5});(0,W.useImperativeHandle)(t,()=>r.current,[]),m7(()=>{Object.assign(r.current,V5({groupId:n,panelId:e}))})}function S7({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,id:s,maxSize:c=`100%`,minSize:l=`0%`,onResize:u,panelRef:d,style:f,...p}){let m=!!s,h=p7(s),g=_7({disabled:a}),_=(0,W.useRef)(null),v=g7(_,o),{getPanelStyles:y,id:b,orientation:x,registerPanel:S,togglePanelDisabled:C}=x7(),w=u!==null,T=h7((e,t,n)=>{u?.(e,s,n)});m7(()=>{let e=_.current;if(e!==null)return S({element:e,id:h,idIsStable:m,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:w?T:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,disabled:g.disabled,maxSize:c,minSize:l}})},[n,r,i,w,h,m,c,l,T,S,g]),(0,W.useEffect)(()=>{C(h,!!a)},[a,h,C]),Dae(h,d);let E=(0,W.useSyncExternalStore)(e=>(O5.addListener(`mountedGroupsChange`,e),()=>{O5.removeListener(`mountedGroupsChange`,e)}),()=>JSON.stringify(y(b,h)),()=>JSON.stringify(y(b,h)));return(0,U.jsx)(`div`,{...p,"aria-disabled":a||void 0,"data-panel":!0,"data-testid":h,id:h,ref:v,style:{...Oae,display:`flex`,flexBasis:0,flexShrink:1,overflow:`hidden`,...JSON.parse(E)},children:(0,U.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,...f,touchAction:x===`horizontal`?`pan-y`:`pan-x`},children:e})})}S7.displayName=`Panel`;var Oae={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function kae(){return(0,W.useState)(null)}function Aae(){return(0,W.useRef)(null)}function jae({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=B5({layout:R5({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=B5({layout:R5({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function C7({children:e,className:t,disabled:n,elementRef:r,id:i,style:a,...o}){let s=p7(i),c=_7({disabled:n}),[l,u]=(0,W.useState)({}),[d,f]=(0,W.useState)(`inactive`),p=(0,W.useRef)(null),m=g7(p,r),{disableCursor:h,id:g,orientation:_,registerSeparator:v,toggleSeparatorDisabled:y}=x7(),b=_===`horizontal`?`vertical`:`horizontal`;m7(()=>{let e=p.current;if(e!==null){let t={disabled:c.disabled,element:e,id:s},n=v(t),r=O5.addListener(`interactionStateChange`,e=>{f(e.state!==`inactive`&&e.hitRegions.some(e=>e.separator===t)?e.state:`inactive`)}),i=O5.addListener(`mountedGroupsChange`,e=>{e.forEach(({derivedPanelConstraints:e,layout:n,separatorToPanels:r},i)=>{if(i.id===g){let a=r.get(t);if(a){let t=a[0],r=i.panels.indexOf(t);u(jae({layout:n,panelConstraints:e,panelId:t.id,panelIndex:r}))}}})});return()=>{r(),i(),n()}}},[g,s,v,c]),(0,W.useEffect)(()=>{y(s,!!n)},[n,s,y]);let x;return n&&!h&&(x=`not-allowed`),(0,U.jsx)(`div`,{...o,"aria-controls":l.valueControls,"aria-disabled":n||void 0,"aria-orientation":b,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":n?`disabled`:d,"data-testid":s,id:s,ref:m,role:`separator`,style:{flexBasis:`auto`,cursor:x,...a,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}C7.displayName=`Separator`;var{usePanelRef:w7}=Xie;function T7({className:e,...t}){return(0,U.jsx)(y7,{"data-slot":`resizable-panel-group`,className:K(`flex h-full w-full aria-[orientation=vertical]:flex-col`,e),...t})}function E7({...e}){return(0,U.jsx)(S7,{"data-slot":`resizable-panel`,...e})}function D7({withHandle:e,className:t,...n}){return(0,U.jsx)(C7,{"data-slot":`resizable-handle`,className:K(`relative flex items-center justify-center bg-border`,`focus-visible:ring-ring focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden`,`after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2`,`aria-[orientation=vertical]:h-auto aria-[orientation=vertical]:w-px`,`aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full`,`aria-[orientation=vertical]:after:left-0 aria-[orientation=vertical]:after:h-1 aria-[orientation=vertical]:after:w-full aria-[orientation=vertical]:after:translate-x-0 aria-[orientation=vertical]:after:-translate-y-1/2`,`[&[aria-orientation=horizontal]>div]:rotate-90`,t),...n,children:e&&(0,U.jsx)(`div`,{className:`bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border`,children:(0,U.jsx)(mp,{className:`size-2.5`})})})}function O7({className:e,...t}){return(0,U.jsx)(`kbd`,{"data-slot":`kbd`,className:K(`bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none`,`[&_svg:not([class*='size-'])]:size-3`,`[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10`,e),...t})}function Mae({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onCancelAll:s,searchInputRef:c}){return(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,U.jsx)(my,{ref:c,placeholder:`Search requests...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,"data-testid":`elicitation-tab-header`,children:`Elicitation`}),(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]})]})}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,U.jsx)(nm,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{side:`bottom`,children:`Cancel all`})]})})]})}function k7({id:e,isSelected:t,isFocused:n,icon:r,title:i,description:a,metadata:o,onClick:s,className:c,"data-testid":l}){return(0,U.jsx)(`button`,{id:e,"data-testid":l,type:`button`,onClick:s,className:K(`w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group`,t&&`bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500`,n&&`ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset`,c),children:(0,U.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3`,children:[r&&(0,U.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,U.jsx)(`div`,{className:K(`p-2.5 rounded-full transition-colors`,t?`bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900`:`bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600`),children:r})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 mb-1`,children:(0,U.jsx)(`h3`,{className:K(`font-medium truncate font-mono text-sm`),children:i})}),a&&(0,U.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 line-clamp-2`,children:a})]}),o&&(0,U.jsx)(`div`,{className:`flex-shrink-0 flex items-center self-center`,children:o})]})})}function Nae({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(Iu,{vertical:!0,noBorder:!0,message:`No elicitation requests`})}):(0,U.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e.request.mode||`form`,s=o===`form`&&`requestedSchema`in e.request&&e.request.requestedSchema;return(0,U.jsx)(k7,{id:`elicitation-request-${e.id}`,"data-testid":`elicitation-request-item-${a}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,U.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,U.jsx)(sn,{variant:`outline`,className:o===`url`?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:o})]}),description:(()=>{let t=i(e.timestamp),n=[];return s&&n.push(`with schema`),o===`url`&&n.push(`external action`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function A7(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.const==`string`&&(t.title===void 0||typeof t.title==`string`)}function Pae(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(A7):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(A7):[];return t.length>0?t:n}function Fae(e){let t=e.items&&typeof e.items==`object`?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(A7):[],r=Array.isArray(t.oneOf)?t.oneOf.filter(A7):[];return n.length>0?n:r}function Iae({request:e,onApprove:t,onReject:r,onClose:i,previewMode:a,onTogglePreview:o,isCopied:s,onCopy:c,onDownload:l,onFullscreen:u}){let[d,f]=(0,W.useState)({}),[p,m]=(0,W.useState)(!1),h=e?.request.mode||`form`,g=h===`form`,_=h===`url`;(0,W.useEffect)(()=>{if(e&&g&&`requestedSchema`in e.request){let t=e.request.requestedSchema,n={};if(t?.type===`object`&&t.properties)for(let[e,r]of Object.entries(t.properties)){let t=r;t.default===void 0?t.type===`array`?n[e]=[]:t.type===`boolean`?n[e]=!1:t.type===`number`||t.type===`integer`?n[e]=0:n[e]=``:n[e]=t.default}f(n)}m(!1)},[e?.id,g]);let v=(e,t)=>{f(n=>({...n,[e]:t}))},y=()=>{if(e){if(g){if(`requestedSchema`in e.request){let t=e.request.requestedSchema;if(t?.required){let e=t.required.filter(e=>d[e]===void 0||d[e]===``||d[e]===null);if(e.length>0){nv.error(`Missing required fields`,{description:`Please fill in: ${e.join(`, `)}`});return}}}t(e.id,{action:`accept`,content:d})}else _&&t(e.id,{action:`accept`});i(),z(()=>import(`./react-C6BFTceN.js`).then(e=>n(e.default,1)).then(e=>{let t=nv(e.createElement(`div`,{className:`space-y-3`},e.createElement(`div`,null,e.createElement(`strong`,null,`Elicitation Response Sent`),e.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),e.createElement(`div`,{className:`flex gap-2`},e.createElement(`button`,{"data-testid":`elicitation-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let e=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:null}});window.dispatchEvent(e),nv.dismiss(t)}},`View Tool Result`))),{duration:5e3})}),[])}},b=()=>{e&&(t(e.id,{action:`decline`}),i())},x=()=>{e&&(r(e.id,`User cancelled elicitation request`),i())},S=()=>{e&&_&&`url`in e.request&&(window.open(e.request.url,`_blank`),m(!0))},C=(0,W.useMemo)(()=>{if(!e||!g||!(`requestedSchema`in e.request))return null;let t=e.request.requestedSchema;if(!t||t.type!==`object`||!t.properties)return(0,U.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No form schema available`});let n=t.properties,r=t.required||[];return(0,U.jsx)(`div`,{className:`space-y-4`,children:Object.entries(n).map(([e,t])=>{let n=t,i=r.includes(e),a=n.type||`string`,o=n.title||e,s=n.description,c=Pae(n),l=c.length>0,u=Array.isArray(n.enum),f=a===`array`&&Array.isArray(n.items?.enum),p=Fae(n),m=a===`array`&&p.length>0,h=Array.isArray(d[e])?d[e]:[];return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:`field-${e}`,children:[o,i&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),s&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s}),a===`boolean`?(0,U.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,U.jsx)(uU,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,checked:d[e]||!1,onCheckedChange:t=>v(e,t)}),(0,U.jsx)(yy,{htmlFor:`field-${e}`,className:`text-sm font-normal cursor-pointer`,children:n.title||e})]}):a===`number`||a===`integer`?(0,U.jsx)(my,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,type:`number`,value:d[e]||``,onChange:t=>v(e,a===`integer`?parseInt(t.target.value,10):parseFloat(t.target.value)),placeholder:n.default?.toString()||``}):l?(0,U.jsxs)(`select`,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,U.jsx)(`option`,{value:``,children:`Select...`}),c.map(e=>(0,U.jsx)(`option`,{value:e.const,children:e.title||e.const},e.const))]}):u?(0,U.jsxs)(`select`,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,U.jsx)(`option`,{value:``,children:`Select...`}),n.enum.map((e,t)=>(0,U.jsx)(`option`,{value:e,children:n.enumNames?.[t]||e},e))]}):f?(0,U.jsx)(`div`,{className:`space-y-2`,"data-testid":`elicitation-field-${e}`,children:n.items.enum.map(t=>{let n=`field-${e}-${t}`;return(0,U.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,U.jsx)(uU,{id:n,checked:h.includes(t),onCheckedChange:n=>{v(e,n?[...h,t]:h.filter(e=>e!==t))}}),(0,U.jsx)(yy,{htmlFor:n,className:`text-sm font-normal cursor-pointer`,children:t})]},t)})}):m?(0,U.jsx)(`div`,{className:`space-y-2`,"data-testid":`elicitation-field-${e}`,children:p.map(t=>{let n=`field-${e}-${t.const}`;return(0,U.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,U.jsx)(uU,{id:n,checked:h.includes(t.const),onCheckedChange:n=>{v(e,n?[...h,t.const]:h.filter(e=>e!==t.const))}}),(0,U.jsx)(yy,{htmlFor:n,className:`text-sm font-normal cursor-pointer`,children:t.title||t.const})]},t.const)})}):a===`string`&&(n.format===`textarea`||n.maxLength>100)?(0,U.jsx)(JH,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),placeholder:n.default||``,rows:4}):(0,U.jsx)(my,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,type:`text`,value:d[e]||``,onChange:t=>v(e,t.target.value),placeholder:n.default||``})]},e)})})},[e,d,g]);return e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.serverName}),(0,U.jsx)(sn,{variant:`outline`,className:_?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:h}),(0,U.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleString()})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:c,className:`h-8 w-8 p-0`,children:s?(0,U.jsx)(Uf,{className:`h-4 w-4 text-green-600`}):(0,U.jsx)(tp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Copy request`})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:l,className:`h-8 w-8 p-0`,children:(0,U.jsx)(rp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Download request`})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,U.jsx)(xp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Fullscreen`})]}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(nm,{className:`h-4 w-4`})})]})]}),(0,U.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Message`}),(0,U.jsx)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.request.message})]}),_&&`url`in e.request&&(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`External Action Required`}),(0,U.jsxs)(`div`,{className:`bg-muted rounded-lg p-4 space-y-3`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This request requires you to complete an action at an external URL:`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-background rounded border`,children:[(0,U.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:e.request.url}),(0,U.jsxs)(q,{size:`sm`,variant:`outline`,onClick:S,className:`flex items-center gap-2`,children:[(0,U.jsx)(ap,{className:`h-4 w-4`}),`Open URL`]})]}),(0,U.jsxs)(`div`,{className:`flex items-center space-x-2 pt-2`,children:[(0,U.jsx)(uU,{id:`url-completed`,checked:p,onCheckedChange:e=>m(!!e)}),(0,U.jsx)(yy,{htmlFor:`url-completed`,className:`text-sm font-normal cursor-pointer`,children:`I have completed the required action`})]})]})]}),g&&(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Form Data`}),C]}),g&&`requestedSchema`in e.request&&e.request.requestedSchema&&(0,U.jsxs)(`details`,{className:`space-y-2`,children:[(0,U.jsx)(`summary`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer`,children:`Schema (for reference)`}),(0,U.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,U.jsx)(pA,{data:e.request.requestedSchema})})]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,U.jsx)(q,{onClick:y,className:`flex-1`,"data-testid":`elicitation-accept-button`,children:`Accept`}),(0,U.jsx)(q,{onClick:b,variant:`outline`,className:`flex-1`,"data-testid":`elicitation-decline-button`,children:`Decline`}),(0,U.jsx)(q,{onClick:x,variant:`outline`,className:`flex-1`,"data-testid":`elicitation-cancel-button`,children:`Cancel`})]})]}):(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select an elicitation request to view details`})})}function j7(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<60?`just now`:r<60?`${r}m ago`:i<24?`${i}h ago`:a<7?`${a}d ago`:new Date(e).toLocaleDateString()}function Lae({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:i}){let{selectedElicitationRequestId:a,setSelectedElicitationRequestId:o}=jB(),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(-1),[p,m]=(0,W.useState)(!0),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(!0),[y,b]=(0,W.useState)(!1),x=(0,W.useRef)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(null),w=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(console.log(`[ElicitationTab] Auto-selection check:`,{selectedElicitationRequestId:a,pendingRequestsCount:e.length,currentSelectedId:s?.id}),a&&e.length>0){let t=e.find(e=>e.id===a);console.log(`[ElicitationTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[ElicitationTab] Auto-selecting request:`,t.id),o(null),c(t),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${t.id}`);console.log(`[ElicitationTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[a,e,o]),(0,W.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[ElicitationTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[ElicitationTab] Selecting request from event:`,n),c(r),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-elicitation`,t),()=>window.removeEventListener(`navigate-to-elicitation`,t)},[e]),(0,W.useEffect)(()=>{p&&e.length>0&&x.current&&!w.current&&(x.current.scrollTop=0)},[e.length,p]),(0,W.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{e.scrollTop>0&&(w.current=!0,m(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,W.useEffect)(()=>{e.length===0&&(w.current=!1,m(!0))},[e.length]),(0,W.useEffect)(()=>{h&&C.current&&C.current.focus()},[h]);let T=(0,W.useCallback)(()=>{l.trim()||g(!1)},[l]),E=(0,W.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||e.request.message.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,l]);(0,W.useEffect)(()=>{f(-1)},[l]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=E;if(e.key===`ArrowDown`)e.preventDefault(),f(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&d>=0){e.preventDefault();let t=E[d];t&&D(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[d,E]),(0,W.useEffect)(()=>{if(d>=0){let e=`elicitation-request-${E[d]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[d,E]);let D=(0,W.useCallback)(e=>{c(e)},[]),O=(0,W.useCallback)(()=>{window.confirm(`Are you sure you want to cancel all elicitation requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User cancelled all requests`)}),c(null))},[e,n]),k=(0,W.useCallback)(async()=>{if(s)try{await ih(JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)),b(!0),setTimeout(()=>b(!1),2e3)}catch(e){console.error(`[ElicitationTab] Failed to copy request:`,e)}},[s]),A=(0,W.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ElicitationTab] Failed to download request:`,e)}},[s]),j=(0,W.useCallback)(async()=>{if(S.current)try{document.fullscreenElement?await document.exitFullscreen():await S.current.requestFullscreen()}catch(e){console.error(`[ElicitationTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,U.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,U.jsx)(E7,{defaultSize:40,minSize:30,children:(0,U.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,U.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,U.jsx)(Mae,{isSearchExpanded:h,searchQuery:l,filteredRequestsCount:E.length,requestsCount:e.length,onSearchExpand:()=>g(!0),onSearchChange:u,onSearchBlur:T,onCancelAll:O,searchInputRef:C}),(0,U.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,U.jsx)(Nae,{requests:E,selectedRequest:s,onRequestSelect:D,focusedIndex:d,formatRelativeTime:j7,listRef:x})})]})})}),(0,U.jsx)(D7,{}),(0,U.jsx)(E7,{defaultSize:60,minSize:40,children:(0,U.jsx)(`div`,{ref:S,className:`h-full bg-white dark:bg-zinc-900`,children:(0,U.jsx)(Iae,{request:s,onApprove:t,onReject:n,onClose:()=>c(null),previewMode:_,onTogglePreview:()=>v(!_),isCopied:y,onCopy:k,onDownload:A,onFullscreen:j})})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(Kp,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function Rae({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onClearAll:s,searchInputRef:c}){return(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,U.jsx)(my,{ref:c,placeholder:`Search notifications...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Notifications`}),(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]})]})}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,U.jsx)($p,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{side:`bottom`,children:`Clear all`})]})})]})}function zae({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(Iu,{vertical:!0,noBorder:!0,message:`No notifications yet`})}):(0,U.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>(0,U.jsx)(k7,{id:`notification-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,U.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.method,!e.read&&(0,U.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=e.params&&Object.keys(e.params).length>0?Object.keys(e.params).length:0;return t+(n>0?` | ${n} param${n>1?`s`:``}`:``)})(),onClick:()=>n(e)},e.id))})}function Bae({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:i,onFullscreen:a,isCopied:o=!1,onClose:s}){return e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(Zf,{className:`h-3 w-3 text-gray-400`}),(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.formatRelativeTime(e.timestamp)})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:n,className:t?``:`text-purple-600 dark:text-purple-400`,children:[t?(0,U.jsx)(Qf,{className:`h-4 w-4 mr-1`}):(0,U.jsx)(Hf,{className:`h-4 w-4 mr-1`}),t?`JSON`:`Formatted`]}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,children:o?(0,U.jsx)(Uf,{className:`h-4 w-4`}):(0,U.jsx)(tp,{className:`h-4 w-4`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,children:(0,U.jsx)(rp,{className:`h-4 w-4`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:a,children:(0,U.jsx)(Sp,{className:`h-4 w-4`})}),s&&(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,children:(0,U.jsx)(nm,{className:`h-4 w-4`})})]})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,U.jsx)(`div`,{className:`px-4 pt-4`,children:(0,U.jsx)(pA,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(zf,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a notification to view details`})]})}function Vae({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:i,serverId:a,isConnected:o}){let[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(-1),[p,m]=(0,W.useState)(!0),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(!0),[y,b]=(0,W.useState)(!1),x=(0,W.useRef)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(null),w=(0,W.useRef)(!1);(0,W.useEffect)(()=>{p&&e.length>0&&x.current&&!w.current&&(x.current.scrollTop=0)},[e.length,p]),(0,W.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{e.scrollTop>0&&(w.current=!0,m(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,W.useEffect)(()=>{e.length===0&&(w.current=!1,m(!0))},[e.length]),(0,W.useEffect)(()=>{s&&!s.read&&n(s.id)},[s,n]),(0,W.useEffect)(()=>{h&&C.current&&C.current.focus()},[h]);let T=(0,W.useCallback)(()=>{l.trim()||g(!1)},[l]),E=(0,W.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.method.toLowerCase().includes(t)||JSON.stringify(e.params||{}).toLowerCase().includes(t))},[e,l]);(0,W.useEffect)(()=>{f(-1)},[l]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=E;if(e.key===`ArrowDown`)e.preventDefault(),f(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&d>=0){e.preventDefault();let t=E[d];t&&D(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[d,E]),(0,W.useEffect)(()=>{if(d>=0){let e=`notification-${E[d]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[d,E]);let D=(0,W.useCallback)(e=>{c(e)},[]),O=(0,W.useCallback)(()=>{window.confirm(`Are you sure you want to clear all notifications? This cannot be undone.`)&&(i(),c(null))},[i]),k=(0,W.useCallback)(async()=>{if(s)try{await ih(JSON.stringify({method:s.method,timestamp:s.timestamp,read:s.read,params:s.params},null,2)),b(!0),setTimeout(()=>b(!1),2e3)}catch(e){console.error(`[NotificationsTab] Failed to copy notification:`,e)}},[s]),A=(0,W.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({method:s.method,timestamp:s.timestamp,read:s.read,params:s.params},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`notification-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[NotificationsTab] Failed to download notification:`,e)}},[s]),j=(0,W.useCallback)(async()=>{if(S.current)try{document.fullscreenElement?await document.exitFullscreen():await S.current.requestFullscreen()}catch(e){console.error(`[NotificationsTab] Failed to toggle fullscreen:`,e)}},[]),M=s?{method:s.method,params:s.params,timestamp:s.timestamp,read:s.read,formatRelativeTime:j7}:null;return o?(0,U.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,U.jsx)(E7,{defaultSize:40,minSize:30,children:(0,U.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,U.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,U.jsx)(Rae,{isSearchExpanded:h,searchQuery:l,filteredNotificationsCount:E.length,notificationsCount:e.length,onSearchExpand:()=>g(!0),onSearchChange:u,onSearchBlur:T,onClearAll:O,searchInputRef:C}),(0,U.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,U.jsx)(zae,{notifications:E,selectedNotification:s,onNotificationSelect:D,focusedIndex:d,formatRelativeTime:j7,listRef:x})})]})})}),(0,U.jsx)(D7,{}),(0,U.jsx)(E7,{defaultSize:60,minSize:40,children:(0,U.jsx)(`div`,{ref:S,className:`h-full bg-white dark:bg-zinc-900`,children:(0,U.jsx)(Bae,{notification:M,previewMode:_,onTogglePreview:()=>v(!_),onCopy:k,onDownload:A,onFullscreen:j,onClose:()=>c(null),isCopied:y})})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(zf,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function M7({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:i,primaryCount:a,secondaryCount:o,secondaryIcon:s,primaryIcon:c,searchPlaceholder:l=`Search...`,onSearchExpand:u,onSearchChange:d,onSearchBlur:f,onTabSwitch:p,searchInputRef:m,primaryTabName:h,onRefresh:g,isRefreshing:_=!1}){let v=e===h;return(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:t?(0,U.jsx)(my,{ref:m,placeholder:l,value:n,onChange:e=>d(e.target.value),onBlur:f,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:v?r:i}),v&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:a}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]}),g&&(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:g,disabled:_,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Pp,{className:`h-4 w-4 ${_?`animate-spin`:``}`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Refresh list`,(0,U.jsx)(O7,{children:`R`})]})]})]})]})}),(0,U.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:p,className:`gap-2 flex-shrink-0`,children:[v?(0,U.jsx)(s,{}):(0,U.jsx)(c,{}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:v?i:r}),v&&o>0&&(0,U.jsx)(sn,{className:`bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent`,variant:`outline`,children:o})]})]})}function Hae({serverIds:e,onCountChange:t,onClearRef:n,onExportRef:r}={}){let[i,a]=(0,W.useState)([]),o=(0,W.useRef)(null),[s,c]=(0,W.useState)(new Set),[l]=(0,W.useState)(``),u=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},d=async()=>{a([]),c(new Set),t?.(0),e&&e.length>0?e.forEach(e=>H(e)):H()},f=async e=>{try{await ih(JSON.stringify(e,null,2)),nv.success(`Message copied to clipboard`)}catch(e){console.error(`Failed to copy message:`,e),nv.error(`Failed to copy to clipboard`)}},p=async()=>{try{await ih(JSON.stringify(h,null,2)),nv.success(`All messages copied to clipboard (${h.length})`)}catch(e){console.error(`Failed to copy all messages:`,e),nv.error(`Failed to copy to clipboard`)}},m=(0,W.useMemo)(()=>!e||e.length===0?``:[...e].sort().join(`,`),[e]);(0,W.useEffect)(()=>(n&&(n.current=d),()=>{n&&(n.current=null)}),[n,d]),(0,W.useEffect)(()=>(r&&(r.current=p),()=>{r&&(r.current=null)}),[r,p]),(0,W.useEffect)(()=>{t?.(i.length)},[i.length,t]),(0,W.useEffect)(()=>{console.log(`[RPC Logger] Subscribing to RPC logs for servers:`,e);let n=ne(),r=(e&&e.length>0?n.filter(t=>e.includes(t.serverId)):n).map(e=>{let t=e.message,n=typeof t?.method==`string`?t.method:t?.result===void 0?t?.error===void 0?`unknown`:`error`:`result`;return{id:`${e.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:e.serverId,direction:e.direction.toUpperCase(),method:n,timestamp:e.timestamp,payload:e.message}}).reverse();a(r),t?.(r.length);let i=te(n=>{if(e&&e.length>0&&!e.includes(n.serverId))return;let r=n.message,i=typeof r?.method==`string`?r.method:r?.result===void 0?r?.error===void 0?`unknown`:`error`:`result`,o={id:`${n.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:n.serverId,direction:n.direction.toUpperCase(),method:i,timestamp:n.timestamp,payload:n.message};console.log(`[RPC Logger] New RPC log:`,{method:i,direction:n.direction,serverId:n.serverId}),a(e=>{let n=[o,...e].slice(0,1e3);return t?.(n.length),n})});return()=>{i(),console.log(`[RPC Logger] Unsubscribed from RPC logs`)}},[m,t]);let h=(0,W.useMemo)(()=>{let t=i;if(e&&e.length>0){let n=new Set(e);t=t.filter(e=>n.has(e.serverId))}if(l.trim()){let e=l.toLowerCase();t=t.filter(t=>t.serverId.toLowerCase().includes(e)||t.method.toLowerCase().includes(e)||t.direction.toLowerCase().includes(e)||JSON.stringify(t.payload).toLowerCase().includes(e))}return t=[...t].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),t},[i,l,e]);return(0,U.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:(0,U.jsx)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-y-auto`,children:h.length===0?(0,U.jsxs)(`div`,{className:`text-center py-8`,children:[(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No messages yet`}),(0,U.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:`JSON-RPC messages will appear here`})]}):h.map(e=>{let t=s.has(e.id);return(0,U.jsxs)(`div`,{className:`group hover:bg-muted/50 transition-all duration-200 overflow-hidden`,"data-testid":`rpc-message-${e.method.replace(/\//g,`-`)}`,children:[(0,U.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>u(e.id),children:[(0,U.jsx)(`div`,{className:`flex-shrink-0`,children:t?(0,U.jsx)(Wf,{className:`h-3 w-3 text-muted-foreground transition-transform`}):(0,U.jsx)(Kf,{className:`h-3 w-3 text-muted-foreground transition-transform`})}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:new Date(e.timestamp).toLocaleTimeString()}),(0,U.jsx)(`span`,{className:`flex items-center justify-center px-1 py-0.5 rounded ${e.direction===`RECEIVE`?`bg-blue-500/10 text-blue-600 dark:text-blue-400`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,title:e.direction===`RECEIVE`?`Incoming`:`Outgoing`,children:e.direction===`RECEIVE`?(0,U.jsx)(Ff,{className:`h-3 w-3`}):(0,U.jsx)(If,{className:`h-3 w-3`})}),(0,U.jsx)(`span`,{className:`text-xs font-mono text-foreground truncate`,children:e.method})]})]}),t&&(0,U.jsx)(`div`,{className:`border-t bg-muted/20`,children:(0,U.jsxs)(`div`,{className:`p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Message Payload`}),(0,U.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),f(e.payload)},className:`h-6 px-2`,title:`Copy message to clipboard`,children:[(0,U.jsx)(tp,{className:`h-3 w-3 mr-1`}),(0,U.jsx)(`span`,{className:`text-xs`,children:`Copy`})]})]}),(0,U.jsx)(`div`,{className:`max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2`,children:(0,U.jsx)(pA,{data:e.payload})})]})})]},e.id)})})})}function N7({serverId:e,className:t}){let[n,r]=(0,W.useState)(0),[i,a]=(0,W.useState)(!0),o=w7(),s=(0,W.useRef)(null),c=(0,W.useRef)(null);return(0,W.useEffect)(()=>{o.current?.collapse()},[]),(0,U.jsxs)(E7,{panelRef:o,defaultSize:46,collapsible:!0,minSize:150,collapsedSize:46,onResize:e=>{i&&e.inPixels>46?a(!1):!i&&e.inPixels<=46&&a(!0)},className:`flex flex-col border-t dark:border-zinc-700 ${t||``}`,children:[(0,U.jsxs)(`div`,{"data-testid":`rpc-panel-toggle`,className:`group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:e=>{e.preventDefault(),e.stopPropagation(),i?(a(!1),setTimeout(()=>{o.current?.expand()},100)):(o.current?.collapse(),setTimeout(()=>{a(!0)},100))},children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-medium`,children:`RPC Messages`}),n>0&&(0,U.jsx)(sn,{"data-testid":`rpc-message-count`,variant:`secondary`,className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,children:n})]}),n>0&&!i&&(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e=>{e.preventDefault(),e.stopPropagation(),c.current?.()},className:`h-6 w-6 p-0`,title:`Copy all messages to clipboard`,children:(0,U.jsx)(tp,{className:`h-3.5 w-3.5`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e=>{e.preventDefault(),e.stopPropagation(),s.current?.()},className:`h-6 w-6 p-0`,title:`Clear all messages`,children:(0,U.jsx)($p,{className:`h-3.5 w-3.5`})})]})]}),(0,U.jsx)(Wf,{className:`h-4 w-4 text-muted-foreground transition-transform ${i?``:`rotate-180`}`})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-hidden min-h-0 ${i?`hidden`:``}`,children:(0,U.jsx)(Hae,{serverIds:[e],onCountChange:r,onClearRef:s,onExportRef:c})})]})}N7.displayName=`RpcPanel`;function P7({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(wp,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No prompts available`})]}):(0,U.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,i)=>(0,U.jsx)(k7,{id:`prompt-${e.name}`,"data-testid":`prompt-item-${e.name}`,isSelected:t?.name===e.name,isFocused:r===i,icon:(0,U.jsx)(wp,{className:`h-4 w-4`}),title:e.name,description:e.description,metadata:e.arguments&&e.arguments.length>0&&(0,U.jsxs)(sn,{variant:`outline`,className:`text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400`,children:[e.arguments.length,` args`]}),onClick:()=>n(e)},e.name))})}function F7({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:i,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d}){return(0,U.jsx)(M7,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:`prompts`,secondaryTabName:`saved`,primaryTabTitle:`Prompts`,secondaryTabTitle:`History`,primaryCount:r,secondaryCount:i,primaryIcon:wp,secondaryIcon:Zf,searchPlaceholder:`Search prompts...`,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d})}function I7({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:i}){return e.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(Zf,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No history`}),(0,U.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500 mt-1`,children:`Prompts you execute will appear here`})]}):(0,U.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,r)=>(0,U.jsx)(k7,{id:`saved-prompt-${e.id}`,isSelected:t?.id===e.id,isFocused:i===r,icon:(0,U.jsx)(Zf,{className:`h-4 w-4`}),title:e.name,description:`${e.promptName} - ${new Date(e.savedAt).toLocaleString()}`,onClick:()=>n(e)},e.id))})}function Uae({selectedPrompt:e,promptArgs:t,onArgChange:n}){let r=e?.arguments||[];if(!(r.length>0))return(0,U.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No arguments required`});let i=e=>{let r=e.name,i=t[r],a=typeof i==`string`?i:JSON.stringify(i);return e.type===`boolean`?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,U.jsx)(`input`,{id:r,type:`checkbox`,checked:!!i,onChange:e=>n(r,e.target.checked),className:`rounded`,"aria-label":`Toggle ${r}`}),(0,U.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:e.description})]})]},r):e.type===`number`?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsx)(my,{id:r,type:`number`,value:Number(i)||0,onChange:e=>n(r,Number(e.target.value)),placeholder:e.description||`Enter ${r}`}),e.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r):e.type===`array`||e.type===`object`?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsx)(JH,{id:r,value:a,onChange:e=>{try{n(r,JSON.parse(e.target.value))}catch{n(r,e.target.value)}},placeholder:e.description||`Enter ${r} as JSON`,className:`font-mono text-sm min-h-[100px]`}),e.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r):(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsx)(my,{id:r,"data-testid":`prompt-param-${r}`,value:a,onChange:e=>n(r,e.target.value),placeholder:e.description||`Enter ${r}`}),e.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r)};return(0,U.jsx)(`div`,{className:`space-y-4`,children:r.map(e=>i(e))})}function L7({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:i,onExecute:a,onSave:o}){return(0,W.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!n&&r&&(t.preventDefault(),a())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n,r,a]),e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsx)(`div`,{className:`flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3`,children:(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,U.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,children:e.name}),(0,U.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,U.jsx)(q,{onClick:a,disabled:n||!r,size:`sm`,className:`lg:size-default pr-1! gap-0`,"data-testid":`prompt-execute-button`,children:n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TB,{className:`mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jp,{className:`h-4 w-4 sm:mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,U.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘↵`})]})}),(0,U.jsxs)(q,{variant:`outline`,onClick:o,disabled:n,size:`sm`,className:`lg:size-default gap-2`,children:[(0,U.jsx)(Ip,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]})]})]}),e.description&&(0,U.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2`,children:e.description})]})}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3`,children:(0,U.jsx)(Uae,{selectedPrompt:e,promptArgs:t,onArgChange:i})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a prompt to get started`}),(0,U.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a prompt from the list to view its details and execute it`})]})}function Wae(e){switch(e){case`system`:return`default`;case`user`:return`outline`;case`assistant`:return`secondary`;default:return`outline`}}function Gae(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Kae(e){return typeof e==`string`?e:e.text?e.text:e.type===`resource`&&e.resource?.text?e.resource.text:e.type===`image`?`[Image: ${e.mimeType||`unknown type`}]`:JSON.stringify(e,null,2)}function qae({message:e,index:t}){let[n,r]=(0,W.useState)(!1);return(0,U.jsxs)(`div`,{className:`border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border`,children:[(0,U.jsx)(sn,{variant:Wae(e.role),children:Gae(e.role)}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{await ih(Kae(e.content)),r(!0),setTimeout(()=>r(!1),2e3)},className:`h-6 px-2`,title:`Copy message content`,children:n?(0,U.jsx)(Uf,{className:`h-3.5 w-3.5`}):(0,U.jsx)(tp,{className:`h-3.5 w-3.5`})})]}),(0,U.jsx)(`div`,{className:`px-4 py-3`,"data-testid":`prompt-message-content-${t}`,children:(()=>{let t=e.content;return typeof t==`string`?(0,U.jsx)(pK,{content:t}):t.type===`text`&&t.text?(0,U.jsx)(pK,{content:t.text}):t.type===`image`?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`font-mono bg-muted px-2 py-1 rounded`,children:[`Image: `,t.mimeType||`unknown type`]}),t.data&&(0,U.jsx)(`img`,{src:`data:${t.mimeType};base64,${t.data}`,alt:`Prompt image`,className:`max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2`})]}):t.type===`resource`&&t.resource?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Resource:`}),(0,U.jsx)(`code`,{className:`bg-muted px-2 py-0.5 rounded text-xs font-mono`,children:t.resource.uri})]}),t.resource.text&&(0,U.jsx)(`div`,{className:`mt-2`,children:(0,U.jsx)(pK,{content:t.resource.text})})]}):(0,U.jsx)(`pre`,{className:`bg-muted p-3 rounded-lg text-sm overflow-x-auto`,children:(0,U.jsx)(`code`,{children:JSON.stringify(t,null,2)})})})()})]})}function Jae(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function Yae(e){return`isError`in e&&!e.isError?null:`error`in e&&e.error?String(e.error):`isError`in e&&e.isError?`An error occurred`:null}function R7({results:e,copiedResult:t,previewMode:n=!0,onCopy:r,onDelete:i,onFullscreen:a,onTogglePreview:o,onMaximize:s,isMaximized:c=!1}){let[l,u]=(0,W.useState)(0),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(!0),h=e[0],g=h?e.filter(e=>e.promptName===h.promptName):[],_=g[l]||g[0],v=e.findIndex(e=>e===_);if((0,W.useEffect)(()=>{g.length>0&&l>=g.length&&u(0)},[g.length,l]),(0,W.useEffect)(()=>{let e=()=>{_&&f(Jae(_.timestamp))};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[_]),e.length===0)return(0,U.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,U.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,U.jsx)(`div`,{className:`text-center`,children:(0,U.jsx)(Iu,{vertical:!0,noBorder:!0,message:`No Results yet`})})})})});let y=_.error||Yae(_.result),b=`messages`in _.result&&Array.isArray(_.result.messages);return(0,U.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,U.jsxs)(`div`,{className:`space-y-0 flex-1 h-full flex flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-medium hidden sm:block`,children:`Response`}),_.duration!==void 0&&(0,U.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1`,children:[(0,U.jsx)(rm,{className:`h-3 w-3 text-gray-400`}),(0,U.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[_.duration,`ms`]})]}),b&&(0,U.jsx)(`div`,{className:`flex items-center gap-4 sm:ml-4`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`button`,{onClick:()=>m(!0),className:`text-xs font-medium ${p?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:`Formatted`}),(0,U.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,U.jsx)(`button`,{onClick:()=>m(!1),className:`text-xs font-medium ${p?`text-zinc-500 dark:text-zinc-400`:`text-black dark:text-white`}`,children:`Raw`})]})}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[g.length>1&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mr-2`,children:[(0,U.jsx)(gp,{className:`h-3 w-3 text-gray-400`}),(0,U.jsxs)(kb,{value:l.toString(),onValueChange:e=>u(parseInt(e)),children:[(0,U.jsx)(jb,{className:`h-7 w-[120px] text-xs`,children:(0,U.jsx)(Ab,{})}),(0,U.jsx)(Mb,{children:g.map((e,t)=>(0,U.jsx)(Nb,{value:t.toString(),children:t===0?`Latest`:`${t+1} call ago`},t))})]})]}),(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 mr-2`,children:d}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>r(v,_.result),className:`h-7 w-7 p-0`,title:`Copy result`,children:t===v?(0,U.jsx)(Uf,{className:`h-4 w-4`}):(0,U.jsx)(tp,{className:`h-4 w-4`})}),i&&(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>i(v),className:`h-7 w-7 p-0`,title:`Delete result`,children:(0,U.jsx)($p,{className:`h-4 w-4`})}),a&&(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>a(v),className:`h-7 w-7 p-0 sm:hidden`,title:`Fullscreen`,children:(0,U.jsx)(Sp,{className:`h-4 w-4`})}),s&&(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,className:`h-7 w-7 p-0 hidden sm:flex`,title:c?`Restore`:`Maximize`,children:c?(0,U.jsx)(Tp,{className:`h-4 w-4`}):(0,U.jsx)(Sp,{className:`h-4 w-4`})})]})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:y?(0,U.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:[(0,U.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,U.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:y})]}):p&&b?(0,U.jsx)(`div`,{className:`space-y-3`,children:(`messages`in _.result?_.result.messages:[]).map((e,t)=>(0,U.jsx)(qae,{message:e,index:t},t))}):(0,U.jsx)(pA,{data:_.result,filename:`prompt-result-${_.promptName}-${Date.now()}.json`})})]})})})}var z7=`mcp-inspector-saved-prompts`;function B7({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:i,refreshPrompts:a}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),{selectedPromptName:u,setSelectedPromptName:d}=jB(),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(`prompts`),[g,_]=(0,W.useState)([]),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(``),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(-1),E=(0,W.useRef)(null),[D,O]=(0,W.useState)(!1),[k,A]=(0,W.useState)(`list`),[j,M]=(0,W.useState)(!1),{filteredPrompts:N,selectedPrompt:P,setSelectedPrompt:F,results:I,handleDeleteResult:L,promptArgs:R,setPromptArgs:z,isExecuting:B,handlePromptSelect:V,handleArgChange:ee,executeSelectedPrompt:te,searchQuery:ne,setSearchQuery:H}=$V({prompts:t,callPrompt:n,serverId:r}),re=w7(),ie=w7();(0,W.useEffect)(()=>{let e=()=>{O(window.innerWidth<1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,W.useEffect)(()=>{A(P?`detail`:`list`)},[P]),(0,W.useEffect)(()=>{D&&I.length>0&&!B&&A(`response`)},[I,B,D]),(0,W.useImperativeHandle)(e,()=>({focusSearch:()=>{C(!0),setTimeout(()=>{E.current&&E.current.focus()},0)},blurSearch:()=>{H(``),C(!1),E.current&&E.current.blur()}})),(0,W.useEffect)(()=>{try{let e=localStorage.getItem(z7);e&&_(JSON.parse(e))}catch(e){console.error(`[PromptsTab] Failed to load saved prompts:`,e)}},[]);let ae=(0,W.useCallback)(e=>{try{localStorage.setItem(z7,JSON.stringify(e))}catch(e){console.error(`[PromptsTab] Failed to save prompts:`,e)}},[]);(0,W.useEffect)(()=>{S&&E.current&&E.current.focus()},[S]);let oe=(0,W.useCallback)(()=>{ne.trim()||C(!1)},[ne]),se=(0,W.useCallback)(async()=>{if(a){s(!0);try{await a()}finally{s(!1)}}},[a]),ce=(0,W.useCallback)(e=>{let n=t.find(t=>t.name===e.promptName);n&&(F(n),z(e.args),l(e))},[t,F,z]);(0,W.useEffect)(()=>{T(-1)},[ne,m]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=m===`prompts`?N:g;if(e.key===`ArrowDown`)e.preventDefault(),T(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),T(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&w>=0)if(e.preventDefault(),m===`prompts`){let e=N[w];e&&V(e)}else{let e=g[w];e&&ce(e)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[w,N,g,m,V,ce]),(0,W.useEffect)(()=>{if(w>=0){let e=m===`prompts`?`prompt-${N[w]?.name}`:`saved-prompt-${g[w]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[w,N,g,m]),(0,W.useEffect)(()=>{if(console.warn(`[PromptsTab] Auto-selection effect triggered:`,{selectedPromptName:u,promptsCount:t.length,currentSelectedPrompt:P?.name}),u&&t.length>0){let e=t.find(e=>e.name===u);if(console.warn(`[PromptsTab] Prompt lookup result:`,{selectedPromptName:u,promptFound:!!e,promptName:e?.name,shouldSelect:e&&P?.name!==e.name}),e&&P?.name!==e.name){console.warn(`[PromptsTab] Selecting prompt:`,e.name),d(null);let t=setTimeout(()=>{V(e);let t=document.getElementById(`prompt-${e.name}`);t&&(console.warn(`[PromptsTab] Scrolling to prompt element`),t.scrollIntoView({behavior:`smooth`,block:`nearest`}))},100);return()=>clearTimeout(t)}}},[u,t,P,V,d]);let le=(0,W.useCallback)(async(e,t)=>{try{await ih(JSON.stringify(t,null,2)),p(e),setTimeout(()=>p(null),2e3)}catch(e){console.error(`[PromptsTab] Failed to copy result:`,e)}},[]),ue=(0,W.useCallback)(e=>{if(D)A(`response`);else{let t=I[e];if(t){let e=window.open(``,`_blank`,`width=800,height=600`);if(e){let n=t.result;e.document.write(`
683
+ `)}`,timestamp:Date.now()})}let T=(b.attachments?.length??0)>0,E=Gie([...o,...y,...w,...T?[b]:[]]),D=T?``:c;for await(let e of p.current.streamEvents(D,10,!1,E,void 0,f.current?.signal)){if(f.current?.signal.aborted)break;if(e.event===`on_chat_model_stream`){let t=e.data?.chunk;if(t?.text){let e=t.text;if(typeof e==`string`&&e.length>0){l+=e;let t=u[u.length-1];t&&t.type===`text`?t.text=l:u.push({type:`text`,text:l}),s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}}let r=t?.tool_call_chunks||t?.kwargs?.tool_call_chunks||t?.lc_kwargs?.tool_call_chunks||t?.additional_kwargs?.tool_calls||t?.tool_calls;if(r&&Array.isArray(r)&&r.length>0){l&&=``;for(let e of r){let t=e.index??0,r=e.name||``,i=e.args||``,a=d.get(t);a||(a={name:r||`unknown`,accumulatedJson:``},d.set(t,a)),r&&a.name===`unknown`&&(a.name=r);let o;if(typeof i==`object`&&i)o=i;else if(typeof i==`string`&&i){a.accumulatedJson+=i;try{o=JSON.parse(a.accumulatedJson)}catch{let e=[()=>{let e=a.accumulatedJson;(e.match(/(?<!\\)"/g)||[]).length%2!=0&&(e+=`"`);let t=(e.match(/{/g)||[]).length-(e.match(/}/g)||[]).length,n=(e.match(/\[/g)||[]).length-(e.match(/]/g)||[]).length;for(let t=0;t<n;t++)e+=`]`;for(let n=0;n<t;n++)e+=`}`;return JSON.parse(e)},()=>{let e=a.accumulatedJson;e=e.replace(/,\s*"[^"]*"?\s*:\s*("([^"\\]|\\.)*)?$/,``),e=e.replace(/,\s*"[^"]*$/,``),(e.match(/(?<!\\)"/g)||[]).length%2!=0&&(e+=`"`);let t=(e.match(/{/g)||[]).length-(e.match(/}/g)||[]).length,n=(e.match(/\[/g)||[]).length-(e.match(/]/g)||[]).length;for(let t=0;t<n;t++)e+=`]`;for(let n=0;n<t;n++)e+=`}`;return JSON.parse(e)}];for(let t of e)try{o=t();break}catch{}}}if(o){let e=u.find(e=>e.type===`tool-invocation`&&e.toolInvocation?.state===`streaming`&&e.toolInvocation?.toolName===a.name);if(e&&e.toolInvocation){let t=e.toolInvocation.partialArgs,n=t?Object.keys(t):[],r=Object.keys(o),i=n.reduce((e,n)=>e+String(t[n]??``).length,0),a=r.reduce((e,t)=>e+String(o[t]??``).length,0);(r.length>n.length||a>=i)&&(e.toolInvocation.partialArgs=o)}else u.push({type:`tool-invocation`,toolInvocation:{toolName:a.name,args:{},state:`streaming`,partialArgs:o}});s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e)),await _()}}}}else if(e.event===`on_tool_start`){l&&=``;let t={};e.data?.input?t=e.data.input:e.data?.tool_input?t=e.data.tool_input:e.data&&(t=e.data),console.log(`[useChatMessagesClientSide] on_tool_start:`,{toolName:e.name,eventData:e.data,extractedArgs:t}),C++;let r=u.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.state===`streaming`&&t.toolInvocation?.toolName===(e.name||`unknown`));r&&r.toolInvocation?(r.toolInvocation.args=t,r.toolInvocation.state=`pending`):u.push({type:`tool-invocation`,toolInvocation:{toolName:e.name||`unknown`,args:t,state:`pending`}}),d.clear(),s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}else if(e.event===`on_tool_end`){let t=u.find(t=>t.type===`tool-invocation`&&t.toolInvocation?.toolName===e.name&&!t.toolInvocation?.result);if(console.log(`[useChatMessagesClientSide] on_tool_end event:`,{toolName:e.name,hasToolPart:!!t,output:e.data?.output}),t&&t.toolInvocation){let i=e.data?.output;if(i?.kwargs?.content&&typeof i.kwargs.content==`string`)try{i=JSON.parse(i.kwargs.content)}catch(e){console.warn(`[useChatMessagesClientSide] Failed to parse kwargs.content:`,e),i=i.kwargs.content}else if(i?.content&&typeof i.content==`string`)try{i=JSON.parse(i.content)}catch{i=i.content}t.toolInvocation.result=i,t.toolInvocation.state=i?.isError?`error`:`result`;let a=i?._meta?.[`openai/outputTemplate`];if(console.log(`[useChatMessagesClientSide] Tool result:`,{toolName:e.name,hasMeta:!!i?._meta,hasStructuredContent:!!i?.structuredContent,appsSdkUri:a}),a&&typeof a==`string`&&r){console.log(`[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:`,a);try{let e=await r(a);console.log(`[useChatMessagesClientSide] Resource fetched:`,e);let n=i?.structuredContent||null;if(e?.contents&&Array.isArray(e.contents)){let r=e.contents.map(e=>({type:`resource`,resource:e}));console.log(`[useChatMessagesClientSide] Created MCP resources:`,r);let a={...i,content:[...i.content||[],...r],structuredContent:n};t.toolInvocation.result=a,console.log(`[useChatMessagesClientSide] Updated result with resources`)}else console.warn(`[useChatMessagesClientSide] No contents in resourceData:`,e)}catch(e){console.error(`Failed to fetch Apps SDK resource:`,e)}}s(e=>e.map(e=>e.id===n?{...e,parts:[...u]}:e))}}}if(f.current?.signal.aborted)for(let e of u)e.type===`tool-invocation`&&e.toolInvocation?.state===`pending`&&(e.toolInvocation.state=`error`,e.toolInvocation.result=`Cancelled by user`);s(e=>e.map(e=>e.id===n?{...e,parts:[...u],content:``}:e)),t&&Ef.getInstance().capture(new _f({serverId:e.url,provider:t.provider,model:t.model,messageCount:o.length+1,toolCallsCount:C,success:!0,executionMode:`client-side`,duration:Date.now()-S})).catch(()=>{})}catch(n){if(n instanceof DOMException&&n.name===`AbortError`)return;console.error(`Client-side agent error:`,n);let r=`Unknown error occurred`;if(n instanceof Error){r=n.message;let e=n;e.status&&(r=`HTTP ${e.status}: ${r}`),(e.code===401||r.includes(`401`)||r.includes(`Unauthorized`))&&(r=`Authentication failed (401). Check your Authorization header in the connection settings.`)}t&&Ef.getInstance().capture(new _f({serverId:e.url,provider:t.provider,model:t.model,messageCount:o.length+1,toolCallsCount:C,success:!1,executionMode:`client-side`,duration:Date.now()-S,error:r})).catch(()=>{});let i={id:`error-${Date.now()}`,role:`assistant`,content:`Error: ${r}`,timestamp:Date.now()};s(e=>[...e,i])}finally{l(!1),f.current=null}},[e,t,n,o,r,u,a]),clearMessages:(0,W.useCallback)(()=>{s([]),p.current&&p.current.clearConversationHistory()},[]),setMessages:s,stop:(0,W.useCallback)(()=>{f.current&&f.current.abort()},[]),addAttachment:(0,W.useCallback)(async e=>{try{let t=await bU(e);d(e=>{let n=[...e,t];return vU(n)?n:(alert(`Total attachment size exceeds 20MB limit`),e)})}catch(e){e instanceof Error?alert(e.message):alert(`Failed to add attachment`)}},[]),removeAttachment:(0,W.useCallback)(e=>{d(t=>t.filter((t,n)=>n!==e))},[]),clearAttachments:(0,W.useCallback)(()=>{d([])},[])}}var f5={openai:`gpt-4o`,anthropic:`claude-haiku-4-5-20251001`,google:`gemini-2.5-flash`};function p5({mcpServerUrl:e}){let[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(`openai`),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(f5.openai),p=(0,W.useCallback)(()=>{let e=localStorage.getItem(`mcp-inspector-api-keys`);if(e)try{return JSON.parse(e)}catch(e){return console.error(`Failed to load API keys:`,e),{}}return{}},[]),m=(0,W.useCallback)(e=>{localStorage.setItem(`mcp-inspector-api-keys`,JSON.stringify(e))},[]),[h,g]=(0,W.useState)(`none`),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(``),[x,S]=(0,W.useState)(``);return(0,W.useEffect)(()=>{let e=()=>{let e=localStorage.getItem(`mcp-inspector-llm-config`),t=p();if(e)try{let r=JSON.parse(e);n(r),c(r.provider),u(t[r.provider]||r.apiKey||``),f(r.model)}catch(e){console.error(`Failed to load LLM config:`,e)}};e();let t=()=>{e()},r=t=>{(t.key===`mcp-inspector-llm-config`||t.key===`mcp-inspector-api-keys`)&&e()};return window.addEventListener(`llm-config-updated`,t),window.addEventListener(`storage`,r),()=>{window.removeEventListener(`llm-config-updated`,t),window.removeEventListener(`storage`,r)}},[p]),(0,W.useEffect)(()=>{let t=localStorage.getItem(`mcp-inspector-auth-config`);if(t)try{let e=JSON.parse(t);i(e),g(e.type),e.username&&v(e.username),e.password&&b(e.password),e.token&&S(e.token)}catch(e){console.error(`Failed to load auth config:`,e)}else try{let t=`mcp:auth_${fU(e)}_tokens`;localStorage.getItem(t)&&(i({type:`oauth`}),g(`oauth`))}catch(e){console.error(`Failed to check for OAuth tokens:`,e)}},[e]),(0,W.useEffect)(()=>{f(f5[s]),u(p()[s]||``)},[s,p]),{llmConfig:t,authConfig:r,configDialogOpen:a,setConfigDialogOpen:o,tempProvider:s,setTempProvider:c,tempApiKey:l,setTempApiKey:u,tempModel:d,setTempModel:f,tempAuthType:h,saveLLMConfig:(0,W.useCallback)(()=>{if(!l.trim())return;let e=p();e[s]=l,m(e);let t={provider:s,apiKey:l,model:d},r={type:h,...h===`basic`&&{username:_.trim(),password:y.trim()},...h===`bearer`&&{token:x.trim()}};n(t),i(r),localStorage.setItem(`mcp-inspector-llm-config`,JSON.stringify(t)),localStorage.setItem(`mcp-inspector-auth-config`,JSON.stringify(r)),window.dispatchEvent(new CustomEvent(`llm-config-updated`)),o(!1)},[s,l,d,h,_,y,x,p,m]),clearConfig:(0,W.useCallback)(()=>{n(null),i(null);let e=p();delete e[s],m(e),u(``),v(``),b(``),S(``),g(`none`),localStorage.removeItem(`mcp-inspector-llm-config`),localStorage.removeItem(`mcp-inspector-auth-config`)},[s,p,m])}}var Jie=/(?:^\/$|\s+\/$)/,Yie=[`ArrowDown`,`ArrowUp`,`Escape`,`Enter`];function m5({connection:e,isConnected:t,useClientSide:n=!0,enableKeyboardShortcuts:r=!0,prompts:i,serverId:a,callPrompt:o,readResource:s,chatApiUrl:c,waitForChatApiUrl:l,initialMessages:u,managedLlmConfig:d,clearButtonLabel:f,hideTitle:p,hideModelBadge:m,hideServerUrl:h,clearButtonHideIcon:g,clearButtonHideShortcut:_,clearButtonVariant:v,hideClearButton:y,hideToolSelector:b,chatQuickQuestions:x=[],chatFollowups:S=[],streamProtocol:C,credentials:w,extraHeaders:T,body:E}){let[D,O]=(0,W.useState)(``),[k,A]=(0,W.useState)(!1),[j,M]=(0,W.useState)(-1),[N,P]=(0,W.useState)(x),[F,I]=(0,W.useState)(S),[L,R]=(0,W.useState)(new Set),B=(0,W.useRef)(null),V=(0,W.useRef)(null),ee=(0,W.useRef)(null),te=(0,W.useMemo)(()=>(e.tools??[]).map(e=>({name:e.name,description:e.description})),[e.tools]),{llmConfig:ne,authConfig:H,configDialogOpen:re,setConfigDialogOpen:ie,tempProvider:ae,setTempProvider:oe,tempApiKey:se,setTempApiKey:ce,tempModel:le,setTempModel:ue,saveLLMConfig:de,clearConfig:fe}=p5({mcpServerUrl:e.url}),pe=d??ne,me=!!d,{getAllModelContexts:he}=DK(),ge=he(),_e={connection:e,llmConfig:pe,isConnected:t,readResource:s,widgetModelContexts:ge,disabledTools:L},ve=Kie({mcpServerUrl:e.url,llmConfig:pe,authConfig:H,isConnected:t,chatApiUrl:c,waitForChatApiUrl:l,widgetModelContexts:ge,initialMessages:u,disabledTools:L,streamProtocol:C,credentials:w,extraHeaders:T,body:E}),ye=qie(_e),{messages:be,isLoading:xe,attachments:Se,sendMessage:Ce,clearMessages:we,setMessages:Te,stop:Ee,addAttachment:De,removeAttachment:Oe}=n?ye:ve,{filteredPrompts:ke,setSelectedPrompt:Ae,selectedPrompt:je,setPromptArgs:Me,executePrompt:Ne,results:Pe,handleDeleteResult:Fe,clearPromptResults:Ie}=$V({prompts:i,callPrompt:o,serverId:a}),Le=(0,W.useCallback)(e=>Array.isArray(e)?e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean).slice(0,8):[],[]),Re=(0,W.useCallback)(e=>typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e.text??``).join(``):``,[]),ze=(0,W.useCallback)(()=>be.map(e=>{let t=Re(e),n=e.parts?.filter(e=>e.type===`tool-invocation`&&e.toolInvocation).map(e=>({toolName:e.toolInvocation.toolName,args:e.toolInvocation.args,state:e.toolInvocation.state,result:typeof e.toolInvocation.result==`string`?e.toolInvocation.result.slice(0,2e3):e.toolInvocation.result==null?void 0:JSON.stringify(e.toolInvocation.result).slice(0,2e3)})),r=t||(n?.length?`[Tool calls: ${n.map(e=>`${e.toolName}(${e.state})`).join(`, `)}]`:``);return{id:e.id,role:e.role,content:r,timestamp:e.timestamp,toolInvocations:n?.length?n:void 0}}),[be,Re]),Be=(0,W.useCallback)((e,t={})=>{typeof window>`u`||window.parent===window||window.parent.postMessage({type:e,serverId:a,...t},`*`)},[a]);(0,W.useEffect)(()=>{Be(`mcp-inspector:chat:ready`,{capabilities:{send:!0,clear:!0,getState:!0,setQuickQuestions:!0,setFollowups:!0,loadMessages:!0}})},[Be]),(0,W.useEffect)(()=>{Be(`mcp-inspector:chat:state_changed`,{isLoading:xe,messageCount:be.length,messages:ze(),quickQuestions:N,followups:F})},[F,ze,xe,be.length,Be,N]),(0,W.useEffect)(()=>{let e=e=>{if(!e.data||typeof e.data!=`object`)return;let n=e.data;if(!n.type?.startsWith(`mcp-inspector:chat:`)||n.serverId&&n.serverId!==a)return;let r=n.requestId,i=(e,t={})=>{Be(`mcp-inspector:chat:command_result`,{requestId:r,ok:e,...t})};if(n.type===`mcp-inspector:chat:send`){let e=(n.message??n.prompt??``).trim();if(!e){i(!1,{error:`Missing message`});return}if(!pe||!t){i(!1,{error:`Chat is not ready to send messages`});return}Ce(e,[]).then(()=>{Be(`mcp-inspector:chat:message_sent`,{requestId:r,message:e,source:`bridge`}),i(!0)}).catch(e=>{i(!1,{error:e instanceof Error?e.message:String(e)})});return}if(n.type===`mcp-inspector:chat:clear`){we(),Be(`mcp-inspector:chat:cleared`,{requestId:r}),i(!0);return}if(n.type===`mcp-inspector:chat:get_state`){Be(`mcp-inspector:chat:state`,{requestId:r,isLoading:xe,messageCount:be.length,messages:ze(),quickQuestions:N,followups:F}),i(!0);return}if(n.type===`mcp-inspector:chat:set_quick_questions`){let e=Le(n.questions);P(e),i(!0,{quickQuestions:e});return}if(n.type===`mcp-inspector:chat:set_followups`){let e=Le(n.followups);I(e),i(!0,{followups:e});return}if(n.type===`mcp-inspector:chat:load_messages`){let e=n.messages;if(!Array.isArray(e)){i(!1,{error:`messages must be an array`});return}Te(e),i(!0,{count:e.length});return}if(n.type===`mcp-inspector:chat:screenshot`){let e=n.toolCallId;(async()=>{try{let t=null;if(e&&(t=document.querySelector(`[data-tool-call-id="${e}"]`)),!t){let e=document.querySelectorAll(`[data-tool-call-id]`);e.length>0&&(t=e[e.length-1])}if(!t&&V.current&&(t=V.current),!t){i(!1,{error:`No screenshot target found`});return}let n=1e4,a=null,o=``,s=``;try{let e=await z(()=>import(`https://esm.sh/html-to-image@1.11.13`),[]);e?.toPng?a=await Promise.race([e.toPng(t,{pixelRatio:1,backgroundColor:`#ffffff`,includeQueryParams:!0}),new Promise((e,t)=>setTimeout(()=>t(Error(`html-to-image timed out`)),n))]):o=`toPng not found on module`}catch(e){o=e instanceof Error?e.message:String(e)}if(!a)try{if(!window.html2canvas){let e=document.createElement(`script`);e.src=`https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js`,document.head.appendChild(e),await new Promise((t,n)=>{e.onload=()=>t(),e.onerror=()=>n(Error(`Failed to load html2canvas`))})}let e=window.html2canvas;a=(await Promise.race([e(t,{useCORS:!0,allowTaint:!0,backgroundColor:`#ffffff`,scale:1,logging:!1,foreignObjectRendering:!1}),new Promise((e,t)=>setTimeout(()=>t(Error(`html2canvas timed out`)),n))])).toDataURL(`image/png`)}catch(e){s=e instanceof Error?e.message:String(e)}if(a)Be(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:a,timestamp:Date.now()}),i(!0);else{let t=V.current||document.body,n=t.innerText?.substring(0,5e3)||``,a=t.innerHTML?.substring(0,1e4)||``;Be(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:``,domText:n,domHtml:a,error:`html-to-image: ${o||`ok`}; html2canvas: ${s||`ok`}`,timestamp:Date.now()}),i(!1,{error:`html-to-image: ${o}; html2canvas: ${s}`})}}catch(t){let n=(V.current||document.body).innerText?.substring(0,5e3)||``;Be(`mcp-inspector:chat:screenshot_result`,{requestId:r,toolCallId:e||null,image:``,domText:n,error:t instanceof Error?t.message:`Screenshot capture failed`,timestamp:Date.now()}),i(!1,{error:t instanceof Error?t.message:`Screenshot failed`})}})();return}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[we,Te,F,ze,xe,be.length,Be,N,Le,Ce,a,pe,t]),FB(r?{onNewChat:we}:{});let Ve=(0,W.useCallback)(()=>{M(-1),A(!1),ee.current=null},[]),He=(0,W.useCallback)(()=>{if(!B.current)return;let e=B.current.selectionStart,t=D.slice(0,e),n=Jie.test(t);A(n),n?(ee.current={start:e-1,end:e},M(0)):Ve()},[D,Ve]);(0,W.useEffect)(()=>{pe&&be.length===0&&B.current&&B.current.focus()},[pe,be.length]),(0,W.useEffect)(()=>{!xe&&be.length>0&&B.current&&B.current.focus()},[xe,be.length]),(0,W.useEffect)(()=>{B.current&&He()},[D,He]);let Ue=(0,W.useCallback)(()=>{Ae(null),Me({}),Ve()},[Ve]),We=(0,W.useCallback)(async e=>{if(Ae(e),e.arguments&&e.arguments.length>0){Ae(null),nv.error(`Prompts with arguments are not supported`,{description:`This prompt requires arguments which are not yet supported in chat mode.`});return}try{await Ne(e,{})}catch(e){console.error(`Error executing prompt`,e)}finally{if(B.current&&ee.current){let{start:e,end:t}=ee.current;O(D.slice(0,e)+D.slice(t)),requestAnimationFrame(()=>{B.current?.focus(),B.current?.setSelectionRange(e,e)})}Ue()}},[Ne,Ue,D]),Ge=(0,W.useCallback)(()=>{(D.trim()||Pe.length>0||Se.length>0)&&(Ce(D,Pe),O(``),Ie())},[D,Pe,Ce,Ie,Se]),G=(0,W.useCallback)(e=>{if(e.key===`ArrowDown`)M(e=>ke.length===0?-1:(e+1)%ke.length);else if(e.key===`ArrowUp`)M(e=>ke.length===0?-1:(e-1+ke.length)%ke.length);else if(e.key===`Escape`)e.stopPropagation(),Ve();else if(e.key===`Enter`&&j>=0){let e=ke[j];e&&We(e)}},[ke,j,We,Ve]),Ke=(0,W.useCallback)(e=>{Yie.includes(e.key)&&k?(e.preventDefault(),G(e)):e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),Ge())},[Ge,G,k]),qe=(0,W.useCallback)(e=>{(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&He()},[He]),Je=(0,W.useCallback)(()=>{fe(),we()},[fe,we]),Ye=(0,W.useCallback)(e=>{e.trim()&&(!pe||!t||Ce(e,[]).then(()=>{Be(`mcp-inspector:chat:message_sent`,{message:e,source:`quick_question`})}))},[Be,Ce,pe,t]),Xe=(0,W.useCallback)(e=>{e.trim()&&(!pe||!t||Ce(e,[]).then(()=>{Be(`mcp-inspector:chat:message_sent`,{message:e,source:`followup`})}))},[Be,Ce,pe,t]);return pe&&be.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[!me&&(0,U.jsx)(`div`,{className:`absolute top-4 right-4 z-10`,children:(0,U.jsx)(KH,{open:re,onOpenChange:ie,tempProvider:ae,tempModel:le,tempApiKey:se,onProviderChange:oe,onModelChange:ue,onApiKeyChange:ce,onSave:de,onClear:Je,showClearButton:!0,buttonLabel:`Change API Key`})}),(0,U.jsx)(DU,{mcpServerUrl:e.url,inputValue:D,isConnected:t,isLoading:xe,textareaRef:B,llmConfig:pe,promptsDropdownOpen:k,promptFocusedIndex:j,prompts:ke,selectedPrompt:je,promptResults:Pe,attachments:Se,tools:b?void 0:te,disabledTools:b?void 0:L,onDisabledToolsChange:b?void 0:R,onDeletePromptResult:Fe,onPromptSelect:We,onInputChange:O,onKeyDown:Ke,onKeyUp:qe,onClick:He,onSubmit:e=>{e.preventDefault(),Ge()},onConfigDialogOpenChange:ie,onAttachmentAdd:De,onAttachmentRemove:Oe,hideModelBadge:m,hideServerUrl:h,quickQuestions:N,onQuickQuestionSelect:Ye})]}):(0,U.jsxs)(`div`,{className:`flex flex-col h-full relative`,children:[(0,U.jsx)(qH,{llmConfig:pe,hasMessages:be.length>0,configDialogOpen:me?!1:re,onConfigDialogOpenChange:me?()=>{}:ie,onClearChat:we,tempProvider:ae,tempModel:le,tempApiKey:se,onProviderChange:oe,onModelChange:ue,onApiKeyChange:ce,onSaveConfig:de,onClearConfig:Je,hideConfigButton:me,clearButtonLabel:f,hideTitle:p,clearButtonHideIcon:g,clearButtonHideShortcut:_,clearButtonVariant:v,hideClearButton:y}),(0,U.jsx)(`div`,{ref:V,className:`flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]`,children:pe?(0,U.jsx)(Uie,{messages:be,isLoading:xe,serverId:e.url,readResource:s,tools:e.tools,sendMessage:(e,t)=>Ce(e,[],t),serverBaseUrl:e.url}):(0,U.jsx)(OU,{onConfigureClick:()=>ie(!0)})}),pe&&(0,U.jsx)(TU,{inputValue:D,isConnected:t,isLoading:xe,textareaRef:B,promptsDropdownOpen:k,promptFocusedIndex:j,prompts:ke,promptResults:Pe,selectedPrompt:je,attachments:Se,tools:b?void 0:te,disabledTools:b?void 0:L,onDisabledToolsChange:b?void 0:R,onDeletePromptResult:Fe,onPromptSelect:We,onInputChange:O,onKeyDown:Ke,onKeyUp:qe,onClick:He,onSendMessage:Ge,onStopStreaming:Ee,onAttachmentAdd:De,onAttachmentRemove:Oe,followups:F,onFollowupSelect:Xe})]})}var Xie=r({Group:()=>y7,Panel:()=>S7,Separator:()=>C7,isCoarsePointer:()=>w5,useDefaultLayout:()=>Cae,useGroupCallbackRef:()=>Tae,useGroupRef:()=>Eae,usePanelCallbackRef:()=>kae,usePanelRef:()=>Aae});function Zie(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Qie(e,t){let n=getComputedStyle(e.ownerDocument.body);return t*parseFloat(n.fontSize)}function $ie(e){return e/100*window.innerHeight}function eae(e){return e/100*window.innerWidth}function tae(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}function h5({groupSize:e,panelElement:t,styleProp:n}){let r,[i,a]=tae(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Qie(t,i);break;case`em`:r=Zie(t,i);break;case`vh`:r=$ie(i);break;case`vw`:r=eae(i);break}return r}function g5(e){return parseFloat(e.toFixed(3))}function _5({group:e}){let{orientation:t,panels:n}=e;return n.reduce((e,n)=>(e+=t===`horizontal`?n.element.offsetWidth:n.element.offsetHeight,e),0)}function v5(e){let{panels:t}=e,n=_5({group:e});return n===0?t.map(e=>({collapsedSize:0,collapsible:e.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:e.panelConstraints.disabled,minSize:0,maxSize:100,panelId:e.id})):t.map(e=>{let{element:t,panelConstraints:r}=e,i=0;r.collapsedSize!==void 0&&(i=g5(h5({groupSize:n,panelElement:t,styleProp:r.collapsedSize})/n*100));let a;r.defaultSize!==void 0&&(a=g5(h5({groupSize:n,panelElement:t,styleProp:r.defaultSize})/n*100));let o=0;r.minSize!==void 0&&(o=g5(h5({groupSize:n,panelElement:t,styleProp:r.minSize})/n*100));let s=100;return r.maxSize!==void 0&&(s=g5(h5({groupSize:n,panelElement:t,styleProp:r.maxSize})/n*100)),{collapsedSize:i,collapsible:r.collapsible===!0,defaultSize:a,disabled:r.disabled,minSize:o,maxSize:s,panelId:e.id}})}function y5(e,t=`Assertion error`){if(!e)throw Error(t)}function b5(e,t){return Array.from(t).sort(e===`horizontal`?nae:rae)}function nae(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function rae(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function x5(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function S5(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function iae({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=S5(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return y5(i,`No rect found`),i}var C5;function w5(){return C5===void 0&&(C5=typeof matchMedia==`function`?!!matchMedia(`(pointer:coarse)`).matches:!1),C5}function T5(e){let{element:t,orientation:n,panels:r,separators:i}=e,a=b5(n,Array.from(t.children).filter(x5).map(e=>({element:e}))).map(({element:e})=>e),o=[],s=!1,c=!1,l=-1,u=-1,d=0,f,p=[];{let e=-1;for(let t of a)t.hasAttribute(`data-panel`)&&(e++,t.ariaDisabled===null&&(d++,l===-1&&(l=e),u=e))}if(d>1){let t=-1;for(let d of a)if(d.hasAttribute(`data-panel`)){t++;let i=r.find(e=>e.element===d);if(i){if(f){let r=f.element.getBoundingClientRect(),a=d.getBoundingClientRect(),m;if(c){let e=n===`horizontal`?new DOMRect(r.right,r.top,0,r.height):new DOMRect(r.left,r.bottom,r.width,0),t=n===`horizontal`?new DOMRect(a.left,a.top,0,a.height):new DOMRect(a.left,a.top,a.width,0);switch(p.length){case 0:m=[e,t];break;case 1:{let i=p[0];m=[i,iae({orientation:n,rects:[r,a],targetRect:i.element.getBoundingClientRect()})===r?t:e];break}default:m=p;break}}else m=p.length?p:[n===`horizontal`?new DOMRect(r.right,a.top,a.left-r.right,a.height):new DOMRect(a.left,r.bottom,a.width,a.top-r.bottom)];for(let n of m){let r=`width`in n?n:n.element.getBoundingClientRect(),a=w5()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(r.width<a){let e=a-r.width;r=new DOMRect(r.x-e/2,r.y,r.width+e,r.height)}if(r.height<a){let e=a-r.height;r=new DOMRect(r.x,r.y-e/2,r.width,r.height+e)}!s&&!(t<=l||t>u)&&o.push({group:e,groupSize:_5({group:e}),panels:[f,i],separator:`width`in n?void 0:n,rect:r}),s=!1}}c=!1,f=i,p=[]}}else if(d.hasAttribute(`data-separator`)){d.ariaDisabled!==null&&(s=!0);let e=i.find(e=>e.element===d);e?p.push(e):(f=void 0,p=[])}else c=!0}return o}var aae=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}};function E5(e,t,n=0){return Math.abs(g5(e)-g5(t))<=n}var D5={cursorFlags:0,interactionState:{state:`inactive`},mountedGroups:new Map},O5=new aae;function k5(){return D5}function A5(e){let t=typeof e==`function`?e(D5):e;if(D5===t)return D5;let n=D5;return D5={...D5,...t},t.cursorFlags!==void 0&&O5.emit(`cursorFlagsChange`,D5.cursorFlags),t.interactionState!==void 0&&O5.emit(`interactionStateChange`,D5.interactionState),t.mountedGroups!==void 0&&(D5.mountedGroups.forEach((e,t)=>{e.derivedPanelConstraints.forEach(r=>{if(r.collapsible){let{layout:i}=n.mountedGroups.get(t)??{};if(i){let n=E5(r.collapsedSize,e.layout[r.panelId]),a=E5(r.collapsedSize,i[r.panelId]);n&&!a&&(t.inMemoryLastExpandedPanelSizes[r.panelId]=i[r.panelId])}}})}),O5.emit(`mountedGroupsChange`,D5.mountedGroups)),D5}function oae(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=S5(n,a.rect);switch(e){case`horizontal`:t.x<=i.x&&(r=a,i=t);break;case`vertical`:t.y<=i.y&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function sae(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function cae(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:N5(e),b:N5(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();y5(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:M5(j5(n.a)),b:M5(j5(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var lae=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function uae(e){let t=getComputedStyle(P5(e)??e).display;return t===`flex`||t===`inline-flex`}function dae(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||uae(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||lae.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function j5(e){let t=e.length;for(;t--;){let n=e[t];if(y5(n,`Missing node`),dae(n))return n}return null}function M5(e){return e&&Number(getComputedStyle(e).zIndex)||0}function N5(e){let t=[];for(;e;)t.push(e),e=P5(e);return t}function P5(e){let{parentNode:t}=e;return sae(t)?t.host:t}function fae(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function pae({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!x5(n)||n.contains(e)||e.contains(n))return!0;if(cae(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(fae(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function F5(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=T5(r),a=oae(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&pae({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function mae(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function I5(e,t){return E5(e,t)?0:e>t?1:-1}function L5({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsible:a,disabled:o,maxSize:s=100,minSize:c=0}=t;if(o&&!e)return n;if(I5(r,c)<0)if(a){let e=(i+c)/2;r=I5(r,e)<0?i:c}else r=c;return r=Math.min(s,r),r=g5(r),r}function R5({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(E5(e,0))return t;let o=a===`imperative-api`,s=Object.values(t),c=Object.values(i),l=[...s],[u,d]=r;y5(u!=null,`Invalid first pivot index`),y5(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];y5(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(y5(n!=null,`Previous layout not found for panel index ${t}`),E5(n,i)){let t=o-n;I5(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];y5(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(y5(n!=null,`Previous layout not found for panel index ${t}`),E5(n,o)){let t=n-i;I5(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];y5(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsible:a,collapsedSize:o,minSize:c}=r;if(a&&I5(i,c)<0)if(e>0){let t=c-o,n=t/2;I5(i+e,c)<0&&(e=I5(e,n)<=0?0:t)}else{let t=c-o,n=100-t/2;I5(i-e,c)<0&&(e=I5(100+e,n)>0?0:-t)}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];y5(e!=null,`Previous layout not found for panel index ${r}`);let a=L5({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];y5(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=L5({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:i,size:a});if(!E5(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(mae(c,l))return i;{let t=e<0?d:u,r=s[t];y5(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=L5({overrideDisabledPanels:o,panelConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!E5(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];y5(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=L5({overrideDisabledPanels:o,panelConstraints:n[r],prevSize:i,size:a});if(E5(i,s)||(t-=s-i,l[r]=s),E5(t,0))break;e>0?r--:r++}}}if(!E5(Object.values(l).reduce((e,t)=>t+e,0),100,.1))return i;let p=Object.keys(i);return l.reduce((e,t,n)=>(e[p[n]]=t,e),{})}function z5(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||I5(e[n],t[n])!==0)return!1;return!0}function B5({layout:e,panelConstraints:t}){let n=Object.values(e),r=[...n],i=r.reduce((e,t)=>e+t,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(e=>`${e}%`).join(`, `)}`);if(!E5(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];y5(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];y5(i!=null,`No layout data found for index ${e}`);let o=r[e];y5(o!=null,`No layout data found for index ${e}`);let s=L5({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!E5(a,0))for(let e=0;e<t.length;e++){let n=r[e];y5(n!=null,`No layout data found for index ${e}`);let i=n+a,o=L5({overrideDisabledPanels:!0,panelConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,E5(a,0)))break}let o=Object.keys(e);return r.reduce((e,t,n)=>(e[o[n]]=t,e),{})}function V5({groupId:e,panelId:t}){let n=()=>{let{mountedGroups:t}=k5();for(let[n,{defaultLayoutDeferred:r,derivedPanelConstraints:i,layout:a,separatorToPanels:o}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:n,layout:a,separatorToPanels:o};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedPanelConstraints.find(e=>e.panelId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().group.panels.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=e=>{let r=a();if(e===r)return;let{defaultLayoutDeferred:i,derivedPanelConstraints:o,group:s,layout:c,separatorToPanels:l}=n(),u=s.panels.findIndex(e=>e.id===t),d=u===s.panels.length-1,f=B5({layout:R5({delta:d?r-e:e-r,initialLayout:c,panelConstraints:o,pivotIndices:d?[u-1,u]:[u,u+1],prevLayout:c,trigger:`imperative-api`}),panelConstraints:o});z5(c,f)||A5(e=>({mountedGroups:new Map(e.mountedGroups).set(s,{defaultLayoutDeferred:i,derivedPanelConstraints:o,layout:f,separatorToPanels:l})}))};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),s=a();e&&s!==t&&(n.expandToSize=s,o(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:s}=i(),c=a();if(e&&c===t){let e=s.expandToSize??n;e===0&&(e=1),o(e)}},getSize:()=>{let{group:e}=n(),t=a(),{element:r}=i();return{asPercentage:t,inPixels:e.orientation===`horizontal`?r.offsetWidth:r.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&E5(t,n)},resize:e=>{if(a()!==e){let t;switch(typeof e){case`number`:{let{group:r}=n();t=g5(e/_5({group:r})*100);break}case`string`:t=parseFloat(e);break}o(t)}}}}function H5(e){if(e.defaultPrevented)return;let{mountedGroups:t}=k5();F5(e,t).forEach(t=>{if(t.separator){let n=t.panels.find(e=>e.panelConstraints.defaultSize!==void 0);if(n){let r=n.panelConstraints.defaultSize,i=V5({groupId:t.group.id,panelId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function U5(e){let{mountedGroups:t}=k5();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function W5({groupId:e}){let t=()=>{let{mountedGroups:t}=k5();for(let[n,r]of t)if(n.id===e)return{group:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedPanelConstraints:r,group:i,layout:a,separatorToPanels:o}=t(),s=B5({layout:e,panelConstraints:r});if(n)return a;if(!z5(a,s)){A5(e=>({mountedGroups:new Map(e.mountedGroups).set(i,{defaultLayoutDeferred:n,derivedPanelConstraints:r,layout:s,separatorToPanels:o})}));let e=i.panels.map(({id:e})=>e).join(`,`);i.inMemoryLayouts[e]=s}return s}}}function G5(e){let{mountedGroups:t}=k5(),n=t.get(e);return y5(n,`Mounted Group ${e.id} not found`),n}function K5(e,t){let n=U5(e),r=G5(n),i=n.separators.find(t=>t.element===e);y5(i,`Matching separator not found`);let a=r.separatorToPanels.get(i);y5(a,`Matching panels not found`);let o=a.map(e=>n.panels.indexOf(e)),s=W5({groupId:n.id}).getLayout(),c=B5({layout:R5({delta:t,initialLayout:s,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),panelConstraints:r.derivedPanelConstraints});z5(s,c)||A5(e=>({mountedGroups:new Map(e.mountedGroups).set(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,layout:c,separatorToPanels:r.separatorToPanels})}))}function q5(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=U5(t);if(!n.disabled)switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&K5(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&K5(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&K5(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&K5(t,-5);break;case`End`:e.preventDefault(),K5(t,100);break;case`Enter`:{e.preventDefault();let n=U5(t),{derivedPanelConstraints:r,layout:i,separatorToPanels:a}=G5(n),o=n.separators.find(e=>e.element===t);y5(o,`Matching separator not found`);let s=a.get(o);y5(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.panelId===c.id);if(y5(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];K5(t,(l.collapsedSize===e?n.inMemoryLastExpandedPanelSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let n=U5(t).separators.map(e=>e.element),r=Array.from(n).findIndex(t=>t===e.currentTarget);y5(r!==null,`Index not found`),n[e.shiftKey?r>0?r-1:n.length-1:r+1<n.length?r+1:0].focus();break}case`Home`:e.preventDefault(),K5(t,-100);break}}function J5(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let{mountedGroups:t}=k5(),n=F5(e,t),r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus()));let n=t.get(e.group);n&&r.set(e.group,n.layout)}),A5({interactionState:{hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:`active`}}),n.length&&e.preventDefault()}var hae=e=>e,Y5=()=>{},X5=1,Z5=2,Q5=4,$5=8,e7=3,t7=12,n7;function r7(){return n7===void 0&&(n7=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(n7=!0)),n7}function gae({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&r7()){let t=(e&X5)!==0,n=(e&Z5)!==0,r=(e&Q5)!==0,i=(e&$5)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return r7()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var i7=new WeakMap;function a7(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=i7.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets.push(n));let{cursorFlags:r,interactionState:i}=k5();switch(i.state){case`active`:case`hover`:{let e=gae({cursorFlags:r,groups:i.hitRegions.map(e=>e.group),state:i.state}),a=`*, *:hover {cursor: ${e} !important; }`;if(t===a)return;t=a,e?n.cssRules.length===0?n.insertRule(a):n.replaceSync(a):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}i7.set(e,{prevStyle:t,styleSheet:n})}function o7({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:a,prevCursorFlags:o}){let s=0,c=new Map(i);n.forEach(e=>{let{group:n,groupSize:o}=e,{disableCursor:l,orientation:u,panels:d}=n,f=0;f=a?u===`horizontal`?(t.clientX-a.x)/o*100:(t.clientY-a.y)/o*100:u===`horizontal`?t.clientX<0?-100:100:t.clientY<0?-100:100;let p=r.get(n),{defaultLayoutDeferred:m,derivedPanelConstraints:h,layout:g,separatorToPanels:_}=i.get(n)??{defaultLayoutDeferred:!1};if(h&&p&&g&&_){let t=R5({delta:f,initialLayout:p,panelConstraints:h,pivotIndices:e.panels.map(e=>d.indexOf(e)),prevLayout:g,trigger:`mouse-or-touch`});if(z5(t,g)){if(f!==0&&!l)switch(u){case`horizontal`:s|=f<0?X5:Z5;break;case`vertical`:s|=f<0?Q5:$5;break}}else{c.set(e.group,{defaultLayoutDeferred:m,derivedPanelConstraints:h,layout:t,separatorToPanels:_});let n=e.group.panels.map(({id:e})=>e).join(`,`);e.group.inMemoryLayouts[n]=t}}});let l=0;t.movementX===0?l|=o&e7:l|=s&e7,t.movementY===0?l|=o&t7:l|=s&t7,A5({cursorFlags:l,mountedGroups:c}),a7(e)}function s7(e){let{cursorFlags:t,interactionState:n,mountedGroups:r}=k5();switch(n.state){case`active`:o7({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:r,prevCursorFlags:t})}}function c7(e){if(e.defaultPrevented)return;let{cursorFlags:t,interactionState:n,mountedGroups:r}=k5();switch(n.state){case`active`:if(e.buttons===0){A5(e=>e.interactionState.state===`inactive`?e:{cursorFlags:0,interactionState:{state:`inactive`}}),A5(e=>({mountedGroups:new Map(e.mountedGroups)}));return}o7({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:t});break;default:{let t=F5(e,r);t.length===0?n.state!==`inactive`&&A5({interactionState:{state:`inactive`}}):A5({interactionState:{hitRegions:t,state:`hover`}}),a7(e.currentTarget);break}}}function l7(e){if(e.relatedTarget instanceof HTMLIFrameElement){let{interactionState:e}=k5();switch(e.state){case`hover`:A5({interactionState:{state:`inactive`}})}}}function u7(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let{interactionState:t}=k5();switch(t.state){case`active`:A5({cursorFlags:0,interactionState:{state:`inactive`}}),t.hitRegions.length>0&&(a7(e.currentTarget),A5(e=>({mountedGroups:new Map(e.mountedGroups)})),e.preventDefault())}}function d7(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=g5(i.defaultSize);n+=e,r[i.panelId]=e}else r[i.panelId]=void 0;let i=e.length-t;if(i!==0){let t=g5((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.panelId]=t)}return r}function _ae(e,t,n){if(!n[0])return;let r=e.panels.find(e=>e.element===t);if(!r||!r.onResize)return;let i=_5({group:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:g5(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function vae(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function yae(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}var f7=new Map;function bae(e){let t=!0;y5(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){if(_5({group:e})===0)return;A5(t=>{let n=t.mountedGroups.get(e);if(n){let r=v5(e),i=n.defaultLayoutDeferred?d7(r):n.layout,a=B5({layout:i,panelConstraints:r});return!n.defaultLayoutDeferred&&z5(i,a)&&vae(n.derivedPanelConstraints,r)?t:{mountedGroups:new Map(t.mountedGroups).set(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:r,layout:a,separatorToPanels:n.separatorToPanels})}}return t})}}else _ae(e,i,n)}});a.observe(e.element),e.panels.forEach(e=>{y5(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=_5({group:e}),s=v5(e),c=e.panels.map(({id:e})=>e).join(`,`),l=e.defaultLayout;l&&(yae(e.panels,l)||(l=void 0));let u=B5({layout:e.inMemoryLayouts[c]??l??d7(s),panelConstraints:s}),d=T5(e),f=e.element.ownerDocument;return A5(t=>{let n=new Map;return f7.set(f,(f7.get(f)??0)+1),d.forEach(e=>{e.separator&&n.set(e.separator,e.panels)}),{mountedGroups:new Map(t.mountedGroups).set(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:s,layout:u,separatorToPanels:n})}}),e.separators.forEach(e=>{y5(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,q5)}),f7.get(f)===1&&(f.addEventListener(`dblclick`,H5,!0),f.addEventListener(`pointerdown`,J5,!0),f.addEventListener(`pointerleave`,s7),f.addEventListener(`pointermove`,c7),f.addEventListener(`pointerout`,l7),f.addEventListener(`pointerup`,u7,!0)),function(){t=!1,f7.set(f,Math.max(0,(f7.get(f)??0)-1)),A5(t=>{let n=new Map(t.mountedGroups);return n.delete(e),{mountedGroups:n}}),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,q5)}),f7.get(f)||(f.removeEventListener(`dblclick`,H5,!0),f.removeEventListener(`pointerdown`,J5,!0),f.removeEventListener(`pointerleave`,s7),f.removeEventListener(`pointermove`,c7),f.removeEventListener(`pointerout`,l7),f.removeEventListener(`pointerup`,u7,!0)),a.disconnect()}}function xae(){let[e,t]=(0,W.useState)({});return[e,(0,W.useCallback)(()=>t({}),[])]}function p7(e){let t=(0,W.useId)();return`${e??t}`}var m7=typeof window<`u`?W.useLayoutEffect:W.useEffect;function h7(e){let t=(0,W.useRef)(e);return m7(()=>{t.current=e},[e]),(0,W.useCallback)((...e)=>t.current?.(...e),[t])}function g7(...e){return h7(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function _7(e){let t=(0,W.useRef)({...e});return m7(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var v7=(0,W.createContext)(null);function Sae(e,t){let n=(0,W.useRef)({getLayout:()=>({}),setLayout:hae});(0,W.useImperativeHandle)(t,()=>n.current,[]),m7(()=>{Object.assign(n.current,W5({groupId:e}))})}function y7({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){let m=(0,W.useRef)({onLayoutChange:{},onLayoutChanged:{}}),h=h7(e=>{z5(m.current.onLayoutChange,e)||(m.current.onLayoutChange=e,c?.(e))}),g=h7(e=>{z5(m.current.onLayoutChanged,e)||(m.current.onLayoutChanged=e,l?.(e))}),_=p7(s),v=(0,W.useRef)(null),[y,b]=xae(),x=(0,W.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),S=g7(v,a);Sae(_,o);let C=h7((e,t)=>{let{interactionState:r,mountedGroups:i}=k5();for(let n of i.keys())if(n.id===e){let e=i.get(n);if(e){let i=!1;switch(r.state){case`active`:i=r.hitRegions.some(e=>e.group===n);break}return{flexGrow:e.layout[t]??1,pointerEvents:i?`none`:void 0}}}return{flexGrow:n?.[t]??1}}),w=_7({defaultLayout:n,disableCursor:r}),T=(0,W.useMemo)(()=>({get disableCursor(){return!!w.disableCursor},getPanelStyles:C,id:_,orientation:u,registerPanel:e=>{let t=x.current;return t.panels=b5(u,[...t.panels,e]),b(),()=>{t.panels=t.panels.filter(t=>t!==e),b()}},registerSeparator:e=>{let t=x.current;return t.separators=b5(u,[...t.separators,e]),b(),()=>{t.separators=t.separators.filter(t=>t!==e),b()}},togglePanelDisabled:(e,t)=>{let n=x.current.panels.find(t=>t.id===e);n&&(n.panelConstraints.disabled=t);let{mountedGroups:r}=k5();for(let e of r.keys())if(e.id===_){let t=r.get(e);t&&(t.derivedPanelConstraints=v5(e))}},toggleSeparatorDisabled:(e,t)=>{let n=x.current.separators.find(t=>t.id===e);n&&(n.disabled=t)}}),[C,_,b,u,w]),E=(0,W.useRef)(null);return m7(()=>{let e=v.current;if(e===null)return;let t=x.current,n;if(w.defaultLayout!==void 0&&Object.keys(w.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=w.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={defaultLayout:n,disableCursor:!!w.disableCursor,disabled:!!i,element:e,id:_,inMemoryLastExpandedPanelSizes:x.current.lastExpandedPanelSizes,inMemoryLayouts:x.current.layouts,orientation:u,panels:t.panels,resizeTargetMinimumSize:t.resizeTargetMinimumSize,separators:t.separators};E.current=r;let a=bae(r),o=k5().mountedGroups.get(r);if(o){let{defaultLayoutDeferred:e,derivedPanelConstraints:t,layout:n}=o;!e&&t.length>0&&(h(n),g(n))}let s=O5.addListener(`interactionStateChange`,e=>{e.state}),c=O5.addListener(`mountedGroupsChange`,e=>{let t=e.get(r);if(t){let{defaultLayoutDeferred:e,derivedPanelConstraints:n,layout:r}=t;if(e||n.length===0)return;let{interactionState:i}=k5(),a=i.state!==`active`;h(r),a&&g(r)}});return()=>{E.current=null,a(),s(),c()}},[i,_,g,h,u,y,w]),(0,W.useEffect)(()=>{let e=E.current;e&&(e.defaultLayout=n,e.disableCursor=!!r)}),(0,U.jsx)(v7.Provider,{value:T,children:(0,U.jsx)(`div`,{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:S,style:{height:`100%`,width:`100%`,overflow:`hidden`,...f,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:e})})}y7.displayName=`Group`;function b7(e,t){return`react-resizable-panels:${[e,...t].join(`:`)}`}function Cae({debounceSaveMs:e=100,panelIds:t,storage:n=localStorage,...r}){let i=t!==void 0,a=`id`in r?r.id:r.groupId,o=b7(a,t??[]),s=(0,W.useSyncExternalStore)(wae,()=>n.getItem(o),()=>n.getItem(o)),c=(0,W.useMemo)(()=>s?JSON.parse(s):void 0,[s]),l=(0,W.useRef)(null),u=(0,W.useCallback)(()=>{let e=l.current;e&&(l.current=null,clearTimeout(e))},[]);(0,W.useLayoutEffect)(()=>()=>{u()},[u]);let d=(0,W.useCallback)(e=>{u();let t;t=i?b7(a,Object.keys(e)):b7(a,[]);try{n.setItem(t,JSON.stringify(e))}catch(e){console.error(e)}},[u,i,a,n]);return{defaultLayout:c,onLayoutChange:(0,W.useCallback)(t=>{u(),e===0?d(t):l.current=setTimeout(()=>{d(t)},e)},[u,e,d]),onLayoutChanged:d}}function wae(){return function(){}}function Tae(){return(0,W.useState)(null)}function Eae(){return(0,W.useRef)(null)}function x7(){let e=(0,W.useContext)(v7);return y5(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function Dae(e,t){let{id:n}=x7(),r=(0,W.useRef)({collapse:Y5,expand:Y5,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Y5});(0,W.useImperativeHandle)(t,()=>r.current,[]),m7(()=>{Object.assign(r.current,V5({groupId:n,panelId:e}))})}function S7({children:e,className:t,collapsedSize:n=`0%`,collapsible:r=!1,defaultSize:i,disabled:a,elementRef:o,id:s,maxSize:c=`100%`,minSize:l=`0%`,onResize:u,panelRef:d,style:f,...p}){let m=!!s,h=p7(s),g=_7({disabled:a}),_=(0,W.useRef)(null),v=g7(_,o),{getPanelStyles:y,id:b,orientation:x,registerPanel:S,togglePanelDisabled:C}=x7(),w=u!==null,T=h7((e,t,n)=>{u?.(e,s,n)});m7(()=>{let e=_.current;if(e!==null)return S({element:e,id:h,idIsStable:m,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:w?T:void 0,panelConstraints:{collapsedSize:n,collapsible:r,defaultSize:i,disabled:g.disabled,maxSize:c,minSize:l}})},[n,r,i,w,h,m,c,l,T,S,g]),(0,W.useEffect)(()=>{C(h,!!a)},[a,h,C]),Dae(h,d);let E=(0,W.useSyncExternalStore)(e=>(O5.addListener(`mountedGroupsChange`,e),()=>{O5.removeListener(`mountedGroupsChange`,e)}),()=>JSON.stringify(y(b,h)),()=>JSON.stringify(y(b,h)));return(0,U.jsx)(`div`,{...p,"aria-disabled":a||void 0,"data-panel":!0,"data-testid":h,id:h,ref:v,style:{...Oae,display:`flex`,flexBasis:0,flexShrink:1,overflow:`hidden`,...JSON.parse(E)},children:(0,U.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,...f,touchAction:x===`horizontal`?`pan-y`:`pan-x`},children:e})})}S7.displayName=`Panel`;var Oae={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0};function kae(){return(0,W.useState)(null)}function Aae(){return(0,W.useRef)(null)}function jae({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,a,o=e[n],s=t.find(e=>e.panelId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=B5({layout:R5({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=B5({layout:R5({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function C7({children:e,className:t,disabled:n,elementRef:r,id:i,style:a,...o}){let s=p7(i),c=_7({disabled:n}),[l,u]=(0,W.useState)({}),[d,f]=(0,W.useState)(`inactive`),p=(0,W.useRef)(null),m=g7(p,r),{disableCursor:h,id:g,orientation:_,registerSeparator:v,toggleSeparatorDisabled:y}=x7(),b=_===`horizontal`?`vertical`:`horizontal`;m7(()=>{let e=p.current;if(e!==null){let t={disabled:c.disabled,element:e,id:s},n=v(t),r=O5.addListener(`interactionStateChange`,e=>{f(e.state!==`inactive`&&e.hitRegions.some(e=>e.separator===t)?e.state:`inactive`)}),i=O5.addListener(`mountedGroupsChange`,e=>{e.forEach(({derivedPanelConstraints:e,layout:n,separatorToPanels:r},i)=>{if(i.id===g){let a=r.get(t);if(a){let t=a[0],r=i.panels.indexOf(t);u(jae({layout:n,panelConstraints:e,panelId:t.id,panelIndex:r}))}}})});return()=>{r(),i(),n()}}},[g,s,v,c]),(0,W.useEffect)(()=>{y(s,!!n)},[n,s,y]);let x;return n&&!h&&(x=`not-allowed`),(0,U.jsx)(`div`,{...o,"aria-controls":l.valueControls,"aria-disabled":n||void 0,"aria-orientation":b,"aria-valuemax":l.valueMax,"aria-valuemin":l.valueMin,"aria-valuenow":l.valueNow,children:e,className:t,"data-separator":n?`disabled`:d,"data-testid":s,id:s,ref:m,role:`separator`,style:{flexBasis:`auto`,cursor:x,...a,flexGrow:0,flexShrink:0,touchAction:`none`},tabIndex:n?void 0:0})}C7.displayName=`Separator`;var{usePanelRef:w7}=Xie;function T7({className:e,...t}){return(0,U.jsx)(y7,{"data-slot":`resizable-panel-group`,className:K(`flex h-full w-full aria-[orientation=vertical]:flex-col`,e),...t})}function E7({...e}){return(0,U.jsx)(S7,{"data-slot":`resizable-panel`,...e})}function D7({withHandle:e,className:t,...n}){return(0,U.jsx)(C7,{"data-slot":`resizable-handle`,className:K(`relative flex items-center justify-center bg-border`,`focus-visible:ring-ring focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden`,`after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2`,`aria-[orientation=vertical]:h-auto aria-[orientation=vertical]:w-px`,`aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full`,`aria-[orientation=vertical]:after:left-0 aria-[orientation=vertical]:after:h-1 aria-[orientation=vertical]:after:w-full aria-[orientation=vertical]:after:translate-x-0 aria-[orientation=vertical]:after:-translate-y-1/2`,`[&[aria-orientation=horizontal]>div]:rotate-90`,t),...n,children:e&&(0,U.jsx)(`div`,{className:`bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border`,children:(0,U.jsx)(mp,{className:`size-2.5`})})})}function O7({className:e,...t}){return(0,U.jsx)(`kbd`,{"data-slot":`kbd`,className:K(`bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none`,`[&_svg:not([class*='size-'])]:size-3`,`[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10`,e),...t})}function Mae({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onCancelAll:s,searchInputRef:c}){return(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,U.jsx)(my,{ref:c,placeholder:`Search requests...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,"data-testid":`elicitation-tab-header`,children:`Elicitation`}),(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]})]})}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,U.jsx)(nm,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{side:`bottom`,children:`Cancel all`})]})})]})}function k7({id:e,isSelected:t,isFocused:n,icon:r,title:i,description:a,metadata:o,onClick:s,className:c,"data-testid":l}){return(0,U.jsx)(`button`,{id:e,"data-testid":l,type:`button`,onClick:s,className:K(`w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group`,t&&`bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500`,n&&`ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset`,c),children:(0,U.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3`,children:[r&&(0,U.jsx)(`div`,{className:`flex-shrink-0 mt-1`,children:(0,U.jsx)(`div`,{className:K(`p-2.5 rounded-full transition-colors`,t?`bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900`:`bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600`),children:r})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 mb-1`,children:(0,U.jsx)(`h3`,{className:K(`font-medium truncate font-mono text-sm`),children:i})}),a&&(0,U.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 line-clamp-2`,children:a})]}),o&&(0,U.jsx)(`div`,{className:`flex-shrink-0 flex items-center self-center`,children:o})]})})}function Nae({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(Iu,{vertical:!0,noBorder:!0,message:`No elicitation requests`})}):(0,U.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e.request.mode||`form`,s=o===`form`&&`requestedSchema`in e.request&&e.request.requestedSchema;return(0,U.jsx)(k7,{id:`elicitation-request-${e.id}`,"data-testid":`elicitation-request-item-${a}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,U.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,U.jsx)(sn,{variant:`outline`,className:o===`url`?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:o})]}),description:(()=>{let t=i(e.timestamp),n=[];return s&&n.push(`with schema`),o===`url`&&n.push(`external action`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function A7(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.const==`string`&&(t.title===void 0||typeof t.title==`string`)}function Pae(e){let t=Array.isArray(e.oneOf)?e.oneOf.filter(A7):[],n=Array.isArray(e.anyOf)?e.anyOf.filter(A7):[];return t.length>0?t:n}function Fae(e){let t=e.items&&typeof e.items==`object`?e.items:{},n=Array.isArray(t.anyOf)?t.anyOf.filter(A7):[],r=Array.isArray(t.oneOf)?t.oneOf.filter(A7):[];return n.length>0?n:r}function Iae({request:e,onApprove:t,onReject:r,onClose:i,previewMode:a,onTogglePreview:o,isCopied:s,onCopy:c,onDownload:l,onFullscreen:u}){let[d,f]=(0,W.useState)({}),[p,m]=(0,W.useState)(!1),h=e?.request.mode||`form`,g=h===`form`,_=h===`url`;(0,W.useEffect)(()=>{if(e&&g&&`requestedSchema`in e.request){let t=e.request.requestedSchema,n={};if(t?.type===`object`&&t.properties)for(let[e,r]of Object.entries(t.properties)){let t=r;t.default===void 0?t.type===`array`?n[e]=[]:t.type===`boolean`?n[e]=!1:t.type===`number`||t.type===`integer`?n[e]=0:n[e]=``:n[e]=t.default}f(n)}m(!1)},[e?.id,g]);let v=(e,t)=>{f(n=>({...n,[e]:t}))},y=()=>{if(e){if(g){if(`requestedSchema`in e.request){let t=e.request.requestedSchema;if(t?.required){let e=t.required.filter(e=>d[e]===void 0||d[e]===``||d[e]===null);if(e.length>0){nv.error(`Missing required fields`,{description:`Please fill in: ${e.join(`, `)}`});return}}}t(e.id,{action:`accept`,content:d})}else _&&t(e.id,{action:`accept`});i(),z(()=>import(`./react-ikqD3Yuv.js`).then(e=>n(e.default,1)).then(e=>{let t=nv(e.createElement(`div`,{className:`space-y-3`},e.createElement(`div`,null,e.createElement(`strong`,null,`Elicitation Response Sent`),e.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),e.createElement(`div`,{className:`flex gap-2`},e.createElement(`button`,{"data-testid":`elicitation-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let e=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:null}});window.dispatchEvent(e),nv.dismiss(t)}},`View Tool Result`))),{duration:5e3})}),[])}},b=()=>{e&&(t(e.id,{action:`decline`}),i())},x=()=>{e&&(r(e.id,`User cancelled elicitation request`),i())},S=()=>{e&&_&&`url`in e.request&&(window.open(e.request.url,`_blank`),m(!0))},C=(0,W.useMemo)(()=>{if(!e||!g||!(`requestedSchema`in e.request))return null;let t=e.request.requestedSchema;if(!t||t.type!==`object`||!t.properties)return(0,U.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No form schema available`});let n=t.properties,r=t.required||[];return(0,U.jsx)(`div`,{className:`space-y-4`,children:Object.entries(n).map(([e,t])=>{let n=t,i=r.includes(e),a=n.type||`string`,o=n.title||e,s=n.description,c=Pae(n),l=c.length>0,u=Array.isArray(n.enum),f=a===`array`&&Array.isArray(n.items?.enum),p=Fae(n),m=a===`array`&&p.length>0,h=Array.isArray(d[e])?d[e]:[];return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:`field-${e}`,children:[o,i&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),s&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s}),a===`boolean`?(0,U.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,U.jsx)(uU,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,checked:d[e]||!1,onCheckedChange:t=>v(e,t)}),(0,U.jsx)(yy,{htmlFor:`field-${e}`,className:`text-sm font-normal cursor-pointer`,children:n.title||e})]}):a===`number`||a===`integer`?(0,U.jsx)(my,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,type:`number`,value:d[e]||``,onChange:t=>v(e,a===`integer`?parseInt(t.target.value,10):parseFloat(t.target.value)),placeholder:n.default?.toString()||``}):l?(0,U.jsxs)(`select`,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,U.jsx)(`option`,{value:``,children:`Select...`}),c.map(e=>(0,U.jsx)(`option`,{value:e.const,children:e.title||e.const},e.const))]}):u?(0,U.jsxs)(`select`,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,U.jsx)(`option`,{value:``,children:`Select...`}),n.enum.map((e,t)=>(0,U.jsx)(`option`,{value:e,children:n.enumNames?.[t]||e},e))]}):f?(0,U.jsx)(`div`,{className:`space-y-2`,"data-testid":`elicitation-field-${e}`,children:n.items.enum.map(t=>{let n=`field-${e}-${t}`;return(0,U.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,U.jsx)(uU,{id:n,checked:h.includes(t),onCheckedChange:n=>{v(e,n?[...h,t]:h.filter(e=>e!==t))}}),(0,U.jsx)(yy,{htmlFor:n,className:`text-sm font-normal cursor-pointer`,children:t})]},t)})}):m?(0,U.jsx)(`div`,{className:`space-y-2`,"data-testid":`elicitation-field-${e}`,children:p.map(t=>{let n=`field-${e}-${t.const}`;return(0,U.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,U.jsx)(uU,{id:n,checked:h.includes(t.const),onCheckedChange:n=>{v(e,n?[...h,t.const]:h.filter(e=>e!==t.const))}}),(0,U.jsx)(yy,{htmlFor:n,className:`text-sm font-normal cursor-pointer`,children:t.title||t.const})]},t.const)})}):a===`string`&&(n.format===`textarea`||n.maxLength>100)?(0,U.jsx)(JH,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,value:d[e]||``,onChange:t=>v(e,t.target.value),placeholder:n.default||``,rows:4}):(0,U.jsx)(my,{id:`field-${e}`,"data-testid":`elicitation-field-${e}`,type:`text`,value:d[e]||``,onChange:t=>v(e,t.target.value),placeholder:n.default||``})]},e)})})},[e,d,g]);return e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.serverName}),(0,U.jsx)(sn,{variant:`outline`,className:_?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:h}),(0,U.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleString()})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:c,className:`h-8 w-8 p-0`,children:s?(0,U.jsx)(Uf,{className:`h-4 w-4 text-green-600`}):(0,U.jsx)(tp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Copy request`})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:l,className:`h-8 w-8 p-0`,children:(0,U.jsx)(rp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Download request`})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,U.jsx)(xp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Fullscreen`})]}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(nm,{className:`h-4 w-4`})})]})]}),(0,U.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Message`}),(0,U.jsx)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.request.message})]}),_&&`url`in e.request&&(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`External Action Required`}),(0,U.jsxs)(`div`,{className:`bg-muted rounded-lg p-4 space-y-3`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This request requires you to complete an action at an external URL:`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-background rounded border`,children:[(0,U.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:e.request.url}),(0,U.jsxs)(q,{size:`sm`,variant:`outline`,onClick:S,className:`flex items-center gap-2`,children:[(0,U.jsx)(ap,{className:`h-4 w-4`}),`Open URL`]})]}),(0,U.jsxs)(`div`,{className:`flex items-center space-x-2 pt-2`,children:[(0,U.jsx)(uU,{id:`url-completed`,checked:p,onCheckedChange:e=>m(!!e)}),(0,U.jsx)(yy,{htmlFor:`url-completed`,className:`text-sm font-normal cursor-pointer`,children:`I have completed the required action`})]})]})]}),g&&(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Form Data`}),C]}),g&&`requestedSchema`in e.request&&e.request.requestedSchema&&(0,U.jsxs)(`details`,{className:`space-y-2`,children:[(0,U.jsx)(`summary`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer`,children:`Schema (for reference)`}),(0,U.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,U.jsx)(pA,{data:e.request.requestedSchema})})]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,U.jsx)(q,{onClick:y,className:`flex-1`,"data-testid":`elicitation-accept-button`,children:`Accept`}),(0,U.jsx)(q,{onClick:b,variant:`outline`,className:`flex-1`,"data-testid":`elicitation-decline-button`,children:`Decline`}),(0,U.jsx)(q,{onClick:x,variant:`outline`,className:`flex-1`,"data-testid":`elicitation-cancel-button`,children:`Cancel`})]})]}):(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select an elicitation request to view details`})})}function j7(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<60?`just now`:r<60?`${r}m ago`:i<24?`${i}h ago`:a<7?`${a}d ago`:new Date(e).toLocaleDateString()}function Lae({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:i}){let{selectedElicitationRequestId:a,setSelectedElicitationRequestId:o}=jB(),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(-1),[p,m]=(0,W.useState)(!0),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(!0),[y,b]=(0,W.useState)(!1),x=(0,W.useRef)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(null),w=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(console.log(`[ElicitationTab] Auto-selection check:`,{selectedElicitationRequestId:a,pendingRequestsCount:e.length,currentSelectedId:s?.id}),a&&e.length>0){let t=e.find(e=>e.id===a);console.log(`[ElicitationTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[ElicitationTab] Auto-selecting request:`,t.id),o(null),c(t),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${t.id}`);console.log(`[ElicitationTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[a,e,o]),(0,W.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[ElicitationTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[ElicitationTab] Selecting request from event:`,n),c(r),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-elicitation`,t),()=>window.removeEventListener(`navigate-to-elicitation`,t)},[e]),(0,W.useEffect)(()=>{p&&e.length>0&&x.current&&!w.current&&(x.current.scrollTop=0)},[e.length,p]),(0,W.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{e.scrollTop>0&&(w.current=!0,m(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,W.useEffect)(()=>{e.length===0&&(w.current=!1,m(!0))},[e.length]),(0,W.useEffect)(()=>{h&&C.current&&C.current.focus()},[h]);let T=(0,W.useCallback)(()=>{l.trim()||g(!1)},[l]),E=(0,W.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||e.request.message.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,l]);(0,W.useEffect)(()=>{f(-1)},[l]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=E;if(e.key===`ArrowDown`)e.preventDefault(),f(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&d>=0){e.preventDefault();let t=E[d];t&&D(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[d,E]),(0,W.useEffect)(()=>{if(d>=0){let e=`elicitation-request-${E[d]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[d,E]);let D=(0,W.useCallback)(e=>{c(e)},[]),O=(0,W.useCallback)(()=>{window.confirm(`Are you sure you want to cancel all elicitation requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User cancelled all requests`)}),c(null))},[e,n]),k=(0,W.useCallback)(async()=>{if(s)try{await ih(JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)),b(!0),setTimeout(()=>b(!1),2e3)}catch(e){console.error(`[ElicitationTab] Failed to copy request:`,e)}},[s]),A=(0,W.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ElicitationTab] Failed to download request:`,e)}},[s]),j=(0,W.useCallback)(async()=>{if(S.current)try{document.fullscreenElement?await document.exitFullscreen():await S.current.requestFullscreen()}catch(e){console.error(`[ElicitationTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,U.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,U.jsx)(E7,{defaultSize:40,minSize:30,children:(0,U.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,U.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,U.jsx)(Mae,{isSearchExpanded:h,searchQuery:l,filteredRequestsCount:E.length,requestsCount:e.length,onSearchExpand:()=>g(!0),onSearchChange:u,onSearchBlur:T,onCancelAll:O,searchInputRef:C}),(0,U.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,U.jsx)(Nae,{requests:E,selectedRequest:s,onRequestSelect:D,focusedIndex:d,formatRelativeTime:j7,listRef:x})})]})})}),(0,U.jsx)(D7,{}),(0,U.jsx)(E7,{defaultSize:60,minSize:40,children:(0,U.jsx)(`div`,{ref:S,className:`h-full bg-white dark:bg-zinc-900`,children:(0,U.jsx)(Iae,{request:s,onApprove:t,onReject:n,onClose:()=>c(null),previewMode:_,onTogglePreview:()=>v(!_),isCopied:y,onCopy:k,onDownload:A,onFullscreen:j})})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(Kp,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function Rae({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onClearAll:s,searchInputRef:c}){return(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,U.jsx)(my,{ref:c,placeholder:`Search notifications...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Notifications`}),(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]})]})}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,U.jsx)($p,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{side:`bottom`,children:`Clear all`})]})})]})}function zae({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(Iu,{vertical:!0,noBorder:!0,message:`No notifications yet`})}):(0,U.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>(0,U.jsx)(k7,{id:`notification-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,U.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.method,!e.read&&(0,U.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=e.params&&Object.keys(e.params).length>0?Object.keys(e.params).length:0;return t+(n>0?` | ${n} param${n>1?`s`:``}`:``)})(),onClick:()=>n(e)},e.id))})}function Bae({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:i,onFullscreen:a,isCopied:o=!1,onClose:s}){return e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(Zf,{className:`h-3 w-3 text-gray-400`}),(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.formatRelativeTime(e.timestamp)})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:n,className:t?``:`text-purple-600 dark:text-purple-400`,children:[t?(0,U.jsx)(Qf,{className:`h-4 w-4 mr-1`}):(0,U.jsx)(Hf,{className:`h-4 w-4 mr-1`}),t?`JSON`:`Formatted`]}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,children:o?(0,U.jsx)(Uf,{className:`h-4 w-4`}):(0,U.jsx)(tp,{className:`h-4 w-4`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,children:(0,U.jsx)(rp,{className:`h-4 w-4`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:a,children:(0,U.jsx)(Sp,{className:`h-4 w-4`})}),s&&(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,children:(0,U.jsx)(nm,{className:`h-4 w-4`})})]})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,U.jsx)(`div`,{className:`px-4 pt-4`,children:(0,U.jsx)(pA,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(zf,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a notification to view details`})]})}function Vae({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:i,serverId:a,isConnected:o}){let[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(-1),[p,m]=(0,W.useState)(!0),[h,g]=(0,W.useState)(!1),[_,v]=(0,W.useState)(!0),[y,b]=(0,W.useState)(!1),x=(0,W.useRef)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(null),w=(0,W.useRef)(!1);(0,W.useEffect)(()=>{p&&e.length>0&&x.current&&!w.current&&(x.current.scrollTop=0)},[e.length,p]),(0,W.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{e.scrollTop>0&&(w.current=!0,m(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,W.useEffect)(()=>{e.length===0&&(w.current=!1,m(!0))},[e.length]),(0,W.useEffect)(()=>{s&&!s.read&&n(s.id)},[s,n]),(0,W.useEffect)(()=>{h&&C.current&&C.current.focus()},[h]);let T=(0,W.useCallback)(()=>{l.trim()||g(!1)},[l]),E=(0,W.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.method.toLowerCase().includes(t)||JSON.stringify(e.params||{}).toLowerCase().includes(t))},[e,l]);(0,W.useEffect)(()=>{f(-1)},[l]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=E;if(e.key===`ArrowDown`)e.preventDefault(),f(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&d>=0){e.preventDefault();let t=E[d];t&&D(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[d,E]),(0,W.useEffect)(()=>{if(d>=0){let e=`notification-${E[d]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[d,E]);let D=(0,W.useCallback)(e=>{c(e)},[]),O=(0,W.useCallback)(()=>{window.confirm(`Are you sure you want to clear all notifications? This cannot be undone.`)&&(i(),c(null))},[i]),k=(0,W.useCallback)(async()=>{if(s)try{await ih(JSON.stringify({method:s.method,timestamp:s.timestamp,read:s.read,params:s.params},null,2)),b(!0),setTimeout(()=>b(!1),2e3)}catch(e){console.error(`[NotificationsTab] Failed to copy notification:`,e)}},[s]),A=(0,W.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({method:s.method,timestamp:s.timestamp,read:s.read,params:s.params},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`notification-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[NotificationsTab] Failed to download notification:`,e)}},[s]),j=(0,W.useCallback)(async()=>{if(S.current)try{document.fullscreenElement?await document.exitFullscreen():await S.current.requestFullscreen()}catch(e){console.error(`[NotificationsTab] Failed to toggle fullscreen:`,e)}},[]),M=s?{method:s.method,params:s.params,timestamp:s.timestamp,read:s.read,formatRelativeTime:j7}:null;return o?(0,U.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,U.jsx)(E7,{defaultSize:40,minSize:30,children:(0,U.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,U.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,U.jsx)(Rae,{isSearchExpanded:h,searchQuery:l,filteredNotificationsCount:E.length,notificationsCount:e.length,onSearchExpand:()=>g(!0),onSearchChange:u,onSearchBlur:T,onClearAll:O,searchInputRef:C}),(0,U.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,U.jsx)(zae,{notifications:E,selectedNotification:s,onNotificationSelect:D,focusedIndex:d,formatRelativeTime:j7,listRef:x})})]})})}),(0,U.jsx)(D7,{}),(0,U.jsx)(E7,{defaultSize:60,minSize:40,children:(0,U.jsx)(`div`,{ref:S,className:`h-full bg-white dark:bg-zinc-900`,children:(0,U.jsx)(Bae,{notification:M,previewMode:_,onTogglePreview:()=>v(!_),onCopy:k,onDownload:A,onFullscreen:j,onClose:()=>c(null),isCopied:y})})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(zf,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function M7({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:i,primaryCount:a,secondaryCount:o,secondaryIcon:s,primaryIcon:c,searchPlaceholder:l=`Search...`,onSearchExpand:u,onSearchChange:d,onSearchBlur:f,onTabSwitch:p,searchInputRef:m,primaryTabName:h,onRefresh:g,isRefreshing:_=!1}){let v=e===h;return(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:t?(0,U.jsx)(my,{ref:m,placeholder:l,value:n,onChange:e=>d(e.target.value),onBlur:f,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:v?r:i}),v&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:a}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]}),g&&(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:g,disabled:_,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Pp,{className:`h-4 w-4 ${_?`animate-spin`:``}`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Refresh list`,(0,U.jsx)(O7,{children:`R`})]})]})]})]})}),(0,U.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:p,className:`gap-2 flex-shrink-0`,children:[v?(0,U.jsx)(s,{}):(0,U.jsx)(c,{}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:v?i:r}),v&&o>0&&(0,U.jsx)(sn,{className:`bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent`,variant:`outline`,children:o})]})]})}function Hae({serverIds:e,onCountChange:t,onClearRef:n,onExportRef:r}={}){let[i,a]=(0,W.useState)([]),o=(0,W.useRef)(null),[s,c]=(0,W.useState)(new Set),[l]=(0,W.useState)(``),u=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},d=async()=>{a([]),c(new Set),t?.(0),e&&e.length>0?e.forEach(e=>H(e)):H()},f=async e=>{try{await ih(JSON.stringify(e,null,2)),nv.success(`Message copied to clipboard`)}catch(e){console.error(`Failed to copy message:`,e),nv.error(`Failed to copy to clipboard`)}},p=async()=>{try{await ih(JSON.stringify(h,null,2)),nv.success(`All messages copied to clipboard (${h.length})`)}catch(e){console.error(`Failed to copy all messages:`,e),nv.error(`Failed to copy to clipboard`)}},m=(0,W.useMemo)(()=>!e||e.length===0?``:[...e].sort().join(`,`),[e]);(0,W.useEffect)(()=>(n&&(n.current=d),()=>{n&&(n.current=null)}),[n,d]),(0,W.useEffect)(()=>(r&&(r.current=p),()=>{r&&(r.current=null)}),[r,p]),(0,W.useEffect)(()=>{t?.(i.length)},[i.length,t]),(0,W.useEffect)(()=>{console.log(`[RPC Logger] Subscribing to RPC logs for servers:`,e);let n=ne(),r=(e&&e.length>0?n.filter(t=>e.includes(t.serverId)):n).map(e=>{let t=e.message,n=typeof t?.method==`string`?t.method:t?.result===void 0?t?.error===void 0?`unknown`:`error`:`result`;return{id:`${e.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:e.serverId,direction:e.direction.toUpperCase(),method:n,timestamp:e.timestamp,payload:e.message}}).reverse();a(r),t?.(r.length);let i=te(n=>{if(e&&e.length>0&&!e.includes(n.serverId))return;let r=n.message,i=typeof r?.method==`string`?r.method:r?.result===void 0?r?.error===void 0?`unknown`:`error`:`result`,o={id:`${n.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:n.serverId,direction:n.direction.toUpperCase(),method:i,timestamp:n.timestamp,payload:n.message};console.log(`[RPC Logger] New RPC log:`,{method:i,direction:n.direction,serverId:n.serverId}),a(e=>{let n=[o,...e].slice(0,1e3);return t?.(n.length),n})});return()=>{i(),console.log(`[RPC Logger] Unsubscribed from RPC logs`)}},[m,t]);let h=(0,W.useMemo)(()=>{let t=i;if(e&&e.length>0){let n=new Set(e);t=t.filter(e=>n.has(e.serverId))}if(l.trim()){let e=l.toLowerCase();t=t.filter(t=>t.serverId.toLowerCase().includes(e)||t.method.toLowerCase().includes(e)||t.direction.toLowerCase().includes(e)||JSON.stringify(t.payload).toLowerCase().includes(e))}return t=[...t].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),t},[i,l,e]);return(0,U.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:(0,U.jsx)(`div`,{ref:o,className:`flex-1 min-h-0 overflow-y-auto`,children:h.length===0?(0,U.jsxs)(`div`,{className:`text-center py-8`,children:[(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No messages yet`}),(0,U.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:`JSON-RPC messages will appear here`})]}):h.map(e=>{let t=s.has(e.id);return(0,U.jsxs)(`div`,{className:`group hover:bg-muted/50 transition-all duration-200 overflow-hidden`,"data-testid":`rpc-message-${e.method.replace(/\//g,`-`)}`,children:[(0,U.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>u(e.id),children:[(0,U.jsx)(`div`,{className:`flex-shrink-0`,children:t?(0,U.jsx)(Wf,{className:`h-3 w-3 text-muted-foreground transition-transform`}):(0,U.jsx)(Kf,{className:`h-3 w-3 text-muted-foreground transition-transform`})}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:new Date(e.timestamp).toLocaleTimeString()}),(0,U.jsx)(`span`,{className:`flex items-center justify-center px-1 py-0.5 rounded ${e.direction===`RECEIVE`?`bg-blue-500/10 text-blue-600 dark:text-blue-400`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,title:e.direction===`RECEIVE`?`Incoming`:`Outgoing`,children:e.direction===`RECEIVE`?(0,U.jsx)(Ff,{className:`h-3 w-3`}):(0,U.jsx)(If,{className:`h-3 w-3`})}),(0,U.jsx)(`span`,{className:`text-xs font-mono text-foreground truncate`,children:e.method})]})]}),t&&(0,U.jsx)(`div`,{className:`border-t bg-muted/20`,children:(0,U.jsxs)(`div`,{className:`p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Message Payload`}),(0,U.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:t=>{t.stopPropagation(),f(e.payload)},className:`h-6 px-2`,title:`Copy message to clipboard`,children:[(0,U.jsx)(tp,{className:`h-3 w-3 mr-1`}),(0,U.jsx)(`span`,{className:`text-xs`,children:`Copy`})]})]}),(0,U.jsx)(`div`,{className:`max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2`,children:(0,U.jsx)(pA,{data:e.payload})})]})})]},e.id)})})})}function N7({serverId:e,className:t}){let[n,r]=(0,W.useState)(0),[i,a]=(0,W.useState)(!0),o=w7(),s=(0,W.useRef)(null),c=(0,W.useRef)(null);return(0,W.useEffect)(()=>{o.current?.collapse()},[]),(0,U.jsxs)(E7,{panelRef:o,defaultSize:46,collapsible:!0,minSize:150,collapsedSize:46,onResize:e=>{i&&e.inPixels>46?a(!1):!i&&e.inPixels<=46&&a(!0)},className:`flex flex-col border-t dark:border-zinc-700 ${t||``}`,children:[(0,U.jsxs)(`div`,{"data-testid":`rpc-panel-toggle`,className:`group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors`,onClick:e=>{e.preventDefault(),e.stopPropagation(),i?(a(!1),setTimeout(()=>{o.current?.expand()},100)):(o.current?.collapse(),setTimeout(()=>{a(!0)},100))},children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-medium`,children:`RPC Messages`}),n>0&&(0,U.jsx)(sn,{"data-testid":`rpc-message-count`,variant:`secondary`,className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,children:n})]}),n>0&&!i&&(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e=>{e.preventDefault(),e.stopPropagation(),c.current?.()},className:`h-6 w-6 p-0`,title:`Copy all messages to clipboard`,children:(0,U.jsx)(tp,{className:`h-3.5 w-3.5`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e=>{e.preventDefault(),e.stopPropagation(),s.current?.()},className:`h-6 w-6 p-0`,title:`Clear all messages`,children:(0,U.jsx)($p,{className:`h-3.5 w-3.5`})})]})]}),(0,U.jsx)(Wf,{className:`h-4 w-4 text-muted-foreground transition-transform ${i?``:`rotate-180`}`})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-hidden min-h-0 ${i?`hidden`:``}`,children:(0,U.jsx)(Hae,{serverIds:[e],onCountChange:r,onClearRef:s,onExportRef:c})})]})}N7.displayName=`RpcPanel`;function P7({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(wp,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No prompts available`})]}):(0,U.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,i)=>(0,U.jsx)(k7,{id:`prompt-${e.name}`,"data-testid":`prompt-item-${e.name}`,isSelected:t?.name===e.name,isFocused:r===i,icon:(0,U.jsx)(wp,{className:`h-4 w-4`}),title:e.name,description:e.description,metadata:e.arguments&&e.arguments.length>0&&(0,U.jsxs)(sn,{variant:`outline`,className:`text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400`,children:[e.arguments.length,` args`]}),onClick:()=>n(e)},e.name))})}function F7({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:i,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d}){return(0,U.jsx)(M7,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:`prompts`,secondaryTabName:`saved`,primaryTabTitle:`Prompts`,secondaryTabTitle:`History`,primaryCount:r,secondaryCount:i,primaryIcon:wp,secondaryIcon:Zf,searchPlaceholder:`Search prompts...`,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d})}function I7({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:i}){return e.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(Zf,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No history`}),(0,U.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-gray-500 mt-1`,children:`Prompts you execute will appear here`})]}):(0,U.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,r)=>(0,U.jsx)(k7,{id:`saved-prompt-${e.id}`,isSelected:t?.id===e.id,isFocused:i===r,icon:(0,U.jsx)(Zf,{className:`h-4 w-4`}),title:e.name,description:`${e.promptName} - ${new Date(e.savedAt).toLocaleString()}`,onClick:()=>n(e)},e.id))})}function Uae({selectedPrompt:e,promptArgs:t,onArgChange:n}){let r=e?.arguments||[];if(!(r.length>0))return(0,U.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No arguments required`});let i=e=>{let r=e.name,i=t[r],a=typeof i==`string`?i:JSON.stringify(i);return e.type===`boolean`?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,U.jsx)(`input`,{id:r,type:`checkbox`,checked:!!i,onChange:e=>n(r,e.target.checked),className:`rounded`,"aria-label":`Toggle ${r}`}),(0,U.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:e.description})]})]},r):e.type===`number`?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsx)(my,{id:r,type:`number`,value:Number(i)||0,onChange:e=>n(r,Number(e.target.value)),placeholder:e.description||`Enter ${r}`}),e.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r):e.type===`array`||e.type===`object`?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsx)(JH,{id:r,value:a,onChange:e=>{try{n(r,JSON.parse(e.target.value))}catch{n(r,e.target.value)}},placeholder:e.description||`Enter ${r} as JSON`,className:`font-mono text-sm min-h-[100px]`}),e.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r):(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsx)(my,{id:r,"data-testid":`prompt-param-${r}`,value:a,onChange:e=>n(r,e.target.value),placeholder:e.description||`Enter ${r}`}),e.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]},r)};return(0,U.jsx)(`div`,{className:`space-y-4`,children:r.map(e=>i(e))})}function L7({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:i,onExecute:a,onSave:o}){return(0,W.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!n&&r&&(t.preventDefault(),a())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n,r,a]),e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsx)(`div`,{className:`flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3`,children:(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,U.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,children:e.name}),(0,U.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,U.jsx)(q,{onClick:a,disabled:n||!r,size:`sm`,className:`lg:size-default pr-1! gap-0`,"data-testid":`prompt-execute-button`,children:n?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TB,{className:`mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jp,{className:`h-4 w-4 sm:mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,U.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘↵`})]})}),(0,U.jsxs)(q,{variant:`outline`,onClick:o,disabled:n,size:`sm`,className:`lg:size-default gap-2`,children:[(0,U.jsx)(Ip,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]})]})]}),e.description&&(0,U.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2`,children:e.description})]})}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3`,children:(0,U.jsx)(Uae,{selectedPrompt:e,promptArgs:t,onArgChange:i})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a prompt to get started`}),(0,U.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a prompt from the list to view its details and execute it`})]})}function Wae(e){switch(e){case`system`:return`default`;case`user`:return`outline`;case`assistant`:return`secondary`;default:return`outline`}}function Gae(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Kae(e){return typeof e==`string`?e:e.text?e.text:e.type===`resource`&&e.resource?.text?e.resource.text:e.type===`image`?`[Image: ${e.mimeType||`unknown type`}]`:JSON.stringify(e,null,2)}function qae({message:e,index:t}){let[n,r]=(0,W.useState)(!1);return(0,U.jsxs)(`div`,{className:`border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border`,children:[(0,U.jsx)(sn,{variant:Wae(e.role),children:Gae(e.role)}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{await ih(Kae(e.content)),r(!0),setTimeout(()=>r(!1),2e3)},className:`h-6 px-2`,title:`Copy message content`,children:n?(0,U.jsx)(Uf,{className:`h-3.5 w-3.5`}):(0,U.jsx)(tp,{className:`h-3.5 w-3.5`})})]}),(0,U.jsx)(`div`,{className:`px-4 py-3`,"data-testid":`prompt-message-content-${t}`,children:(()=>{let t=e.content;return typeof t==`string`?(0,U.jsx)(pK,{content:t}):t.type===`text`&&t.text?(0,U.jsx)(pK,{content:t.text}):t.type===`image`?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`font-mono bg-muted px-2 py-1 rounded`,children:[`Image: `,t.mimeType||`unknown type`]}),t.data&&(0,U.jsx)(`img`,{src:`data:${t.mimeType};base64,${t.data}`,alt:`Prompt image`,className:`max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2`})]}):t.type===`resource`&&t.resource?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground font-medium`,children:`Resource:`}),(0,U.jsx)(`code`,{className:`bg-muted px-2 py-0.5 rounded text-xs font-mono`,children:t.resource.uri})]}),t.resource.text&&(0,U.jsx)(`div`,{className:`mt-2`,children:(0,U.jsx)(pK,{content:t.resource.text})})]}):(0,U.jsx)(`pre`,{className:`bg-muted p-3 rounded-lg text-sm overflow-x-auto`,children:(0,U.jsx)(`code`,{children:JSON.stringify(t,null,2)})})})()})]})}function Jae(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function Yae(e){return`isError`in e&&!e.isError?null:`error`in e&&e.error?String(e.error):`isError`in e&&e.isError?`An error occurred`:null}function R7({results:e,copiedResult:t,previewMode:n=!0,onCopy:r,onDelete:i,onFullscreen:a,onTogglePreview:o,onMaximize:s,isMaximized:c=!1}){let[l,u]=(0,W.useState)(0),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(!0),h=e[0],g=h?e.filter(e=>e.promptName===h.promptName):[],_=g[l]||g[0],v=e.findIndex(e=>e===_);if((0,W.useEffect)(()=>{g.length>0&&l>=g.length&&u(0)},[g.length,l]),(0,W.useEffect)(()=>{let e=()=>{_&&f(Jae(_.timestamp))};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[_]),e.length===0)return(0,U.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,U.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,U.jsx)(`div`,{className:`text-center`,children:(0,U.jsx)(Iu,{vertical:!0,noBorder:!0,message:`No Results yet`})})})})});let y=_.error||Yae(_.result),b=`messages`in _.result&&Array.isArray(_.result.messages);return(0,U.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,U.jsxs)(`div`,{className:`space-y-0 flex-1 h-full flex flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-medium hidden sm:block`,children:`Response`}),_.duration!==void 0&&(0,U.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1`,children:[(0,U.jsx)(rm,{className:`h-3 w-3 text-gray-400`}),(0,U.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[_.duration,`ms`]})]}),b&&(0,U.jsx)(`div`,{className:`flex items-center gap-4 sm:ml-4`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`button`,{onClick:()=>m(!0),className:`text-xs font-medium ${p?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:`Formatted`}),(0,U.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,U.jsx)(`button`,{onClick:()=>m(!1),className:`text-xs font-medium ${p?`text-zinc-500 dark:text-zinc-400`:`text-black dark:text-white`}`,children:`Raw`})]})}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[g.length>1&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mr-2`,children:[(0,U.jsx)(gp,{className:`h-3 w-3 text-gray-400`}),(0,U.jsxs)(kb,{value:l.toString(),onValueChange:e=>u(parseInt(e)),children:[(0,U.jsx)(jb,{className:`h-7 w-[120px] text-xs`,children:(0,U.jsx)(Ab,{})}),(0,U.jsx)(Mb,{children:g.map((e,t)=>(0,U.jsx)(Nb,{value:t.toString(),children:t===0?`Latest`:`${t+1} call ago`},t))})]})]}),(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 mr-2`,children:d}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>r(v,_.result),className:`h-7 w-7 p-0`,title:`Copy result`,children:t===v?(0,U.jsx)(Uf,{className:`h-4 w-4`}):(0,U.jsx)(tp,{className:`h-4 w-4`})}),i&&(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>i(v),className:`h-7 w-7 p-0`,title:`Delete result`,children:(0,U.jsx)($p,{className:`h-4 w-4`})}),a&&(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>a(v),className:`h-7 w-7 p-0 sm:hidden`,title:`Fullscreen`,children:(0,U.jsx)(Sp,{className:`h-4 w-4`})}),s&&(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,className:`h-7 w-7 p-0 hidden sm:flex`,title:c?`Restore`:`Maximize`,children:c?(0,U.jsx)(Tp,{className:`h-4 w-4`}):(0,U.jsx)(Sp,{className:`h-4 w-4`})})]})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:y?(0,U.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:[(0,U.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,U.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:y})]}):p&&b?(0,U.jsx)(`div`,{className:`space-y-3`,children:(`messages`in _.result?_.result.messages:[]).map((e,t)=>(0,U.jsx)(qae,{message:e,index:t},t))}):(0,U.jsx)(pA,{data:_.result,filename:`prompt-result-${_.promptName}-${Date.now()}.json`})})]})})})}var z7=`mcp-inspector-saved-prompts`;function B7({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:i,refreshPrompts:a}){let[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(null),{selectedPromptName:u,setSelectedPromptName:d}=jB(),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(`prompts`),[g,_]=(0,W.useState)([]),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(``),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(-1),E=(0,W.useRef)(null),[D,O]=(0,W.useState)(!1),[k,A]=(0,W.useState)(`list`),[j,M]=(0,W.useState)(!1),{filteredPrompts:N,selectedPrompt:P,setSelectedPrompt:F,results:I,handleDeleteResult:L,promptArgs:R,setPromptArgs:z,isExecuting:B,handlePromptSelect:V,handleArgChange:ee,executeSelectedPrompt:te,searchQuery:ne,setSearchQuery:H}=$V({prompts:t,callPrompt:n,serverId:r}),re=w7(),ie=w7();(0,W.useEffect)(()=>{let e=()=>{O(window.innerWidth<1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,W.useEffect)(()=>{A(P?`detail`:`list`)},[P]),(0,W.useEffect)(()=>{D&&I.length>0&&!B&&A(`response`)},[I,B,D]),(0,W.useImperativeHandle)(e,()=>({focusSearch:()=>{C(!0),setTimeout(()=>{E.current&&E.current.focus()},0)},blurSearch:()=>{H(``),C(!1),E.current&&E.current.blur()}})),(0,W.useEffect)(()=>{try{let e=localStorage.getItem(z7);e&&_(JSON.parse(e))}catch(e){console.error(`[PromptsTab] Failed to load saved prompts:`,e)}},[]);let ae=(0,W.useCallback)(e=>{try{localStorage.setItem(z7,JSON.stringify(e))}catch(e){console.error(`[PromptsTab] Failed to save prompts:`,e)}},[]);(0,W.useEffect)(()=>{S&&E.current&&E.current.focus()},[S]);let oe=(0,W.useCallback)(()=>{ne.trim()||C(!1)},[ne]),se=(0,W.useCallback)(async()=>{if(a){s(!0);try{await a()}finally{s(!1)}}},[a]),ce=(0,W.useCallback)(e=>{let n=t.find(t=>t.name===e.promptName);n&&(F(n),z(e.args),l(e))},[t,F,z]);(0,W.useEffect)(()=>{T(-1)},[ne,m]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=m===`prompts`?N:g;if(e.key===`ArrowDown`)e.preventDefault(),T(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),T(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&w>=0)if(e.preventDefault(),m===`prompts`){let e=N[w];e&&V(e)}else{let e=g[w];e&&ce(e)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[w,N,g,m,V,ce]),(0,W.useEffect)(()=>{if(w>=0){let e=m===`prompts`?`prompt-${N[w]?.name}`:`saved-prompt-${g[w]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[w,N,g,m]),(0,W.useEffect)(()=>{if(console.warn(`[PromptsTab] Auto-selection effect triggered:`,{selectedPromptName:u,promptsCount:t.length,currentSelectedPrompt:P?.name}),u&&t.length>0){let e=t.find(e=>e.name===u);if(console.warn(`[PromptsTab] Prompt lookup result:`,{selectedPromptName:u,promptFound:!!e,promptName:e?.name,shouldSelect:e&&P?.name!==e.name}),e&&P?.name!==e.name){console.warn(`[PromptsTab] Selecting prompt:`,e.name),d(null);let t=setTimeout(()=>{V(e);let t=document.getElementById(`prompt-${e.name}`);t&&(console.warn(`[PromptsTab] Scrolling to prompt element`),t.scrollIntoView({behavior:`smooth`,block:`nearest`}))},100);return()=>clearTimeout(t)}}},[u,t,P,V,d]);let le=(0,W.useCallback)(async(e,t)=>{try{await ih(JSON.stringify(t,null,2)),p(e),setTimeout(()=>p(null),2e3)}catch(e){console.error(`[PromptsTab] Failed to copy result:`,e)}},[]),ue=(0,W.useCallback)(e=>{if(D)A(`response`);else{let t=I[e];if(t){let e=window.open(``,`_blank`,`width=800,height=600`);if(e){let n=t.result;e.document.write(`
684
684
  <html>
685
685
  <head>
686
686
  <title>${t.promptName} Result</title>
@@ -695,7 +695,7 @@ Example format: {"theme": "dark", "width": "400", "title": "My Widget"}`),new d(
695
695
  </body>
696
696
  </html>
697
697
  `),e.document.close()}}}},[D,I]),de=(0,W.useCallback)(()=>{j?(re.current&&re.current.expand(),ie.current&&ie.current.expand(),M(!1)):(re.current&&re.current.collapse(),ie.current&&ie.current.collapse(),M(!0))},[j,re,ie]),fe=(0,W.useCallback)(()=>{P&&(x(``),y(!0))},[P]),pe=(0,W.useCallback)(e=>{ae(g.filter(t=>t.id!==e)),c?.id===e&&l(null)},[g,ae,c]);return D?(0,U.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[k!==`list`&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>{k===`response`?A(`detail`):(F(null),A(`list`))},className:`p-0 h-8 w-8`,children:(0,U.jsx)(Gf,{className:`h-4 w-4`})}),(0,U.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,U.jsx)(`button`,{onClick:()=>{F(null),A(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Prompts`}),k===`detail`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,U.jsx)(`button`,{onClick:()=>{A(`response`)},className:k===`detail`?`text-foreground hover:underline`:k===`response`?`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`:`text-muted-foreground`,children:`Execute`})]}),k===`response`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,U.jsx)(`span`,{className:`text-foreground`,children:`Response`})]})]})]}),(0,U.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,U.jsxs)(wR,{initial:!1,mode:`popLayout`,children:[k===`list`&&(0,U.jsxs)(bB.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:[(0,U.jsx)(F7,{activeTab:m,isSearchExpanded:S,searchQuery:ne,filteredPromptsCount:N.length,savedPromptsCount:g.length,onSearchExpand:()=>C(!0),onSearchChange:H,onSearchBlur:oe,onTabSwitch:()=>h(m===`prompts`?`saved`:`prompts`),searchInputRef:E,onRefresh:a?se:void 0,isRefreshing:o}),m===`prompts`?(0,U.jsx)(P7,{prompts:N,selectedPrompt:P,onPromptSelect:V,focusedIndex:w}):(0,U.jsx)(I7,{savedPrompts:g,selectedPrompt:c,onLoadPrompt:ce,onDeletePrompt:pe,focusedIndex:w})]},`list`),k===`detail`&&(0,U.jsx)(bB.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-10`,children:(0,U.jsx)(L7,{selectedPrompt:P,promptArgs:R,isExecuting:B,isConnected:i,onArgChange:ee,onExecute:te,onSave:fe})},`detail`),k===`response`&&(0,U.jsx)(bB.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-background z-20`,children:(0,U.jsx)(R7,{results:I,copiedResult:f,onCopy:le,onDelete:L,onFullscreen:ue})},`response`)]})})]}):(0,U.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,U.jsx)(E7,{id:`left-panel`,panelRef:re,defaultSize:`33%`,collapsible:!0,className:`flex flex-col h-full relative`,children:(0,U.jsxs)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:[(0,U.jsx)(E7,{defaultSize:`75%`,minSize:`30%`,children:(0,U.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,U.jsx)(F7,{activeTab:m,isSearchExpanded:S,searchQuery:ne,filteredPromptsCount:N.length,savedPromptsCount:g.length,onSearchExpand:()=>C(!0),onSearchChange:H,onSearchBlur:oe,onTabSwitch:()=>h(m===`prompts`?`saved`:`prompts`),searchInputRef:E,onRefresh:a?se:void 0,isRefreshing:o}),m===`prompts`?(0,U.jsx)(P7,{prompts:N,selectedPrompt:P,onPromptSelect:V,focusedIndex:w}):(0,U.jsx)(I7,{savedPrompts:g,selectedPrompt:c,onLoadPrompt:ce,onDeletePrompt:pe,focusedIndex:w})]})}),(0,U.jsx)(D7,{withHandle:!0}),(0,U.jsx)(N7,{serverId:r})]})}),(0,U.jsx)(D7,{withHandle:!0}),(0,U.jsx)(E7,{defaultSize:`67%`,children:(0,U.jsxs)(T7,{orientation:`vertical`,children:[(0,U.jsx)(E7,{panelRef:ie,defaultSize:`40%`,collapsible:!0,children:(0,U.jsx)(L7,{selectedPrompt:P,promptArgs:R,isExecuting:B,isConnected:i,onArgChange:ee,onExecute:te,onSave:fe})}),(0,U.jsx)(D7,{withHandle:!0}),(0,U.jsx)(E7,{defaultSize:`60%`,children:(0,U.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,U.jsx)(R7,{results:I,copiedResult:f,onCopy:le,onDelete:L,onFullscreen:ue,onMaximize:de,isMaximized:j})})})]})})]})}B7.displayName=`PromptsTab`;function V7(e){if(!e?.mimeType)return!1;let t=e.mimeType.toLowerCase();return t===`text/html`||t===`text/html;profile=mcp-app`||t===`text/html+skybridge`||t===`text/uri-list`||t.startsWith(`application/vnd.mcp-ui.remote-dom`)}function H7({resource:e,className:t}){let n=e,r=(0,W.useMemo)(()=>{if(n.text)return n.text;if(n.blob)try{return atob(n.blob)}catch{return null}return null},[n.text,n.blob]);return r?(0,U.jsx)(`div`,{className:t,children:(0,U.jsx)(`iframe`,{srcDoc:r,sandbox:`allow-scripts allow-forms allow-popups`,title:e.uri??`MCP UI Resource`,style:{width:`100%`,minHeight:`200px`,border:`none`}})}):null}function Xae(e){if(`error`in e&&e.error&&typeof e.error==`string`)return e.error;if(!(`isError`in e&&e.isError))return null;if(`contents`in e&&Array.isArray(e.contents)){let t=e.contents.filter(e=>`text`in e).map(e=>e.text).filter(Boolean);if(t.length>0)return t.join(`
698
- `)}return`An error occurred`}function U7({result:e,isLoading:t,previewMode:n,serverId:r,readResource:i,onTogglePreview:a,onCopy:o,onDownload:s,onFullscreen:c,isCopied:l=!1,selectedResource:u,llmConfig:d}){let f=(0,W.useMemo)(()=>({}),[]),[p,m]=(0,W.useState)(null),h=(0,W.useCallback)(e=>{m(e)},[]),[g,_]=(0,W.useState)(`inline`),v=[],y;if(e?.resourceAnnotations&&(v=Object.keys(e.resourceAnnotations).filter(e=>e.startsWith(`openai/`)),y=e.resourceAnnotations[`openai/outputTemplate`]),e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents[0]?._meta){let t=e.result.contents[0]._meta,n=Object.keys(t).filter(e=>e.startsWith(`openai/`));n.length>0&&(v=[...v,...n]),!y&&t[`openai/outputTemplate`]&&(y=t[`openai/outputTemplate`]),!y&&e.uri&&e.uri.startsWith(`ui://widget/`)&&(y=e.uri)}let b=!!(v.length>0&&y&&typeof y==`string`&&r&&i),x=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents[0]?._meta||{},S={...e?.resourceAnnotations,...x},C=(0,W.useMemo)(()=>{let e=S?.[`mcp-use/propsSchema`];if(!e)return[];let t=e.def?.shape;return t?Object.entries(t).filter(([,e])=>{let t=e?.def?.type??e?.type;return t!==`optional`&&t!==`default`}).map(([e])=>e):e.required??[]},[S]),w=AK(S,e?.result),T=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(e=>e.mimeType===`text/html;profile=mcp-app`),E=S?.ui?.resourceUri||x?.ui?.resourceUri||(T?e.uri:void 0),D=(w===`mcp-apps`||T)&&!!E,O=C.length>0&&!p;if(t)return(0,U.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full`,children:(0,U.jsx)(TB,{className:`size-5`})});if(!e)return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a resource to view its contents`}),(0,U.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a resource from the list to see its data`})]});let k=e.error||(e.result?Xae(e.result):null);if(k)return(0,U.jsx)(`div`,{className:`p-4`,children:(0,U.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:[(0,U.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,U.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:k})]})});let A=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(e=>e.mimeType&&V7(e)),j=A&&e.result&&`contents`in e.result&&Array.isArray(e.result.contents)?e.result.contents.filter(e=>e.mimeType&&V7(e)):[];return(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(Zf,{className:`h-3 w-3 text-gray-400`}),(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{let t=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return t===void 0?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(rm,{className:`h-3 w-3 text-gray-400`}),(0,U.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[t,`ms`]})]})})(),A&&(0,U.jsx)(sn,{variant:`outline`,className:`text-xs bg-purple-50 dark:bg-purple-900/20 border-none border-purple-200 dark:border-purple-800/50 text-purple-600 dark:text-purple-400`,children:`MCP UI`}),D&&(0,U.jsx)(sn,{variant:`outline`,className:`text-xs bg-green-50 dark:bg-green-900/20 border-none border-green-200 dark:border-green-800/50 text-green-600 dark:text-green-400`,children:`MCP Apps`}),b&&(0,U.jsx)(sn,{variant:`outline`,className:`text-xs bg-blue-50 dark:bg-blue-900/20 border-none border-blue-200 dark:border-blue-800/50 text-blue-600 dark:text-blue-400`,children:`OpenAI Widget`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(D||A||b)&&(0,U.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:a,className:n?``:`text-purple-600 dark:text-purple-400`,children:[n?(0,U.jsx)(Qf,{className:`h-4 w-4 mr-1`}):(0,U.jsx)(Hf,{className:`h-4 w-4 mr-1`}),n?`JSON`:b?`Component`:`Preview`]}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:o,children:l?(0,U.jsx)(Uf,{className:`h-4 w-4`}):(0,U.jsx)(tp,{className:`h-4 w-4`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,children:(0,U.jsx)(rp,{className:`h-4 w-4`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:c,children:(0,U.jsx)(Sp,{className:`h-4 w-4`})})]})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto relative`,children:D&&r&&i&&E?n?(0,U.jsxs)(`div`,{className:`flex-1 h-full relative`,"data-testid":`resource-widget-preview`,children:[(0,U.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-2`,children:(0,U.jsx)(o5,{toolCallId:`resource-${e.timestamp}`,displayMode:g,onDisplayModeChange:_,propsContext:`resource`,resourceUri:e.uri,resourceAnnotations:S,llmConfig:d||null,resource:u||null,onPropsChange:h,requiredProps:C.length>0&&!p?C:void 0})}),O?(0,U.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4`,children:(0,U.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center px-6`,children:`This widget requires props, set or generate them in the props debugger`})}):(0,U.jsx)(J8,{serverId:r,toolCallId:`resource-${e.timestamp}`,toolName:e.uri,toolInput:f,toolOutput:e.result,toolMetadata:S,resourceUri:E,readResource:i,className:`w-full h-full relative flex p-4`,customProps:p||void 0,displayMode:g,onDisplayModeChange:_})]}):(0,U.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,U.jsx)(pA,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-mcp-apps-${Date.now()}.json`})}):b&&r&&i&&y?n?(0,U.jsx)(`div`,{className:`flex-1 h-full relative`,children:O?(0,U.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4`,children:(0,U.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center px-6`,children:`This widget requires props, set or generate them in the props debugger`})}):(0,U.jsx)(c5,{componentUrl:y,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:r,readResource:i,className:`w-full h-full relative flex p-4`,customProps:p||void 0})}):(0,U.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,U.jsx)(pA,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})}):A?n?(0,U.jsxs)(`div`,{className:`space-y-0 h-full`,children:[j.map((e,t)=>(0,U.jsx)(`div`,{className:`mx-0 size-full`,children:(0,U.jsx)(`div`,{className:`w-full h-full`,children:(0,U.jsx)(H7,{resource:e,className:`w-full h-full`,customProps:p||void 0})})},`mcp-ui-${e.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result&&`contents`in e.result&&Array.isArray(e.result.contents)){let t=e.result.contents.filter(e=>!(e.mimeType&&V7(e)));if(t.length>0)return(0,U.jsx)(`div`,{className:`px-4`,children:(0,U.jsx)(pA,{data:t,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-non-ui-${Date.now()}.json`})})}return null})()]}):(0,U.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,U.jsx)(pA,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-mcp-ui-${Date.now()}.json`})}):(0,U.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,U.jsx)(pA,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]})}function Zae(e,t){if(!e&&!t)return(0,U.jsx)(dp,{className:`h-5 w-5`});let n=(e||t||``).toLowerCase();return n.includes(`image`)?(0,U.jsx)(lp,{className:`h-5 w-5`}):n.includes(`json`)||n.includes(`javascript`)||n.includes(`typescript`)?(0,U.jsx)(cp,{className:`h-5 w-5`}):n.includes(`html`)||n.includes(`xml`)?(0,U.jsx)(pp,{className:`h-5 w-5`}):n.includes(`database`)||n.includes(`sql`)?(0,U.jsx)(np,{className:`h-5 w-5`}):(0,U.jsx)(up,{className:`h-5 w-5`})}function W7({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:r}){return e.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(np,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No resources available`})]}):(0,U.jsx)(`div`,{className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,i)=>{let a=Zae(e.mimeType,e.uri),o=[e.description,e.mimeType&&(0,U.jsx)(`span`,{className:`font-mono`,children:e.mimeType},`mime`)].filter(Boolean);return(0,U.jsx)(k7,{id:`resource-${e.uri}`,"data-testid":`resource-item-${e.name}`,isSelected:t?.uri===e.uri,isFocused:r===i,icon:a,title:e.name,description:o.length>0?(0,U.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[e.description&&(0,U.jsx)(`span`,{children:e.description}),e.mimeType&&(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-500 font-mono`,children:e.mimeType})]}):void 0,onClick:()=>n(e)},e.uri)})})}function G7({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:r,onSearchChange:i,onSearchBlur:a,searchInputRef:o,onRefresh:s,isRefreshing:c=!1}){return(0,U.jsx)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:e?(0,U.jsx)(my,{ref:o,placeholder:`Search resources...`,value:t,onChange:e=>i(e.target.value),onBlur:a,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Resources`}),(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]}),s&&(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,disabled:c,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Pp,{className:`h-4 w-4 ${c?`animate-spin`:``}`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Refresh list`,(0,U.jsx)(O7,{children:`R`})]})]})]})})})}function K7({ref:e,resources:t,readResource:n,serverId:r,isConnected:i,mcpServerUrl:a,refreshResources:o}){let[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(null),{selectedResourceUri:d,setSelectedResourceUri:f}=jB(),{llmConfig:p}=p5({mcpServerUrl:a}),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(``),[b]=(0,W.useState)(`resources`),[x,S]=(0,W.useState)(!0),[C,w]=(0,W.useState)(!1),[T,E]=(0,W.useState)(-1),[D,O]=(0,W.useState)(!1),k=(0,W.useRef)(null),A=(0,W.useRef)(null),[j,M]=(0,W.useState)(!1),[N,P]=(0,W.useState)(`list`);(0,W.useEffect)(()=>{let e=()=>{M(window.innerWidth<1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,W.useEffect)(()=>{P(l?`detail`:`list`)},[l]),(0,W.useImperativeHandle)(e,()=>({focusSearch:()=>{w(!0),setTimeout(()=>{k.current&&k.current.focus()},0)},blurSearch:()=>{y(``),w(!1),k.current&&k.current.blur()}})),(0,W.useEffect)(()=>{C&&k.current&&k.current.focus()},[C]);let F=(0,W.useCallback)(()=>{v.trim()||w(!1)},[v]),I=(0,W.useCallback)(async()=>{if(o){c(!0);try{await o()}finally{c(!1)}}},[o]),L=(0,W.useMemo)(()=>{if(!v)return t;let e=v.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e)||t.uri.toLowerCase().includes(e))},[t,v]),R=(0,W.useCallback)(async e=>{if(u(e),i){_(!0);let t=Date.now();try{let i=await n(e.uri);Ef.getInstance().capture(new hf({resourceUri:e.uri,serverId:r,success:!0})).catch(()=>{}),h({uri:e.uri,result:i,timestamp:t,resourceAnnotations:{...e.annotations,...e._meta||{}}})}catch(n){Ef.getInstance().capture(new hf({resourceUri:e.uri,serverId:r,success:!1,error:n instanceof Error?n.message:`Unknown error`})).catch(()=>{}),h({uri:e.uri,result:{contents:[],_meta:{}},error:n instanceof Error?n.message:`Unknown error`,timestamp:t,resourceAnnotations:{...e.annotations,...e._meta||{}}})}finally{_(!1)}}},[n,r,i]);(0,W.useEffect)(()=>{E(-1)},[v,b]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=L;if(e.key===`ArrowDown`)e.preventDefault(),E(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),E(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&T>=0){e.preventDefault();let t=L[T];t&&R(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[T,L,R]),(0,W.useEffect)(()=>{if(T>=0){let e=`resource-${L[T]?.uri}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[T,L]),(0,W.useEffect)(()=>{if(d&&t.length>0){let e=t.find(e=>e.uri===d);e&&l?.uri!==e.uri&&(f(null),setTimeout(()=>{R(e);let t=document.getElementById(`resource-${e.uri}`);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[d,t,l,R,f]),(0,W.useEffect)(()=>{if(l){let e=t.find(e=>e.uri===l.uri);e&&e!==l&&(e.description!==l.description||e.mimeType!==l.mimeType||e.name!==l.name)&&u(e)}},[t,l]);let z=(0,W.useCallback)(async()=>{if(m)try{await ih(JSON.stringify(m.result,null,2)),O(!0),setTimeout(()=>O(!1),2e3)}catch(e){console.error(`[ResourcesTab] Failed to copy result:`,e)}},[m]),B=(0,W.useCallback)(()=>{if(m)try{let e=new globalThis.Blob([JSON.stringify(m.result,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`resource-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ResourcesTab] Failed to download result:`,e)}},[m]),V=(0,W.useCallback)(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(e){console.error(`[ResourcesTab] Failed to toggle fullscreen:`,e)}},[]);return j?(0,U.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[N!==`list`&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>{u(null),P(`list`)},className:`p-0 h-8 w-8`,children:(0,U.jsx)(Gf,{className:`h-4 w-4`})}),(0,U.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,U.jsx)(`button`,{onClick:()=>{u(null),P(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Resources`}),N===`detail`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,U.jsx)(`span`,{className:`text-foreground`,children:`Content`})]})]})]}),(0,U.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,U.jsxs)(wR,{initial:!1,mode:`popLayout`,children:[N===`list`&&(0,U.jsxs)(bB.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:[(0,U.jsx)(G7,{activeTab:b,isSearchExpanded:C,searchQuery:v,filteredResourcesCount:L.length,onSearchExpand:()=>w(!0),onSearchChange:y,onSearchBlur:F,onTabSwitch:()=>{},searchInputRef:k,onRefresh:o?I:void 0,isRefreshing:s}),(0,U.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,U.jsx)(W7,{resources:L,selectedResource:l,onResourceSelect:R,focusedIndex:T})})]},`list`),N===`detail`&&(0,U.jsx)(bB.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-white dark:bg-zinc-900 z-10`,children:(0,U.jsx)(`div`,{ref:A,className:`h-full`,children:(0,U.jsx)(U7,{result:m,isLoading:g,previewMode:x,serverId:r,readResource:n,onTogglePreview:()=>S(!x),onCopy:z,onDownload:B,onFullscreen:V,isCopied:D,selectedResource:l,llmConfig:p})})},`detail`)]})})]}):(0,U.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,U.jsx)(E7,{defaultSize:`33%`,children:(0,U.jsxs)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:[(0,U.jsx)(E7,{minSize:`30%`,children:(0,U.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,U.jsx)(G7,{activeTab:b,isSearchExpanded:C,searchQuery:v,filteredResourcesCount:L.length,onSearchExpand:()=>w(!0),onSearchChange:y,onSearchBlur:F,onTabSwitch:()=>{},searchInputRef:k,onRefresh:o?I:void 0,isRefreshing:s}),(0,U.jsx)(W7,{resources:L,selectedResource:l,onResourceSelect:R,focusedIndex:T})]})}),(0,U.jsx)(D7,{withHandle:!0}),(0,U.jsx)(N7,{serverId:r})]})}),(0,U.jsx)(D7,{}),(0,U.jsx)(E7,{defaultSize:`67%`,children:(0,U.jsx)(`div`,{ref:A,className:`h-full bg-white dark:bg-zinc-900`,children:(0,U.jsx)(U7,{result:m,isLoading:g,previewMode:x,serverId:r,readResource:n,onTogglePreview:()=>S(!x),onCopy:z,onDownload:B,onFullscreen:V,isCopied:D,selectedResource:l,llmConfig:p})})})]})}K7.displayName=`ResourcesTab`;function Qae({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onRejectAll:s,searchInputRef:c}){return(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,U.jsx)(my,{ref:c,placeholder:`Search requests...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Sampling`}),(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]})]})}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,U.jsx)($p,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{side:`bottom`,children:`Reject all`})]})})]})}function $ae({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(Iu,{vertical:!0,noBorder:!0,message:`No sampling requests`})}):(0,U.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e.request.params?.messages?.length||0,s=e.request.params?.maxTokens;return(0,U.jsx)(k7,{id:`sampling-request-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,U.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,U.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=[];return o>0&&n.push(`${o} message${o>1?`s`:``}`),s&&n.push(`max ${s} tokens`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function eoe({llmConfig:e}){let t=(0,W.useRef)(null);return{generateResponse:(0,W.useCallback)(async({request:n})=>{if(!e)throw Error(`LLM config is not available`);let r=n.params||{},i=r.maxTokens,a=r.temperature;r.modelPreferences;let o=r.messages||[];if(console.log(`[useSamplingLLM] Request structure:`,{hasParams:!!r,messagesCount:o.length,messages:o,params:r}),o.length===0)throw Error(`No messages found in sampling request`);let s=[],{HumanMessage:c,AIMessage:l}=await z(async()=>{let{HumanMessage:e,AIMessage:t}=await import(`./messages-D4_mH1tk.js`).then(e=>e.n);return{HumanMessage:e,AIMessage:t}},__vite__mapDeps([198,3,199]));for(let e of o){if(!e||!e.role){console.warn(`Skipping invalid message:`,e);continue}let t=Array.isArray(e.content)?e.content[0]:e.content;if(!t){console.warn(`Skipping message with no content:`,e);continue}t.type===`text`&&t.text?e.role===`user`?s.push(new c(t.text)):e.role===`assistant`&&s.push(new l(t.text)):console.warn(`Skipping message with unsupported content type:`,t)}if(s.length===0)throw Error(`No valid messages could be converted. Please ensure messages have 'text' content type.`);if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let n,r={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(r.maxTokens=i),a===void 0?e.temperature!==void 0&&(r.temperature=e.temperature):r.temperature=a,e.provider===`openai`){let{ChatOpenAI:e}=await z(async()=>{let{ChatOpenAI:e}=await import(`./dist-JsQmV3pO.js`);return{ChatOpenAI:e}},__vite__mapDeps([200,198,3,199,201,202,203,204,205]));n=new e(r)}else if(e.provider===`anthropic`){let{ChatAnthropic:e}=await z(async()=>{let{ChatAnthropic:e}=await import(`./dist-t5Yo0YiG.js`);return{ChatAnthropic:e}},__vite__mapDeps([206,198,3,199,201,204,205]));n=new e(r)}else if(e.provider===`google`){let{ChatGoogleGenerativeAI:e}=await z(async()=>{let{ChatGoogleGenerativeAI:e}=await import(`./dist-BZmXa__p.js`);return{ChatGoogleGenerativeAI:e}},__vite__mapDeps([207,198,3,199,201,202]));n=new e(r)}else throw Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:n,provider:e.provider,model:e.model,apiKey:e.apiKey}}let u=await t.current.instance.invoke(s);return{role:`assistant`,content:{type:`text`,text:u.content||u.text||``},model:e.model,stopReason:`endTurn`}},[e]),isAvailable:e!==null}}function toe({request:e,onApprove:t,onReject:r,onClose:i,previewMode:a,onTogglePreview:o,isCopied:s,onCopy:c,onDownload:l,onFullscreen:u,llmConfig:d}){let[f,p]=(0,W.useState)(`manual`),[m,h]=(0,W.useState)(`stub-model`),[g,_]=(0,W.useState)(`endTurn`),[v,y]=(0,W.useState)(`assistant`),[b,x]=(0,W.useState)(`text`),[S,C]=(0,W.useState)(`positive`),[w,T]=(0,W.useState)(``),[E,O]=(0,W.useState)(`image/png`),[k,A]=(0,W.useState)(!1),[j,M]=(0,W.useState)(null),{generateResponse:N,isAvailable:P}=eoe({llmConfig:d});(0,W.useEffect)(()=>{e&&(h(f===`llm`&&d?.model?d.model:`stub-model`),_(`endTurn`),y(`assistant`),x(`text`),C(`positive`),T(``),O(`image/png`),M(null))},[e?.id]),(0,W.useEffect)(()=>{f===`llm`&&d?.model&&h(d.model)},[f,d?.model]);let F=async()=>{if(!e||!P){console.log(`[SamplingRequestDisplay] Cannot generate:`,{hasRequest:!!e,isAvailable:P});return}console.log(`[SamplingRequestDisplay] Starting LLM generation:`,{requestId:e.id,llmConfig:d}),A(!0),M(null);try{let t=await N({request:e.request});console.log(`[SamplingRequestDisplay] LLM generation result:`,{result:t,model:t.model,stopReason:t.stopReason,role:t.role,contentIsArray:Array.isArray(t.content),content:t.content}),h(t.model||d?.model||`stub-model`),_(t.stopReason||`endTurn`),y(t.role||`assistant`);let n=Array.isArray(t.content)?t.content[0]:t.content;console.log(`[SamplingRequestDisplay] Setting content:`,{contentType:n.type,hasText:`text`in n,text:`text`in n?n.text:void 0}),n.type===`text`?(x(`text`),C(n.text||``),console.log(`[SamplingRequestDisplay] Set text content:`,n.text)):n.type===`image`&&(x(`image`),T(n.data||``),O(n.mimeType||`image/png`),console.log(`[SamplingRequestDisplay] Set image content`)),console.log(`[SamplingRequestDisplay] Form state after update:`,{model:m,stopReason:g,role:v,contentType:b,textContent:S})}catch(e){console.error(`[SamplingRequestDisplay] LLM generation error:`,e);let t=e instanceof Error?e.message:`Failed to generate response`;M(t),nv.error(`LLM Generation Failed`,{description:t})}finally{A(!1),console.log(`[SamplingRequestDisplay] Generation complete`)}},I=(0,W.useMemo)(()=>{let e={model:m,stopReason:g,role:v,content:{type:b}};return b===`text`?e.content.text=S:b===`image`&&(e.content.data=w,e.content.mimeType=E),e},[m,g,v,b,S,w,E]);return e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.serverName}),(0,U.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleString()})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:c,className:`h-8 w-8 p-0`,children:s?(0,U.jsx)(Uf,{className:`h-4 w-4 text-green-600`}):(0,U.jsx)(tp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Copy request`})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:l,className:`h-8 w-8 p-0`,children:(0,U.jsx)(rp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Download request`})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,U.jsx)(xp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Fullscreen`})]}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(nm,{className:`h-4 w-4`})})]})]}),(0,U.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Request`}),(0,U.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,U.jsx)(pA,{data:e.request})})]}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Response`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(yy,{htmlFor:`responseMode-${e.id}`,className:`text-xs text-gray-500 dark:text-gray-400`,children:`Mode:`}),(0,U.jsxs)(kb,{value:f,onValueChange:e=>p(e),children:[(0,U.jsx)(jb,{id:`responseMode-${e.id}`,className:`w-32 h-8 text-xs`,"data-testid":`sampling-response-mode-select`,children:(0,U.jsx)(Ab,{})}),(0,U.jsxs)(Mb,{children:[(0,U.jsx)(Nb,{value:`manual`,"data-testid":`sampling-response-mode-manual`,children:`Manual`}),(0,U.jsx)(Nb,{value:`llm`,"data-testid":`sampling-response-mode-llm`,children:`LLM`})]})]})]})]}),f===`llm`&&(0,U.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted rounded-lg`,children:[P?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(q,{onClick:F,disabled:k,size:`sm`,className:`flex items-center gap-2`,"data-testid":`sampling-generate-llm-button`,children:k?(0,U.jsxs)(`span`,{"data-testid":`sampling-generating`,className:`flex items-center gap-2`,children:[(0,U.jsx)(bp,{className:`h-4 w-4 animate-spin`}),`Generating...`]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Gp,{className:`h-4 w-4`}),`Generate with LLM`]})}),(0,U.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`Using `,d?.provider,` (`,d?.model,`)`]})]}):(0,U.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`LLM not configured. Please configure LLM in the Chat tab.`}),j&&(0,U.jsx)(`div`,{className:`text-xs text-red-600 dark:text-red-400`,"data-testid":`sampling-generation-error`,children:j})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`model-${e.id}`,children:`Model`}),(0,U.jsx)(my,{id:`model-${e.id}`,value:m,onChange:e=>h(e.target.value),placeholder:`stub-model`,disabled:f===`llm`&&k,"data-testid":`sampling-model-input`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`stopReason-${e.id}`,children:`Stop Reason`}),(0,U.jsx)(my,{id:`stopReason-${e.id}`,value:g,onChange:e=>_(e.target.value),placeholder:`endTurn`,disabled:f===`llm`&&k,"data-testid":`sampling-stop-reason-input`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`role-${e.id}`,children:`Role`}),(0,U.jsxs)(kb,{value:v,onValueChange:e=>y(e),disabled:f===`llm`&&k,children:[(0,U.jsx)(jb,{id:`role-${e.id}`,"data-testid":`sampling-role-select`,children:(0,U.jsx)(Ab,{})}),(0,U.jsxs)(Mb,{children:[(0,U.jsx)(Nb,{value:`assistant`,children:`assistant`}),(0,U.jsx)(Nb,{value:`user`,children:`user`})]})]})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`contentType-${e.id}`,children:`Content Type`}),(0,U.jsxs)(kb,{value:b,onValueChange:e=>x(e),disabled:f===`llm`&&k,children:[(0,U.jsx)(jb,{id:`contentType-${e.id}`,"data-testid":`sampling-content-type-select`,children:(0,U.jsx)(Ab,{})}),(0,U.jsxs)(Mb,{children:[(0,U.jsx)(Nb,{value:`text`,children:`text`}),(0,U.jsx)(Nb,{value:`image`,children:`image`})]})]})]}),b===`text`&&(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`text-${e.id}`,children:`Text Content`}),(0,U.jsx)(JH,{id:`text-${e.id}`,value:S,onChange:e=>C(e.target.value),placeholder:`Enter response text...`,rows:6,disabled:f===`llm`&&k,"data-testid":`sampling-text-content`})]}),b===`image`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`imageData-${e.id}`,children:`Base64 Image Data`}),(0,U.jsx)(JH,{id:`imageData-${e.id}`,value:w,onChange:e=>T(e.target.value),placeholder:`Base64 encoded image data...`,rows:4,disabled:f===`llm`&&k})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`mimeType-${e.id}`,children:`MIME Type`}),(0,U.jsx)(my,{id:`mimeType-${e.id}`,value:E,onChange:e=>O(e.target.value),placeholder:`image/png`,disabled:f===`llm`&&k})]})]})]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,U.jsx)(q,{onClick:()=>{if(!e)return;let r=D.safeParse(I);if(!r.success){nv.error(`Invalid response`,{description:`Validation failed: ${r.error.message}`});return}t(e.id,r.data),i(),z(()=>import(`./react-C6BFTceN.js`).then(e=>n(e.default,1)).then(t=>{let n=nv(t.createElement(`div`,{className:`space-y-3`},t.createElement(`div`,null,t.createElement(`strong`,null,`Sampling Response Sent`),t.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),t.createElement(`div`,{className:`flex gap-2`},t.createElement(`button`,{"data-testid":`sampling-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let t=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:e.toolName}});window.dispatchEvent(t),nv.dismiss(n)}},`View Tool Result`))),{duration:5e3})}),[])},className:`flex-1`,disabled:f===`llm`&&k,"data-testid":`sampling-approve-button`,children:`Approve`}),(0,U.jsx)(q,{onClick:()=>{e&&(r(e.id,`User rejected sampling request`),i())},variant:`outline`,className:`flex-1`,disabled:f===`llm`&&k,"data-testid":`sampling-reject-button`,children:`Reject`})]})]}):(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a sampling request to view details`})})}var noe={model:`stub-model`,stopReason:`endTurn`,role:`assistant`,content:{type:`text`,text:`positive`}};function roe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:i}){return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:`Sampling Request Received`}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:[`New request from `,t]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`button`,{"data-testid":`sampling-toast-view-details`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),n()},children:`View Details`}),(0,U.jsx)(`button`,{"data-testid":`sampling-toast-approve`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),r(noe)},children:`Approve`}),(0,U.jsx)(`button`,{"data-testid":`sampling-toast-deny`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),i()},children:`Deny`})]})]})}function ioe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:i,mcpServerUrl:a}){let{selectedSamplingRequestId:o,setSelectedSamplingRequestId:s}=jB(),{llmConfig:c}=p5({mcpServerUrl:a}),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(-1),[h,g]=(0,W.useState)(!0),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(!0),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(null),w=(0,W.useRef)(null),T=(0,W.useRef)(null),E=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(console.log(`[SamplingTab] Auto-selection check:`,{selectedSamplingRequestId:o,pendingRequestsCount:e.length,currentSelectedId:l?.id}),o&&e.length>0){let t=e.find(e=>e.id===o);console.log(`[SamplingTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[SamplingTab] Auto-selecting request:`,t.id),s(null),u(t),setTimeout(()=>{let e=document.getElementById(`sampling-request-${t.id}`);console.log(`[SamplingTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[o,e,s]),(0,W.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[SamplingTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[SamplingTab] Selecting request from event:`,n),u(r),setTimeout(()=>{let e=document.getElementById(`sampling-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-sampling`,t),()=>window.removeEventListener(`navigate-to-sampling`,t)},[e]),(0,W.useEffect)(()=>{h&&e.length>0&&C.current&&!E.current&&(C.current.scrollTop=0)},[e.length,h]),(0,W.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{e.scrollTop>0&&(E.current=!0,g(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,W.useEffect)(()=>{e.length===0&&(E.current=!1,g(!0))},[e.length]),(0,W.useEffect)(()=>{_&&T.current&&T.current.focus()},[_]);let D=(0,W.useCallback)(()=>{d.trim()||v(!1)},[d]),O=(0,W.useMemo)(()=>{if(!d.trim())return e;let t=d.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,d]);(0,W.useEffect)(()=>{m(-1)},[d]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=O;if(e.key===`ArrowDown`)e.preventDefault(),m(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),m(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&p>=0){e.preventDefault();let t=O[p];t&&k(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p,O]),(0,W.useEffect)(()=>{if(p>=0){let e=`sampling-request-${O[p]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[p,O]);let k=(0,W.useCallback)(e=>{u(e)},[]),A=(0,W.useCallback)(()=>{window.confirm(`Are you sure you want to reject all sampling requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User rejected all requests`)}),u(null))},[e,n]),j=(0,W.useCallback)(async()=>{if(l)try{await ih(JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){console.error(`[SamplingTab] Failed to copy request:`,e)}},[l]),M=(0,W.useCallback)(()=>{if(l)try{let e=new globalThis.Blob([JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[SamplingTab] Failed to download request:`,e)}},[l]),N=(0,W.useCallback)(async()=>{if(w.current)try{document.fullscreenElement?await document.exitFullscreen():await w.current.requestFullscreen()}catch(e){console.error(`[SamplingTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,U.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,U.jsx)(E7,{defaultSize:40,minSize:30,children:(0,U.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,U.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,U.jsx)(Qae,{isSearchExpanded:_,searchQuery:d,filteredRequestsCount:O.length,requestsCount:e.length,onSearchExpand:()=>v(!0),onSearchChange:f,onSearchBlur:D,onRejectAll:A,searchInputRef:T}),(0,U.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,U.jsx)($ae,{requests:O,selectedRequest:l,onRequestSelect:k,focusedIndex:p,formatRelativeTime:j7,listRef:C})})]})})}),(0,U.jsx)(D7,{}),(0,U.jsx)(E7,{defaultSize:60,minSize:40,children:(0,U.jsx)(`div`,{ref:w,className:`h-full bg-white dark:bg-zinc-900`,children:(0,U.jsx)(toe,{request:l,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:y,onTogglePreview:()=>b(!y),isCopied:x,onCopy:j,onDownload:M,onFullscreen:N,llmConfig:c})})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(hp,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function q7({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:r,focusedIndex:i}){if(e.length===0)return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(np,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`No saved requests yet`}),(0,U.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Execute a tool and click Save to store requests`})]});let a=(e,t)=>{e.stopPropagation(),t()};return(0,U.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,o)=>(0,U.jsxs)(`div`,{className:`relative group`,children:[(0,U.jsx)(k7,{id:`saved-${e.id}`,isSelected:t?.id===e.id,isFocused:i===o,icon:(0,U.jsx)(gp,{className:`h-4 w-4`}),title:e.name,description:e.toolName,metadata:(0,U.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,U.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:new Date(e.savedAt).toLocaleString()})}),onClick:()=>n(e)}),(0,U.jsx)(`div`,{className:`absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10`,children:(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`secondary`,size:`sm`,onClick:t=>a(t,()=>r(e.id)),className:`h-8 w-8 p-0`,children:(0,U.jsx)($p,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`Delete saved request`})})]})})]},e.id))})}function J7({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:r,onSave:i,onCancel:a}){return e?(0,U.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:a,children:(0,U.jsxs)(`div`,{className:`bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`h3`,{className:`text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100`,children:`Save Request`}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(yy,{htmlFor:`request-name`,children:`Request Name (optional)`}),(0,U.jsx)(my,{id:`request-name`,value:t,onChange:e=>r(e.target.value),placeholder:n,className:`mt-2`,onKeyDown:e=>{e.key===`Enter`&&i()},autoFocus:!0})]}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(q,{variant:`outline`,onClick:a,children:`Cancel`}),(0,U.jsxs)(q,{onClick:i,children:[(0,U.jsx)(Ip,{className:`h-4 w-4 mr-2`}),`Save`]})]})]})]})}):null}function Y7(e,t){if(!e?.$ref)return e;let n=e.$ref;if(!n.startsWith(`#/`))return e;let r=n.substring(2).split(`/`),i=t;for(let t of r)if(i&&typeof i==`object`&&t in i)i=i[t];else return e;return i}function aoe(e,t){if(e?.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(e=>Y7(e,t)?.type!==`null`);if(n)return{...Y7(n,t),nullable:!0}}return e}function X7(e,t){let n=aoe(e||{},t);return n=Y7(n,t),n}function Z7(e,t){let n=X7(e,t);if(typeof n.type==`string`)return n.type;if(Array.isArray(n.type)){let e=n.type.find(e=>e!==`null`);return typeof e==`string`?e:void 0}}function ooe(e){let t=e?.enum;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:null}function Q7(e){let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`on`].includes(t)?!0:[`false`,`0`,`no`,`off`].includes(t)?!1:e}function soe(e,t){if(t===`number`||t===`integer`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return t===`boolean`?Q7(e):e}function coe(e,t){if(e===void 0)return e;if(t===`object`||t===`array`){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}if(t===`number`||t===`integer`){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return e}return t===`boolean`?typeof e==`boolean`?e:typeof e==`string`?Q7(e):e:e}function $7(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(i){t+=a,i=!1,n++;continue}if(a===`\\`){i=!0,t+=a,n++;continue}if(a==="`"){r?(t+=`"`,r=!1):(t+=`"`,r=!0),n++;continue}if(r&&a===`"`){t+=`\\"`,n++;continue}t+=a,n++}return t}function loe(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{try{let e=$7(t),n=JSON.parse(e);if(n&&typeof n==`object`&&!Array.isArray(n))return n}catch{return null}}return null}function uoe({selectedTool:e,toolArgs:t,onArgChange:n,onBulkPaste:r,autoFilledFields:i,setFields:a,sendEmptyFields:o,onToggleEmpty:s}){let c=e?.inputSchema?.properties||{},l=e?.inputSchema?.required||[],u=Object.keys(c).length>0,d=async(e,t)=>{r&&await r(e.clipboardData.getData(`text`),t)&&e.preventDefault()};return u?(0,U.jsx)(`div`,{className:`space-y-4`,children:Object.entries(c).map(([r,c])=>{let u=X7(c,e?.inputSchema||{}),f=ooe(u),p=u.type===`string`&&f!==null,m=u;m.required=l.includes(r);let h=t[r],g=``;h!=null&&(g=typeof h==`string`?h:typeof h==`object`&&h?JSON.stringify(h,null,2):String(h));let _=m.type===`object`||m.type===`array`,v=_?m.type===`array`?`array`:`object`:`string`,y=a?.has(r)??!0,b=s&&(m.type===`string`||_);return _?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,m?.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),b&&s&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:v===`array`?`Send empty array explicitly`:`Send empty object explicitly`}),(0,U.jsx)(Hb,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,v,e),"aria-label":v===`array`?`Send empty array`:`Send empty object`,title:v===`array`?`Send empty array []`:`Send empty object {}`})]})]}),(0,U.jsx)(JH,{id:r,"data-testid":`tool-param-${r}`,value:g,onChange:e=>n(r,e.target.value),onPaste:e=>d(e,r),placeholder:m?.description||`Enter ${r}`,disabled:o?.has(r)??!1,className:`min-h-[100px] ${y?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`}),m?.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r):p&&f?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,m.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsxs)(kb,{value:String(t[r]||``),onValueChange:e=>n(r,e),children:[(0,U.jsx)(jb,{id:r,className:`w-full ${y?``:`opacity-70`}`,"data-testid":`tool-param-${r}`,children:(0,U.jsx)(Ab,{placeholder:m.description||`Select an option`})}),(0,U.jsx)(Mb,{children:f.map((e,t)=>(0,U.jsx)(Nb,{value:e,children:m.enumNames?.[t]||e},e))})]}),m.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r):(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,m?.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),b&&s&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`Send empty string`}),(0,U.jsx)(Hb,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,`string`,e),"aria-label":`Send empty string`,title:`Send empty string`})]})]}),(0,U.jsx)(my,{id:r,"data-testid":`tool-param-${r}`,value:g,onChange:e=>n(r,e.target.value),onPaste:e=>d(e,r),placeholder:m?.description||`Enter ${r}`,disabled:o?.has(r)??!1,className:`${y?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`}),m?.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r)})}):(0,U.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No parameters required`})}function e9({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:r,isConnected:i,onArgChange:a,onExecute:o,onSave:s,onCancel:c,onBulkPaste:l,autoFilledFields:u,setFields:d,sendEmptyFields:f,onToggleEmpty:p}){let[m,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(!1),E=(0,W.useRef)(null);return(0,W.useEffect)(()=>{if(E.current&&e?.description){let e=E.current,t=parseFloat(getComputedStyle(e).lineHeight),n=e.scrollHeight;T(Math.round(n/t)>3),C(!1)}},[e?.description]),(0,W.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!r&&i&&(t.preventDefault(),o()),t.key===`Escape`&&r&&c&&(t.preventDefault(),c())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r,i,o,c]),e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsx)(`div`,{className:`shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4`,children:(0,U.jsx)(`div`,{children:(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,U.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,"data-testid":`tool-execution-title`,children:e.name}),(0,U.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsxs)(q,{"data-testid":`tool-execution-metadata-button`,variant:g?`default`:`outline`,onClick:()=>_(!g),disabled:r,size:`sm`,className:`lg:size-default gap-2`,title:`View tool metadata`,children:[(0,U.jsx)(Qf,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Metadata`})]})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`View tool definition metadata`})})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsxs)(q,{"data-testid":`tool-execution-copy-payload-button`,variant:`outline`,onClick:async()=>{if(e)try{await ih(JSON.stringify(n??t,null,2)),x(!0),setTimeout(()=>x(!1),2e3)}catch{}},disabled:r,size:`sm`,className:`lg:size-default gap-2`,title:`Copy payload as JSON`,children:[b?(0,U.jsx)(Uf,{className:`h-4 w-4 text-green-600`}):(0,U.jsx)(tp,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:b?`Copied!`:`Payload`})]})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`Copy payload as JSON`})})]}),(0,U.jsxs)(q,{"data-testid":`tool-execution-save-button`,variant:`outline`,onClick:s,disabled:r,size:`sm`,className:`lg:size-default gap-2`,children:[(0,U.jsx)(Ip,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]}),r&&c?(0,U.jsxs)(uf,{open:m?void 0:!1,children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(`div`,{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),className:`relative`,children:(0,U.jsx)(q,{"data-testid":`tool-execution-cancel-button`,onClick:c,variant:m?`destructive`:`default`,size:`sm`,className:`lg:size-default gap-2 transition-all`,children:m?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(nm,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Cancel`}),(0,U.jsx)(`span`,{className:`hidden sm:inline text-[12px] border border-current p-1 rounded-full ml-2`,children:`Esc`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TB,{className:`mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]})})})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`Hover to cancel (or press Esc)`})})]}):(0,U.jsx)(q,{"data-testid":`tool-execution-execute-button`,onClick:o,disabled:r||!i,size:`sm`,className:`lg:size-default pr-1! gap-0`,children:r?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TB,{className:`mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jp,{className:`h-4 w-4 sm:mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,U.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘↵`})]})})]})]})})}),(0,U.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3`,children:[e.description&&(0,U.jsxs)(`div`,{className:`relative mb-4`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`p`,{ref:E,"data-testid":`tool-execution-description`,className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!S&&w?`line-clamp-3`:``}`,children:e.description}),w&&!S&&(0,U.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none`})]}),w&&(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(`button`,{onClick:()=>C(!S),className:`relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors`,children:S?(0,U.jsxs)(U.Fragment,{children:[`Show less`,(0,U.jsx)(qf,{className:`h-3 w-3`})]}):(0,U.jsxs)(U.Fragment,{children:[`Show more`,(0,U.jsx)(Wf,{className:`h-3 w-3`})]})})})]}),(0,U.jsx)(uoe,{selectedTool:e,toolArgs:t,onArgChange:a,onBulkPaste:l,autoFilledFields:u,setFields:d,sendEmptyFields:f,onToggleEmpty:p})]}),(0,U.jsx)(ay,{open:g,onOpenChange:_,children:(0,U.jsxs)(ly,{className:`max-w-3xl max-h-[80vh] overflow-y-auto`,children:[(0,U.jsx)(uy,{children:(0,U.jsxs)(fy,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`span`,{children:`Tool Definition`}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{if(e)try{await ih(JSON.stringify(e,null,2)),y(!0),setTimeout(()=>y(!1),2e3)}catch{}},className:`h-7 w-7 p-0`,title:`Copy metadata`,children:v?(0,U.jsx)(Uf,{className:`h-3.5 w-3.5 text-green-600`}):(0,U.jsx)(tp,{className:`h-3.5 w-3.5`})})]})}),(0,U.jsx)(pA,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})]})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a tool to get started`}),(0,U.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a tool from the list to view its details and execute it`})]})}function doe({timestamp:e}){let[t,n]=(0,W.useState)(()=>t9(e));return(0,W.useEffect)(()=>{let t=()=>n(t9(e));t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),(0,U.jsx)(`span`,{children:t})}function t9(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function n9(e){if(!e?.isError)return null;let t=e.content;if(Array.isArray(t)){let e=t.filter(e=>e.type===`text`).map(e=>e.text).filter(Boolean);if(e.length>0)return e.join(`
698
+ `)}return`An error occurred`}function U7({result:e,isLoading:t,previewMode:n,serverId:r,readResource:i,onTogglePreview:a,onCopy:o,onDownload:s,onFullscreen:c,isCopied:l=!1,selectedResource:u,llmConfig:d}){let f=(0,W.useMemo)(()=>({}),[]),[p,m]=(0,W.useState)(null),h=(0,W.useCallback)(e=>{m(e)},[]),[g,_]=(0,W.useState)(`inline`),v=[],y;if(e?.resourceAnnotations&&(v=Object.keys(e.resourceAnnotations).filter(e=>e.startsWith(`openai/`)),y=e.resourceAnnotations[`openai/outputTemplate`]),e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents[0]?._meta){let t=e.result.contents[0]._meta,n=Object.keys(t).filter(e=>e.startsWith(`openai/`));n.length>0&&(v=[...v,...n]),!y&&t[`openai/outputTemplate`]&&(y=t[`openai/outputTemplate`]),!y&&e.uri&&e.uri.startsWith(`ui://widget/`)&&(y=e.uri)}let b=!!(v.length>0&&y&&typeof y==`string`&&r&&i),x=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents[0]?._meta||{},S={...e?.resourceAnnotations,...x},C=(0,W.useMemo)(()=>{let e=S?.[`mcp-use/propsSchema`];if(!e)return[];let t=e.def?.shape;return t?Object.entries(t).filter(([,e])=>{let t=e?.def?.type??e?.type;return t!==`optional`&&t!==`default`}).map(([e])=>e):e.required??[]},[S]),w=AK(S,e?.result),T=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(e=>e.mimeType===`text/html;profile=mcp-app`),E=S?.ui?.resourceUri||x?.ui?.resourceUri||(T?e.uri:void 0),D=(w===`mcp-apps`||T)&&!!E,O=C.length>0&&!p;if(t)return(0,U.jsx)(`div`,{className:`flex absolute left-0 top-0 items-center justify-center w-full h-full`,children:(0,U.jsx)(TB,{className:`size-5`})});if(!e)return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a resource to view its contents`}),(0,U.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a resource from the list to see its data`})]});let k=e.error||(e.result?Xae(e.result):null);if(k)return(0,U.jsx)(`div`,{className:`p-4`,children:(0,U.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:[(0,U.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,U.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:k})]})});let A=e?.result&&`contents`in e.result&&Array.isArray(e.result.contents)&&e.result.contents.some(e=>e.mimeType&&V7(e)),j=A&&e.result&&`contents`in e.result&&Array.isArray(e.result.contents)?e.result.contents.filter(e=>e.mimeType&&V7(e)):[];return(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(Zf,{className:`h-3 w-3 text-gray-400`}),(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{let t=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return t===void 0?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(rm,{className:`h-3 w-3 text-gray-400`}),(0,U.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[t,`ms`]})]})})(),A&&(0,U.jsx)(sn,{variant:`outline`,className:`text-xs bg-purple-50 dark:bg-purple-900/20 border-none border-purple-200 dark:border-purple-800/50 text-purple-600 dark:text-purple-400`,children:`MCP UI`}),D&&(0,U.jsx)(sn,{variant:`outline`,className:`text-xs bg-green-50 dark:bg-green-900/20 border-none border-green-200 dark:border-green-800/50 text-green-600 dark:text-green-400`,children:`MCP Apps`}),b&&(0,U.jsx)(sn,{variant:`outline`,className:`text-xs bg-blue-50 dark:bg-blue-900/20 border-none border-blue-200 dark:border-blue-800/50 text-blue-600 dark:text-blue-400`,children:`OpenAI Widget`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(D||A||b)&&(0,U.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:a,className:n?``:`text-purple-600 dark:text-purple-400`,children:[n?(0,U.jsx)(Qf,{className:`h-4 w-4 mr-1`}):(0,U.jsx)(Hf,{className:`h-4 w-4 mr-1`}),n?`JSON`:b?`Component`:`Preview`]}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:o,children:l?(0,U.jsx)(Uf,{className:`h-4 w-4`}):(0,U.jsx)(tp,{className:`h-4 w-4`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,children:(0,U.jsx)(rp,{className:`h-4 w-4`})}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:c,children:(0,U.jsx)(Sp,{className:`h-4 w-4`})})]})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto relative`,children:D&&r&&i&&E?n?(0,U.jsxs)(`div`,{className:`flex-1 h-full relative`,"data-testid":`resource-widget-preview`,children:[(0,U.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-2`,children:(0,U.jsx)(o5,{toolCallId:`resource-${e.timestamp}`,displayMode:g,onDisplayModeChange:_,propsContext:`resource`,resourceUri:e.uri,resourceAnnotations:S,llmConfig:d||null,resource:u||null,onPropsChange:h,requiredProps:C.length>0&&!p?C:void 0})}),O?(0,U.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4`,children:(0,U.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center px-6`,children:`This widget requires props, set or generate them in the props debugger`})}):(0,U.jsx)(J8,{serverId:r,toolCallId:`resource-${e.timestamp}`,toolName:e.uri,toolInput:f,toolOutput:e.result,toolMetadata:S,resourceUri:E,readResource:i,className:`w-full h-full relative flex p-4`,customProps:p||void 0,displayMode:g,onDisplayModeChange:_})]}):(0,U.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,U.jsx)(pA,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-mcp-apps-${Date.now()}.json`})}):b&&r&&i&&y?n?(0,U.jsx)(`div`,{className:`flex-1 h-full relative`,children:O?(0,U.jsx)(`div`,{className:`flex items-center justify-center w-full h-full min-h-[200px] rounded-xl border-2 border-dashed border-gray-300 dark:border-zinc-600 bg-gray-50 dark:bg-zinc-800/50 m-4`,children:(0,U.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center px-6`,children:`This widget requires props, set or generate them in the props debugger`})}):(0,U.jsx)(c5,{componentUrl:y,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:r,readResource:i,className:`w-full h-full relative flex p-4`,customProps:p||void 0})}):(0,U.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,U.jsx)(pA,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})}):A?n?(0,U.jsxs)(`div`,{className:`space-y-0 h-full`,children:[j.map((e,t)=>(0,U.jsx)(`div`,{className:`mx-0 size-full`,children:(0,U.jsx)(`div`,{className:`w-full h-full`,children:(0,U.jsx)(H7,{resource:e,className:`w-full h-full`,customProps:p||void 0})})},`mcp-ui-${e.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result&&`contents`in e.result&&Array.isArray(e.result.contents)){let t=e.result.contents.filter(e=>!(e.mimeType&&V7(e)));if(t.length>0)return(0,U.jsx)(`div`,{className:`px-4`,children:(0,U.jsx)(pA,{data:t,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-non-ui-${Date.now()}.json`})})}return null})()]}):(0,U.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,U.jsx)(pA,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-mcp-ui-${Date.now()}.json`})}):(0,U.jsx)(`div`,{className:`px-4 pt-4`,"data-testid":`resource-result-json`,children:(0,U.jsx)(pA,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]})}function Zae(e,t){if(!e&&!t)return(0,U.jsx)(dp,{className:`h-5 w-5`});let n=(e||t||``).toLowerCase();return n.includes(`image`)?(0,U.jsx)(lp,{className:`h-5 w-5`}):n.includes(`json`)||n.includes(`javascript`)||n.includes(`typescript`)?(0,U.jsx)(cp,{className:`h-5 w-5`}):n.includes(`html`)||n.includes(`xml`)?(0,U.jsx)(pp,{className:`h-5 w-5`}):n.includes(`database`)||n.includes(`sql`)?(0,U.jsx)(np,{className:`h-5 w-5`}):(0,U.jsx)(up,{className:`h-5 w-5`})}function W7({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:r}){return e.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(np,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No resources available`})]}):(0,U.jsx)(`div`,{className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,i)=>{let a=Zae(e.mimeType,e.uri),o=[e.description,e.mimeType&&(0,U.jsx)(`span`,{className:`font-mono`,children:e.mimeType},`mime`)].filter(Boolean);return(0,U.jsx)(k7,{id:`resource-${e.uri}`,"data-testid":`resource-item-${e.name}`,isSelected:t?.uri===e.uri,isFocused:r===i,icon:a,title:e.name,description:o.length>0?(0,U.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[e.description&&(0,U.jsx)(`span`,{children:e.description}),e.mimeType&&(0,U.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-500 font-mono`,children:e.mimeType})]}):void 0,onClick:()=>n(e)},e.uri)})})}function G7({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:r,onSearchChange:i,onSearchBlur:a,searchInputRef:o,onRefresh:s,isRefreshing:c=!1}){return(0,U.jsx)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:e?(0,U.jsx)(my,{ref:o,placeholder:`Search resources...`,value:t,onChange:e=>i(e.target.value),onBlur:a,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Resources`}),(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]}),s&&(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,disabled:c,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Pp,{className:`h-4 w-4 ${c?`animate-spin`:``}`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Refresh list`,(0,U.jsx)(O7,{children:`R`})]})]})]})})})}function K7({ref:e,resources:t,readResource:n,serverId:r,isConnected:i,mcpServerUrl:a,refreshResources:o}){let[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(null),{selectedResourceUri:d,setSelectedResourceUri:f}=jB(),{llmConfig:p}=p5({mcpServerUrl:a}),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(``),[b]=(0,W.useState)(`resources`),[x,S]=(0,W.useState)(!0),[C,w]=(0,W.useState)(!1),[T,E]=(0,W.useState)(-1),[D,O]=(0,W.useState)(!1),k=(0,W.useRef)(null),A=(0,W.useRef)(null),[j,M]=(0,W.useState)(!1),[N,P]=(0,W.useState)(`list`);(0,W.useEffect)(()=>{let e=()=>{M(window.innerWidth<1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,W.useEffect)(()=>{P(l?`detail`:`list`)},[l]),(0,W.useImperativeHandle)(e,()=>({focusSearch:()=>{w(!0),setTimeout(()=>{k.current&&k.current.focus()},0)},blurSearch:()=>{y(``),w(!1),k.current&&k.current.blur()}})),(0,W.useEffect)(()=>{C&&k.current&&k.current.focus()},[C]);let F=(0,W.useCallback)(()=>{v.trim()||w(!1)},[v]),I=(0,W.useCallback)(async()=>{if(o){c(!0);try{await o()}finally{c(!1)}}},[o]),L=(0,W.useMemo)(()=>{if(!v)return t;let e=v.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e)||t.uri.toLowerCase().includes(e))},[t,v]),R=(0,W.useCallback)(async e=>{if(u(e),i){_(!0);let t=Date.now();try{let i=await n(e.uri);Ef.getInstance().capture(new hf({resourceUri:e.uri,serverId:r,success:!0})).catch(()=>{}),h({uri:e.uri,result:i,timestamp:t,resourceAnnotations:{...e.annotations,...e._meta||{}}})}catch(n){Ef.getInstance().capture(new hf({resourceUri:e.uri,serverId:r,success:!1,error:n instanceof Error?n.message:`Unknown error`})).catch(()=>{}),h({uri:e.uri,result:{contents:[],_meta:{}},error:n instanceof Error?n.message:`Unknown error`,timestamp:t,resourceAnnotations:{...e.annotations,...e._meta||{}}})}finally{_(!1)}}},[n,r,i]);(0,W.useEffect)(()=>{E(-1)},[v,b]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=L;if(e.key===`ArrowDown`)e.preventDefault(),E(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),E(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&T>=0){e.preventDefault();let t=L[T];t&&R(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[T,L,R]),(0,W.useEffect)(()=>{if(T>=0){let e=`resource-${L[T]?.uri}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[T,L]),(0,W.useEffect)(()=>{if(d&&t.length>0){let e=t.find(e=>e.uri===d);e&&l?.uri!==e.uri&&(f(null),setTimeout(()=>{R(e);let t=document.getElementById(`resource-${e.uri}`);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[d,t,l,R,f]),(0,W.useEffect)(()=>{if(l){let e=t.find(e=>e.uri===l.uri);e&&e!==l&&(e.description!==l.description||e.mimeType!==l.mimeType||e.name!==l.name)&&u(e)}},[t,l]);let z=(0,W.useCallback)(async()=>{if(m)try{await ih(JSON.stringify(m.result,null,2)),O(!0),setTimeout(()=>O(!1),2e3)}catch(e){console.error(`[ResourcesTab] Failed to copy result:`,e)}},[m]),B=(0,W.useCallback)(()=>{if(m)try{let e=new globalThis.Blob([JSON.stringify(m.result,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`resource-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ResourcesTab] Failed to download result:`,e)}},[m]),V=(0,W.useCallback)(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(e){console.error(`[ResourcesTab] Failed to toggle fullscreen:`,e)}},[]);return j?(0,U.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden relative bg-background`,children:[N!==`list`&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10`,children:[(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>{u(null),P(`list`)},className:`p-0 h-8 w-8`,children:(0,U.jsx)(Gf,{className:`h-4 w-4`})}),(0,U.jsxs)(`div`,{className:`flex items-center text-sm font-medium`,children:[(0,U.jsx)(`button`,{onClick:()=>{u(null),P(`list`)},className:`text-muted-foreground hover:text-foreground hover:underline cursor-pointer`,children:`Resources`}),N===`detail`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`mx-2 text-muted-foreground`,children:`/`}),(0,U.jsx)(`span`,{className:`text-foreground`,children:`Content`})]})]})]}),(0,U.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,U.jsxs)(wR,{initial:!1,mode:`popLayout`,children:[N===`list`&&(0,U.jsxs)(bB.div,{initial:{x:`-100%`},animate:{x:0},exit:{x:`-100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 flex flex-col bg-background z-0`,children:[(0,U.jsx)(G7,{activeTab:b,isSearchExpanded:C,searchQuery:v,filteredResourcesCount:L.length,onSearchExpand:()=>w(!0),onSearchChange:y,onSearchBlur:F,onTabSwitch:()=>{},searchInputRef:k,onRefresh:o?I:void 0,isRefreshing:s}),(0,U.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,U.jsx)(W7,{resources:L,selectedResource:l,onResourceSelect:R,focusedIndex:T})})]},`list`),N===`detail`&&(0,U.jsx)(bB.div,{initial:{x:`100%`},animate:{x:0},exit:{x:`100%`},transition:{type:`spring`,stiffness:300,damping:30},className:`absolute inset-0 bg-white dark:bg-zinc-900 z-10`,children:(0,U.jsx)(`div`,{ref:A,className:`h-full`,children:(0,U.jsx)(U7,{result:m,isLoading:g,previewMode:x,serverId:r,readResource:n,onTogglePreview:()=>S(!x),onCopy:z,onDownload:B,onFullscreen:V,isCopied:D,selectedResource:l,llmConfig:p})})},`detail`)]})})]}):(0,U.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,U.jsx)(E7,{defaultSize:`33%`,children:(0,U.jsxs)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:[(0,U.jsx)(E7,{minSize:`30%`,children:(0,U.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,U.jsx)(G7,{activeTab:b,isSearchExpanded:C,searchQuery:v,filteredResourcesCount:L.length,onSearchExpand:()=>w(!0),onSearchChange:y,onSearchBlur:F,onTabSwitch:()=>{},searchInputRef:k,onRefresh:o?I:void 0,isRefreshing:s}),(0,U.jsx)(W7,{resources:L,selectedResource:l,onResourceSelect:R,focusedIndex:T})]})}),(0,U.jsx)(D7,{withHandle:!0}),(0,U.jsx)(N7,{serverId:r})]})}),(0,U.jsx)(D7,{}),(0,U.jsx)(E7,{defaultSize:`67%`,children:(0,U.jsx)(`div`,{ref:A,className:`h-full bg-white dark:bg-zinc-900`,children:(0,U.jsx)(U7,{result:m,isLoading:g,previewMode:x,serverId:r,readResource:n,onTogglePreview:()=>S(!x),onCopy:z,onDownload:B,onFullscreen:V,isCopied:D,selectedResource:l,llmConfig:p})})})]})}K7.displayName=`ResourcesTab`;function Qae({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:i,onSearchChange:a,onSearchBlur:o,onRejectAll:s,searchInputRef:c}){return(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2 flex-1`,children:e?(0,U.jsx)(my,{ref:c,placeholder:`Search requests...`,value:t,onChange:e=>a(e.target.value),onBlur:o,className:`h-8 border-gray-300 dark:border-zinc-600`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:`text-lg font-medium text-gray-900 dark:text-gray-100`,children:`Sampling`}),(0,U.jsx)(sn,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:n}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(Lp,{className:`h-4 w-4`})})}),(0,U.jsxs)(ff,{side:`bottom`,className:`flex gap-2`,children:[`Search`,(0,U.jsx)(O7,{children:`F`})]})]})]})}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,disabled:r===0,className:`h-8 w-8 p-0`,children:(0,U.jsx)($p,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{side:`bottom`,children:`Reject all`})]})})]})}function $ae({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:i,listRef:a}){return e.length===0?(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(Iu,{vertical:!0,noBorder:!0,message:`No sampling requests`})}):(0,U.jsx)(`div`,{ref:a,className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e.request.params?.messages?.length||0,s=e.request.params?.maxTokens;return(0,U.jsx)(k7,{id:`sampling-request-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,U.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,U.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=[];return o>0&&n.push(`${o} message${o>1?`s`:``}`),s&&n.push(`max ${s} tokens`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function eoe({llmConfig:e}){let t=(0,W.useRef)(null);return{generateResponse:(0,W.useCallback)(async({request:n})=>{if(!e)throw Error(`LLM config is not available`);let r=n.params||{},i=r.maxTokens,a=r.temperature;r.modelPreferences;let o=r.messages||[];if(console.log(`[useSamplingLLM] Request structure:`,{hasParams:!!r,messagesCount:o.length,messages:o,params:r}),o.length===0)throw Error(`No messages found in sampling request`);let s=[],{HumanMessage:c,AIMessage:l}=await z(async()=>{let{HumanMessage:e,AIMessage:t}=await import(`./messages-D4_mH1tk.js`).then(e=>e.n);return{HumanMessage:e,AIMessage:t}},__vite__mapDeps([198,3,199]));for(let e of o){if(!e||!e.role){console.warn(`Skipping invalid message:`,e);continue}let t=Array.isArray(e.content)?e.content[0]:e.content;if(!t){console.warn(`Skipping message with no content:`,e);continue}t.type===`text`&&t.text?e.role===`user`?s.push(new c(t.text)):e.role===`assistant`&&s.push(new l(t.text)):console.warn(`Skipping message with unsupported content type:`,t)}if(s.length===0)throw Error(`No valid messages could be converted. Please ensure messages have 'text' content type.`);if(!t.current||t.current.provider!==e.provider||t.current.model!==e.model||t.current.apiKey!==e.apiKey){let n,r={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(r.maxTokens=i),a===void 0?e.temperature!==void 0&&(r.temperature=e.temperature):r.temperature=a,e.provider===`openai`){let{ChatOpenAI:e}=await z(async()=>{let{ChatOpenAI:e}=await import(`./dist-JsQmV3pO.js`);return{ChatOpenAI:e}},__vite__mapDeps([200,198,3,199,201,202,203,204,205]));n=new e(r)}else if(e.provider===`anthropic`){let{ChatAnthropic:e}=await z(async()=>{let{ChatAnthropic:e}=await import(`./dist-t5Yo0YiG.js`);return{ChatAnthropic:e}},__vite__mapDeps([206,198,3,199,201,204,205]));n=new e(r)}else if(e.provider===`google`){let{ChatGoogleGenerativeAI:e}=await z(async()=>{let{ChatGoogleGenerativeAI:e}=await import(`./dist-BZmXa__p.js`);return{ChatGoogleGenerativeAI:e}},__vite__mapDeps([207,198,3,199,201,202]));n=new e(r)}else throw Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:n,provider:e.provider,model:e.model,apiKey:e.apiKey}}let u=await t.current.instance.invoke(s);return{role:`assistant`,content:{type:`text`,text:u.content||u.text||``},model:e.model,stopReason:`endTurn`}},[e]),isAvailable:e!==null}}function toe({request:e,onApprove:t,onReject:r,onClose:i,previewMode:a,onTogglePreview:o,isCopied:s,onCopy:c,onDownload:l,onFullscreen:u,llmConfig:d}){let[f,p]=(0,W.useState)(`manual`),[m,h]=(0,W.useState)(`stub-model`),[g,_]=(0,W.useState)(`endTurn`),[v,y]=(0,W.useState)(`assistant`),[b,x]=(0,W.useState)(`text`),[S,C]=(0,W.useState)(`positive`),[w,T]=(0,W.useState)(``),[E,O]=(0,W.useState)(`image/png`),[k,A]=(0,W.useState)(!1),[j,M]=(0,W.useState)(null),{generateResponse:N,isAvailable:P}=eoe({llmConfig:d});(0,W.useEffect)(()=>{e&&(h(f===`llm`&&d?.model?d.model:`stub-model`),_(`endTurn`),y(`assistant`),x(`text`),C(`positive`),T(``),O(`image/png`),M(null))},[e?.id]),(0,W.useEffect)(()=>{f===`llm`&&d?.model&&h(d.model)},[f,d?.model]);let F=async()=>{if(!e||!P){console.log(`[SamplingRequestDisplay] Cannot generate:`,{hasRequest:!!e,isAvailable:P});return}console.log(`[SamplingRequestDisplay] Starting LLM generation:`,{requestId:e.id,llmConfig:d}),A(!0),M(null);try{let t=await N({request:e.request});console.log(`[SamplingRequestDisplay] LLM generation result:`,{result:t,model:t.model,stopReason:t.stopReason,role:t.role,contentIsArray:Array.isArray(t.content),content:t.content}),h(t.model||d?.model||`stub-model`),_(t.stopReason||`endTurn`),y(t.role||`assistant`);let n=Array.isArray(t.content)?t.content[0]:t.content;console.log(`[SamplingRequestDisplay] Setting content:`,{contentType:n.type,hasText:`text`in n,text:`text`in n?n.text:void 0}),n.type===`text`?(x(`text`),C(n.text||``),console.log(`[SamplingRequestDisplay] Set text content:`,n.text)):n.type===`image`&&(x(`image`),T(n.data||``),O(n.mimeType||`image/png`),console.log(`[SamplingRequestDisplay] Set image content`)),console.log(`[SamplingRequestDisplay] Form state after update:`,{model:m,stopReason:g,role:v,contentType:b,textContent:S})}catch(e){console.error(`[SamplingRequestDisplay] LLM generation error:`,e);let t=e instanceof Error?e.message:`Failed to generate response`;M(t),nv.error(`LLM Generation Failed`,{description:t})}finally{A(!1),console.log(`[SamplingRequestDisplay] Generation complete`)}},I=(0,W.useMemo)(()=>{let e={model:m,stopReason:g,role:v,content:{type:b}};return b===`text`?e.content.text=S:b===`image`&&(e.content.data=w,e.content.mimeType=E),e},[m,g,v,b,S,w,E]);return e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:e.serverName}),(0,U.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleString()})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:c,className:`h-8 w-8 p-0`,children:s?(0,U.jsx)(Uf,{className:`h-4 w-4 text-green-600`}):(0,U.jsx)(tp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Copy request`})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:l,className:`h-8 w-8 p-0`,children:(0,U.jsx)(rp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Download request`})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,U.jsx)(xp,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:`Fullscreen`})]}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:i,className:`h-8 w-8 p-0`,children:(0,U.jsx)(nm,{className:`h-4 w-4`})})]})]}),(0,U.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Request`}),(0,U.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,U.jsx)(pA,{data:e.request})})]}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Response`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(yy,{htmlFor:`responseMode-${e.id}`,className:`text-xs text-gray-500 dark:text-gray-400`,children:`Mode:`}),(0,U.jsxs)(kb,{value:f,onValueChange:e=>p(e),children:[(0,U.jsx)(jb,{id:`responseMode-${e.id}`,className:`w-32 h-8 text-xs`,"data-testid":`sampling-response-mode-select`,children:(0,U.jsx)(Ab,{})}),(0,U.jsxs)(Mb,{children:[(0,U.jsx)(Nb,{value:`manual`,"data-testid":`sampling-response-mode-manual`,children:`Manual`}),(0,U.jsx)(Nb,{value:`llm`,"data-testid":`sampling-response-mode-llm`,children:`LLM`})]})]})]})]}),f===`llm`&&(0,U.jsxs)(`div`,{className:`space-y-2 p-3 bg-muted rounded-lg`,children:[P?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(q,{onClick:F,disabled:k,size:`sm`,className:`flex items-center gap-2`,"data-testid":`sampling-generate-llm-button`,children:k?(0,U.jsxs)(`span`,{"data-testid":`sampling-generating`,className:`flex items-center gap-2`,children:[(0,U.jsx)(bp,{className:`h-4 w-4 animate-spin`}),`Generating...`]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Gp,{className:`h-4 w-4`}),`Generate with LLM`]})}),(0,U.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`Using `,d?.provider,` (`,d?.model,`)`]})]}):(0,U.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`LLM not configured. Please configure LLM in the Chat tab.`}),j&&(0,U.jsx)(`div`,{className:`text-xs text-red-600 dark:text-red-400`,"data-testid":`sampling-generation-error`,children:j})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`model-${e.id}`,children:`Model`}),(0,U.jsx)(my,{id:`model-${e.id}`,value:m,onChange:e=>h(e.target.value),placeholder:`stub-model`,disabled:f===`llm`&&k,"data-testid":`sampling-model-input`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`stopReason-${e.id}`,children:`Stop Reason`}),(0,U.jsx)(my,{id:`stopReason-${e.id}`,value:g,onChange:e=>_(e.target.value),placeholder:`endTurn`,disabled:f===`llm`&&k,"data-testid":`sampling-stop-reason-input`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`role-${e.id}`,children:`Role`}),(0,U.jsxs)(kb,{value:v,onValueChange:e=>y(e),disabled:f===`llm`&&k,children:[(0,U.jsx)(jb,{id:`role-${e.id}`,"data-testid":`sampling-role-select`,children:(0,U.jsx)(Ab,{})}),(0,U.jsxs)(Mb,{children:[(0,U.jsx)(Nb,{value:`assistant`,children:`assistant`}),(0,U.jsx)(Nb,{value:`user`,children:`user`})]})]})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`contentType-${e.id}`,children:`Content Type`}),(0,U.jsxs)(kb,{value:b,onValueChange:e=>x(e),disabled:f===`llm`&&k,children:[(0,U.jsx)(jb,{id:`contentType-${e.id}`,"data-testid":`sampling-content-type-select`,children:(0,U.jsx)(Ab,{})}),(0,U.jsxs)(Mb,{children:[(0,U.jsx)(Nb,{value:`text`,children:`text`}),(0,U.jsx)(Nb,{value:`image`,children:`image`})]})]})]}),b===`text`&&(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`text-${e.id}`,children:`Text Content`}),(0,U.jsx)(JH,{id:`text-${e.id}`,value:S,onChange:e=>C(e.target.value),placeholder:`Enter response text...`,rows:6,disabled:f===`llm`&&k,"data-testid":`sampling-text-content`})]}),b===`image`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`imageData-${e.id}`,children:`Base64 Image Data`}),(0,U.jsx)(JH,{id:`imageData-${e.id}`,value:w,onChange:e=>T(e.target.value),placeholder:`Base64 encoded image data...`,rows:4,disabled:f===`llm`&&k})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(yy,{htmlFor:`mimeType-${e.id}`,children:`MIME Type`}),(0,U.jsx)(my,{id:`mimeType-${e.id}`,value:E,onChange:e=>O(e.target.value),placeholder:`image/png`,disabled:f===`llm`&&k})]})]})]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,U.jsx)(q,{onClick:()=>{if(!e)return;let r=D.safeParse(I);if(!r.success){nv.error(`Invalid response`,{description:`Validation failed: ${r.error.message}`});return}t(e.id,r.data),i(),z(()=>import(`./react-ikqD3Yuv.js`).then(e=>n(e.default,1)).then(t=>{let n=nv(t.createElement(`div`,{className:`space-y-3`},t.createElement(`div`,null,t.createElement(`strong`,null,`Sampling Response Sent`),t.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),t.createElement(`div`,{className:`flex gap-2`},t.createElement(`button`,{"data-testid":`sampling-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let t=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:e.toolName}});window.dispatchEvent(t),nv.dismiss(n)}},`View Tool Result`))),{duration:5e3})}),[])},className:`flex-1`,disabled:f===`llm`&&k,"data-testid":`sampling-approve-button`,children:`Approve`}),(0,U.jsx)(q,{onClick:()=>{e&&(r(e.id,`User rejected sampling request`),i())},variant:`outline`,className:`flex-1`,disabled:f===`llm`&&k,"data-testid":`sampling-reject-button`,children:`Reject`})]})]}):(0,U.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a sampling request to view details`})})}var noe={model:`stub-model`,stopReason:`endTurn`,role:`assistant`,content:{type:`text`,text:`positive`}};function roe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:i}){return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:`Sampling Request Received`}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:[`New request from `,t]})]}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`button`,{"data-testid":`sampling-toast-view-details`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),n()},children:`View Details`}),(0,U.jsx)(`button`,{"data-testid":`sampling-toast-approve`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),r(noe)},children:`Approve`}),(0,U.jsx)(`button`,{"data-testid":`sampling-toast-deny`,className:`px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground`,onClick:e=>{e.stopPropagation(),i()},children:`Deny`})]})]})}function ioe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:i,mcpServerUrl:a}){let{selectedSamplingRequestId:o,setSelectedSamplingRequestId:s}=jB(),{llmConfig:c}=p5({mcpServerUrl:a}),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(-1),[h,g]=(0,W.useState)(!0),[_,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(!0),[x,S]=(0,W.useState)(!1),C=(0,W.useRef)(null),w=(0,W.useRef)(null),T=(0,W.useRef)(null),E=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(console.log(`[SamplingTab] Auto-selection check:`,{selectedSamplingRequestId:o,pendingRequestsCount:e.length,currentSelectedId:l?.id}),o&&e.length>0){let t=e.find(e=>e.id===o);console.log(`[SamplingTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[SamplingTab] Auto-selecting request:`,t.id),s(null),u(t),setTimeout(()=>{let e=document.getElementById(`sampling-request-${t.id}`);console.log(`[SamplingTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[o,e,s]),(0,W.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[SamplingTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[SamplingTab] Selecting request from event:`,n),u(r),setTimeout(()=>{let e=document.getElementById(`sampling-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-sampling`,t),()=>window.removeEventListener(`navigate-to-sampling`,t)},[e]),(0,W.useEffect)(()=>{h&&e.length>0&&C.current&&!E.current&&(C.current.scrollTop=0)},[e.length,h]),(0,W.useEffect)(()=>{let e=C.current;if(!e)return;let t=()=>{e.scrollTop>0&&(E.current=!0,g(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,W.useEffect)(()=>{e.length===0&&(E.current=!1,g(!0))},[e.length]),(0,W.useEffect)(()=>{_&&T.current&&T.current.focus()},[_]);let D=(0,W.useCallback)(()=>{d.trim()||v(!1)},[d]),O=(0,W.useMemo)(()=>{if(!d.trim())return e;let t=d.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,d]);(0,W.useEffect)(()=>{m(-1)},[d]),(0,W.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=O;if(e.key===`ArrowDown`)e.preventDefault(),m(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),m(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&p>=0){e.preventDefault();let t=O[p];t&&k(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[p,O]),(0,W.useEffect)(()=>{if(p>=0){let e=`sampling-request-${O[p]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[p,O]);let k=(0,W.useCallback)(e=>{u(e)},[]),A=(0,W.useCallback)(()=>{window.confirm(`Are you sure you want to reject all sampling requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User rejected all requests`)}),u(null))},[e,n]),j=(0,W.useCallback)(async()=>{if(l)try{await ih(JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){console.error(`[SamplingTab] Failed to copy request:`,e)}},[l]),M=(0,W.useCallback)(()=>{if(l)try{let e=new globalThis.Blob([JSON.stringify({id:l.id,serverName:l.serverName,timestamp:l.timestamp,request:l.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[SamplingTab] Failed to download request:`,e)}},[l]),N=(0,W.useCallback)(async()=>{if(w.current)try{document.fullscreenElement?await document.exitFullscreen():await w.current.requestFullscreen()}catch(e){console.error(`[SamplingTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,U.jsxs)(T7,{orientation:`horizontal`,className:`h-full`,children:[(0,U.jsx)(E7,{defaultSize:40,minSize:30,children:(0,U.jsx)(T7,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,U.jsxs)(E7,{defaultSize:75,minSize:30,children:[(0,U.jsx)(Qae,{isSearchExpanded:_,searchQuery:d,filteredRequestsCount:O.length,requestsCount:e.length,onSearchExpand:()=>v(!0),onSearchChange:f,onSearchBlur:D,onRejectAll:A,searchInputRef:T}),(0,U.jsx)(`div`,{className:`flex flex-col h-full`,children:(0,U.jsx)($ae,{requests:O,selectedRequest:l,onRequestSelect:k,focusedIndex:p,formatRelativeTime:j7,listRef:C})})]})})}),(0,U.jsx)(D7,{}),(0,U.jsx)(E7,{defaultSize:60,minSize:40,children:(0,U.jsx)(`div`,{ref:w,className:`h-full bg-white dark:bg-zinc-900`,children:(0,U.jsx)(toe,{request:l,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:y,onTogglePreview:()=>b(!y),isCopied:x,onCopy:j,onDownload:M,onFullscreen:N,llmConfig:c})})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(hp,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}function q7({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:r,focusedIndex:i}){if(e.length===0)return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(np,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`No saved requests yet`}),(0,U.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Execute a tool and click Save to store requests`})]});let a=(e,t)=>{e.stopPropagation(),t()};return(0,U.jsx)(`div`,{className:`overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain`,children:e.map((e,o)=>(0,U.jsxs)(`div`,{className:`relative group`,children:[(0,U.jsx)(k7,{id:`saved-${e.id}`,isSelected:t?.id===e.id,isFocused:i===o,icon:(0,U.jsx)(gp,{className:`h-4 w-4`}),title:e.name,description:e.toolName,metadata:(0,U.jsx)(`div`,{className:`flex flex-col gap-1`,children:(0,U.jsx)(`span`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:new Date(e.savedAt).toLocaleString()})}),onClick:()=>n(e)}),(0,U.jsx)(`div`,{className:`absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10`,children:(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(q,{variant:`secondary`,size:`sm`,onClick:t=>a(t,()=>r(e.id)),className:`h-8 w-8 p-0`,children:(0,U.jsx)($p,{className:`h-4 w-4`})})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`Delete saved request`})})]})})]},e.id))})}function J7({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:r,onSave:i,onCancel:a}){return e?(0,U.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:a,children:(0,U.jsxs)(`div`,{className:`bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(`h3`,{className:`text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100`,children:`Save Request`}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(yy,{htmlFor:`request-name`,children:`Request Name (optional)`}),(0,U.jsx)(my,{id:`request-name`,value:t,onChange:e=>r(e.target.value),placeholder:n,className:`mt-2`,onKeyDown:e=>{e.key===`Enter`&&i()},autoFocus:!0})]}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(q,{variant:`outline`,onClick:a,children:`Cancel`}),(0,U.jsxs)(q,{onClick:i,children:[(0,U.jsx)(Ip,{className:`h-4 w-4 mr-2`}),`Save`]})]})]})]})}):null}function Y7(e,t){if(!e?.$ref)return e;let n=e.$ref;if(!n.startsWith(`#/`))return e;let r=n.substring(2).split(`/`),i=t;for(let t of r)if(i&&typeof i==`object`&&t in i)i=i[t];else return e;return i}function aoe(e,t){if(e?.anyOf&&Array.isArray(e.anyOf)){let n=e.anyOf.find(e=>Y7(e,t)?.type!==`null`);if(n)return{...Y7(n,t),nullable:!0}}return e}function X7(e,t){let n=aoe(e||{},t);return n=Y7(n,t),n}function Z7(e,t){let n=X7(e,t);if(typeof n.type==`string`)return n.type;if(Array.isArray(n.type)){let e=n.type.find(e=>e!==`null`);return typeof e==`string`?e:void 0}}function ooe(e){let t=e?.enum;return Array.isArray(t)&&t.every(e=>typeof e==`string`)?t:null}function Q7(e){let t=e.trim().toLowerCase();return[`true`,`1`,`yes`,`on`].includes(t)?!0:[`false`,`0`,`no`,`off`].includes(t)?!1:e}function soe(e,t){if(t===`number`||t===`integer`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return t===`boolean`?Q7(e):e}function coe(e,t){if(e===void 0)return e;if(t===`object`||t===`array`){if(typeof e==`string`)try{return JSON.parse(e)}catch{return e}return e}if(t===`number`||t===`integer`){if(typeof e==`number`)return e;if(typeof e==`string`){let t=e.trim();if(!t)return e;let n=Number(t);return Number.isFinite(n)?n:e}return e}return t===`boolean`?typeof e==`boolean`?e:typeof e==`string`?Q7(e):e:e}function $7(e){let t=``,n=0,r=!1,i=!1;for(;n<e.length;){let a=e[n];if(i){t+=a,i=!1,n++;continue}if(a===`\\`){i=!0,t+=a,n++;continue}if(a==="`"){r?(t+=`"`,r=!1):(t+=`"`,r=!0),n++;continue}if(r&&a===`"`){t+=`\\"`,n++;continue}t+=a,n++}return t}function loe(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t.startsWith(`{`))return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}catch{try{let e=$7(t),n=JSON.parse(e);if(n&&typeof n==`object`&&!Array.isArray(n))return n}catch{return null}}return null}function uoe({selectedTool:e,toolArgs:t,onArgChange:n,onBulkPaste:r,autoFilledFields:i,setFields:a,sendEmptyFields:o,onToggleEmpty:s}){let c=e?.inputSchema?.properties||{},l=e?.inputSchema?.required||[],u=Object.keys(c).length>0,d=async(e,t)=>{r&&await r(e.clipboardData.getData(`text`),t)&&e.preventDefault()};return u?(0,U.jsx)(`div`,{className:`space-y-4`,children:Object.entries(c).map(([r,c])=>{let u=X7(c,e?.inputSchema||{}),f=ooe(u),p=u.type===`string`&&f!==null,m=u;m.required=l.includes(r);let h=t[r],g=``;h!=null&&(g=typeof h==`string`?h:typeof h==`object`&&h?JSON.stringify(h,null,2):String(h));let _=m.type===`object`||m.type===`array`,v=_?m.type===`array`?`array`:`object`:`string`,y=a?.has(r)??!0,b=s&&(m.type===`string`||_);return _?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,m?.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),b&&s&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:v===`array`?`Send empty array explicitly`:`Send empty object explicitly`}),(0,U.jsx)(Hb,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,v,e),"aria-label":v===`array`?`Send empty array`:`Send empty object`,title:v===`array`?`Send empty array []`:`Send empty object {}`})]})]}),(0,U.jsx)(JH,{id:r,"data-testid":`tool-param-${r}`,value:g,onChange:e=>n(r,e.target.value),onPaste:e=>d(e,r),placeholder:m?.description||`Enter ${r}`,disabled:o?.has(r)??!1,className:`min-h-[100px] ${y?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`}),m?.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r):p&&f?(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,m.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),(0,U.jsxs)(kb,{value:String(t[r]||``),onValueChange:e=>n(r,e),children:[(0,U.jsx)(jb,{id:r,className:`w-full ${y?``:`opacity-70`}`,"data-testid":`tool-param-${r}`,children:(0,U.jsx)(Ab,{placeholder:m.description||`Select an option`})}),(0,U.jsx)(Mb,{children:f.map((e,t)=>(0,U.jsx)(Nb,{value:e,children:m.enumNames?.[t]||e},e))})]}),m.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r):(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(yy,{htmlFor:r,className:`text-sm font-medium`,children:[r,m?.required&&(0,U.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),b&&s&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`Send empty string`}),(0,U.jsx)(Hb,{checked:o?.has(r)??!1,onCheckedChange:e=>s(r,`string`,e),"aria-label":`Send empty string`,title:`Send empty string`})]})]}),(0,U.jsx)(my,{id:r,"data-testid":`tool-param-${r}`,value:g,onChange:e=>n(r,e.target.value),onPaste:e=>d(e,r),placeholder:m?.description||`Enter ${r}`,disabled:o?.has(r)??!1,className:`${y?``:`opacity-70`} ${i?.has(r)?`animate-pulse ring-2 ring-green-500 dark:ring-green-400`:``}`}),m?.description&&(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:m.description})]},r)})}):(0,U.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No parameters required`})}function e9({selectedTool:e,toolArgs:t,payloadToSend:n,isExecuting:r,isConnected:i,onArgChange:a,onExecute:o,onSave:s,onCancel:c,onBulkPaste:l,autoFilledFields:u,setFields:d,sendEmptyFields:f,onToggleEmpty:p}){let[m,h]=(0,W.useState)(!1),[g,_]=(0,W.useState)(!1),[v,y]=(0,W.useState)(!1),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(!1),E=(0,W.useRef)(null);return(0,W.useEffect)(()=>{if(E.current&&e?.description){let e=E.current,t=parseFloat(getComputedStyle(e).lineHeight),n=e.scrollHeight;T(Math.round(n/t)>3),C(!1)}},[e?.description]),(0,W.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!r&&i&&(t.preventDefault(),o()),t.key===`Escape`&&r&&c&&(t.preventDefault(),c())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r,i,o,c]),e?(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsx)(`div`,{className:`shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4`,children:(0,U.jsx)(`div`,{children:(0,U.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,U.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,"data-testid":`tool-execution-title`,children:e.name}),(0,U.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsxs)(q,{"data-testid":`tool-execution-metadata-button`,variant:g?`default`:`outline`,onClick:()=>_(!g),disabled:r,size:`sm`,className:`lg:size-default gap-2`,title:`View tool metadata`,children:[(0,U.jsx)(Qf,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Metadata`})]})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`View tool definition metadata`})})]}),(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsxs)(q,{"data-testid":`tool-execution-copy-payload-button`,variant:`outline`,onClick:async()=>{if(e)try{await ih(JSON.stringify(n??t,null,2)),x(!0),setTimeout(()=>x(!1),2e3)}catch{}},disabled:r,size:`sm`,className:`lg:size-default gap-2`,title:`Copy payload as JSON`,children:[b?(0,U.jsx)(Uf,{className:`h-4 w-4 text-green-600`}):(0,U.jsx)(tp,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:b?`Copied!`:`Payload`})]})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`Copy payload as JSON`})})]}),(0,U.jsxs)(q,{"data-testid":`tool-execution-save-button`,variant:`outline`,onClick:s,disabled:r,size:`sm`,className:`lg:size-default gap-2`,children:[(0,U.jsx)(Ip,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]}),r&&c?(0,U.jsxs)(uf,{open:m?void 0:!1,children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(`div`,{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),className:`relative`,children:(0,U.jsx)(q,{"data-testid":`tool-execution-cancel-button`,onClick:c,variant:m?`destructive`:`default`,size:`sm`,className:`lg:size-default gap-2 transition-all`,children:m?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(nm,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Cancel`}),(0,U.jsx)(`span`,{className:`hidden sm:inline text-[12px] border border-current p-1 rounded-full ml-2`,children:`Esc`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TB,{className:`mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]})})})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`Hover to cancel (or press Esc)`})})]}):(0,U.jsx)(q,{"data-testid":`tool-execution-execute-button`,onClick:o,disabled:r||!i,size:`sm`,className:`lg:size-default pr-1! gap-0`,children:r?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(TB,{className:`mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(jp,{className:`h-4 w-4 sm:mr-2`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,U.jsx)(`span`,{className:`hidden sm:inline text-[12px] border text-zinc-300 p-1 rounded-full border-zinc-300 dark:text-zinc-600 dark:border-zinc-500 ml-2`,children:`⌘↵`})]})})]})]})})}),(0,U.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3`,children:[e.description&&(0,U.jsxs)(`div`,{className:`relative mb-4`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`p`,{ref:E,"data-testid":`tool-execution-description`,className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!S&&w?`line-clamp-3`:``}`,children:e.description}),w&&!S&&(0,U.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none`})]}),w&&(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(`button`,{onClick:()=>C(!S),className:`relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors`,children:S?(0,U.jsxs)(U.Fragment,{children:[`Show less`,(0,U.jsx)(qf,{className:`h-3 w-3`})]}):(0,U.jsxs)(U.Fragment,{children:[`Show more`,(0,U.jsx)(Wf,{className:`h-3 w-3`})]})})})]}),(0,U.jsx)(uoe,{selectedTool:e,toolArgs:t,onArgChange:a,onBulkPaste:l,autoFilledFields:u,setFields:d,sendEmptyFields:f,onToggleEmpty:p})]}),(0,U.jsx)(ay,{open:g,onOpenChange:_,children:(0,U.jsxs)(ly,{className:`max-w-3xl max-h-[80vh] overflow-y-auto`,children:[(0,U.jsx)(uy,{children:(0,U.jsxs)(fy,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`span`,{children:`Tool Definition`}),(0,U.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{if(e)try{await ih(JSON.stringify(e,null,2)),y(!0),setTimeout(()=>y(!1),2e3)}catch{}},className:`h-7 w-7 p-0`,title:`Copy metadata`,children:v?(0,U.jsx)(Uf,{className:`h-3.5 w-3.5 text-green-600`}):(0,U.jsx)(tp,{className:`h-3.5 w-3.5`})})]})}),(0,U.jsx)(pA,{data:e,filename:`tool-definition-${e.name}-${Date.now()}.json`})]})})]}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a tool to get started`}),(0,U.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a tool from the list to view its details and execute it`})]})}function doe({timestamp:e}){let[t,n]=(0,W.useState)(()=>t9(e));return(0,W.useEffect)(()=>{let t=()=>n(t9(e));t();let r=setInterval(t,1e3);return()=>clearInterval(r)},[e]),(0,U.jsx)(`span`,{children:t})}function t9(e){let t=Date.now()-e,n=Math.floor(t/1e3),r=Math.floor(n/60),i=Math.floor(r/60),a=Math.floor(i/24);return n<10?`now`:n<60?`${n}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${a}d ago`}function n9(e){if(!e?.isError)return null;let t=e.content;if(Array.isArray(t)){let e=t.filter(e=>e.type===`text`).map(e=>e.text).filter(Boolean);if(e.length>0)return e.join(`
699
699
  `)}return`An error occurred`}function foe(e){try{return JSON.parse(e),!0}catch{return!1}}function poe({content:e}){let[t,n]=(0,W.useState)(new Set),r=(0,W.useCallback)(e=>{n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return!Array.isArray(e)||e.length===0?(0,U.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No content`}):(0,U.jsx)(`div`,{className:`space-y-4`,children:e.map((e,n)=>{if(e.type===`text`){let i=e.text||``,a=t.has(n),o=foe(i),s=o?(()=>{try{return JSON.parse(i)}catch{return null}})():null;return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:[`Text Content`,a?` (formatted)`:``]}),o&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(n),className:`text-xs text-blue-600 dark:text-blue-400 hover:underline`,"data-testid":`tool-result-format-toggle-${n}`,children:a?`Show as text`:`Try to format`})]}),a&&s!==null?(0,U.jsx)(pA,{data:s,filename:`content-${n}.json`}):(0,U.jsx)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words`,"data-testid":`tool-execution-results-text-content`,children:i})]},n)}if(e.type===`image`)return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Image Content`}),(0,U.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3`,children:[(0,U.jsx)(`img`,{src:`data:${e.mimeType||`image/png`};base64,${e.data}`,alt:`Result`,className:`max-w-full rounded`,"data-testid":`tool-execution-results-image-content`}),e.annotations&&(0,U.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:(0,U.jsx)(pA,{data:e.annotations,filename:`image-annotations-${n}.json`,"data-testid":`tool-execution-results-image-annotations`})})]})]},n);if(e.type===`audio`)return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Audio Content`}),(0,U.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3`,children:[(0,U.jsx)(`audio`,{controls:!0,src:`data:${e.mimeType||`audio/wav`};base64,${e.data}`,className:`w-full`,"data-testid":`tool-execution-results-audio-content`}),e.annotations&&(0,U.jsx)(`div`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:(0,U.jsx)(pA,{data:e.annotations,filename:`audio-annotations-${n}.json`,"data-testid":`tool-execution-results-audio-annotations`})})]})]},n);if(e.type===`resource_link`)return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Resource Link`}),(0,U.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2`,children:[(0,U.jsxs)(`div`,{className:`font-mono text-sm break-all`,children:[(0,U.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`URI:`}),` `,e.uri]}),e.name&&(0,U.jsxs)(`div`,{className:`text-sm`,children:[(0,U.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`Name:`}),` `,e.name]}),e.description&&(0,U.jsxs)(`div`,{className:`text-sm`,children:[(0,U.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`Description:`}),` `,e.description]}),e.mimeType&&(0,U.jsxs)(`div`,{className:`text-sm`,children:[(0,U.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`MIME Type:`}),` `,e.mimeType]}),e.annotations&&(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Annotations:`}),(0,U.jsx)(pA,{data:e.annotations,filename:`resource-link-annotations-${n}.json`,"data-testid":`tool-execution-results-resource-link-annotations`})]})]})]},n);if(e.type===`resource`){let t=e.resource||{};return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Embedded Resource`}),(0,U.jsxs)(`div`,{className:`bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2`,children:[(0,U.jsxs)(`div`,{className:`font-mono text-sm break-all`,"data-testid":`tool-execution-results-resource-uri`,children:[(0,U.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:`URI:`}),` `,t.uri]}),t.mimeType&&(0,U.jsxs)(`div`,{className:`text-sm`,children:[(0,U.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,"data-testid":`tool-execution-results-mime-type`,children:`MIME Type:`}),` `,t.mimeType]}),t.text&&(0,U.jsxs)(`div`,{"data-testid":`tool-execution-results-resource-text-content`,children:[(0,U.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Content:`}),(0,U.jsx)(`div`,{className:`bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto`,children:t.text})]}),t.blob&&(0,U.jsxs)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[`[Binary content: `,t.blob.length||0,` bytes]`]}),t.annotations&&(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:`Annotations:`}),(0,U.jsx)(pA,{data:t.annotations,filename:`resource-annotations-${n}.json`,"data-testid":`tool-execution-results-resource-annotations`})]})]})]},n)}return(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:[`Unknown Content Type: `,e.type||`N/A`]}),(0,U.jsx)(pA,{data:e,filename:`content-${n}.json`,"data-testid":`tool-execution-results-unknown-content`})]},n)})})}function r9({results:e,copiedResult:t,serverId:n,readResource:r,onCopy:i,onMaximize:a,isMaximized:o=!1,onRerunTool:s}){let[c,l]=(0,W.useState)(0),[u,d]=(0,W.useState)(!0),[f,p]=(0,W.useState)(null),[m,h]=(0,W.useState)(`inline`),[g,_]=(0,W.useState)(null),v=(0,W.useRef)(!1),y=e[0],b=y?e.filter(e=>e.toolName===y.toolName):[],x=b[c]||b[0],S=e.findIndex(e=>e===x),C=(x?x.error||n9(x.result):null)??(x==null?``:JSON.stringify(x.result,null,2));(0,W.useEffect)(()=>{b.length>0&&c>=b.length&&l(0)},[b.length,c]),(0,W.useEffect)(()=>{v.current=!1,p(null)},[y?.toolName]);let w=(0,W.useMemo)(()=>x?.args,[x?.timestamp,c]),T=(0,W.useMemo)(()=>x?.result,[x?.timestamp,x?.duration,c]),E=(0,W.useCallback)(e=>r(e),[r]),D=(0,W.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
700
700
  `),n=e.filter(e=>e.type===`image`).length,r=e.filter(e=>e.type===`resource`).length,i=[n>0&&`${n} image${n>1?`s`:``}`,r>0&&`${r} resource${r>1?`s`:``}`].filter(Boolean).join(`, `);nv.info(`Widget follow-up`,{description:[t,i].filter(Boolean).join(` — `),duration:5e3})},[]),{playground:O}=DK(),k=(0,W.useMemo)(()=>x?AK(x.toolMeta,x.result):null,[x]),A=(0,W.useMemo)(()=>x?kK(x.toolMeta):!1,[x]),j=(0,W.useMemo)(()=>k?k===`both`?O.selectedProtocol?O.selectedProtocol:`mcp-apps`:k:null,[k,O.selectedProtocol]),M=(0,W.useMemo)(()=>x?A?MK(`mcp-apps`,x.toolMeta):x.toolMeta?.ui?.resourceUri:null,[x,A]),N=(0,W.useMemo)(()=>(j===`mcp-apps`||A)&&!!M,[j,A,M]),P=(0,W.useMemo)(()=>x?A?MK(`chatgpt-app`,x.toolMeta):x.toolMeta?.[`openai/outputTemplate`]:null,[x,A]),F=(0,W.useMemo)(()=>!!((j===`chatgpt-app`||A)&&P&&typeof P==`string`&&x?.appsSdkResource),[j,A,P,x]),I=P,L=(0,W.useMemo)(()=>x?.result?.content||[],[x]),R=(0,W.useMemo)(()=>L.filter(e=>e.type===`resource`&&V7(e.resource)),[L]),z=R.length>0,B=(0,W.useMemo)(()=>I||M||R[0]?.resource?.uri||null,[I,M,R]),V=(0,W.useMemo)(()=>!!(L&&L.length>0||x?.result?.structuredContent),[L,x]),ee=(0,W.useMemo)(()=>!N&&!z&&!F&&V,[N,z,F,V]),te=(0,W.useMemo)(()=>{let e=[];return(N||A&&M)&&e.push({mode:`mcp-apps`,label:`Component (MCP Apps)`}),(F||A&&P)&&e.push({mode:`chatgpt-app`,label:`Component (Apps SDK)`}),z&&e.push({mode:`mcp-ui`,label:`Component (MCP-UI)`}),e.push({mode:`json`,label:`Raw JSON`}),e},[F,N,z,A,P,M]);return(0,W.useEffect)(()=>{if(te.length===0)return;let e=f&&te.some(e=>e.mode===f),t=te.find(e=>e.mode!==`json`);if(t){let n=v.current;if(v.current=!0,!f||!e||f===`json`&&!n){p(t.mode);return}}else (!f||!e)&&p(`json`)},[te,f]),e.length===0?(0,U.jsx)(`div`,{className:`flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,U.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,U.jsx)(`div`,{className:`text-center`,children:(0,U.jsx)(Iu,{vertical:!0,noBorder:!0,message:`No Results yet`})})})})}):(0,U.jsxs)(`div`,{className:`relative flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700`,children:[(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto h-full`,children:(0,U.jsxs)(`div`,{className:`space-y-0 flex flex-col flex-1 h-full`,children:[(0,U.jsxs)(`div`,{className:`sticky top-0 z-40 flex items-center gap-2 px-4 pt-2 backdrop-blur-xs bg-white/50 dark:bg-black/50 ${N||z||F||ee?`border-b border-gray-200 dark:border-zinc-600 pb-2`:``}`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-medium hidden sm:block`,children:`Response`}),x.duration!==void 0&&(0,U.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1`,children:[(0,U.jsx)(rm,{className:`h-3 w-3 text-gray-400`}),(0,U.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[x.duration,`ms`]})]}),(F||N||z)&&(0,U.jsx)(`div`,{className:`flex items-center gap-4 sm:ml-4`,children:(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:te.map((e,t)=>(0,U.jsxs)(W.Fragment,{children:[t>0&&(0,U.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,U.jsx)(`button`,{"data-testid":`tool-result-view-${e.mode}`,onClick:()=>p(e.mode),className:`text-xs font-medium ${f===e.mode?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:e.label})]},e.mode))})}),ee&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 sm:ml-4`,children:[(0,U.jsx)(`button`,{onClick:()=>d(!0),className:`text-xs font-medium ${u?`text-black dark:text-white`:`text-zinc-500 dark:text-zinc-400`}`,children:`Formatted`}),(0,U.jsx)(`span`,{className:`text-xs text-zinc-400`,children:`|`}),(0,U.jsx)(`button`,{onClick:()=>d(!1),className:`text-xs font-medium ${u?`text-zinc-500 dark:text-zinc-400`:`text-black dark:text-white`}`,children:`Raw`})]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[o&&s&&(0,U.jsxs)(q,{"data-testid":`tool-result-rerun`,variant:`ghost`,size:`sm`,onClick:s,title:`Re-run with same arguments`,children:[(0,U.jsx)(jp,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline ml-1`,children:`Re-run`})]}),(N||F||z)&&a&&(0,U.jsx)(q,{"data-testid":`tool-result-maximize`,variant:`ghost`,size:`sm`,onClick:a,title:o?`Restore`:`Maximize`,children:o?(0,U.jsx)(Tp,{className:`h-4 w-4`}):(0,U.jsx)(Sp,{className:`h-4 w-4`})}),b.length>1&&(0,U.jsxs)(kb,{value:c.toString(),onValueChange:e=>l(parseInt(e)),children:[(0,U.jsx)(jb,{size:`sm`,className:`w-[140px] h-8 text-xs`,children:(0,U.jsx)(Ab,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(gp,{className:`h-3 w-3`}),(0,U.jsx)(doe,{timestamp:x.timestamp})]})})}),(0,U.jsx)(Mb,{children:b.map((e,t)=>(0,U.jsx)(Nb,{value:t.toString(),children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(gp,{className:`h-3 w-3`}),(0,U.jsx)(`span`,{children:t9(e.timestamp)}),(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,new Date(e.timestamp).toLocaleTimeString(),`)`]})]})},t))})]}),(0,U.jsx)(q,{"data-testid":`tool-result-copy-${S}`,variant:`ghost`,size:`sm`,onClick:()=>i(S,C),children:t===S?(0,U.jsx)(Uf,{className:`h-4 w-4`}):(0,U.jsx)(tp,{className:`h-4 w-4`})})]})]}),(()=>{let e=x.error||n9(x.result);return e?(0,U.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4`,children:[(0,U.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Error:`}),(0,U.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:e})]}):(()=>{if(!f)return(0,U.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px]`,children:(0,U.jsx)(TB,{className:`size-5`})});switch(f){case`chatgpt-app`:{if(!F||!x.appsSdkResource)return(0,U.jsx)(`div`,{className:`px-4 pt-4`,children:(0,U.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`Apps SDK resource not available`})})});let e=x.appsSdkResource;return e.isLoading?(0,U.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px]`,children:(0,U.jsx)(TB,{className:`size-5`})}):e.error?(0,U.jsxs)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4`,children:[(0,U.jsx)(`p`,{className:`text-red-800 dark:text-red-300 font-medium`,children:`Resource Error:`}),(0,U.jsx)(`p`,{className:`text-red-700 dark:text-red-400 text-sm`,children:e.error})]}):(0,U.jsx)(`div`,{className:`flex-1`,children:(0,U.jsx)(c5,{componentUrl:e.uri,toolName:x.toolName,toolArgs:w,toolResult:T,serverId:n,readResource:E,className:`w-full h-full relative p-4`,invoking:x.toolMeta?.[`openai/toolInvocation/invoking`],invoked:x.toolMeta?.[`openai/toolInvocation/invoked`]},`openai-${x.timestamp}`)})}case`mcp-apps`:return!N||!M?(0,U.jsx)(`div`,{className:`px-4 pt-4`,children:(0,U.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`MCP Apps resource not available`})})}):(0,U.jsxs)(`div`,{className:`flex-1 relative`,children:[(0,U.jsx)(`div`,{className:`absolute top-2 right-2 z-30 flex items-center gap-2`,children:(0,U.jsx)(o5,{toolCallId:`tool-${x.timestamp}`,displayMode:m,onDisplayModeChange:h,propsContext:`tool`,resourceUri:M,toolInput:x.args,resourceAnnotations:x.toolMeta,llmConfig:null,resource:null,onPropsChange:_})}),(0,U.jsx)(J8,{serverId:n,invoking:x.toolMeta?.[`openai/toolInvocation/invoking`],invoked:x.toolMeta?.[`openai/toolInvocation/invoked`],toolCallId:`tool-${x.timestamp}`,toolName:x.toolName,toolInput:w,toolOutput:T,toolMetadata:x.toolMeta,resourceUri:M,readResource:E,className:`w-full h-full relative p-4`,customProps:g||void 0,displayMode:m,onDisplayModeChange:h,onSendFollowUp:D,onRerun:s},`mcp-apps-${x.timestamp}`)]});case`mcp-ui`:return z?(0,U.jsxs)(`div`,{className:`space-y-0 h-full`,children:[R.map((e,t)=>(0,U.jsx)(`div`,{className:`mx-0 size-full`,children:(0,U.jsx)(H7,{resource:e.resource,onUIAction:e=>{},className:`w-full h-full relative`})},t)),L.filter(e=>!(e.type===`resource`&&V7(e.resource))).length>0&&(0,U.jsx)(`div`,{className:`px-4`,children:(0,U.jsx)(pA,{data:L.filter(e=>!(e.type===`resource`&&V7(e.resource))),filename:`tool-result-${x.toolName}-non-ui-${Date.now()}.json`})})]}):(0,U.jsx)(`div`,{className:`px-4 pt-4`,children:(0,U.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3`,children:(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`MCP-UI resource not available`})})});case`json`:if(ee&&u){let e=x.result?.structuredContent;return(0,U.jsxs)(`div`,{className:`px-4 pt-4 space-y-4`,"data-testid":`tool-execution-results-content`,children:[e&&(0,U.jsxs)(`div`,{className:`space-y-2`,"data-testid":`tool-execution-results-structured-content`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400`,children:`Structured Content`}),(0,U.jsx)(pA,{data:e,filename:`structured-content-${x.toolName}-${Date.now()}.json`})]}),L&&L.length>0&&(0,U.jsx)(poe,{content:L}),!e&&(!L||L.length===0)&&(0,U.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,"data-testid":`tool-execution-results-no-content`,children:`No content to display`})]})}return(0,U.jsx)(`div`,{className:`px-4 pt-4`,children:(0,U.jsx)(pA,{data:x.result,filename:`tool-result-${x.toolName}-${Date.now()}.json`})});default:return null}})()})()]})}),B&&(f===`chatgpt-app`||f===`mcp-apps`||f===`mcp-ui`)&&(0,U.jsx)(`div`,{className:`absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none`,children:(0,U.jsx)(`span`,{className:`text-[11px] bg-gray-200 dark:bg-zinc-800 text-gray-500 dark:text-gray-400 px-3 py-0.5 rounded-t-xl font-mono max-w-[320px] truncate block`,children:B})})]})}function i9({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:r}){if(e.length===0)return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,U.jsx)(tm,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,U.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`No tools available`})]});let i=e.some(e=>e.inputSchema?.properties&&Object.keys(e.inputSchema.properties).length>0);return(0,U.jsx)(`div`,{className:`overflow-y-auto flex-1 overscroll-contain`,children:e.map((e,a)=>{let o=e._meta,s=AK(o,void 0),c=e.inputSchema?.properties,l=c?Object.keys(c).length:0,u=i&&l>0&&(0,U.jsxs)(sn,{variant:`outline`,className:`text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400`,children:[l,` params`]}),d=s===`mcp-apps`||s===`chatgpt-app`||s===`both`||u?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(s===`mcp-apps`||s===`both`)&&(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(`span`,{className:`inline-flex`,children:(0,U.jsx)(YV,{className:`h-3.5 w-3.5`})})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`MCP-APP`})})]}),(s===`chatgpt-app`||s===`both`)&&(0,U.jsxs)(uf,{children:[(0,U.jsx)(df,{asChild:!0,children:(0,U.jsx)(`span`,{className:`inline-flex`,children:(0,U.jsx)(XV,{className:`h-3.5 w-3.5`})})}),(0,U.jsx)(ff,{children:(0,U.jsx)(`p`,{children:`Apps SDK`})})]}),u]}):void 0;return(0,U.jsx)(k7,{id:`tool-${e.name}`,"data-testid":`tool-item-${e.name}`,isSelected:t?.name===e.name,isFocused:r===a,icon:(0,U.jsx)(tm,{className:`h-4 w-4`}),title:e.name,description:e.description,metadata:d,onClick:()=>n(e)},e.name)})})}function a9({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredToolsCount:r,savedRequestsCount:i,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d}){return(0,U.jsx)(M7,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:`tools`,secondaryTabName:`saved`,primaryTabTitle:`Tools`,secondaryTabTitle:`Saved`,primaryCount:r,secondaryCount:i,primaryIcon:tm,secondaryIcon:np,searchPlaceholder:`Search tools...`,onSearchExpand:a,onSearchChange:o,onSearchBlur:s,onTabSwitch:c,searchInputRef:l,onRefresh:u,isRefreshing:d})}var o9=`AlertDialog`,[moe,hoe]=dn(o9,[bv]),s9=bv(),c9=e=>{let{__scopeAlertDialog:t,...n}=e,r=s9(t);return(0,U.jsx)(Zv,{...r,...n,modal:!0})};c9.displayName=o9;var goe=`AlertDialogTrigger`,_oe=W.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=s9(n);return(0,U.jsx)(Qv,{...i,...r,ref:t})});_oe.displayName=goe;var voe=`AlertDialogPortal`,l9=e=>{let{__scopeAlertDialog:t,...n}=e,r=s9(t);return(0,U.jsx)($v,{...r,...n})};l9.displayName=voe;var yoe=`AlertDialogOverlay`,u9=W.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=s9(n);return(0,U.jsx)(ey,{...i,...r,ref:t})});u9.displayName=yoe;var d9=`AlertDialogContent`,[boe,xoe]=moe(d9),Soe=Sn(`AlertDialogContent`),f9=W.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...i}=e,a=s9(n),o=W.useRef(null),s=_e(t,o),c=W.useRef(null);return(0,U.jsx)(qv,{contentName:d9,titleName:p9,docsSlug:`alert-dialog`,children:(0,U.jsx)(boe,{scope:n,cancelRef:c,children:(0,U.jsxs)(ty,{role:`alertdialog`,...a,...i,ref:s,onOpenAutoFocus:ln(i.onOpenAutoFocus,e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,U.jsx)(Soe,{children:r}),(0,U.jsx)(woe,{contentRef:o})]})})})});f9.displayName=d9;var p9=`AlertDialogTitle`,m9=W.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=s9(n);return(0,U.jsx)(ny,{...i,...r,ref:t})});m9.displayName=p9;var h9=`AlertDialogDescription`,g9=W.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=s9(n);return(0,U.jsx)(ry,{...i,...r,ref:t})});g9.displayName=h9;var Coe=`AlertDialogAction`,_9=W.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=s9(n);return(0,U.jsx)(iy,{...i,...r,ref:t})});_9.displayName=Coe;var v9=`AlertDialogCancel`,y9=W.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=xoe(v9,n),a=s9(n),o=_e(t,i);return(0,U.jsx)(iy,{...a,...r,ref:o})});y9.displayName=v9;var woe=({contentRef:e})=>{let t=`\`${d9}\` requires a description for the component to be accessible for screen reader users.
701
701