@mcp-use/inspector 0.14.2-canary.2 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/{browser-DQo0fId8.js → browser-BLnflEDD.js} +3 -3
- package/dist/web/assets/{client-BbJjBc4j.js → client-D72CJBab.js} +1 -1
- package/dist/web/assets/{display-A5IEINAP-DqrQsAul.js → display-A5IEINAP-DWRfr5cj.js} +2 -2
- package/dist/web/assets/{embeddings-BIlnjV4N.js → embeddings-CVWvogFr.js} +1 -1
- package/dist/web/assets/{index-CtIyN4y7.js → index-BDlTOMS5.js} +1 -1
- package/dist/web/assets/{index-BGIedjx0.js → index-BgQZjv_u.js} +1 -1
- package/dist/web/assets/{index-5cZBoeuY.js → index-Bi42MNIH.js} +6 -6
- package/dist/web/assets/{index-Bjv2gAs_.js → index-CbPoLZEh.js} +1 -1
- package/dist/web/assets/{index-CNAwsRc_.js → index-Cv4xpdR-.js} +1 -1
- package/dist/web/assets/{index-Cpg-k5c6.js → index-D7_719w8.js} +1 -1
- package/dist/web/assets/{index-Bey-QuvV.js → index-DdkxcTE2.js} +1 -1
- package/dist/web/assets/{index-sxfbjETB.js → index-DdrkmeYH.js} +1 -1
- package/dist/web/assets/{index-DXYQAomq.js → index-pQiGNlCj.js} +1 -1
- package/dist/web/assets/{llms-DBOurxhD.js → llms-xXlg9f0z.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
var w7=Object.defineProperty;var x7=(e,t,n)=>t in e?w7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Bh=(e,t,n)=>x7(e,typeof t!="symbol"?t+"":t,n);function E7(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const o=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function Yp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function zxe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){var a=!1;try{a=this instanceof r}catch{}return a?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}),n}var Yx={exports:{}},Cf={};var FL;function S7(){if(FL)return Cf;FL=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,o){var i=null;if(o!==void 0&&(i=""+o),a.key!==void 0&&(i=""+a.key),"key"in a){o={};for(var c in a)c!=="key"&&(o[c]=a[c])}else o=a;return a=o.ref,{$$typeof:e,type:r,key:i,ref:a!==void 0?a:null,props:o}}return Cf.Fragment=t,Cf.jsx=n,Cf.jsxs=n,Cf}var BL;function _7(){return BL||(BL=1,Yx.exports=S7()),Yx.exports}var u=_7();const T7="modulepreload",N7=function(e){return"/inspector/"+e},HL={},pa=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let d=function(f){return Promise.all(f.map(m=>Promise.resolve(m).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=i?.nonce||i?.getAttribute("nonce");a=d(n.map(f=>{if(f=N7(f),f in HL)return;HL[f]=!0;const m=f.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":T7,m||(g.as="script"),g.crossOrigin="",g.href=f,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,E)=>{g.addEventListener("load",v),g.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return a.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})};var k7=Object.defineProperty,De=(e,t)=>k7(e,"name",{value:t,configurable:!0}),Fxe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});function Gz(e){return e==="localhost"||e==="127.0.0.1"||e.startsWith("127.")||e.startsWith("192.168.")||e.startsWith("10.")||e.startsWith("172.")}De(Gz,"isLocalServer");function Wz(e){const t=e.split(".");return t.length<=2?e:t.slice(t.length-2).join(".")}De(Wz,"getBaseDomain");function Kz(e){return new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{t(r.result)},r.onerror=n,r.readAsDataURL(e)})}De(Kz,"blobToBase64");async function Yz(e){try{let t;if(e.startsWith("http://")||e.startsWith("https://")?t=new URL(e).hostname:e.includes("://")?t=e.split("://")[1].split("/")[0]:t=e.split("/")[0],Gz(t))return null;const n=Wz(t),r=t!==n?[t,n]:[t];for(const a of r)try{const o=`https://favicon.tools.mcp-use.com/${a}`,i=new AbortController,c=setTimeout(()=>i.abort(),2e3);try{const d=await fetch(o,{signal:i.signal});if(clearTimeout(c),!d.ok)continue;const f=await d.blob();return await Kz(f)}catch{clearTimeout(c);continue}}catch{continue}return null}catch(t){return console.warn("[favicon-detector] Error detecting favicon:",t),null}}De(Yz,"detectFavicon");function b_(e,t){const 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};const r=new URL(t.proxyAddress),a=new URL(e),o=`${r.origin}${r.pathname}${a.pathname}${a.search}`,i={"X-Target-URL":e,...n};return{url:o,headers:i}}De(b_,"applyProxyConfig");var Pf={},Zz="mcp-use";function gE(e){switch((typeof process<"u"&&Pf?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}De(gE,"resolveLevel");function qz(e){return e.length===0?"":e.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ")}De(qz,"formatArgs");var _u,C7=(_u=class{_level;name;format;constructor(t=Zz,n="info",r="minimal"){this.name=t,this._level=n,this.format=r}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],r=n.indexOf(this._level);return n.indexOf(t)<=r}formatMessage(t,n,r){const a=new Date().toLocaleTimeString("en-US",{hour12:!1}),o=qz(r),i=o?`${n} ${o}`:n;switch(this.format){case"detailed":return`${a} [${this.name}] ${t.toUpperCase()}: ${i}`;case"emoji":{const c={error:"❌",warn:"⚠️",info:"ℹ️",http:"🌐",verbose:"📝",debug:"🔍",silly:"🤪"};return`${a} [${this.name}] ${c[t]||""} ${t.toUpperCase()}: ${i}`}case"minimal":default:return`${a} [${this.name}] ${t}: ${i}`}}error(t,...n){this.shouldLog("error")&&console.error(this.formatMessage("error",t,n))}warn(t,...n){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t,n))}info(t,...n){this.shouldLog("info")&&console.info(this.formatMessage("info",t,n))}debug(t,...n){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t,n))}http(t,...n){this.shouldLog("http")&&console.log(this.formatMessage("http",t,n))}verbose(t,...n){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t,n))}silly(t,...n){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t,n))}get level(){return this._level}set level(t){this._level=t}setFormat(t){this.format=t}},De(_u,"SimpleConsoleLogger"),_u),Ii,R7=(Ii=class{static get(t=Zz){if(!this.instances[t]){const n=typeof process<"u"&&Pf?.DEBUG||void 0;this.instances[t]=new C7(t,gE(n),this.currentFormat)}return this.instances[t]}static configure(t={}){const{level:n,format:r="minimal"}=t,a=typeof process<"u"&&Pf?.DEBUG||void 0,o=n??gE(a);this.currentFormat=r,Object.values(this.instances).forEach(i=>{i.level=o,i.setFormat(r)})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.instances).forEach(r=>{r.level=n}),typeof process<"u"&&Pf&&(Pf.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},De(Ii,"Logger"),Bh(Ii,"instances",{}),Bh(Ii,"currentFormat","minimal"),Ii),Le=R7.get(),A7="1.12.2-canary.2";function Ny(){return A7}De(Ny,"getPackageVersion");var Tu,As=(Tu=class{},De(Tu,"BaseTelemetryEvent"),Tu),Nu,I7=(Nu=class extends As{constructor(t){super(),this.data=t}get name(){return"mcp_agent_execution"}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}},De(Nu,"MCPAgentExecutionEvent"),Nu);function Xz(e,t){const n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),a=Array.from(e.registrations.resources.values()),o=Array.from(e.registrations.resourceTemplates.values()),i=a.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,uri:m.config.uri??null,mime_type:m.config.mimeType??null})),c=i.filter(m=>m.mime_type==="text/html+skybridge"),d=i.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),f=i.filter(m=>m.mime_type==="text/html+mcp");return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,input_schema:m.config.schema?JSON.stringify(m.config.schema):null,output_schema:m.config.outputSchema?JSON.stringify(m.config.outputSchema):null})):null,resources:i.length>0?i:null,prompts:r.length>0?r.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,args:m.config.args?JSON.stringify(m.config.args):null})):null,templates:o.length>0?o.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:c.length>0?c:null,appsSdkResourcesNumber:c.length,mcpUiResources:d.length>0?d:null,mcpUiResourcesNumber:d.length,mcpAppsResources:f.length>0?f:null,mcpAppsResourcesNumber:f.length}}De(Xz,"createServerRunEventData");var ku,O7=(ku=class extends As{constructor(t){super(),this.data=t}get name(){return"server_run"}get properties(){return{transport:this.data.transport,tools_number:this.data.toolsNumber,resources_number:this.data.resourcesNumber,prompts_number:this.data.promptsNumber,auth:this.data.auth,name:this.data.name,description:this.data.description??null,base_url:this.data.baseUrl??null,tool_names:this.data.toolNames??null,resource_names:this.data.resourceNames??null,prompt_names:this.data.promptNames??null,tools:this.data.tools??null,resources:this.data.resources??null,prompts:this.data.prompts??null,templates:this.data.templates??null,capabilities:this.data.capabilities?JSON.stringify(this.data.capabilities):null,apps_sdk_resources:this.data.appsSdkResources?JSON.stringify(this.data.appsSdkResources):null,apps_sdk_resources_number:this.data.appsSdkResourcesNumber??0,mcp_ui_resources:this.data.mcpUiResources?JSON.stringify(this.data.mcpUiResources):null,mcp_ui_resources_number:this.data.mcpUiResourcesNumber??0,mcp_apps_resources:this.data.mcpAppsResources?JSON.stringify(this.data.mcpAppsResources):null,mcp_apps_resources_number:this.data.mcpAppsResourcesNumber??0}}},De(ku,"ServerRunEvent"),ku),Cu,D7=(Cu=class extends As{constructor(t){super(),this.data=t}get name(){return"server_initialize_call"}get properties(){return{protocol_version:this.data.protocolVersion,client_info:JSON.stringify(this.data.clientInfo),client_capabilities:JSON.stringify(this.data.clientCapabilities),session_id:this.data.sessionId??null}}},De(Cu,"ServerInitializeEvent"),Cu),Ru,L7=(Ru=class extends As{constructor(t){super(),this.data=t}get name(){return"server_tool_call"}get properties(){return{tool_name:this.data.toolName,length_input_argument:this.data.lengthInputArgument,success:this.data.success,error_type:this.data.errorType??null,execution_time_ms:this.data.executionTimeMs??null}}},De(Ru,"ServerToolCallEvent"),Ru),Au,M7=(Au=class extends As{constructor(t){super(),this.data=t}get name(){return"server_resource_call"}get properties(){return{name:this.data.name,description:this.data.description,contents:this.data.contents,success:this.data.success,error_type:this.data.errorType??null}}},De(Au,"ServerResourceCallEvent"),Au),Iu,j7=(Iu=class extends As{constructor(t){super(),this.data=t}get name(){return"server_prompt_call"}get properties(){return{name:this.data.name,description:this.data.description,success:this.data.success,error_type:this.data.errorType??null}}},De(Iu,"ServerPromptCallEvent"),Iu),Ou,P7=(Ou=class extends As{constructor(t){super(),this.data=t}get name(){return`server_context_${this.data.contextType}`}get properties(){return{context_type:this.data.contextType,notification_type:this.data.notificationType??null}}},De(Ou,"ServerContextEvent"),Ou),Du,$7=(Du=class extends As{constructor(t){super(),this.data=t}get name(){return"mcpclient_init"}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},De(Du,"MCPClientInitEvent"),Du),Lu,U7=(Lu=class extends As{constructor(t){super(),this.data=t}get name(){return"connector_init"}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},De(Lu,"ConnectorInitEvent"),Lu),Mu,z7=(Mu=class extends As{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,r=n.url;return{server_name:t,server_url_domain:r?this._extractHostname(r):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},De(Mu,"ClientAddServerEvent"),Mu),ju,F7=(ju=class extends As{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},De(ju,"ClientRemoveServerEvent"),ju);function Jz(e){return e._llm_type||e.constructor.name.toLowerCase()}De(Jz,"getModelProvider");function Qz(e){if("_identifyingParams"in e){const t=e._identifyingParams;if(typeof t=="object"&&t!==null){for(const n of["model","modelName","model_name","modelId","model_id","deploymentName","deployment_name"])if(n in t)return String(t[n])}}return e.model||e.modelName||e.constructor.name}De(Qz,"getModelName");function B7(e){return[Jz(e),Qz(e)]}De(B7,"extractModelInfo");function eb(){if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function")return globalThis.crypto.randomUUID();if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){const e=new Uint8Array(16);globalThis.crypto.getRandomValues(e);const t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}return`${Date.now()}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}De(eb,"generateUUID");function tb(){if(typeof window<"u"&&window.crypto&&typeof window.crypto.getRandomValues=="function"){const e=new Uint8Array(8);return window.crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){const e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}return Math.random().toString(36).substring(2,15)}De(tb,"secureRandomString");var VL="mcp_use_user_id";function e2(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}De(e2,"detectRuntimeEnvironment");function t2(e){if(e==="browser")try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only"}De(t2,"getStorageCapability");var Zx=null;function n2(){return Zx===null&&(Zx=e2()),Zx}De(n2,"getRuntimeEnvironment");var Es,r2=(Es=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogBrowserClient=null;_posthogLoading=null;_runtimeEnvironment;_storageCapability;_source;constructor(){this._runtimeEnvironment=n2(),this._storageCapability=t2(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";t?(this._posthogBrowserClient=null,Le.debug("Telemetry disabled via localStorage")):n?(Le.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable."),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,Le.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(typeof localStorage<"u")return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE")}catch{}return null}_checkTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHogBrowser(){try{const n=await pa(()=>import("./module-D4IOASh4.js"),[]),r=n.default||n.posthog;if(!r||typeof r.init!="function")throw new Error("posthog-js module did not export expected interface");r.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:De(()=>{Le.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=r}catch(t){Le.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return Es.instance||(Es.instance=new Es),Es.instance}setSource(t){this._source=t;try{typeof localStorage<"u"&&localStorage.setItem("MCP_USE_TELEMETRY_SOURCE",t)}catch{}Le.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogBrowserClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:try{this._currUserId=`session-${eb()}`}catch{this._currUserId=`session-${Date.now()}-${tb()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(typeof localStorage>"u")throw new Error("localStorage is not available");try{localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__")}catch(n){throw new Error(`localStorage is not writable: ${n}`)}let t=localStorage.getItem(VL);if(!t){try{t=eb()}catch{t=`${Date.now()}-${tb()}`}localStorage.setItem(VL,t)}return t}catch(t){Le.debug(`Failed to access localStorage for user ID: ${t}`);let n;try{n=`session-${eb()}`}catch{n=`session-${Date.now()}-${tb()}`}return n}}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;const n=this.userId,r={...t.properties};if(r.mcp_use_version=Ny(),r.language="typescript",r.source=this._source,r.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(t.name,{...r,distinct_id:n})}catch(a){Le.debug(`Failed to track PostHog Browser event ${t.name}: ${a}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new I7(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const r=Xz(t,n),a=new O7(r);await this.capture(a)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new D7(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new L7(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new M7(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new j7(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new P7(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new $7(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new U7(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const r=new z7({serverName:t,serverConfig:n});await this.capture(r)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new F7({serverName:t});await this.capture(n)}async trackUseMcpConnection(t){this.isEnabled&&await this.capture({name:"usemcp_connection",properties:{url_domain:new URL(t.url).hostname,transport_type:t.transportType,success:t.success,error_type:t.errorType??null,connection_time_ms:t.connectionTimeMs??null,has_oauth:t.hasOAuth,has_sampling:t.hasSampling,has_elicitation:t.hasElicitation}})}async trackUseMcpToolCall(t){this.isEnabled&&await this.capture({name:"usemcp_tool_call",properties:{tool_name:t.toolName,success:t.success,error_type:t.errorType??null,execution_time_ms:t.executionTimeMs??null}})}async trackUseMcpResourceRead(t){this.isEnabled&&await this.capture({name:"usemcp_resource_read",properties:{resource_uri_scheme:t.resourceUri.split(":")[0],success:t.success,error_type:t.errorType??null}})}identify(t,n){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(t,n)}catch(r){Le.debug(`Failed to identify user: ${r}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){Le.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(t){}},De(Es,"Telemetry"),Bh(Es,"instance",null),Es),Bs=r2;function H7(e){Bs.getInstance().setSource(e)}De(H7,"setTelemetrySource");const V7=Object.freeze({status:"aborted"});function Te(e,t,n){function r(c,d){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:d,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,d);const f=i.prototype,m=Object.keys(f);for(let h=0;h<m.length;h++){const g=m[h];g in c||(c[g]=f[g].bind(c))}}const a=n?.Parent??Object;class o extends a{}Object.defineProperty(o,"name",{value:e});function i(c){var d;const f=n?.Parent?new o:this;r(f,c),(d=f._zod).deferred??(d.deferred=[]);for(const m of f._zod.deferred)m();return f}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class mu extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class a2 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const bE={};function $i(e){return e&&Object.assign(bE,e),bE}function s2(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function Bxe(e,t="|"){return e.map(n=>Z7(n)).join(t)}function yE(e,t){return typeof t=="bigint"?t.toString():t}function ky(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function y_(e){return e==null}function v_(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function G7(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let a=(r.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(r)){const d=r.match(/\d?e-(\d?)/);d?.[1]&&(a=Number.parseInt(d[1]))}const o=n>a?n:a,i=Number.parseInt(e.toFixed(o).replace(".","")),c=Number.parseInt(t.toFixed(o).replace(".",""));return i%c/10**o}const GL=Symbol("evaluating");function On(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==GL)return r===void 0&&(r=GL,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Kl(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Yl(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function WL(e){return JSON.stringify(e)}function W7(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const o2="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function fp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const K7=ky(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Yu(e){if(fp(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(fp(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function i2(e){return Yu(e)?{...e}:Array.isArray(e)?[...e]:e}const Y7=new Set(["string","number","symbol"]);function Zu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function lt(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Z7(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function q7(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const X7={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function J7(e,t){const n=e._zod.def,r=Yl(e._zod.def,{get shape(){const a={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(a[o]=n.shape[o])}return Kl(this,"shape",a),a},checks:[]});return Wi(e,r)}function Q7(e,t){const n=e._zod.def,r=Yl(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete a[o]}return Kl(this,"shape",a),a},checks:[]});return Wi(e,r)}function eW(e,t){if(!Yu(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const a=Yl(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Kl(this,"shape",o),o},checks:[]});return Wi(e,a)}function tW(e,t){if(!Yu(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return Kl(this,"shape",r),r},checks:e._zod.def.checks};return Wi(e,n)}function nW(e,t){const n=Yl(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Kl(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Wi(e,n)}function rW(e,t,n){const r=Yl(t._zod.def,{get shape(){const a=t._zod.def.shape,o={...a};if(n)for(const i in n){if(!(i in a))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=e?new e({type:"optional",innerType:a[i]}):a[i])}else for(const i in a)o[i]=e?new e({type:"optional",innerType:a[i]}):a[i];return Kl(this,"shape",o),o},checks:[]});return Wi(t,r)}function aW(e,t,n){const r=Yl(t._zod.def,{get shape(){const a=t._zod.def.shape,o={...a};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:a[i]}))}else for(const i in a)o[i]=new e({type:"nonoptional",innerType:a[i]});return Kl(this,"shape",o),o},checks:[]});return Wi(t,r)}function Qc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Cl(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Hh(e){return typeof e=="string"?e:e?.message}function Ui(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const a=Hh(e.inst?._zod.def?.error?.(e))??Hh(t?.error?.(e))??Hh(n.customError?.(e))??Hh(n.localeError?.(e))??"Invalid input";r.message=a}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function w_(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function pp(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const l2=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,yE,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},c2=Te("$ZodError",l2),Cy=Te("$ZodError",l2,{Parent:Error});function sW(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function oW(e,t=n=>n.message){const n={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(i=>r({issues:i}));else if(o.code==="invalid_key")r({issues:o.issues});else if(o.code==="invalid_element")r({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let i=n,c=0;for(;c<o.path.length;){const d=o.path[c];c===o.path.length-1?(i[d]=i[d]||{_errors:[]},i[d]._errors.push(t(o))):i[d]=i[d]||{_errors:[]},i=i[d],c++}}};return r(e),n}function iW(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function Hxe(e){const t=[],n=[...e.issues].sort((r,a)=>(r.path??[]).length-(a.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${iW(r.path)}`);return t.join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BDlTOMS5.js","assets/index-DdrkmeYH.js","assets/index-pQiGNlCj.js","assets/llms-xXlg9f0z.js","assets/embeddings-CVWvogFr.js","assets/index-CbPoLZEh.js","assets/index-DdkxcTE2.js","assets/index-D7_719w8.js","assets/browser-BLnflEDD.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var w7=Object.defineProperty;var x7=(e,t,n)=>t in e?w7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Bh=(e,t,n)=>x7(e,typeof t!="symbol"?t+"":t,n);function E7(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const o=Object.getOwnPropertyDescriptor(r,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();function Yp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function zxe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function r(){var a=!1;try{a=this instanceof r}catch{}return a?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:function(){return e[r]}})}),n}var Yx={exports:{}},Cf={};var FL;function S7(){if(FL)return Cf;FL=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,a,o){var i=null;if(o!==void 0&&(i=""+o),a.key!==void 0&&(i=""+a.key),"key"in a){o={};for(var c in a)c!=="key"&&(o[c]=a[c])}else o=a;return a=o.ref,{$$typeof:e,type:r,key:i,ref:a!==void 0?a:null,props:o}}return Cf.Fragment=t,Cf.jsx=n,Cf.jsxs=n,Cf}var BL;function _7(){return BL||(BL=1,Yx.exports=S7()),Yx.exports}var u=_7();const T7="modulepreload",N7=function(e){return"/inspector/"+e},HL={},pa=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let d=function(f){return Promise.all(f.map(m=>Promise.resolve(m).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),c=i?.nonce||i?.getAttribute("nonce");a=d(n.map(f=>{if(f=N7(f),f in HL)return;HL[f]=!0;const m=f.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${h}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":T7,m||(g.as="script"),g.crossOrigin="",g.href=f,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,E)=>{g.addEventListener("load",v),g.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return a.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})};var k7=Object.defineProperty,De=(e,t)=>k7(e,"name",{value:t,configurable:!0}),Fxe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});function Gz(e){return e==="localhost"||e==="127.0.0.1"||e.startsWith("127.")||e.startsWith("192.168.")||e.startsWith("10.")||e.startsWith("172.")}De(Gz,"isLocalServer");function Wz(e){const t=e.split(".");return t.length<=2?e:t.slice(t.length-2).join(".")}De(Wz,"getBaseDomain");function Kz(e){return new Promise((t,n)=>{const r=new FileReader;r.onloadend=()=>{t(r.result)},r.onerror=n,r.readAsDataURL(e)})}De(Kz,"blobToBase64");async function Yz(e){try{let t;if(e.startsWith("http://")||e.startsWith("https://")?t=new URL(e).hostname:e.includes("://")?t=e.split("://")[1].split("/")[0]:t=e.split("/")[0],Gz(t))return null;const n=Wz(t),r=t!==n?[t,n]:[t];for(const a of r)try{const o=`https://favicon.tools.mcp-use.com/${a}`,i=new AbortController,c=setTimeout(()=>i.abort(),2e3);try{const d=await fetch(o,{signal:i.signal});if(clearTimeout(c),!d.ok)continue;const f=await d.blob();return await Kz(f)}catch{clearTimeout(c);continue}}catch{continue}return null}catch(t){return console.warn("[favicon-detector] Error detecting favicon:",t),null}}De(Yz,"detectFavicon");function b_(e,t){const 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};const r=new URL(t.proxyAddress),a=new URL(e),o=`${r.origin}${r.pathname}${a.pathname}${a.search}`,i={"X-Target-URL":e,...n};return{url:o,headers:i}}De(b_,"applyProxyConfig");var Pf={},Zz="mcp-use";function gE(e){switch((typeof process<"u"&&Pf?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}De(gE,"resolveLevel");function qz(e){return e.length===0?"":e.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ")}De(qz,"formatArgs");var _u,C7=(_u=class{_level;name;format;constructor(t=Zz,n="info",r="minimal"){this.name=t,this._level=n,this.format=r}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],r=n.indexOf(this._level);return n.indexOf(t)<=r}formatMessage(t,n,r){const a=new Date().toLocaleTimeString("en-US",{hour12:!1}),o=qz(r),i=o?`${n} ${o}`:n;switch(this.format){case"detailed":return`${a} [${this.name}] ${t.toUpperCase()}: ${i}`;case"emoji":{const c={error:"❌",warn:"⚠️",info:"ℹ️",http:"🌐",verbose:"📝",debug:"🔍",silly:"🤪"};return`${a} [${this.name}] ${c[t]||""} ${t.toUpperCase()}: ${i}`}case"minimal":default:return`${a} [${this.name}] ${t}: ${i}`}}error(t,...n){this.shouldLog("error")&&console.error(this.formatMessage("error",t,n))}warn(t,...n){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t,n))}info(t,...n){this.shouldLog("info")&&console.info(this.formatMessage("info",t,n))}debug(t,...n){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t,n))}http(t,...n){this.shouldLog("http")&&console.log(this.formatMessage("http",t,n))}verbose(t,...n){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t,n))}silly(t,...n){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t,n))}get level(){return this._level}set level(t){this._level=t}setFormat(t){this.format=t}},De(_u,"SimpleConsoleLogger"),_u),Ii,R7=(Ii=class{static get(t=Zz){if(!this.instances[t]){const n=typeof process<"u"&&Pf?.DEBUG||void 0;this.instances[t]=new C7(t,gE(n),this.currentFormat)}return this.instances[t]}static configure(t={}){const{level:n,format:r="minimal"}=t,a=typeof process<"u"&&Pf?.DEBUG||void 0,o=n??gE(a);this.currentFormat=r,Object.values(this.instances).forEach(i=>{i.level=o,i.setFormat(r)})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.instances).forEach(r=>{r.level=n}),typeof process<"u"&&Pf&&(Pf.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},De(Ii,"Logger"),Bh(Ii,"instances",{}),Bh(Ii,"currentFormat","minimal"),Ii),Le=R7.get(),A7="1.12.2";function Ny(){return A7}De(Ny,"getPackageVersion");var Tu,As=(Tu=class{},De(Tu,"BaseTelemetryEvent"),Tu),Nu,I7=(Nu=class extends As{constructor(t){super(),this.data=t}get name(){return"mcp_agent_execution"}get properties(){return{execution_method:this.data.executionMethod,query:this.data.query,query_length:this.data.query.length,success:this.data.success,model_provider:this.data.modelProvider,model_name:this.data.modelName,server_count:this.data.serverCount,server_identifiers:this.data.serverIdentifiers,total_tools_available:this.data.totalToolsAvailable,tools_available_names:this.data.toolsAvailableNames,max_steps_configured:this.data.maxStepsConfigured,memory_enabled:this.data.memoryEnabled,use_server_manager:this.data.useServerManager,max_steps_used:this.data.maxStepsUsed,manage_connector:this.data.manageConnector,external_history_used:this.data.externalHistoryUsed,steps_taken:this.data.stepsTaken??null,tools_used_count:this.data.toolsUsedCount??null,tools_used_names:this.data.toolsUsedNames??null,response:this.data.response??null,response_length:this.data.response?this.data.response.length:null,execution_time_ms:this.data.executionTimeMs??null,error_type:this.data.errorType??null,conversation_history_length:this.data.conversationHistoryLength??null}}},De(Nu,"MCPAgentExecutionEvent"),Nu);function Xz(e,t){const n=Array.from(e.registrations.tools.values()),r=Array.from(e.registrations.prompts.values()),a=Array.from(e.registrations.resources.values()),o=Array.from(e.registrations.resourceTemplates.values()),i=a.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,uri:m.config.uri??null,mime_type:m.config.mimeType??null})),c=i.filter(m=>m.mime_type==="text/html+skybridge"),d=i.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),f=i.filter(m=>m.mime_type==="text/html+mcp");return{transport:t,toolsNumber:e.registeredTools.length,resourcesNumber:e.registeredResources.length,promptsNumber:e.registeredPrompts.length,auth:!!e.oauthProvider,name:e.config.name,description:e.config.description??null,baseUrl:e.serverBaseUrl??null,toolNames:e.registeredTools.length>0?e.registeredTools:null,resourceNames:e.registeredResources.length>0?e.registeredResources:null,promptNames:e.registeredPrompts.length>0?e.registeredPrompts:null,tools:n.length>0?n.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,input_schema:m.config.schema?JSON.stringify(m.config.schema):null,output_schema:m.config.outputSchema?JSON.stringify(m.config.outputSchema):null})):null,resources:i.length>0?i:null,prompts:r.length>0?r.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null,args:m.config.args?JSON.stringify(m.config.args):null})):null,templates:o.length>0?o.map(m=>({name:m.config.name,title:m.config.title??null,description:m.config.description??null})):null,capabilities:{logging:!0,resources:{subscribe:!0,listChanged:!0}},appsSdkResources:c.length>0?c:null,appsSdkResourcesNumber:c.length,mcpUiResources:d.length>0?d:null,mcpUiResourcesNumber:d.length,mcpAppsResources:f.length>0?f:null,mcpAppsResourcesNumber:f.length}}De(Xz,"createServerRunEventData");var ku,O7=(ku=class extends As{constructor(t){super(),this.data=t}get name(){return"server_run"}get properties(){return{transport:this.data.transport,tools_number:this.data.toolsNumber,resources_number:this.data.resourcesNumber,prompts_number:this.data.promptsNumber,auth:this.data.auth,name:this.data.name,description:this.data.description??null,base_url:this.data.baseUrl??null,tool_names:this.data.toolNames??null,resource_names:this.data.resourceNames??null,prompt_names:this.data.promptNames??null,tools:this.data.tools??null,resources:this.data.resources??null,prompts:this.data.prompts??null,templates:this.data.templates??null,capabilities:this.data.capabilities?JSON.stringify(this.data.capabilities):null,apps_sdk_resources:this.data.appsSdkResources?JSON.stringify(this.data.appsSdkResources):null,apps_sdk_resources_number:this.data.appsSdkResourcesNumber??0,mcp_ui_resources:this.data.mcpUiResources?JSON.stringify(this.data.mcpUiResources):null,mcp_ui_resources_number:this.data.mcpUiResourcesNumber??0,mcp_apps_resources:this.data.mcpAppsResources?JSON.stringify(this.data.mcpAppsResources):null,mcp_apps_resources_number:this.data.mcpAppsResourcesNumber??0}}},De(ku,"ServerRunEvent"),ku),Cu,D7=(Cu=class extends As{constructor(t){super(),this.data=t}get name(){return"server_initialize_call"}get properties(){return{protocol_version:this.data.protocolVersion,client_info:JSON.stringify(this.data.clientInfo),client_capabilities:JSON.stringify(this.data.clientCapabilities),session_id:this.data.sessionId??null}}},De(Cu,"ServerInitializeEvent"),Cu),Ru,L7=(Ru=class extends As{constructor(t){super(),this.data=t}get name(){return"server_tool_call"}get properties(){return{tool_name:this.data.toolName,length_input_argument:this.data.lengthInputArgument,success:this.data.success,error_type:this.data.errorType??null,execution_time_ms:this.data.executionTimeMs??null}}},De(Ru,"ServerToolCallEvent"),Ru),Au,M7=(Au=class extends As{constructor(t){super(),this.data=t}get name(){return"server_resource_call"}get properties(){return{name:this.data.name,description:this.data.description,contents:this.data.contents,success:this.data.success,error_type:this.data.errorType??null}}},De(Au,"ServerResourceCallEvent"),Au),Iu,j7=(Iu=class extends As{constructor(t){super(),this.data=t}get name(){return"server_prompt_call"}get properties(){return{name:this.data.name,description:this.data.description,success:this.data.success,error_type:this.data.errorType??null}}},De(Iu,"ServerPromptCallEvent"),Iu),Ou,P7=(Ou=class extends As{constructor(t){super(),this.data=t}get name(){return`server_context_${this.data.contextType}`}get properties(){return{context_type:this.data.contextType,notification_type:this.data.notificationType??null}}},De(Ou,"ServerContextEvent"),Ou),Du,$7=(Du=class extends As{constructor(t){super(),this.data=t}get name(){return"mcpclient_init"}get properties(){return{code_mode:this.data.codeMode,sandbox:this.data.sandbox,all_callbacks:this.data.allCallbacks,verify:this.data.verify,servers:this.data.servers,num_servers:this.data.numServers,is_browser:this.data.isBrowser}}},De(Du,"MCPClientInitEvent"),Du),Lu,U7=(Lu=class extends As{constructor(t){super(),this.data=t}get name(){return"connector_init"}get properties(){return{connector_type:this.data.connectorType,server_command:this.data.serverCommand??null,server_args:this.data.serverArgs??null,server_url:this.data.serverUrl??null,public_identifier:this.data.publicIdentifier??null}}},De(Lu,"ConnectorInitEvent"),Lu),Mu,z7=(Mu=class extends As{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,r=n.url;return{server_name:t,server_url_domain:r?this._extractHostname(r):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},De(Mu,"ClientAddServerEvent"),Mu),ju,F7=(ju=class extends As{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},De(ju,"ClientRemoveServerEvent"),ju);function Jz(e){return e._llm_type||e.constructor.name.toLowerCase()}De(Jz,"getModelProvider");function Qz(e){if("_identifyingParams"in e){const t=e._identifyingParams;if(typeof t=="object"&&t!==null){for(const n of["model","modelName","model_name","modelId","model_id","deploymentName","deployment_name"])if(n in t)return String(t[n])}}return e.model||e.modelName||e.constructor.name}De(Qz,"getModelName");function B7(e){return[Jz(e),Qz(e)]}De(B7,"extractModelInfo");function eb(){if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.randomUUID=="function")return globalThis.crypto.randomUUID();if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){const e=new Uint8Array(16);globalThis.crypto.getRandomValues(e);const t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}return`${Date.now()}-${Math.random().toString(36).substring(2,15)}-${Math.random().toString(36).substring(2,15)}`}De(eb,"generateUUID");function tb(){if(typeof window<"u"&&window.crypto&&typeof window.crypto.getRandomValues=="function"){const e=new Uint8Array(8);return window.crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}if(typeof globalThis<"u"&&globalThis.crypto&&typeof globalThis.crypto.getRandomValues=="function"){const e=new Uint8Array(8);return globalThis.crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}return Math.random().toString(36).substring(2,15)}De(tb,"secureRandomString");var VL="mcp_use_user_id";function e2(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}De(e2,"detectRuntimeEnvironment");function t2(e){if(e==="browser")try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only"}De(t2,"getStorageCapability");var Zx=null;function n2(){return Zx===null&&(Zx=e2()),Zx}De(n2,"getRuntimeEnvironment");var Es,r2=(Es=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogBrowserClient=null;_posthogLoading=null;_runtimeEnvironment;_storageCapability;_source;constructor(){this._runtimeEnvironment=n2(),this._storageCapability=t2(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";t?(this._posthogBrowserClient=null,Le.debug("Telemetry disabled via localStorage")):n?(Le.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable."),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,Le.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`))}_getSourceFromLocalStorage(){try{if(typeof localStorage<"u")return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE")}catch{}return null}_checkTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHogBrowser(){try{const n=await pa(()=>import("./module-D4IOASh4.js"),[]),r=n.default||n.posthog;if(!r||typeof r.init!="function")throw new Error("posthog-js module did not export expected interface");r.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:De(()=>{Le.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=r}catch(t){Le.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return Es.instance||(Es.instance=new Es),Es.instance}setSource(t){this._source=t;try{typeof localStorage<"u"&&localStorage.setItem("MCP_USE_TELEMETRY_SOURCE",t)}catch{}Le.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogBrowserClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:try{this._currUserId=`session-${eb()}`}catch{this._currUserId=`session-${Date.now()}-${tb()}`}break}}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromLocalStorage(){try{if(typeof localStorage>"u")throw new Error("localStorage is not available");try{localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__")}catch(n){throw new Error(`localStorage is not writable: ${n}`)}let t=localStorage.getItem(VL);if(!t){try{t=eb()}catch{t=`${Date.now()}-${tb()}`}localStorage.setItem(VL,t)}return t}catch(t){Le.debug(`Failed to access localStorage for user ID: ${t}`);let n;try{n=`session-${eb()}`}catch{n=`session-${Date.now()}-${tb()}`}return n}}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;const n=this.userId,r={...t.properties};if(r.mcp_use_version=Ny(),r.language="typescript",r.source=this._source,r.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(t.name,{...r,distinct_id:n})}catch(a){Le.debug(`Failed to track PostHog Browser event ${t.name}: ${a}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new I7(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const r=Xz(t,n),a=new O7(r);await this.capture(a)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new D7(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new L7(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new M7(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new j7(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new P7(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new $7(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new U7(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const r=new z7({serverName:t,serverConfig:n});await this.capture(r)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new F7({serverName:t});await this.capture(n)}async trackUseMcpConnection(t){this.isEnabled&&await this.capture({name:"usemcp_connection",properties:{url_domain:new URL(t.url).hostname,transport_type:t.transportType,success:t.success,error_type:t.errorType??null,connection_time_ms:t.connectionTimeMs??null,has_oauth:t.hasOAuth,has_sampling:t.hasSampling,has_elicitation:t.hasElicitation}})}async trackUseMcpToolCall(t){this.isEnabled&&await this.capture({name:"usemcp_tool_call",properties:{tool_name:t.toolName,success:t.success,error_type:t.errorType??null,execution_time_ms:t.executionTimeMs??null}})}async trackUseMcpResourceRead(t){this.isEnabled&&await this.capture({name:"usemcp_resource_read",properties:{resource_uri_scheme:t.resourceUri.split(":")[0],success:t.success,error_type:t.errorType??null}})}identify(t,n){if(this._posthogBrowserClient)try{this._posthogBrowserClient.identify(t,n)}catch(r){Le.debug(`Failed to identify user: ${r}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){Le.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(t){}},De(Es,"Telemetry"),Bh(Es,"instance",null),Es),Bs=r2;function H7(e){Bs.getInstance().setSource(e)}De(H7,"setTelemetrySource");const V7=Object.freeze({status:"aborted"});function Te(e,t,n){function r(c,d){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:d,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,d);const f=i.prototype,m=Object.keys(f);for(let h=0;h<m.length;h++){const g=m[h];g in c||(c[g]=f[g].bind(c))}}const a=n?.Parent??Object;class o extends a{}Object.defineProperty(o,"name",{value:e});function i(c){var d;const f=n?.Parent?new o:this;r(f,c),(d=f._zod).deferred??(d.deferred=[]);for(const m of f._zod.deferred)m();return f}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class mu extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class a2 extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const bE={};function $i(e){return e&&Object.assign(bE,e),bE}function s2(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,a])=>t.indexOf(+r)===-1).map(([r,a])=>a)}function Bxe(e,t="|"){return e.map(n=>Z7(n)).join(t)}function yE(e,t){return typeof t=="bigint"?t.toString():t}function ky(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function y_(e){return e==null}function v_(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function G7(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let a=(r.split(".")[1]||"").length;if(a===0&&/\d?e-\d?/.test(r)){const d=r.match(/\d?e-(\d?)/);d?.[1]&&(a=Number.parseInt(d[1]))}const o=n>a?n:a,i=Number.parseInt(e.toFixed(o).replace(".","")),c=Number.parseInt(t.toFixed(o).replace(".",""));return i%c/10**o}const GL=Symbol("evaluating");function On(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==GL)return r===void 0&&(r=GL,r=n()),r},set(a){Object.defineProperty(e,t,{value:a})},configurable:!0})}function Kl(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Yl(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function WL(e){return JSON.stringify(e)}function W7(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const o2="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function fp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const K7=ky(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Yu(e){if(fp(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(fp(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function i2(e){return Yu(e)?{...e}:Array.isArray(e)?[...e]:e}const Y7=new Set(["string","number","symbol"]);function Zu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function lt(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Z7(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function q7(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const X7={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function J7(e,t){const n=e._zod.def,r=Yl(e._zod.def,{get shape(){const a={};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(a[o]=n.shape[o])}return Kl(this,"shape",a),a},checks:[]});return Wi(e,r)}function Q7(e,t){const n=e._zod.def,r=Yl(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete a[o]}return Kl(this,"shape",a),a},checks:[]});return Wi(e,r)}function eW(e,t){if(!Yu(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const a=Yl(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Kl(this,"shape",o),o},checks:[]});return Wi(e,a)}function tW(e,t){if(!Yu(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return Kl(this,"shape",r),r},checks:e._zod.def.checks};return Wi(e,n)}function nW(e,t){const n=Yl(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Kl(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return Wi(e,n)}function rW(e,t,n){const r=Yl(t._zod.def,{get shape(){const a=t._zod.def.shape,o={...a};if(n)for(const i in n){if(!(i in a))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=e?new e({type:"optional",innerType:a[i]}):a[i])}else for(const i in a)o[i]=e?new e({type:"optional",innerType:a[i]}):a[i];return Kl(this,"shape",o),o},checks:[]});return Wi(t,r)}function aW(e,t,n){const r=Yl(t._zod.def,{get shape(){const a=t._zod.def.shape,o={...a};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(o[i]=new e({type:"nonoptional",innerType:a[i]}))}else for(const i in a)o[i]=new e({type:"nonoptional",innerType:a[i]});return Kl(this,"shape",o),o},checks:[]});return Wi(t,r)}function Qc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Cl(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Hh(e){return typeof e=="string"?e:e?.message}function Ui(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const a=Hh(e.inst?._zod.def?.error?.(e))??Hh(t?.error?.(e))??Hh(n.customError?.(e))??Hh(n.localeError?.(e))??"Invalid input";r.message=a}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function w_(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function pp(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const l2=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,yE,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},c2=Te("$ZodError",l2),Cy=Te("$ZodError",l2,{Parent:Error});function sW(e,t=n=>n.message){const n={},r=[];for(const a of e.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(t(a))):r.push(t(a));return{formErrors:r,fieldErrors:n}}function oW(e,t=n=>n.message){const n={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(i=>r({issues:i}));else if(o.code==="invalid_key")r({issues:o.issues});else if(o.code==="invalid_element")r({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let i=n,c=0;for(;c<o.path.length;){const d=o.path[c];c===o.path.length-1?(i[d]=i[d]||{_errors:[]},i[d]._errors.push(t(o))):i[d]=i[d]||{_errors:[]},i=i[d],c++}}};return r(e),n}function iW(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function Hxe(e){const t=[],n=[...e.issues].sort((r,a)=>(r.path??[]).length-(a.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${iW(r.path)}`);return t.join(`
|
|
3
3
|
`)}const Ry=e=>(t,n,r,a)=>{const o=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new mu;if(i.issues.length){const c=new(a?.Err??e)(i.issues.map(d=>Ui(d,o,$i())));throw o2(c,a?.callee),c}return i.value},Vxe=Ry(Cy),Ay=e=>async(t,n,r,a)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(a?.Err??e)(i.issues.map(d=>Ui(d,o,$i())));throw o2(c,a?.callee),c}return i.value},Gxe=Ay(Cy),Iy=e=>(t,n,r)=>{const a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new mu;return o.issues.length?{success:!1,error:new(e??c2)(o.issues.map(i=>Ui(i,a,$i())))}:{success:!0,data:o.value}},u2=Iy(Cy),Oy=e=>async(t,n,r)=>{const a=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},a);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(i=>Ui(i,a,$i())))}:{success:!0,data:o.value}},lW=Oy(Cy),cW=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ry(e)(t,n,a)},uW=e=>(t,n,r)=>Ry(e)(t,n,r),dW=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ay(e)(t,n,a)},fW=e=>async(t,n,r)=>Ay(e)(t,n,r),pW=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Iy(e)(t,n,a)},mW=e=>(t,n,r)=>Iy(e)(t,n,r),hW=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oy(e)(t,n,a)},gW=e=>async(t,n,r)=>Oy(e)(t,n,r),bW=/^[cC][^\s-]{8,}$/,yW=/^[0-9a-z]+$/,vW=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,wW=/^[0-9a-vA-V]{20}$/,xW=/^[A-Za-z0-9]{27}$/,EW=/^[a-zA-Z0-9_-]{21}$/,SW=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,_W=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,KL=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,TW=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,NW="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function kW(){return new RegExp(NW,"u")}const CW=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,RW=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,AW=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,IW=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,OW=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,d2=/^[A-Za-z0-9_-]*$/,DW=/^\+(?:[0-9]){6,14}[0-9]$/,f2="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",LW=new RegExp(`^${f2}$`);function p2(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function MW(e){return new RegExp(`^${p2(e)}$`)}function jW(e){const t=p2({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${f2}T(?:${r})$`)}const PW=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},$W=/^-?\d+$/,UW=/^-?\d+(?:\.\d+)?/,zW=/^(?:true|false)$/i,FW=/^null$/i,BW=/^[^A-Z]*$/,HW=/^[^a-z]*$/,Ra=Te("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),m2={number:"number",bigint:"bigint",object:"date"},h2=Te("$ZodCheckLessThan",(e,t)=>{Ra.init(e,t);const n=m2[typeof t.value];e._zod.onattach.push(r=>{const a=r._zod.bag,o=(t.inclusive?a.maximum:a.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?a.maximum=t.value:a.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),g2=Te("$ZodCheckGreaterThan",(e,t)=>{Ra.init(e,t);const n=m2[typeof t.value];e._zod.onattach.push(r=>{const a=r._zod.bag,o=(t.inclusive?a.minimum:a.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?a.minimum=t.value:a.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),VW=Te("$ZodCheckMultipleOf",(e,t)=>{Ra.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):G7(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),GW=Te("$ZodCheckNumberFormat",(e,t)=>{Ra.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[a,o]=X7[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=a,c.maximum=o,n&&(c.pattern=$W)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}c<a&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:a,inclusive:!0,inst:e,continue:!t.abort}),c>o&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inst:e})}}),WW=Te("$ZodCheckMaxLength",(e,t)=>{var n;Ra.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!y_(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<a&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const a=r.value;if(a.length<=t.maximum)return;const i=w_(a);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),KW=Te("$ZodCheckMinLength",(e,t)=>{var n;Ra.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!y_(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>a&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const a=r.value;if(a.length>=t.minimum)return;const i=w_(a);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:a,inst:e,continue:!t.abort})}}),YW=Te("$ZodCheckLengthEquals",(e,t)=>{var n;Ra.init(e,t),(n=e._zod.def).when??(n.when=r=>{const a=r.value;return!y_(a)&&a.length!==void 0}),e._zod.onattach.push(r=>{const a=r._zod.bag;a.minimum=t.length,a.maximum=t.length,a.length=t.length}),e._zod.check=r=>{const a=r.value,o=a.length;if(o===t.length)return;const i=w_(a),c=o>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Dy=Te("$ZodCheckStringFormat",(e,t)=>{var n,r;Ra.init(e,t),e._zod.onattach.push(a=>{const o=a._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=a=>{t.pattern.lastIndex=0,!t.pattern.test(a.value)&&a.issues.push({origin:"string",code:"invalid_format",format:t.format,input:a.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ZW=Te("$ZodCheckRegex",(e,t)=>{Dy.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),qW=Te("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=BW),Dy.init(e,t)}),XW=Te("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=HW),Dy.init(e,t)}),JW=Te("$ZodCheckIncludes",(e,t)=>{Ra.init(e,t);const n=Zu(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(a=>{const o=a._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=a=>{a.value.includes(t.includes,t.position)||a.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:a.value,inst:e,continue:!t.abort})}}),QW=Te("$ZodCheckStartsWith",(e,t)=>{Ra.init(e,t);const n=new RegExp(`^${Zu(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),eK=Te("$ZodCheckEndsWith",(e,t)=>{Ra.init(e,t);const n=new RegExp(`.*${Zu(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const a=r._zod.bag;a.patterns??(a.patterns=new Set),a.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),tK=Te("$ZodCheckOverwrite",(e,t)=>{Ra.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class nK{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
4
4
|
`).filter(i=>i),a=Math.min(...r.map(i=>i.length-i.trimStart().length)),o=r.map(i=>i.slice(a)).map(i=>" ".repeat(this.indent*2)+i);for(const i of o)this.content.push(i)}compile(){const t=Function,n=this?.args,a=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,a.join(`
|
|
5
5
|
`))}}const rK={major:4,minor:2,patch:0},Dn=Te("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=rK;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const a of r)for(const o of a._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const a=(i,c,d)=>{let f=Qc(i),m;for(const h of c){if(h._zod.def.when){if(!h._zod.def.when(i))continue}else if(f)continue;const g=i.issues.length,v=h._zod.check(i);if(v instanceof Promise&&d?.async===!1)throw new mu;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,i.issues.length!==g&&(f||(f=Qc(i,g)))});else{if(i.issues.length===g)continue;f||(f=Qc(i,g))}}return m?m.then(()=>i):i},o=(i,c,d)=>{if(Qc(i))return i.aborted=!0,i;const f=a(c,r,d);if(f instanceof Promise){if(d.async===!1)throw new mu;return f.then(m=>e._zod.parse(m,d))}return e._zod.parse(f,d)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const f=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return f instanceof Promise?f.then(m=>o(m,i,c)):o(f,i,c)}const d=e._zod.parse(i,c);if(d instanceof Promise){if(c.async===!1)throw new mu;return d.then(f=>a(f,r,c))}return a(d,r,c)}}e["~standard"]={validate:a=>{try{const o=u2(e,a);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return lW(e,a).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),x_=Te("$ZodString",(e,t)=>{Dn.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??PW(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Xn=Te("$ZodStringFormat",(e,t)=>{Dy.init(e,t),x_.init(e,t)}),aK=Te("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=_W),Xn.init(e,t)}),sK=Te("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=KL(r))}else t.pattern??(t.pattern=KL());Xn.init(e,t)}),oK=Te("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=TW),Xn.init(e,t)}),iK=Te("$ZodURL",(e,t)=>{Xn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),a=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(":")?a.protocol.slice(0,-1):a.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=a.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),lK=Te("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=kW()),Xn.init(e,t)}),cK=Te("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=EW),Xn.init(e,t)}),uK=Te("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=bW),Xn.init(e,t)}),dK=Te("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=yW),Xn.init(e,t)}),fK=Te("$ZodULID",(e,t)=>{t.pattern??(t.pattern=vW),Xn.init(e,t)}),pK=Te("$ZodXID",(e,t)=>{t.pattern??(t.pattern=wW),Xn.init(e,t)}),mK=Te("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=xW),Xn.init(e,t)}),hK=Te("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=jW(t)),Xn.init(e,t)}),gK=Te("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=LW),Xn.init(e,t)}),bK=Te("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=MW(t)),Xn.init(e,t)}),yK=Te("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=SW),Xn.init(e,t)}),vK=Te("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=CW),Xn.init(e,t),e._zod.bag.format="ipv4"}),wK=Te("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=RW),Xn.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),xK=Te("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=AW),Xn.init(e,t)}),EK=Te("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=IW),Xn.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[a,o]=r;if(!o)throw new Error;const i=Number(o);if(`${i}`!==o)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${a}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function b2(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const SK=Te("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=OW),Xn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{b2(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function _K(e){if(!d2.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return b2(n)}const TK=Te("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=d2),Xn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{_K(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),NK=Te("$ZodE164",(e,t)=>{t.pattern??(t.pattern=DW),Xn.init(e,t)});function kK(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const a=JSON.parse(atob(r));return!("typ"in a&&a?.typ!=="JWT"||!a.alg||t&&(!("alg"in a)||a.alg!==t))}catch{return!1}}const CK=Te("$ZodJWT",(e,t)=>{Xn.init(e,t),e._zod.check=n=>{kK(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),y2=Te("$ZodNumber",(e,t)=>{Dn.init(e,t),e._zod.pattern=e._zod.bag.pattern??UW,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const a=n.value;if(typeof a=="number"&&!Number.isNaN(a)&&Number.isFinite(a))return n;const o=typeof a=="number"?Number.isNaN(a)?"NaN":Number.isFinite(a)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:a,inst:e,...o?{received:o}:{}}),n}}),RK=Te("$ZodNumberFormat",(e,t)=>{GW.init(e,t),y2.init(e,t)}),AK=Te("$ZodBoolean",(e,t)=>{Dn.init(e,t),e._zod.pattern=zW,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const a=n.value;return typeof a=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:a,inst:e}),n}}),IK=Te("$ZodNull",(e,t)=>{Dn.init(e,t),e._zod.pattern=FW,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const a=n.value;return a===null||n.issues.push({expected:"null",code:"invalid_type",input:a,inst:e}),n}}),OK=Te("$ZodAny",(e,t)=>{Dn.init(e,t),e._zod.parse=n=>n}),DK=Te("$ZodUnknown",(e,t)=>{Dn.init(e,t),e._zod.parse=n=>n}),LK=Te("$ZodNever",(e,t)=>{Dn.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function YL(e,t,n){e.issues.length&&t.issues.push(...Cl(n,e.issues)),t.value[n]=e.value}const MK=Te("$ZodArray",(e,t)=>{Dn.init(e,t),e._zod.parse=(n,r)=>{const a=n.value;if(!Array.isArray(a))return n.issues.push({expected:"array",code:"invalid_type",input:a,inst:e}),n;n.value=Array(a.length);const o=[];for(let i=0;i<a.length;i++){const c=a[i],d=t.element._zod.run({value:c,issues:[]},r);d instanceof Promise?o.push(d.then(f=>YL(f,n,i))):YL(d,n,i)}return o.length?Promise.all(o).then(()=>n):n}});function Nb(e,t,n,r){e.issues.length&&t.issues.push(...Cl(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function v2(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=q7(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function w2(e,t,n,r,a,o){const i=[],c=a.keySet,d=a.catchall._zod,f=d.def.type;for(const m in t){if(c.has(m))continue;if(f==="never"){i.push(m);continue}const h=d.run({value:t[m],issues:[]},r);h instanceof Promise?e.push(h.then(g=>Nb(g,n,m,t))):Nb(h,n,m,t)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const jK=Te("$ZodObject",(e,t)=>{if(Dn.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...c};return Object.defineProperty(t,"shape",{value:d}),d}})}const r=ky(()=>v2(t));On(e._zod,"propValues",()=>{const c=t.shape,d={};for(const f in c){const m=c[f]._zod;if(m.values){d[f]??(d[f]=new Set);for(const h of m.values)d[f].add(h)}}return d});const a=fp,o=t.catchall;let i;e._zod.parse=(c,d)=>{i??(i=r.value);const f=c.value;if(!a(f))return c.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),c;c.value={};const m=[],h=i.shape;for(const g of i.keys){const E=h[g]._zod.run({value:f[g],issues:[]},d);E instanceof Promise?m.push(E.then(x=>Nb(x,c,g,f))):Nb(E,c,g,f)}return o?w2(m,f,c,d,r.value,e):m.length?Promise.all(m).then(()=>c):c}}),PK=Te("$ZodObjectJIT",(e,t)=>{jK.init(e,t);const n=e._zod.parse,r=ky(()=>v2(t)),a=g=>{const v=new nK(["shape","payload","ctx"]),E=r.value,x=T=>{const R=WL(T);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};v.write("const input = payload.value;");const w=Object.create(null);let S=0;for(const T of E.keys)w[T]=`key_${S++}`;v.write("const newResult = {};");for(const T of E.keys){const R=w[T],C=WL(T);v.write(`const ${R} = ${x(T)};`),v.write(`
|
|
@@ -32,7 +32,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
32
32
|
`;break;case"id":c=w.includes("\0")?void 0:w;break;case"retry":/^\d+$/.test(w)?r(parseInt(w,10)):n(new Lj(`Invalid \`retry\` value: "${w}"`,{type:"invalid-retry",value:w,line:S}));break;default:n(new Lj(`Unknown field "${x.length>20?`${x.slice(0,20)}…`:x}"`,{type:"unknown-field",field:x,value:w,line:S}));break}}function v(){d.length>0&&t({id:c,event:f||void 0,data:d.endsWith(`
|
|
33
33
|
`)?d.slice(0,-1):d}),c=void 0,d="",f=""}function E(x={}){o&&x.consume&&h(o),i=!0,c=void 0,d="",f="",o=""}return{feed:m,reset:E}}function JQ(e){const t=[];let n="",r=0;for(;r<e.length;){const a=e.indexOf("\r",r),o=e.indexOf(`
|
|
34
34
|
`,r);let i=-1;if(a!==-1&&o!==-1?i=Math.min(a,o):a!==-1?a===e.length-1?i=-1:i=a:o!==-1&&(i=o),i===-1){n=e.slice(r);break}else{const c=e.slice(r,i);t.push(c),r=i+1,e[r-1]==="\r"&&e[r]===`
|
|
35
|
-
`&&r++}}return[t,n]}class QQ extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let a;super({start(o){a=n4({onEvent:i=>{o.enqueue(i)},onError(i){t==="terminate"?o.error(i):typeof t=="function"&&t(i)},onRetry:n,onComment:r})},transform(o){a.feed(o)}})}}const eee={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Ni extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class tee{constructor(t,n){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=BF(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=n?.reconnectionOptions??eee}async _authThenStart(){if(!this._authProvider)throw new rs("No auth provider");let t;try{t=await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new rs;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=jb(this._requestInit?.headers);return new Headers({...t,...n})}async _startOrAuthSse(t){const{resumptionToken:n}=t;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),n&&r.set("last-event-id",n);const a=await(this._fetch??fetch)(this._url,{method:"GET",headers:r,signal:this._abortController?.signal});if(!a.ok){if(await a.body?.cancel(),a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new Ni(a.status,`Failed to open SSE stream: ${a.statusText}`)}this._handleSseStream(a.body,t,!0)}catch(r){throw this.onerror?.(r),r}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(r,t),a)}_scheduleReconnection(t,n=0){const r=this._reconnectionOptions.maxRetries;if(n>=r){this.onerror?.(new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const a=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(o=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(t,n+1)})},a)}_handleSseStream(t,n,r){if(!t)return;const{onresumptiontoken:a,replayMessageId:o}=n;let i,c=!1,d=!1;(async()=>{try{const m=t.pipeThrough(new TextDecoderStream).pipeThrough(new QQ({onRetry:v=>{this._serverRetryMs=v}})).getReader();for(;;){const{value:v,done:E}=await m.read();if(E)break;if(v.id&&(i=v.id,c=!0,a?.(v.id)),!!v.data&&(!v.event||v.event==="message"))try{const x=nb.parse(JSON.parse(v.data));Uf(x)&&(d=!0,o!==void 0&&(x.id=o)),this.onmessage?.(x)}catch(x){this.onerror?.(x)}}(r||c)&&!d&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:a,replayMessageId:o},0)}catch(m){if(this.onerror?.(new Error(`SSE stream disconnected: ${m}`)),(r||c)&&!d&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:a,replayMessageId:o},0)}catch(v){this.onerror?.(new Error(`Failed to reconnect: ${v instanceof Error?v.message:String(v)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new rs("No auth provider");if(await Ao(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new rs("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,n){try{const{resumptionToken:r,onresumptiontoken:a}=n||{};if(r){this._startOrAuthSse({resumptionToken:r,replayMessageId:EE(t)?t.id:void 0}).catch(g=>this.onerror?.(g));return}const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const i={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(t),signal:this._abortController?.signal},c=await(this._fetch??fetch)(this._url,i),d=c.headers.get("mcp-session-id");if(d&&(this._sessionId=d),!c.ok){const g=await c.text().catch(()=>null);if(c.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Ni(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:v,scope:E}=hp(c);if(this._resourceMetadataUrl=v,this._scope=E,await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new rs;return this._hasCompletedAuthFlow=!0,this.send(t)}if(c.status===403&&this._authProvider){const{resourceMetadataUrl:v,scope:E,error:x}=hp(c);if(x==="insufficient_scope"){const w=c.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===w)throw new Ni(403,"Server returned 403 after trying upscoping");if(E&&(this._scope=E),v&&(this._resourceMetadataUrl=v),this._lastUpscopingHeader=w??void 0,await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new rs;return this.send(t)}}throw new Ni(c.status,`Error POSTing to endpoint: ${g}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,c.status===202){await c.body?.cancel(),Vq(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(g=>this.onerror?.(g));return}const m=(Array.isArray(t)?t:[t]).filter(g=>"method"in g&&"id"in g&&g.id!==void 0).length>0,h=c.headers.get("content-type");if(m)if(h?.includes("text/event-stream"))this._handleSseStream(c.body,{onresumptiontoken:a},!1);else if(h?.includes("application/json")){const g=await c.json(),v=Array.isArray(g)?g.map(E=>nb.parse(E)):[nb.parse(g)];for(const E of v)this.onmessage?.(E)}else throw await c.body?.cancel(),new Ni(-1,`Unexpected content type: ${h}`);else await c.body?.cancel()}catch(r){throw this.onerror?.(r),r}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const t=await this._commonHeaders(),n={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._url,n);if(await r.body?.cancel(),!r.ok&&r.status!==405)throw new Ni(r.status,`Failed to terminate session: ${r.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class Mj extends Event{constructor(t,n){var r,a;super(t),this.code=(r=n?.code)!=null?r:void 0,this.message=(a=n?.message)!=null?a:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(jj(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(jj(this),n)}}function nee(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function ME(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(ME).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${ME(e.cause)}`:e.message:`${e}`}function jj(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var r4=e=>{throw TypeError(e)},X_=(e,t,n)=>t.has(e)||r4("Cannot "+n),Xt=(e,t,n)=>(X_(e,t,"read from private field"),n?n.call(e):t.get(e)),_r=(e,t,n)=>t.has(e)?r4("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Yn=(e,t,n,r)=>(X_(e,t,"write to private field"),t.set(e,n),n),Co=(e,t,n)=>(X_(e,t,"access private method"),n),Na,Nl,Vc,ab,Fb,qf,tu,Xf,Ci,Gc,hu,Wc,zf,ys,jE,PE,$E,Pj,UE,zE,Ff,FE,BE;class sb extends EventTarget{constructor(t,n){var r,a;super(),_r(this,ys),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,_r(this,Na),_r(this,Nl),_r(this,Vc),_r(this,ab),_r(this,Fb),_r(this,qf),_r(this,tu),_r(this,Xf,null),_r(this,Ci),_r(this,Gc),_r(this,hu,null),_r(this,Wc,null),_r(this,zf,null),_r(this,PE,async o=>{var i;Xt(this,Gc).reset();const{body:c,redirected:d,status:f,headers:m}=o;if(f===204){Co(this,ys,Ff).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(d?Yn(this,Vc,new URL(o.url)):Yn(this,Vc,void 0),f!==200){Co(this,ys,Ff).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){Co(this,ys,Ff).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(Xt(this,Na)===this.CLOSED)return;Yn(this,Na,this.OPEN);const h=new Event("open");if((i=Xt(this,zf))==null||i.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){Co(this,ys,Ff).call(this,"Invalid response body, expected a web ReadableStream",f),this.close();return}const g=new TextDecoder,v=c.getReader();let E=!0;do{const{done:x,value:w}=await v.read();w&&Xt(this,Gc).feed(g.decode(w,{stream:!x})),x&&(E=!1,Xt(this,Gc).reset(),Co(this,ys,FE).call(this))}while(E)}),_r(this,$E,o=>{Yn(this,Ci,void 0),!(o.name==="AbortError"||o.type==="aborted")&&Co(this,ys,FE).call(this,ME(o))}),_r(this,UE,o=>{typeof o.id=="string"&&Yn(this,Xf,o.id);const i=new MessageEvent(o.event||"message",{data:o.data,origin:Xt(this,Vc)?Xt(this,Vc).origin:Xt(this,Nl).origin,lastEventId:o.id||""});Xt(this,Wc)&&(!o.event||o.event==="message")&&Xt(this,Wc).call(this,i),this.dispatchEvent(i)}),_r(this,zE,o=>{Yn(this,qf,o)}),_r(this,BE,()=>{Yn(this,tu,void 0),Xt(this,Na)===this.CONNECTING&&Co(this,ys,jE).call(this)});try{if(t instanceof URL)Yn(this,Nl,t);else if(typeof t=="string")Yn(this,Nl,new URL(t,ree()));else throw new Error("Invalid URL")}catch{throw nee("An invalid or illegal string was specified")}Yn(this,Gc,n4({onEvent:Xt(this,UE),onRetry:Xt(this,zE)})),Yn(this,Na,this.CONNECTING),Yn(this,qf,3e3),Yn(this,Fb,(r=n?.fetch)!=null?r:globalThis.fetch),Yn(this,ab,(a=n?.withCredentials)!=null?a:!1),Co(this,ys,jE).call(this)}get readyState(){return Xt(this,Na)}get url(){return Xt(this,Nl).href}get withCredentials(){return Xt(this,ab)}get onerror(){return Xt(this,hu)}set onerror(t){Yn(this,hu,t)}get onmessage(){return Xt(this,Wc)}set onmessage(t){Yn(this,Wc,t)}get onopen(){return Xt(this,zf)}set onopen(t){Yn(this,zf,t)}addEventListener(t,n,r){const a=n;super.addEventListener(t,a,r)}removeEventListener(t,n,r){const a=n;super.removeEventListener(t,a,r)}close(){Xt(this,tu)&&clearTimeout(Xt(this,tu)),Xt(this,Na)!==this.CLOSED&&(Xt(this,Ci)&&Xt(this,Ci).abort(),Yn(this,Na,this.CLOSED),Yn(this,Ci,void 0))}}Na=new WeakMap,Nl=new WeakMap,Vc=new WeakMap,ab=new WeakMap,Fb=new WeakMap,qf=new WeakMap,tu=new WeakMap,Xf=new WeakMap,Ci=new WeakMap,Gc=new WeakMap,hu=new WeakMap,Wc=new WeakMap,zf=new WeakMap,ys=new WeakSet,jE=function(){Yn(this,Na,this.CONNECTING),Yn(this,Ci,new AbortController),Xt(this,Fb)(Xt(this,Nl),Co(this,ys,Pj).call(this)).then(Xt(this,PE)).catch(Xt(this,$E))},PE=new WeakMap,$E=new WeakMap,Pj=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Xt(this,Xf)?{"Last-Event-ID":Xt(this,Xf)}:void 0},cache:"no-store",signal:(e=Xt(this,Ci))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},UE=new WeakMap,zE=new WeakMap,Ff=function(e,t){var n;Xt(this,Na)!==this.CLOSED&&Yn(this,Na,this.CLOSED);const r=new Mj("error",{code:t,message:e});(n=Xt(this,hu))==null||n.call(this,r),this.dispatchEvent(r)},FE=function(e,t){var n;if(Xt(this,Na)===this.CLOSED)return;Yn(this,Na,this.CONNECTING);const r=new Mj("error",{code:t,message:e});(n=Xt(this,hu))==null||n.call(this,r),this.dispatchEvent(r),Yn(this,tu,setTimeout(Xt(this,BE),Xt(this,qf)))},BE=new WeakMap,sb.CONNECTING=0,sb.OPEN=1,sb.CLOSED=2;function ree(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}class aee extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class see{constructor(t,n){this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=n?.eventSourceInit,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=BF(n?.fetch,n?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new rs("No auth provider");let t;try{t=await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new rs;return await this._startOrAuth()}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=jb(this._requestInit?.headers);return new Headers({...t,...n})}_startOrAuth(){const t=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((n,r)=>{this._eventSource=new sb(this._url.href,{...this._eventSourceInit,fetch:async(a,o)=>{const i=await this._commonHeaders();i.set("Accept","text/event-stream");const c=await t(a,{...o,headers:i});if(c.status===401&&c.headers.has("www-authenticate")){const{resourceMetadataUrl:d,scope:f}=hp(c);this._resourceMetadataUrl=d,this._scope=f}return c}}),this._abortController=new AbortController,this._eventSource.onerror=a=>{if(a.code===401&&this._authProvider){this._authThenStart().then(n,r);return}const o=new aee(a.code,a.message,a);r(o),this.onerror?.(o)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",a=>{const o=a;try{if(this._endpoint=new URL(o.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(i){r(i),this.onerror?.(i),this.close();return}n()}),this._eventSource.onmessage=a=>{const o=a;let i;try{i=nb.parse(JSON.parse(o.data))}catch(c){this.onerror?.(c);return}this.onmessage?.(i)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new rs("No auth provider");if(await Ao(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new rs("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(t){if(!this._endpoint)throw new Error("Not connected");try{const n=await this._commonHeaders();n.set("content-type","application/json");const r={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._endpoint,r);if(!a.ok){const o=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){const{resourceMetadataUrl:i,scope:c}=hp(a);if(this._resourceMetadataUrl=i,this._scope=c,await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new rs;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${a.status}): ${o}`)}await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}setProtocolVersion(t){this._protocolVersion=t}}var $u,oee=($u=class{connector;autoConnect;constructor(t,n=!0){this.connector=t,this.autoConnect=n}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(t,n){t==="notification"&&this.connector.onNotification(n)}async setRoots(t){return this.connector.setRoots(t)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(t){return this.connector.listTools(t)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}async callTool(t,n={},r){return this.connector.callTool(t,n,r)}async listResources(t,n){return this.connector.listResources(t,n)}async listAllResources(t){return this.connector.listAllResources(t)}async listResourceTemplates(t){return this.connector.listResourceTemplates(t)}async readResource(t,n){return this.connector.readResource(t,n)}async subscribeToResource(t,n){return this.connector.subscribeToResource(t,n)}async unsubscribeFromResource(t,n){return this.connector.unsubscribeFromResource(t,n)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(t,n){return this.connector.getPrompt(t,n)}async request(t,n=null,r){return this.connector.request(t,n,r)}},De($u,"MCPSession"),$u),Uu,iee=(Uu=class{config={};sessions={};activeSessions=[];constructor(t){t&&(this.config=t)}static fromDict(t){throw new Error("fromDict must be implemented by concrete class")}addServer(t,n){this.config.mcpServers=this.config.mcpServers||{},this.config.mcpServers[t]=n,Bs.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Bs.getInstance().trackClientRemoveServer(t))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(t){return this.config.mcpServers?.[t]}getConfig(){return this.config??{}}async createSession(t,n=!0){const r=this.config.mcpServers??{};if(Object.keys(r).length===0&&Le.warn("No MCP servers defined in config"),!r[t])throw new Error(`Server '${t}' not found in config`);const a=this.createConnectorFromConfig(r[t]),o=new oee(a);return n&&await o.initialize(),this.sessions[t]=o,this.activeSessions.includes(t)||this.activeSessions.push(t),o}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&Le.warn("No MCP servers defined in config");for(const r of Object.keys(n))await this.createSession(r,t);return this.sessions}getSession(t){const n=this.sessions[t];return n||null}requireSession(t){const n=this.sessions[t];if(!n)throw new Error(`Session '${t}' not found. Available sessions: ${this.activeSessions.join(", ")||"none"}`);return n}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){Le.warn(`No session exists for server ${t}, nothing to close`);return}try{Le.debug(`Closing session for server ${t}`),await n.disconnect()}catch(r){Le.error(`Error closing session for server '${t}': ${r}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(r=>r!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const r of t)try{Le.debug(`Closing session for server ${r}`),await this.closeSession(r)}catch(a){const o=`Failed to close session for server '${r}': ${a}`;Le.error(o),n.push(o)}n.length?Le.error(`Encountered ${n.length} errors while closing sessions`):Le.debug("All sessions closed successfully")}},De(Uu,"BaseMCPClient"),Uu),zu,lee=(zu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),Le.debug(`Starting ${this.constructor.name}`),this._task=this.connectionTask(),await this._readyPromise,this._exception)throw this._exception;if(this._connection===null)throw new Error("Connection was not established");return this._connection}async stop(){if(this._task&&this._abortController){Le.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?Le.debug(`${this.constructor.name} task aborted successfully`):Le.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,Le.debug(`${this.constructor.name} task completed`)}reset(){this._readyPromise=new Promise(t=>this._readyResolver=t),this._donePromise=new Promise(t=>this._doneResolver=t),this._exception=null,this._connection=null,this._task=null,this._abortController=new AbortController}async connectionTask(){Le.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),Le.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,Le.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){Le.warn(`Error closing connection in ${this.constructor.name}: ${t}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((t,n)=>{if(!this._abortController)return;const r=this._abortController.signal;if(r.aborted){t();return}const a=De(()=>{r.removeEventListener("abort",a),t()},"onAbort");r.addEventListener("abort",a)})}},De(zu,"ConnectionManager"),zu),Fu,cee=(Fu=class extends lee{url;opts;_transport=null;reinitializing=!1;constructor(t,n){super(),this.url=typeof t=="string"?new URL(t):t,this.opts=n}async establishConnection(){const t=new see(this.url,this.opts),n=t.send.bind(t);return t.send=async r=>{const a=De(async o=>{if(Array.isArray(o))for(const i of o)await n(i);else await n(o)},"sendMessage");try{await a(r)}catch(o){if(o?.code===404&&t.sessionId&&!this.reinitializing){Le.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),Le.info("[SSE] Re-initialization successful, retrying request"),await a(r)}finally{this.reinitializing=!1}}else throw o}},this._transport=t,Le.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){Le.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){Le.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},De(Fu,"SseConnectionManager"),Fu),Bu,uee=(Bu=class extends oJ{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;disableSseFallback;gatewayUrl;serverId;transportType=null;streamableTransport=null;constructor(t,n={}){super(n);const r=t.replace(/\/$/,"");this.gatewayUrl=n.gatewayUrl,this.serverId=n.serverId,this.gatewayUrl?(this.baseUrl=this.gatewayUrl.replace(/\/$/,""),this.headers={...n.headers??{}},this.headers["X-Target-URL"]=r,this.serverId&&(this.headers["X-Server-Id"]=this.serverId)):(this.baseUrl=r,this.headers={...n.headers??{}}),n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.timeout=n.timeout??1e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1,this.disableSseFallback=n.disableSseFallback??!1}async connect(){if(this.connected){Le.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){Le.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}Le.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{Le.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),Le.info("✅ Successfully connected via streamable HTTP")}catch(n){console.log("error in http connector connect",n);let r="Unknown error",a=!1,o,i=null;if(n instanceof Ni?i=n:n instanceof Error&&n.cause instanceof Ni&&(i=n.cause),i)a=i.code===401,o=i.code,console.log("Captured HTTP status code:",o),i.code===400&&i.message.includes("Missing session ID")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Le.warn(`⚠️ ${r}`)):i.code===404||i.code===405?(r=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,Le.debug(r)):(r=`Server returned ${i.code}: ${i.message}`,Le.debug(r));else if(n instanceof Error){const c=n.toString(),d=n.message||"";a=c.includes("401")||d.includes("Unauthorized"),c.includes("Missing session ID")||c.includes("Bad Request: Missing session ID")||d.includes("FastMCP session ID error")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Le.warn(`⚠️ ${r}`)):c.includes("405 Method Not Allowed")||c.includes("404 Not Found")?(r="Server doesn't support streamable HTTP (405/404)",Le.debug(r)):(r=`Streamable HTTP failed: ${n.message}`,Le.debug(r))}if(a){Le.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const c=new Error("Authentication required");throw c.code=401,c}Le.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(c){if(console.error("Failed to connect with both transports:"),console.error(` Streamable HTTP: ${r}`),console.error(` SSE: ${c}`),await this.cleanupResources(),c?.message?.includes("401")||c?.message?.includes("Unauthorized")){const m=new Error("Authentication required");throw m.code=401,m}const f=new Error(`Could not connect to server with any available transport. Streamable HTTP: ${r}`);throw o!==void 0&&(Object.defineProperty(f,"code",{value:o,writable:!1,enumerable:!0,configurable:!0}),Le.debug(`Preserving HTTP status code ${o} in error for proxy fallback detection`)),f}}}async connectWithStreamableHttp(t){try{console.log("[HttpConnector] Connecting with Streamable HTTP:"),console.log(` Base URL: ${t}`),console.log(` Original URL: ${this.baseUrl}`),console.log(` Gateway URL: ${this.gatewayUrl||"none"}`),console.log(` Auth Provider URL: ${this.opts.authProvider?.serverUrl||"none"}`),console.log(` Headers: ${JSON.stringify(this.headers)}`);const n=new tee(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let r=n;if(this.opts.wrapTransport){const o=this.baseUrl;r=this.opts.wrapTransport(r,o)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};Le.debug("Creating Client with capabilities:",JSON.stringify(a.capabilities,null,2)),this.client=new Aj(this.clientInfo,a),this.setupRootsHandler(),Le.debug("Roots handler registered before connect");try{await this.client.connect(r,{timeout:this.timeout});const o=n.sessionId;o?Le.debug(`Session ID obtained: ${o}`):Le.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(o){if(o instanceof Error){const i=o.message||o.toString();if(i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||i.includes("Mcp-Session-Id header is required")){const c=new Error(`Session ID error: ${i}. The SDK should automatically extract session ID from initialize response.`);throw c.cause=o,c}}throw o}this.streamableTransport=n,this.connectionManager={stop:De(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(o){Le.warn(`Error closing Streamable HTTP transport: ${o}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),Le.debug(`Successfully connected to MCP implementation via streamable HTTP: ${t}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (streamable-http)`})}catch(n){throw await this.cleanupResources(),n}}async connectWithSse(t){try{this.connectionManager=new cee(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const a=this.baseUrl;n=this.opts.wrapTransport(n,a)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};Le.debug("Creating Client with capabilities (SSE):",JSON.stringify(r.capabilities,null,2)),this.client=new Aj(this.clientInfo,r),this.setupRootsHandler(),Le.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),Le.debug(`Successfully connected to MCP implementation via HTTP/SSE: ${t}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (sse)`})}catch(n){throw await this.cleanupResources(),n}}get publicIdentifier(){return{type:"http",url:this.baseUrl,transport:this.transportType||"unknown"}}getTransportType(){return this.transportType}},De(Bu,"HttpConnector"),Bu),jl,dee=(jl=class extends iee{static getPackageVersion(){return Ny()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Bs.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>Le.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new jl(t)}createConnectorFromConfig(t){const{url:n,headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:c,onSampling:d,samplingCallback:f,elicitationCallback:m,disableSseFallback:h,preferSse:g,clientInfo:v,gatewayUrl:E,serverId:x}=t;if(!n)throw new Error("Server URL is required");const w=d??f,S={headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:c,onSampling:w,samplingCallback:w,elicitationCallback:m,disableSseFallback:h,preferSse:g,clientInfo:v,gatewayUrl:E,serverId:x};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new uee(n,S)}},De(jl,"BrowserMCPClient"),jl);function nu(e){const t=De(()=>{throw new Error(`Invalid url to pass to open(): ${e}`)},"abort");let n;try{n=new URL(e)}catch{t()}return n.protocol!=="https:"&&n.protocol!=="http:"&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&(n.username=encodeURIComponent(n.username)),n.password&&(n.password=encodeURIComponent(n.password)),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,"/"),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(a4).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}De(nu,"sanitizeUrl");function a4([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}De(a4,"sanitizeParam");async function s4(e){return typeof e=="string"?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}De(s4,"serializeBody");var Hu,ob=(Hu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;originalFetch;onPopupWindow;constructor(t,n={}){this.serverUrl=t,this.storageKeyPrefix=n.storageKeyPrefix||"mcp:auth",this.serverUrlHash=this.hashString(t),this.clientName=n.clientName||"mcp-use",this.clientUri=n.clientUri||(typeof window<"u"?window.location.origin:""),this.logoUri=n.logoUri||"https://mcp-use.com/logo.png",this.callbackUrl=nu(n.callbackUrl||(typeof window<"u"?new URL("/oauth/callback",window.location.origin).toString():"/oauth/callback")),this.preventAutoAuth=n.preventAutoAuth,this.useRedirectFlow=n.useRedirectFlow,this.oauthProxyUrl=n.oauthProxyUrl,this.connectionUrl=n.connectionUrl,this.onPopupWindow=n.onPopupWindow}installFetchInterceptor(){if(!this.oauthProxyUrl){console.warn("[BrowserOAuthProvider] No OAuth proxy URL configured, skipping fetch interceptor installation");return}if(!this.originalFetch)this.originalFetch=window.fetch;else{console.warn("[BrowserOAuthProvider] Fetch interceptor already installed");return}const t=this.oauthProxyUrl,n=this.connectionUrl,r=this.originalFetch;console.log(`[BrowserOAuthProvider] Installing fetch interceptor with proxy: ${t}`),window.fetch=De(async function(o,i){const c=typeof o=="string"?o:o instanceof URL?o.toString():o.url;if(!(c.includes("/.well-known/")||c.match(/\/(register|token|authorize)$/)))return await r(o,i);try{const f=new URL(c),m=new URL(t);if(f.origin===m.origin&&(f.pathname.startsWith(m.pathname)||c.includes("/inspector/api/oauth")))return await r(o,i)}catch{}try{const f=c.includes("/.well-known/"),m=f?`${t}/metadata?url=${encodeURIComponent(c)}`:`${t}/proxy`;if(console.log(`[OAuth Proxy] Routing ${f?"metadata":"request"} through: ${m}`),f){const E={...i?.headers?Object.fromEntries(new Headers(i.headers)):{}};return n&&(E["X-Connection-URL"]=n),await r(m,{...i,method:"GET",headers:E})}const h=i?.body?await s4(i.body):void 0,v=await(await r(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:c,method:i?.method||"POST",headers:i?.headers?Object.fromEntries(new Headers(i.headers)):{},body:h})})).json();return new Response(JSON.stringify(v.body),{status:v.status,statusText:v.statusText,headers:new Headers(v.headers)})}catch(f){return console.error("[OAuth Proxy] Request failed, falling back to direct fetch:",f),await r(o,i)}},"interceptedFetch")}restoreFetch(){this.originalFetch&&(console.log("[BrowserOAuthProvider] Restoring original fetch"),window.fetch=this.originalFetch,this.originalFetch=void 0)}get redirectUrl(){return nu(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:"none",grant_types:["authorization_code","refresh_token"],response_types:["code"],client_name:this.clientName,client_uri:this.clientUri,logo_uri:this.logoUri}}async clientInformation(){const t=this.getKey("client_info"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,r),localStorage.removeItem(t);return}}async saveClientInformation(t){const n=this.getKey("client_info");localStorage.setItem(n,JSON.stringify(t))}async tokens(){const t=this.getKey("tokens"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,r),localStorage.removeItem(t);return}}async saveTokens(t){const n=this.getKey("tokens");localStorage.setItem(n,JSON.stringify(t)),localStorage.removeItem(this.getKey("code_verifier")),localStorage.removeItem(this.getKey("last_auth_url"))}async saveCodeVerifier(t){const n=this.getKey("code_verifier");localStorage.setItem(n,t)}async codeVerifier(){const t=this.getKey("code_verifier"),n=localStorage.getItem(t);if(!n)throw new Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${t}. Auth flow likely corrupted or timed out.`);return n}async prepareAuthorizationUrl(t){const n=globalThis.crypto.randomUUID(),r=`${this.storageKeyPrefix}:state_${n}`,a={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:this.useRedirectFlow&&typeof window<"u"?window.location.href:void 0};localStorage.setItem(r,JSON.stringify(a)),t.searchParams.set("state",n);const o=t.toString(),i=nu(o);return localStorage.setItem(this.getKey("last_auth_url"),i),i}async redirectToAuthorization(t){const n=await this.prepareAuthorizationUrl(t);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=n;return}const r="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const a=window.open(n,`mcp_auth_${this.serverUrlHash}`,r);this.onPopupWindow&&this.onPopupWindow(n,r,a),!a||a.closed||typeof a.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(a.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(a){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,a)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?nu(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,r=[];let a=0;for(let i=0;i<localStorage.length;i++){const c=localStorage.key(i);if(c){if(c.startsWith(t))r.push(c);else if(c.startsWith(n))try{const d=localStorage.getItem(c);d&&JSON.parse(d).serverUrlHash===this.serverUrlHash&&r.push(c)}catch(d){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${c} during clearStorage:`,d)}}}return[...new Set(r)].forEach(i=>{localStorage.removeItem(i),a++}),a}hashString(t){let n=0;for(let r=0;r<t.length;r++){const a=t.charCodeAt(r);n=(n<<5)-n+a,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},De(Hu,"BrowserOAuthClientProvider"),Hu);async function J_(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),r=e.get("error"),a=e.get("error_description"),o="[mcp-callback]";console.log(`${o} Handling callback...`,{code:t,state:n,error:r,errorDescription:a});let i=null,c=null;const d=n?`mcp:auth:state_${n}`:null;try{if(r)throw new Error(`OAuth error: ${r} - ${a||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!d)throw new Error("State parameter not found or invalid in callback query parameters.");const f=localStorage.getItem(d);if(!f)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{c=JSON.parse(f)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!c.expiry||c.expiry<Date.now())throw localStorage.removeItem(d),new Error("OAuth state has expired. Please try initiating authentication again.");if(!c.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:m,...h}=c.providerOptions;console.log(`${o} Re-instantiating provider for server: ${m}`),i=new ob(m,h),console.log(`${o} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await Ao(i,{serverUrl:g,authorizationCode:t});if(v==="AUTHORIZED")if(console.log(`${o} Authorization successful via SDK auth().`),c.flowType==="redirect"&&c.returnUrl)console.log(`${o} Redirect flow complete. Returning to: ${c.returnUrl}`),localStorage.removeItem(d),window.location.href=c.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${o} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(d),window.close();else{console.warn(`${o} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(d);const x=window.location.pathname.split("/").filter(Boolean),w=x.length>0&&x[x.length-1]==="callback"?"/"+x.slice(0,-2).join("/"):"/";window.location.href=w||"/"}else throw console.warn(`${o} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(f){console.error(`${o} Error during OAuth callback handling:`,f);const m=f instanceof Error?f.message:String(f);window.opener&&!window.opener.closed&&window.opener.postMessage({type:"mcp_auth_callback",success:!1,error:m},window.location.origin);try{document.body.innerHTML="";const h=document.createElement("div");h.style.fontFamily="sans-serif",h.style.padding="20px";const g=document.createElement("h1");g.textContent="Authentication Error",h.appendChild(g);const v=document.createElement("p");v.style.color="red",v.style.backgroundColor="#ffebeb",v.style.border="1px solid red",v.style.padding="10px",v.style.borderRadius="4px",v.textContent=m,h.appendChild(v);const E=document.createElement("p");E.textContent="You can close this window or ";const x=document.createElement("a");if(x.href="#",x.textContent="click here to close",x.onclick=w=>(w.preventDefault(),window.close(),!1),E.appendChild(x),E.appendChild(document.createTextNode(".")),h.appendChild(E),f instanceof Error&&f.stack){const w=document.createElement("pre");w.style.fontSize="0.8em",w.style.color="#555",w.style.marginTop="20px",w.style.whiteSpace="pre-wrap",w.textContent=f.stack,h.appendChild(w)}document.body.appendChild(h)}catch(h){console.error(`${o} Could not display error in callback window:`,h)}d&&localStorage.removeItem(d),i&&(localStorage.removeItem(i.getKey("code_verifier")),localStorage.removeItem(i.getKey("last_auth_url")))}}De(J_,"onMcpAuthorization");var h0={exports:{}},Ct={};var $j;function fee(){if($j)return Ct;$j=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),i=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(M){return M===null||typeof M!="object"?null:(M=g&&M[g]||M["@@iterator"],typeof M=="function"?M:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function S(M,B,P){this.props=M,this.context=B,this.refs=w,this.updater=P||E}S.prototype.isReactComponent={},S.prototype.setState=function(M,B){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,B,"setState")},S.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function _(){}_.prototype=S.prototype;function T(M,B,P){this.props=M,this.context=B,this.refs=w,this.updater=P||E}var R=T.prototype=new _;R.constructor=T,x(R,S.prototype),R.isPureReactComponent=!0;var C=Array.isArray;function A(){}var I={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function U(M,B,P){var D=P.ref;return{$$typeof:e,type:M,key:B,ref:D!==void 0?D:null,props:P}}function L(M,B){return U(M.type,B,M.props)}function $(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function H(M){var B={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(P){return B[P]})}var Y=/\/+/g;function q(M,B){return typeof M=="object"&&M!==null&&M.key!=null?H(""+M.key):B.toString(36)}function ne(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(A,A):(M.status="pending",M.then(function(B){M.status==="pending"&&(M.status="fulfilled",M.value=B)},function(B){M.status==="pending"&&(M.status="rejected",M.reason=B)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function G(M,B,P,D,j){var V=typeof M;(V==="undefined"||V==="boolean")&&(M=null);var W=!1;if(M===null)W=!0;else switch(V){case"bigint":case"string":case"number":W=!0;break;case"object":switch(M.$$typeof){case e:case t:W=!0;break;case m:return W=M._init,G(W(M._payload),B,P,D,j)}}if(W)return j=j(M),W=D===""?"."+q(M,0):D,C(j)?(P="",W!=null&&(P=W.replace(Y,"$&/")+"/"),G(j,B,P,"",function(fe){return fe})):j!=null&&($(j)&&(j=L(j,P+(j.key==null||M&&M.key===j.key?"":(""+j.key).replace(Y,"$&/")+"/")+W)),B.push(j)),1;W=0;var te=D===""?".":D+":";if(C(M))for(var de=0;de<M.length;de++)D=M[de],V=te+q(D,de),W+=G(D,B,P,V,j);else if(de=v(M),typeof de=="function")for(M=de.call(M),de=0;!(D=M.next()).done;)D=D.value,V=te+q(D,de++),W+=G(D,B,P,V,j);else if(V==="object"){if(typeof M.then=="function")return G(ne(M),B,P,D,j);throw B=String(M),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return W}function K(M,B,P){if(M==null)return M;var D=[],j=0;return G(M,D,"","",function(V){return B.call(P,V,j++)}),D}function F(M){if(M._status===-1){var B=M._result;B=B(),B.then(function(P){(M._status===0||M._status===-1)&&(M._status=1,M._result=P)},function(P){(M._status===0||M._status===-1)&&(M._status=2,M._result=P)}),M._status===-1&&(M._status=0,M._result=B)}if(M._status===1)return M._result.default;throw M._result}var re=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var B=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ee={map:K,forEach:function(M,B,P){K(M,function(){B.apply(this,arguments)},P)},count:function(M){var B=0;return K(M,function(){B++}),B},toArray:function(M){return K(M,function(B){return B})||[]},only:function(M){if(!$(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ct.Activity=h,Ct.Children=ee,Ct.Component=S,Ct.Fragment=n,Ct.Profiler=a,Ct.PureComponent=T,Ct.StrictMode=r,Ct.Suspense=d,Ct.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,Ct.__COMPILER_RUNTIME={__proto__:null,c:function(M){return I.H.useMemoCache(M)}},Ct.cache=function(M){return function(){return M.apply(null,arguments)}},Ct.cacheSignal=function(){return null},Ct.cloneElement=function(M,B,P){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var D=x({},M.props),j=M.key;if(B!=null)for(V in B.key!==void 0&&(j=""+B.key),B)!O.call(B,V)||V==="key"||V==="__self"||V==="__source"||V==="ref"&&B.ref===void 0||(D[V]=B[V]);var V=arguments.length-2;if(V===1)D.children=P;else if(1<V){for(var W=Array(V),te=0;te<V;te++)W[te]=arguments[te+2];D.children=W}return U(M.type,j,D)},Ct.createContext=function(M){return M={$$typeof:i,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:o,_context:M},M},Ct.createElement=function(M,B,P){var D,j={},V=null;if(B!=null)for(D in B.key!==void 0&&(V=""+B.key),B)O.call(B,D)&&D!=="key"&&D!=="__self"&&D!=="__source"&&(j[D]=B[D]);var W=arguments.length-2;if(W===1)j.children=P;else if(1<W){for(var te=Array(W),de=0;de<W;de++)te[de]=arguments[de+2];j.children=te}if(M&&M.defaultProps)for(D in W=M.defaultProps,W)j[D]===void 0&&(j[D]=W[D]);return U(M,V,j)},Ct.createRef=function(){return{current:null}},Ct.forwardRef=function(M){return{$$typeof:c,render:M}},Ct.isValidElement=$,Ct.lazy=function(M){return{$$typeof:m,_payload:{_status:-1,_result:M},_init:F}},Ct.memo=function(M,B){return{$$typeof:f,type:M,compare:B===void 0?null:B}},Ct.startTransition=function(M){var B=I.T,P={};I.T=P;try{var D=M(),j=I.S;j!==null&&j(P,D),typeof D=="object"&&D!==null&&typeof D.then=="function"&&D.then(A,re)}catch(V){re(V)}finally{B!==null&&P.types!==null&&(B.types=P.types),I.T=B}},Ct.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},Ct.use=function(M){return I.H.use(M)},Ct.useActionState=function(M,B,P){return I.H.useActionState(M,B,P)},Ct.useCallback=function(M,B){return I.H.useCallback(M,B)},Ct.useContext=function(M){return I.H.useContext(M)},Ct.useDebugValue=function(){},Ct.useDeferredValue=function(M,B){return I.H.useDeferredValue(M,B)},Ct.useEffect=function(M,B){return I.H.useEffect(M,B)},Ct.useEffectEvent=function(M){return I.H.useEffectEvent(M)},Ct.useId=function(){return I.H.useId()},Ct.useImperativeHandle=function(M,B,P){return I.H.useImperativeHandle(M,B,P)},Ct.useInsertionEffect=function(M,B){return I.H.useInsertionEffect(M,B)},Ct.useLayoutEffect=function(M,B){return I.H.useLayoutEffect(M,B)},Ct.useMemo=function(M,B){return I.H.useMemo(M,B)},Ct.useOptimistic=function(M,B){return I.H.useOptimistic(M,B)},Ct.useReducer=function(M,B,P){return I.H.useReducer(M,B,P)},Ct.useRef=function(M){return I.H.useRef(M)},Ct.useState=function(M){return I.H.useState(M)},Ct.useSyncExternalStore=function(M,B,P){return I.H.useSyncExternalStore(M,B,P)},Ct.useTransition=function(){return I.H.useTransition()},Ct.version="19.2.3",Ct}var Uj;function Q_(){return Uj||(Uj=1,h0.exports=fee()),h0.exports}var y=Q_();const ie=Yp(y),pd=E7({__proto__:null,default:ie},[y]);function HE(e,t){if(!e)throw new Error(t)}De(HE,"assert");var zj=3e3,pee=5e3;function o4(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}De(o4,"deriveClientConfigFromClientInfo");function i4(e){const n=(e instanceof Error?e.message:String(e)).toLowerCase();return n.includes("oauth discovery failed")||n.includes("oauth-authorization-server")||n.includes("not valid json")||n.includes("404")&&(n.includes("openid-configuration")||n.includes("oauth-protected-resources")||n.includes("oauth-authorization-url")||n.includes("register"))||n.includes("invalid oauth error response")&&n.includes("not found")}De(i4,"isOAuthDiscoveryFailure");function eT(e){const{url:t,enabled:n=!0,callbackUrl:r=typeof window<"u"?nu(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:a="mcp:auth",clientConfig:o={},headers:i,customHeaders:c,proxyConfig:d,autoProxyFallback:f=!0,debug:m=!1,autoRetry:h=!1,autoReconnect:g=zj,transportType:v="auto",preventAutoAuth:E=!1,useRedirectFlow:x=!1,onPopupWindow:w,timeout:S=3e4,sseReadTimeout:_=3e5,wrapTransport:T,onNotification:R,onSampling:C,samplingCallback:A,onElicitation:I}=e,O=i??c??{};c&&!i&&console.warn('[useMcp] The "customHeaders" option is deprecated. Use "headers" instead.');const U=C??A;A&&!C&&console.warn('[useMcp] The "samplingCallback" option is deprecated. Use "onSampling" instead.');const L=y.useMemo(()=>({name:"mcp-use",title:"mcp-use",version:Ny(),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"}),[]),$=y.useMemo(()=>e.clientInfo?{...L,...e.clientInfo}:L,[e.clientInfo,L]),H=y.useMemo(()=>o4($),[$]),Y=y.useMemo(()=>o&&Object.keys(o).length>0?(console.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."),{...H,...o}):H,[o,H]),q=y.useMemo(()=>f?typeof f=="boolean"?{enabled:f,proxyAddress:"https://inspector.mcp-use.com/inspector/api/proxy"}:{enabled:f.enabled!==!1,proxyAddress:f.proxyAddress||"https://inspector.mcp-use.com/inspector/api/proxy"}:{enabled:!1,proxyAddress:void 0},[f]),ne=y.useRef(!1),[G,K]=y.useState(d),{gatewayUrl:F,proxyHeaders:re}=y.useMemo(()=>{const je=b_(t||"",G);return{gatewayUrl:G?.proxyAddress,proxyHeaders:je.headers}},[t,G]),ee=y.useMemo(()=>t||"",[t]),M=y.useMemo(()=>({...re,...O}),[re,O]),[B,P]=y.useState("discovering"),[D,j]=y.useState([]),[V,W]=y.useState([]),[te,de]=y.useState([]),[fe,J]=y.useState([]),[Q,se]=y.useState(),[pe,he]=y.useState(),[Ne,He]=y.useState(void 0),[$e,Pe]=y.useState([]),[ot,Me]=y.useState(void 0),[Je,We]=y.useState(void 0),we=y.useRef(null),Ee=y.useRef(null),oe=y.useRef(null),Se=y.useRef(!1),Re=y.useRef(!0),Ve=y.useRef(0),ct=y.useRef(null),vt=y.useRef(!1),Ge=y.useRef(B),wn=y.useRef(g),pn=y.useRef(null),Fe=y.useRef(null),Ue=y.useRef(null);y.useEffect(()=>{Ge.current=B,wn.current=g},[B,g]);const ce=y.useCallback((je,Be,...Ye)=>{const Qe=Ye.length>0?`${Be} ${Ye.map(gt=>JSON.stringify(gt)).join(" ")}`:Be;console[je](`[useMcp] ${Qe}`),Re.current&&Pe(gt=>[...gt.slice(-100),{level:je,message:Qe,timestamp:Date.now()}])},[]),wt=y.useCallback(async(je=!1)=>{if(je||ce("info","Disconnecting..."),Se.current=!1,ct.current&&clearTimeout(ct.current),ct.current=null,we.current)try{const Be="inspector-server",Ye=we.current.getSession(Be);Ye&&Ye._healthCheckCleanup&&(Ye._healthCheckCleanup(),Ye._healthCheckCleanup=null),Ye&&await we.current.closeSession(Be)}catch(Be){je||ce("warn","Error closing session:",Be)}we.current=null,Re.current&&!je&&(P("discovering"),j([]),W([]),de([]),J([]),He(void 0),Me(void 0))},[ce]),ht=y.useCallback((je,Be)=>{ce("error",je,Be??"");const Ye=Be&&"code"in Be?Be.code:void 0,Qe=q.enabled&&!G?.proxyAddress,gt=je.includes("CORS")||je.includes("blocked by CORS policy")||je.includes("Failed to fetch"),an=Ye===400,xt=typeof Ye=="number"&&Ye>=404&&Ye<500;if(Qe&&(gt||an||xt)&&!(Ye===401||Ye===403))return ce("info",`Direct connection failed with ${gt?"CORS error":an?"HTTP 400 (Bad Request)":"HTTP 4xx error"}. Trying with proxy...`),we.current=null,Ee.current=null,ce("debug","Cleared client and auth provider for proxy fallback"),K({proxyAddress:q.proxyAddress}),Re.current&&P("discovering"),setTimeout(()=>{Re.current&&Fe.current?.()},1e3),!0;if(Re.current){console.log("[useMcp] Setting state to FAILED:",je),P("failed"),He(je);const _t=Ee.current?.getLastAttemptedAuthUrl();_t&&(Me(_t),ce("info","Manual authentication URL may be available.",_t))}return Se.current=!1,t&&Bs.getInstance().trackUseMcpConnection({url:t,transportType:v,success:!1,errorType:Be?.name||"UnknownError",hasOAuth:!!Ee.current,hasSampling:!!U,hasElicitation:!!I}).catch(()=>{}),!1},[ce,t,v,U,I,q,G]),Dt=y.useCallback(async()=>{if(!n||!t){ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(Se.current){ce("debug","Connection attempt already in progress.");return}if(!Re.current){ce("debug","Connect called after unmount, aborting.");return}if(Se.current=!0,Ve.current+=1,He(void 0),Me(void 0),pn.current=null,P("discovering"),ce("info",`Connecting attempt #${Ve.current} to ${t}...`),!Ee.current){let Ye;if(F){const Qe=new URL(F),gt=Qe.pathname.replace(/\/proxy\/?$/,"");Ye=`${Qe.origin}${gt}/oauth`,ce("debug",`OAuth proxy URL derived from gateway: ${Ye}`)}Ee.current=new ob(ee,{storageKeyPrefix:a,clientName:Y.name,clientUri:Y.uri,logoUri:Y.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:E,useRedirectFlow:x,oauthProxyUrl:Ye,onPopupWindow:w}),ce("debug",`BrowserOAuthClientProvider initialized with URL: ${ee}, proxy: ${Ye?"enabled":"disabled"}, gateway: ${F?"enabled":"disabled"}`),Ye&&(Ee.current.installFetchInterceptor(),ce("debug","Installed OAuth fetch interceptor"))}we.current?ce("debug","BrowserMCPClient already exists, reusing."):(we.current=new dee,ce("debug","BrowserMCPClient initialized in connect."));const je=De(async(Ye,Qe=!1)=>{if(!Re.current)return ce("debug","Connection attempt aborted - component unmounted"),"failed";ce("info",`Attempting connection with transport: ${Ye}`),ce("debug",`Client ref status at start of tryConnectWithTransport: ${we.current?"initialized":"NULL"}`);try{const gt="inspector-server",an={url:t,transport:Ye==="sse"?"http":Ye,disableSseFallback:v==="http",preferSse:Ye==="sse",clientInfo:$};if(F&&(an.gatewayUrl=F,console.log(`[useMcp] Using proxy gateway: ${F} for target: ${t}`)),M&&Object.keys(M).length>0&&(an.headers=M),Ee.current){const Ze=await Ee.current.tokens();if(!Re.current)return ce("debug","Connection aborted after token fetch - component unmounted"),"failed";Ze?.access_token&&(an.headers={...an.headers,Authorization:`Bearer ${Ze.access_token}`})}if(!we.current){if(!Re.current)return ce("debug","Connection aborted - component unmounted, client cleaned up"),"failed";const Ze=new Error("Client not initialized - this is a bug in the connection flow");throw ce("error","Client ref is null in tryConnectWithTransport but component is still mounted"),Ze}we.current.addServer(gt,{...an,authProvider:Ee.current,clientOptions:Y,onSampling:U,samplingCallback:U,elicitationCallback:I,wrapTransport:T?Ze=>(console.log("[useMcp] Applying transport wrapper for server:",gt,"url:",t),T(Ze,t)):void 0});const xt=await we.current.createSession(gt,!1);if(!Re.current)return ce("debug","Connection aborted after session creation - component unmounted"),"failed";if(xt.on("notification",Ze=>{R?.(Ze),Ze.method==="notifications/tools/list_changed"?(ce("info","Tools list changed, auto-refreshing..."),Jn().catch(tt=>ce("warn","Auto-refresh tools failed:",tt))):Ze.method==="notifications/resources/list_changed"?(ce("info","Resources list changed, auto-refreshing..."),rn().catch(tt=>ce("warn","Auto-refresh resources failed:",tt))):Ze.method==="notifications/prompts/list_changed"&&(ce("info","Prompts list changed, auto-refreshing..."),Ln().catch(tt=>ce("warn","Auto-refresh prompts failed:",tt)))}),await xt.initialize(),!Re.current)return ce("debug","Connection completed but component unmounted, aborting"),"failed";if(ce("info","✅ Successfully connected to MCP server"),ce("info","Server info:",xt.connector.serverInfo),ce("info","Server capabilities:",xt.connector.serverCapabilities),console.log("[useMcp] Server info:",xt.connector.serverInfo),console.log("[useMcp] Server capabilities:",xt.connector.serverCapabilities),!Re.current)return ce("debug","Skipping state update - component unmounted"),"failed";P("ready"),pn.current=Ye;const Wn=De(()=>{let Ze=null,tt=Date.now();const Lt=1e4,Un=3e4;return Ze=setInterval(De(async()=>{if(!Re.current||Ge.current!=="ready"){Ze&&(clearInterval(Ze),Ze=null);return}try{await xt.connector.listTools(),tt=Date.now()}catch{const kt=Date.now()-tt;kt>Un&&(ce("warn",`Connection appears to be broken (no response for ${Math.round(kt/1e3)}s), attempting to reconnect...`),Ze&&(clearInterval(Ze),Ze=null),wn.current&&Re.current&&(P("discovering"),ce("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{Re.current&&Ge.current==="discovering"&&Dt()},typeof wn.current=="number"?wn.current:zj)))}},"checkConnectionHealth"),Lt),()=>{Ze&&(clearInterval(Ze),Ze=null)}},"setupConnectionMonitoring");if(g){const Ze=Wn();xt._healthCheckCleanup=Ze}Bs.getInstance().trackUseMcpConnection({url:t,transportType:Ye,success:!0,hasOAuth:!!Ee.current,hasSampling:!!U,hasElicitation:!!I}).catch(()=>{}),j(xt.connector.tools||[]);const Ia=await xt.connector.listAllResources();if(!Re.current)return ce("debug","Connection aborted after listing resources - component unmounted"),"failed";W(Ia.resources||[]);const _t=await xt.connector.listPrompts();if(!Re.current)return ce("debug","Connection aborted after listing prompts - component unmounted"),"failed";J(_t.prompts||[]);const Bt=xt.connector.serverInfo,Kt=xt.connector.serverCapabilities;if(Bt){if(console.log("[useMcp] Server info:",Bt),!Re.current)return ce("debug","Skipping state update - component unmounted"),"failed";se(Bt);const Ze=(async()=>{try{const tt=Bt.icons;if(tt&&Array.isArray(tt)&&tt.length>0){const Lt=tt[0].src||tt[0].url;if(Lt){ce("info","Server provided icon:",Lt);const ft=await(await fetch(Lt)).blob(),Cr=await new Promise((kt,Rn)=>{const cn=new FileReader;cn.onloadend=()=>kt(cn.result),cn.onerror=Rn,cn.readAsDataURL(ft)});return Re.current&&(se(kt=>kt?{...kt,icon:Cr}:void 0),ce("debug","Server icon converted to base64")),Cr}}if(t){const Lt=await Yz(t);if(!Re.current)return ce("debug","Connection aborted after favicon detection - component unmounted"),null;if(Lt)return se(Un=>Un?{...Un,icon:Lt}:void 0),ce("debug","Favicon detected and added to serverInfo"),Lt}return null}catch(tt){return ce("debug","Icon loading failed (non-critical):",tt),null}})();oe.current=Ze}if(Kt){if(console.log("[useMcp] Server capabilities:",Kt),!Re.current)return ce("debug","Skipping state update - component unmounted"),"failed";he(Kt)}if(Ee.current){const Ze=await Ee.current.tokens();if(!Re.current)return ce("debug","Connection aborted after token fetch for auth tokens - component unmounted"),"failed";if(Ze?.access_token){const tt=Ze.expires_in?Date.now()+Ze.expires_in*1e3:void 0;if(!Re.current)return ce("debug","Skipping state update - component unmounted"),"failed";We({access_token:Ze.access_token,token_type:Ze.token_type||"Bearer",expires_at:tt,refresh_token:Ze.refresh_token,scope:Ze.scope})}}return"success"}catch(gt){const an=gt,xt=an?.message||String(gt),Wn=i4(gt),Ia=an.code===401||xt.includes("401")||xt.includes("Unauthorized");if(Wn&&O&&Object.keys(O).length>0)return ht("Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct."),"failed";if(Ia){if(Wn)return ht("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed";if(Ee.current){ce("info","Authentication required. OAuth provider available.");try{const{auth:Bt}=await pa(async()=>{const{auth:Ze}=await Promise.resolve().then(()=>Dj);return{auth:Ze}},void 0),Kt=new URL(t).origin;Bt(Ee.current,{serverUrl:Kt}).catch(()=>{}),setTimeout(()=>{if(Re.current){const Ze=Ee.current?.getLastAttemptedAuthUrl();Ze?(Me(Ze),ce("info","Manual authentication URL available:",Ze)):ce("warn","Could not generate authentication URL")}},100)}catch(Bt){ce("warn","Error generating auth URL:",Bt)}return Re.current&&P("pending_auth"),Se.current=!1,"auth_redirect"}return O&&Object.keys(O).length>0?(ht("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(ht("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return ht(xt,an instanceof Error?an:new Error(String(an)))?"auth_redirect":"failed"}},"tryConnectWithTransport");let Be="failed";if(v==="sse")ce("debug","Using SSE-only transport mode"),Be=await je("sse");else if(v==="http")ce("debug","Using HTTP-only transport mode"),Be=await je("http");else{ce("debug","Using auto transport mode (HTTP with SSE fallback)");const Ye=await je("http");Ye==="fallback"&&Re.current&&Ge.current!=="authenticating"?(ce("info","HTTP failed, attempting SSE fallback..."),Be=await je("sse")):Be=Ye}(Be==="success"||Be==="failed"||Be==="auth_redirect")&&(Se.current=!1),ce("debug",`Connection sequence finished with status: ${Be}`)},[ce,ht,wt,t,a,r,Y.name,Y.version,Y.uri,Y.logo_uri,O,v,E,x,w,n,S,_,$,F,M,ee]);y.useEffect(()=>{Fe.current=Dt,Ue.current=ht},[Dt,ht]);const Nt=y.useCallback(async(je,Be,Ye)=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot call tool "${je}".`);ce("info",`Calling tool: ${je}`,Be);const Qe=Date.now();try{const an=we.current.getSession("inspector-server");if(!an)throw new Error("No active session found");const xt=await an.connector.callTool(je,Be||{},Ye);return ce("info",`Tool "${je}" call successful:`,xt),Bs.getInstance().trackUseMcpToolCall({toolName:je,success:!0,executionTimeMs:Date.now()-Qe}).catch(()=>{}),xt}catch(gt){throw ce("error",`Tool "${je}" call failed:`,gt),Bs.getInstance().trackUseMcpToolCall({toolName:je,success:!1,errorType:gt instanceof Error?gt.name:"UnknownError",executionTimeMs:Date.now()-Qe}).catch(()=>{}),gt}},[B]),Wt=y.useCallback(()=>{Ge.current==="failed"?(ce("info","Retry requested..."),Fe.current?.()):ce("warn",`Retry called but state is not 'failed' (state: ${Ge.current}). Ignoring.`)},[ce]),bn=y.useCallback(async()=>{ce("info","Manual authentication requested...");const je=Ge.current;if(je==="failed")ce("info","Attempting to reconnect and authenticate via retry..."),Wt();else if(je==="pending_auth"){ce("info","Proceeding with authentication from pending state...");try{HE(Ee.current,"Auth Provider not available for manual auth"),HE(t,"Server URL is required for authentication"),ce("info","Clearing all OAuth state and initiating fresh flow...");const Be=`${a}:${Ee.current.serverUrlHash}`;Object.keys(localStorage).forEach(xt=>{xt.startsWith(Be)&&(ce("debug",`Removing stale OAuth key: ${xt}`),localStorage.removeItem(xt)),xt.startsWith(`${a}:state_`)&&(ce("debug",`Removing orphaned state: ${xt}`),localStorage.removeItem(xt))}),P("authenticating");let Ye;if(F){const xt=new URL(F),Wn=xt.pathname.replace(/\/proxy\/?$/,"");Ye=`${xt.origin}${Wn}/oauth`}const Qe=new ob(ee,{storageKeyPrefix:a,clientName:Y.name,clientUri:Y.uri,logoUri:Y.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:x,oauthProxyUrl:Ye,onPopupWindow:w});Ye&&!F?(Qe.installFetchInterceptor(),ce("info","Installed OAuth fetch interceptor for manual auth")):Ye&&F&&ce("info","Using MCP gateway proxy for OAuth (no fetch interceptor needed)"),Ee.current=Qe,ce("info","Triggering fresh OAuth authorization...");const{auth:gt}=await pa(async()=>{const{auth:xt}=await Promise.resolve().then(()=>Dj);return{auth:xt}},void 0),an=new URL(t).origin;gt(Qe,{serverUrl:an}).catch(xt=>{ce("info","OAuth flow initiated:",xt instanceof Error?xt.message:"Redirecting...")})}catch(Be){if(!Re.current)return;P("pending_auth"),ce("error",`Manual authentication failed: ${Be instanceof Error?Be.message:String(Be)}`)}}else if(je==="authenticating"){ce("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Be=Ee.current?.getLastAttemptedAuthUrl();Be&&!ot&&(Me(Be),ce("info","Manual authentication URL retrieved:",Be))}else ce("info",`Client not in a state requiring manual authentication trigger (state: ${je}). If needed, try disconnecting and reconnecting.`)},[ce,Wt,ot,t,x,w,a,Y.name,Y.uri,Y.logo_uri,r,$]),et=y.useCallback(()=>{if(Ee.current){const je=Ee.current.clearStorage();ce("info",`Cleared ${je} item(s) from localStorage for ${t}.`),Me(void 0),wt()}else ce("warn","Auth provider not initialized, cannot clear storage.")},[t,ce,wt]),Tt=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot list resources.`);ce("info","Listing resources");try{const Be=we.current.getSession("inspector-server");if(!Be)throw new Error("No active session found");const Ye=await Be.connector.listAllResources();W(Ye.resources||[]),ce("info","Resources listed successfully")}catch(je){throw ce("error","List resources failed:",je),je}},[B]),Ut=y.useCallback(async je=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot read resource.`);ce("info",`Reading resource: ${je}`);try{const Ye=we.current.getSession("inspector-server");if(!Ye)throw new Error("No active session found");const Qe=await Ye.connector.readResource(je);return ce("info","Resource read successful:",Qe),Bs.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!0}).catch(()=>{}),Qe}catch(Be){throw ce("error","Resource read failed:",Be),Bs.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!1,errorType:Be instanceof Error?Be.name:"UnknownError"}).catch(()=>{}),Be}},[B]),zt=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot list prompts.`);ce("info","Listing prompts");try{const Be=we.current.getSession("inspector-server");if(!Be)throw new Error("No active session found");const Ye=await Be.connector.listPrompts();J(Ye.prompts||[]),ce("info","Prompts listed successfully")}catch(je){throw ce("error","List prompts failed:",je),je}},[B]),Jn=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current){ce("debug","Cannot refresh tools - client not ready");return}ce("debug","Refreshing tools list");try{const Be=we.current.getSession("inspector-server");if(!Be){ce("warn","No active session found for tools refresh");return}const Ye=await Be.connector.listTools();j(Ye||[]),ce("info","Tools list refreshed successfully")}catch(je){ce("warn","Failed to refresh tools:",je)}},[ce]),rn=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current){ce("debug","Cannot refresh resources - client not ready");return}ce("debug","Refreshing resources list");try{const Be=we.current.getSession("inspector-server");if(!Be){ce("warn","No active session found for resources refresh");return}const Ye=await Be.connector.listAllResources();W(Ye.resources||[]),ce("info","Resources list refreshed successfully")}catch(je){ce("warn","Failed to refresh resources:",je)}},[ce]),Ln=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current){ce("debug","Cannot refresh prompts - client not ready");return}ce("debug","Refreshing prompts list");try{const Be=we.current.getSession("inspector-server");if(!Be){ce("warn","No active session found for prompts refresh");return}const Ye=await Be.connector.listPrompts();J(Ye.prompts||[]),ce("info","Prompts list refreshed successfully")}catch(je){ce("warn","Failed to refresh prompts:",je)}},[ce]),Qn=y.useCallback(async()=>{ce("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([Jn(),rn(),Ln()])},[Jn,rn,Ln,ce]),xn=y.useCallback(async(je,Be)=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot get prompt.`);ce("info",`Getting prompt: ${je}`,Be);try{const Qe=we.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const gt=await Qe.connector.getPrompt(je,Be||{});return ce("info",`Prompt "${je}" retrieved successfully:`,gt),gt}catch(Ye){throw ce("error",`Prompt "${je}" retrieval failed:`,Ye),Ye}},[B]);y.useEffect(()=>{const je=De(Be=>{Be.origin===window.location.origin&&Be.data?.type==="mcp_auth_callback"&&(ce("info","Received auth callback message.",Be.data),ct.current&&clearTimeout(ct.current),ct.current=null,Be.data.success?(ce("info","Authentication successful via popup. Reconnecting client..."),Se.current&&ce("debug","Connection attempt already in progress, resetting flag to allow reconnection."),Se.current=!1,setTimeout(()=>{Re.current&&(ce("debug","Initiating reconnection after successful auth callback."),Fe.current?.())},100)):Ue.current?.(`Authentication failed in callback: ${Be.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",je),ce("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",je),ce("debug","Auth callback message listener removed."),ct.current&&clearTimeout(ct.current)}},[ce]),y.useEffect(()=>{ne.current=!1,K(d)},[t,d]),y.useEffect(()=>{if(Re.current=!0,!n||!t)return ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),P("discovering"),()=>{Re.current=!1};if(ce("debug","useMcp mounted, initiating connection."),Ve.current=0,!Ee.current||Ee.current.serverUrl!==ee){let je;if(F){const Be=new URL(F),Ye=Be.pathname.replace(/\/proxy\/?$/,"");je=`${Be.origin}${Ye}/oauth`,ce("debug",`OAuth proxy URL derived from gateway: ${je}`)}Ee.current=new ob(ee,{storageKeyPrefix:a,clientName:Y.name,clientUri:Y.uri,logoUri:Y.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:E,useRedirectFlow:x,oauthProxyUrl:je,onPopupWindow:w}),ce("debug",`BrowserOAuthClientProvider initialized/updated with URL: ${ee}, proxy: ${je?"enabled":"disabled"}, gateway: ${F?"enabled":"disabled"}`),je&&(Ee.current.installFetchInterceptor(),ce("debug","Installed OAuth fetch interceptor"))}return Dt(),()=>{if(Re.current=!1,ce("debug","useMcp unmounting, disconnecting."),(Ge.current==="authenticating"||Ge.current==="pending_auth")&&Ee.current)try{const je=Ee.current.clearStorage();je>0&&ce("debug",`Cleared ${je} OAuth state item(s) during unmount to prevent corruption`)}catch(je){ce("debug","Error clearing OAuth state during unmount:",je)}wt(!0)}},[t,n,a,r,Y.name,Y.version,Y.uri,Y.logo_uri,x,$,ee]);const fn=y.useRef(Wt),Mr=y.useRef(ce);y.useEffect(()=>{fn.current=Wt,Mr.current=ce},[Wt,ce]),y.useEffect(()=>{let je=null;if(B==="failed"&&h&&Ve.current>0){if(!vt.current){vt.current=!0;const Be=typeof h=="number"?h:pee;Mr.current("info",`Connection failed, auto-retrying in ${Be}ms...`),je=setTimeout(()=>{vt.current=!1,Re.current&&Ge.current==="failed"&&fn.current()},Be)}}else B!=="failed"&&(vt.current=!1);return()=>{je&&(clearTimeout(je),vt.current=!1)}},[B,h]);const Qt=y.useCallback(async()=>Ge.current!=="ready"?(ce("warn","Cannot ensure icon loaded - not connected"),null):Q?.icon?Q.icon:oe.current?(ce("debug","Waiting for icon to finish loading..."),await oe.current):(ce("debug","No icon available and no loading in progress"),null),[Q,ce]);return{state:B,name:Q?.name||t||"",tools:D,resources:V,resourceTemplates:te,prompts:fe,serverInfo:Q,capabilities:pe,error:Ne,log:$e,authUrl:ot,authTokens:Je,client:we.current,callTool:Nt,readResource:Ut,listResources:Tt,listPrompts:zt,getPrompt:xn,refreshTools:Jn,refreshResources:rn,refreshPrompts:Ln,refreshAll:Qn,retry:Wt,disconnect:wt,authenticate:bn,clearStorage:et,ensureIconLoaded:Qt}}De(eT,"useMcp");var Vu,mee=(Vu=class extends ie.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Widget Error:",t,n)}render(){return this.state.hasError?ie.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"},ie.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),ie.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},De(Vu,"ErrorBoundary"),Vu),Jf="openai:set_globals";function bs(e){return y.useSyncExternalStore(t=>{const n=De(r=>{r.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(Jf,n),()=>{typeof window<"u"&&window.removeEventListener(Jf,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}De(bs,"useOpenAiGlobal");function md(e){const[t,n]=y.useState(()=>typeof window<"u"&&!!window.openai);y.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const L=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},100),$=De(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(Jf,$);const H=setTimeout(()=>{clearInterval(L),typeof window<"u"&&window.removeEventListener(Jf,$)},5e3);return()=>{clearInterval(L),clearTimeout(H),typeof window<"u"&&window.removeEventListener(Jf,$)}},[]);const r=y.useMemo(()=>t?"openai":"mcp-ui",[t]),a=typeof window<"u"?window.location.search:"",o=y.useMemo(()=>{const L=new URLSearchParams(a);return L.has("mcpUseParams")?JSON.parse(L.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[a]),i=r==="openai"?bs("toolInput"):o.toolInput,c=r==="openai"?bs("toolOutput"):o.toolOutput,d=bs("toolResponseMetadata"),f=y.useMemo(()=>{if(d&&typeof d=="object"){const L=d["mcp-use/props"];if(L)return L}return e||{}},[d,e]),m=bs("widgetState"),h=bs("theme"),g=bs("displayMode"),v=bs("safeArea"),E=bs("maxHeight"),x=bs("userAgent"),w=bs("locale"),S=y.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,T]=y.useState(null);y.useEffect(()=>{m!==void 0&&T(m)},[m]);const R=y.useCallback(async(L,$)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(L,$)},[]),C=y.useCallback(async L=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:L})},[]),A=y.useCallback(L=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:L})},[]),I=y.useCallback(async L=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:L})},[]),O=y.useCallback(async L=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const H=typeof L=="function"?L(m!==void 0?m:_):L;return T(H),window.openai.setWidgetState(H)},[m,_]),U=y.useMemo(()=>r==="openai"&&d===null,[r,d]);return{props:f,toolInput:i||{},output:c??null,metadata:d??null,state:_,setState:O,theme:h||"light",displayMode:g||"inline",safeArea:v||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:E||600,userAgent:x||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:w||"en",mcp_url:S,callTool:R,sendFollowUpMessage:C,openExternal:A,requestDisplayMode:I,isAvailable:t,isPending:U}}De(md,"useWidget");function hee(e){const{props:t}=md(e);return t}De(hee,"useWidgetProps");function gee(){const{theme:e}=md();return e}De(gee,"useWidgetTheme");function bee(e){const{state:t,setState:n}=md();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}De(bee,"useWidgetState");var Fj=De(({children:e})=>{const{theme:t,isAvailable:n}=md();console.log("theme",t);const[r,a]=y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");y.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),c=De(d=>{a(d.matches?"dark":"light")},"handleChange");return i.addEventListener("change",c),()=>i.removeEventListener("change",c)},[]);const o=n?t:r;return y.useLayoutEffect(()=>{typeof document>"u"||(o==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[o]),ie.createElement(ie.Fragment,null,e)},"ThemeProvider");function l4({children:e,className:t="",position:n="top-right",attachTo:r,showLabels:a=!0,debugger:o=!1,viewControls:i=!1}){const{props:c,output:d,metadata:f,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:E,userAgent:x,locale:w,isAvailable:S,callTool:_,sendFollowUpMessage:T,openExternal:R,requestDisplayMode:C,setState:A}=md(),[I,O]=y.useState(!1),[U,L]=y.useState(!1),$=y.useRef(null),H=y.useRef(null),[Y,q]=y.useState([]),[ne,G]=y.useState(""),[K,F]=y.useState("get-my-city"),[re,ee]=y.useState("{}"),[M,B]=y.useState("Test follow-up message"),[P,D]=y.useState("https://docs.mcp-use.com"),j=g==="fullscreen"&&S,V=g==="pip"&&S,W=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const we=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const Ee=Object.keys(window.openai);q(Ee)}catch{q([])}else q([])},100);return()=>{clearTimeout(we)}},[]);const te=h==="dark",de=De(()=>{const we=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",I?"opacity-100":"opacity-0",I?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...we,"top-4","left-4"];case"top-center":return[...we,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...we,"top-4","right-4"];case"center-left":return[...we,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...we,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...we,"bottom-4","left-4"];case"bottom-center":return[...we,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...we,"bottom-4","right-4"];default:return[...we,"top-4","right-4"]}},"getPositionClasses"),fe=De(()=>{const Ee=v?.insets?.top?Math.max(16,v.insets.top+8):16,oe=v?.insets?.right?Math.max(16,v.insets.right+8):16,Se=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Re=v?.insets?.left?Math.max(16,v.insets.left+8):16,Ve={};switch(n){case"top-left":Ve.top=`${Ee}px`,Ve.left=`${Re}px`;break;case"top-center":Ve.top=`${Ee}px`;break;case"top-right":Ve.top=`${Ee}px`,Ve.right=`${oe}px`;break;case"center-left":Ve.left=`${Re}px`;break;case"center-right":Ve.right=`${oe}px`;break;case"bottom-left":Ve.bottom=`${Se}px`,Ve.left=`${Re}px`;break;case"bottom-center":Ve.bottom=`${Se}px`;break;case"bottom-right":Ve.bottom=`${Se}px`,Ve.right=`${oe}px`;break;default:Ve.top=`${Ee}px`,Ve.right=`${oe}px`;break}return Ve},"getPositionOffsetStyles");y.useEffect(()=>{if(!r)return;const we=De(()=>O(!0),"handleMouseEnter"),Ee=De(()=>O(!1),"handleMouseLeave");return r.addEventListener("mouseenter",we),r.addEventListener("mouseleave",Ee),()=>{r.removeEventListener("mouseenter",we),r.removeEventListener("mouseleave",Ee)}},[r]),y.useEffect(()=>{if(!U)return;const we=De(Ee=>{H.current&&!H.current.contains(Ee.target)&&L(!1)},"handleClickOutside");return document.addEventListener("mousedown",we),()=>{document.removeEventListener("mousedown",we)}},[U]),y.useEffect(()=>(U?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[U]);const J=De(()=>{L(!U)},"handleToggleOverlay"),Q=De(async()=>{try{G("Calling tool...");const we=re.trim()?JSON.parse(re):{},Ee=await _(K,we);G(`Success: ${JSON.stringify(Ee,null,2)}`)}catch(we){G(`Error: ${we.message}`)}},"handleCallTool"),se=De(async()=>{try{G("Sending follow-up message..."),await T(M),G("Follow-up message sent successfully")}catch(we){G(`Error: ${we.message}`)}},"handleSendFollowUpMessage"),pe=De(()=>{try{R(P),G(`Opened external link: ${P}`)}catch(we){G(`Error: ${we.message}`)}},"handleOpenExternal"),he=De(async we=>{try{G(`Requesting display mode: ${we}...`);const Ee=await C(we);G(`Display mode granted: ${Ee.mode}`)}catch(Ee){G(`Error: ${Ee.message}`)}},"handleRequestDisplayMode"),Ne=De(async()=>{try{const we=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};G("Setting state..."),await A(we),G(`State updated: ${JSON.stringify(we,null,2)}`)}catch(we){G(`Error: ${we.message}`)}},"handleSetState"),He=De(async()=>{try{await C("fullscreen")}catch(we){console.error("Failed to go fullscreen:",we)}},"handleFullscreen"),$e=De(async()=>{try{await C("pip")}catch(we){console.error("Failed to go pip:",we)}},"handlePip"),Pe=De(()=>{const we=["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[...we,"top-full","right-0","mt-2"];case"top-left":return[...we,"top-full","left-0","mt-2"];case"top-center":return[...we,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...we,"bottom-full","right-0","mb-2"];case"bottom-left":return[...we,"bottom-full","left-0","mb-2"];case"bottom-center":return[...we,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...we,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...we,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...we,"top-full","right-0","mt-2"]}},"getTooltipClasses"),ot=De(({onClick:we,label:Ee,children:oe})=>{const[Se,Re]=y.useState(!1),Ve=Pe();return ie.createElement("button",{className:`p-2 ${te?"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 ${te?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Re(!0),onMouseLeave:()=>Re(!1),onClick:we,"aria-label":Ee},ie.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"},oe),a&&ie.createElement("span",{className:`${Ve.join(" ")} ${Se?"opacity-100":"opacity-0"}`},Ee))},"IconButton"),Me=De(we=>{if(we===null)return"null";if(we===void 0)return"undefined";if(typeof we=="object")try{return JSON.stringify(we,null,2)}catch{return String(we)}return String(we)},"formatValue"),Je=De(we=>we?`${we.device?.type||"unknown"}`:"N/A","formatUserAgent"),We=De(we=>{if(!we?.insets)return"N/A";const{top:Ee,bottom:oe,left:Se,right:Re}=we.insets;return`T:${Ee} B:${oe} L:${Se} R:${Re}`},"formatSafeArea");return ie.createElement(ie.Fragment,null,ie.createElement("div",{ref:$,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&O(!0),onMouseLeave:()=>!r&&O(!1)},ie.createElement("div",{className:de().join(" "),style:fe()},!W&&ie.createElement(ie.Fragment,null,!j&&!V&&ie.createElement(ie.Fragment,null,(i===!0||i==="fullscreen")&&ie.createElement(ot,{onClick:He,label:"Fullscreen"},ie.createElement("path",{d:"M15 3h6v6"}),ie.createElement("path",{d:"m21 3-7 7"}),ie.createElement("path",{d:"m3 21 7-7"}),ie.createElement("path",{d:"M9 21H3v-6"})),(i===!0||i==="pip")&&ie.createElement(ot,{onClick:$e,label:"Picture in Picture"},ie.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),ie.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),o&&ie.createElement(ot,{onClick:J,label:"Debug Info"},ie.createElement("path",{d:"M12 20v-9"}),ie.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),ie.createElement("path",{d:"M14.12 3.88 16 2"}),ie.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),ie.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),ie.createElement("path",{d:"M22 13h-4"}),ie.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),ie.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),ie.createElement("path",{d:"M6 13H2"}),ie.createElement("path",{d:"m8 2 1.88 1.88"}),ie.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),U&&o&&ie.createElement("div",{ref:H,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:we=>{we.target===H.current&&L(!1)}},ie.createElement("button",{onClick:()=>L(!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"},"×"),ie.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},ie.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),ie.createElement("table",{className:"w-full border-collapse border-spacing-0"},ie.createElement("tbody",null,ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),ie.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Me(c))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),ie.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Me(d))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),ie.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Me(f))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),ie.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Me(m))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),ie.createElement("td",{className:"p-2"},h)),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),ie.createElement("td",{className:"p-2"},g)),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),ie.createElement("td",{className:"p-2"},w)),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),ie.createElement("td",{className:"p-2"},E,"px")),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),ie.createElement("td",{className:"p-2"},Je(x))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),ie.createElement("td",{className:"p-2"},We(v))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),ie.createElement("td",{className:"p-2"},S?"Yes":"No")),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),ie.createElement("td",{className:"p-2"},Y.length>0?Y.join(", "):"N/A")))),ie.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),ie.createElement("div",{className:"flex flex-col gap-3"},ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("input",{type:"text",value:K,onChange:we=>F(we.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]"}),ie.createElement("input",{type:"text",value:re,onChange:we=>ee(we.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"}),ie.createElement("button",{onClick:Q,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("input",{type:"text",value:M,onChange:we=>B(we.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"}),ie.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")),ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("input",{type:"text",value:P,onChange:we=>D(we.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"}),ie.createElement("button",{onClick:pe,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),ie.createElement("button",{onClick:()=>he("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"),ie.createElement("button",{onClick:()=>he("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"),ie.createElement("button",{onClick:()=>he("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")),ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("button",{onClick:Ne,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)")),ne&&ie.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"},ie.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ne,ie.createElement("button",{onClick:()=>G(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}De(l4,"WidgetControls");function c4(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}De(c4,"getBasename");var yee=150,vee=5;function wee({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!1}){const a=c4(),o=y.useRef(null),i=y.useRef(0),c=y.useRef(null),d=y.useRef(!1),[f,m]=y.useState(null),[h,g]=y.useState(null),[v,E]=y.useState(!0);y.useEffect(()=>{let _=!0;return(async()=>{try{const T=await pa(()=>import("./index-BGIedjx0.js"),[]);_&&(m(()=>T.BrowserRouter),E(!1))}catch{_&&(g(new Error(`❌ react-router not installed!
|
|
35
|
+
`&&r++}}return[t,n]}class QQ extends TransformStream{constructor({onError:t,onRetry:n,onComment:r}={}){let a;super({start(o){a=n4({onEvent:i=>{o.enqueue(i)},onError(i){t==="terminate"?o.error(i):typeof t=="function"&&t(i)},onRetry:n,onComment:r})},transform(o){a.feed(o)}})}}const eee={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Ni extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class tee{constructor(t,n){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=BF(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=n?.reconnectionOptions??eee}async _authThenStart(){if(!this._authProvider)throw new rs("No auth provider");let t;try{t=await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new rs;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=jb(this._requestInit?.headers);return new Headers({...t,...n})}async _startOrAuthSse(t){const{resumptionToken:n}=t;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),n&&r.set("last-event-id",n);const a=await(this._fetch??fetch)(this._url,{method:"GET",headers:r,signal:this._abortController?.signal});if(!a.ok){if(await a.body?.cancel(),a.status===401&&this._authProvider)return await this._authThenStart();if(a.status===405)return;throw new Ni(a.status,`Failed to open SSE stream: ${a.statusText}`)}this._handleSseStream(a.body,t,!0)}catch(r){throw this.onerror?.(r),r}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(r,t),a)}_scheduleReconnection(t,n=0){const r=this._reconnectionOptions.maxRetries;if(n>=r){this.onerror?.(new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const a=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(o=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(t,n+1)})},a)}_handleSseStream(t,n,r){if(!t)return;const{onresumptiontoken:a,replayMessageId:o}=n;let i,c=!1,d=!1;(async()=>{try{const m=t.pipeThrough(new TextDecoderStream).pipeThrough(new QQ({onRetry:v=>{this._serverRetryMs=v}})).getReader();for(;;){const{value:v,done:E}=await m.read();if(E)break;if(v.id&&(i=v.id,c=!0,a?.(v.id)),!!v.data&&(!v.event||v.event==="message"))try{const x=nb.parse(JSON.parse(v.data));Uf(x)&&(d=!0,o!==void 0&&(x.id=o)),this.onmessage?.(x)}catch(x){this.onerror?.(x)}}(r||c)&&!d&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:a,replayMessageId:o},0)}catch(m){if(this.onerror?.(new Error(`SSE stream disconnected: ${m}`)),(r||c)&&!d&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:a,replayMessageId:o},0)}catch(v){this.onerror?.(new Error(`Failed to reconnect: ${v instanceof Error?v.message:String(v)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new rs("No auth provider");if(await Ao(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new rs("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,n){try{const{resumptionToken:r,onresumptiontoken:a}=n||{};if(r){this._startOrAuthSse({resumptionToken:r,replayMessageId:EE(t)?t.id:void 0}).catch(g=>this.onerror?.(g));return}const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const i={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(t),signal:this._abortController?.signal},c=await(this._fetch??fetch)(this._url,i),d=c.headers.get("mcp-session-id");if(d&&(this._sessionId=d),!c.ok){const g=await c.text().catch(()=>null);if(c.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Ni(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:v,scope:E}=hp(c);if(this._resourceMetadataUrl=v,this._scope=E,await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new rs;return this._hasCompletedAuthFlow=!0,this.send(t)}if(c.status===403&&this._authProvider){const{resourceMetadataUrl:v,scope:E,error:x}=hp(c);if(x==="insufficient_scope"){const w=c.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===w)throw new Ni(403,"Server returned 403 after trying upscoping");if(E&&(this._scope=E),v&&(this._resourceMetadataUrl=v),this._lastUpscopingHeader=w??void 0,await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new rs;return this.send(t)}}throw new Ni(c.status,`Error POSTing to endpoint: ${g}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,c.status===202){await c.body?.cancel(),Vq(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(g=>this.onerror?.(g));return}const m=(Array.isArray(t)?t:[t]).filter(g=>"method"in g&&"id"in g&&g.id!==void 0).length>0,h=c.headers.get("content-type");if(m)if(h?.includes("text/event-stream"))this._handleSseStream(c.body,{onresumptiontoken:a},!1);else if(h?.includes("application/json")){const g=await c.json(),v=Array.isArray(g)?g.map(E=>nb.parse(E)):[nb.parse(g)];for(const E of v)this.onmessage?.(E)}else throw await c.body?.cancel(),new Ni(-1,`Unexpected content type: ${h}`);else await c.body?.cancel()}catch(r){throw this.onerror?.(r),r}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const t=await this._commonHeaders(),n={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._url,n);if(await r.body?.cancel(),!r.ok&&r.status!==405)throw new Ni(r.status,`Failed to terminate session: ${r.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class Mj extends Event{constructor(t,n){var r,a;super(t),this.code=(r=n?.code)!=null?r:void 0,this.message=(a=n?.message)!=null?a:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(jj(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(jj(this),n)}}function nee(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function ME(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(ME).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${ME(e.cause)}`:e.message:`${e}`}function jj(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var r4=e=>{throw TypeError(e)},X_=(e,t,n)=>t.has(e)||r4("Cannot "+n),Xt=(e,t,n)=>(X_(e,t,"read from private field"),n?n.call(e):t.get(e)),_r=(e,t,n)=>t.has(e)?r4("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Yn=(e,t,n,r)=>(X_(e,t,"write to private field"),t.set(e,n),n),Co=(e,t,n)=>(X_(e,t,"access private method"),n),Na,Nl,Vc,ab,Fb,qf,tu,Xf,Ci,Gc,hu,Wc,zf,ys,jE,PE,$E,Pj,UE,zE,Ff,FE,BE;class sb extends EventTarget{constructor(t,n){var r,a;super(),_r(this,ys),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,_r(this,Na),_r(this,Nl),_r(this,Vc),_r(this,ab),_r(this,Fb),_r(this,qf),_r(this,tu),_r(this,Xf,null),_r(this,Ci),_r(this,Gc),_r(this,hu,null),_r(this,Wc,null),_r(this,zf,null),_r(this,PE,async o=>{var i;Xt(this,Gc).reset();const{body:c,redirected:d,status:f,headers:m}=o;if(f===204){Co(this,ys,Ff).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(d?Yn(this,Vc,new URL(o.url)):Yn(this,Vc,void 0),f!==200){Co(this,ys,Ff).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){Co(this,ys,Ff).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(Xt(this,Na)===this.CLOSED)return;Yn(this,Na,this.OPEN);const h=new Event("open");if((i=Xt(this,zf))==null||i.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){Co(this,ys,Ff).call(this,"Invalid response body, expected a web ReadableStream",f),this.close();return}const g=new TextDecoder,v=c.getReader();let E=!0;do{const{done:x,value:w}=await v.read();w&&Xt(this,Gc).feed(g.decode(w,{stream:!x})),x&&(E=!1,Xt(this,Gc).reset(),Co(this,ys,FE).call(this))}while(E)}),_r(this,$E,o=>{Yn(this,Ci,void 0),!(o.name==="AbortError"||o.type==="aborted")&&Co(this,ys,FE).call(this,ME(o))}),_r(this,UE,o=>{typeof o.id=="string"&&Yn(this,Xf,o.id);const i=new MessageEvent(o.event||"message",{data:o.data,origin:Xt(this,Vc)?Xt(this,Vc).origin:Xt(this,Nl).origin,lastEventId:o.id||""});Xt(this,Wc)&&(!o.event||o.event==="message")&&Xt(this,Wc).call(this,i),this.dispatchEvent(i)}),_r(this,zE,o=>{Yn(this,qf,o)}),_r(this,BE,()=>{Yn(this,tu,void 0),Xt(this,Na)===this.CONNECTING&&Co(this,ys,jE).call(this)});try{if(t instanceof URL)Yn(this,Nl,t);else if(typeof t=="string")Yn(this,Nl,new URL(t,ree()));else throw new Error("Invalid URL")}catch{throw nee("An invalid or illegal string was specified")}Yn(this,Gc,n4({onEvent:Xt(this,UE),onRetry:Xt(this,zE)})),Yn(this,Na,this.CONNECTING),Yn(this,qf,3e3),Yn(this,Fb,(r=n?.fetch)!=null?r:globalThis.fetch),Yn(this,ab,(a=n?.withCredentials)!=null?a:!1),Co(this,ys,jE).call(this)}get readyState(){return Xt(this,Na)}get url(){return Xt(this,Nl).href}get withCredentials(){return Xt(this,ab)}get onerror(){return Xt(this,hu)}set onerror(t){Yn(this,hu,t)}get onmessage(){return Xt(this,Wc)}set onmessage(t){Yn(this,Wc,t)}get onopen(){return Xt(this,zf)}set onopen(t){Yn(this,zf,t)}addEventListener(t,n,r){const a=n;super.addEventListener(t,a,r)}removeEventListener(t,n,r){const a=n;super.removeEventListener(t,a,r)}close(){Xt(this,tu)&&clearTimeout(Xt(this,tu)),Xt(this,Na)!==this.CLOSED&&(Xt(this,Ci)&&Xt(this,Ci).abort(),Yn(this,Na,this.CLOSED),Yn(this,Ci,void 0))}}Na=new WeakMap,Nl=new WeakMap,Vc=new WeakMap,ab=new WeakMap,Fb=new WeakMap,qf=new WeakMap,tu=new WeakMap,Xf=new WeakMap,Ci=new WeakMap,Gc=new WeakMap,hu=new WeakMap,Wc=new WeakMap,zf=new WeakMap,ys=new WeakSet,jE=function(){Yn(this,Na,this.CONNECTING),Yn(this,Ci,new AbortController),Xt(this,Fb)(Xt(this,Nl),Co(this,ys,Pj).call(this)).then(Xt(this,PE)).catch(Xt(this,$E))},PE=new WeakMap,$E=new WeakMap,Pj=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Xt(this,Xf)?{"Last-Event-ID":Xt(this,Xf)}:void 0},cache:"no-store",signal:(e=Xt(this,Ci))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},UE=new WeakMap,zE=new WeakMap,Ff=function(e,t){var n;Xt(this,Na)!==this.CLOSED&&Yn(this,Na,this.CLOSED);const r=new Mj("error",{code:t,message:e});(n=Xt(this,hu))==null||n.call(this,r),this.dispatchEvent(r)},FE=function(e,t){var n;if(Xt(this,Na)===this.CLOSED)return;Yn(this,Na,this.CONNECTING);const r=new Mj("error",{code:t,message:e});(n=Xt(this,hu))==null||n.call(this,r),this.dispatchEvent(r),Yn(this,tu,setTimeout(Xt(this,BE),Xt(this,qf)))},BE=new WeakMap,sb.CONNECTING=0,sb.OPEN=1,sb.CLOSED=2;function ree(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}class aee extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class see{constructor(t,n){this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=n?.eventSourceInit,this._requestInit=n?.requestInit,this._authProvider=n?.authProvider,this._fetch=n?.fetch,this._fetchWithInit=BF(n?.fetch,n?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new rs("No auth provider");let t;try{t=await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(n){throw this.onerror?.(n),n}if(t!=="AUTHORIZED")throw new rs;return await this._startOrAuth()}async _commonHeaders(){const t={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(t.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);const n=jb(this._requestInit?.headers);return new Headers({...t,...n})}_startOrAuth(){const t=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((n,r)=>{this._eventSource=new sb(this._url.href,{...this._eventSourceInit,fetch:async(a,o)=>{const i=await this._commonHeaders();i.set("Accept","text/event-stream");const c=await t(a,{...o,headers:i});if(c.status===401&&c.headers.has("www-authenticate")){const{resourceMetadataUrl:d,scope:f}=hp(c);this._resourceMetadataUrl=d,this._scope=f}return c}}),this._abortController=new AbortController,this._eventSource.onerror=a=>{if(a.code===401&&this._authProvider){this._authThenStart().then(n,r);return}const o=new aee(a.code,a.message,a);r(o),this.onerror?.(o)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",a=>{const o=a;try{if(this._endpoint=new URL(o.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(i){r(i),this.onerror?.(i),this.close();return}n()}),this._eventSource.onmessage=a=>{const o=a;let i;try{i=nb.parse(JSON.parse(o.data))}catch(c){this.onerror?.(c);return}this.onmessage?.(i)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(t){if(!this._authProvider)throw new rs("No auth provider");if(await Ao(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new rs("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(t){if(!this._endpoint)throw new Error("Not connected");try{const n=await this._commonHeaders();n.set("content-type","application/json");const r={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._endpoint,r);if(!a.ok){const o=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){const{resourceMetadataUrl:i,scope:c}=hp(a);if(this._resourceMetadataUrl=i,this._scope=c,await Ao(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new rs;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${a.status}): ${o}`)}await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}setProtocolVersion(t){this._protocolVersion=t}}var $u,oee=($u=class{connector;autoConnect;constructor(t,n=!0){this.connector=t,this.autoConnect=n}async connect(){await this.connector.connect()}async disconnect(){await this.connector.disconnect()}async initialize(){!this.isConnected&&this.autoConnect&&await this.connect(),await this.connector.initialize()}get isConnected(){return this.connector&&this.connector.isClientConnected}on(t,n){t==="notification"&&this.connector.onNotification(n)}async setRoots(t){return this.connector.setRoots(t)}getRoots(){return this.connector.getRoots()}get tools(){return this.connector.tools}async listTools(t){return this.connector.listTools(t)}get serverCapabilities(){return this.connector.serverCapabilities}get serverInfo(){return this.connector.serverInfo}async callTool(t,n={},r){return this.connector.callTool(t,n,r)}async listResources(t,n){return this.connector.listResources(t,n)}async listAllResources(t){return this.connector.listAllResources(t)}async listResourceTemplates(t){return this.connector.listResourceTemplates(t)}async readResource(t,n){return this.connector.readResource(t,n)}async subscribeToResource(t,n){return this.connector.subscribeToResource(t,n)}async unsubscribeFromResource(t,n){return this.connector.unsubscribeFromResource(t,n)}async listPrompts(){return this.connector.listPrompts()}async getPrompt(t,n){return this.connector.getPrompt(t,n)}async request(t,n=null,r){return this.connector.request(t,n,r)}},De($u,"MCPSession"),$u),Uu,iee=(Uu=class{config={};sessions={};activeSessions=[];constructor(t){t&&(this.config=t)}static fromDict(t){throw new Error("fromDict must be implemented by concrete class")}addServer(t,n){this.config.mcpServers=this.config.mcpServers||{},this.config.mcpServers[t]=n,Bs.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Bs.getInstance().trackClientRemoveServer(t))}getServerNames(){return Object.keys(this.config.mcpServers??{})}getServerConfig(t){return this.config.mcpServers?.[t]}getConfig(){return this.config??{}}async createSession(t,n=!0){const r=this.config.mcpServers??{};if(Object.keys(r).length===0&&Le.warn("No MCP servers defined in config"),!r[t])throw new Error(`Server '${t}' not found in config`);const a=this.createConnectorFromConfig(r[t]),o=new oee(a);return n&&await o.initialize(),this.sessions[t]=o,this.activeSessions.includes(t)||this.activeSessions.push(t),o}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&Le.warn("No MCP servers defined in config");for(const r of Object.keys(n))await this.createSession(r,t);return this.sessions}getSession(t){const n=this.sessions[t];return n||null}requireSession(t){const n=this.sessions[t];if(!n)throw new Error(`Session '${t}' not found. Available sessions: ${this.activeSessions.join(", ")||"none"}`);return n}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){Le.warn(`No session exists for server ${t}, nothing to close`);return}try{Le.debug(`Closing session for server ${t}`),await n.disconnect()}catch(r){Le.error(`Error closing session for server '${t}': ${r}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(r=>r!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const r of t)try{Le.debug(`Closing session for server ${r}`),await this.closeSession(r)}catch(a){const o=`Failed to close session for server '${r}': ${a}`;Le.error(o),n.push(o)}n.length?Le.error(`Encountered ${n.length} errors while closing sessions`):Le.debug("All sessions closed successfully")}},De(Uu,"BaseMCPClient"),Uu),zu,lee=(zu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),Le.debug(`Starting ${this.constructor.name}`),this._task=this.connectionTask(),await this._readyPromise,this._exception)throw this._exception;if(this._connection===null)throw new Error("Connection was not established");return this._connection}async stop(){if(this._task&&this._abortController){Le.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?Le.debug(`${this.constructor.name} task aborted successfully`):Le.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,Le.debug(`${this.constructor.name} task completed`)}reset(){this._readyPromise=new Promise(t=>this._readyResolver=t),this._donePromise=new Promise(t=>this._doneResolver=t),this._exception=null,this._connection=null,this._task=null,this._abortController=new AbortController}async connectionTask(){Le.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),Le.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,Le.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){Le.warn(`Error closing connection in ${this.constructor.name}: ${t}`)}this._connection=null}this._doneResolver()}}async waitForAbort(){return new Promise((t,n)=>{if(!this._abortController)return;const r=this._abortController.signal;if(r.aborted){t();return}const a=De(()=>{r.removeEventListener("abort",a),t()},"onAbort");r.addEventListener("abort",a)})}},De(zu,"ConnectionManager"),zu),Fu,cee=(Fu=class extends lee{url;opts;_transport=null;reinitializing=!1;constructor(t,n){super(),this.url=typeof t=="string"?new URL(t):t,this.opts=n}async establishConnection(){const t=new see(this.url,this.opts),n=t.send.bind(t);return t.send=async r=>{const a=De(async o=>{if(Array.isArray(o))for(const i of o)await n(i);else await n(o)},"sendMessage");try{await a(r)}catch(o){if(o?.code===404&&t.sessionId&&!this.reinitializing){Le.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),Le.info("[SSE] Re-initialization successful, retrying request"),await a(r)}finally{this.reinitializing=!1}}else throw o}},this._transport=t,Le.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){Le.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){Le.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},De(Fu,"SseConnectionManager"),Fu),Bu,uee=(Bu=class extends oJ{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;disableSseFallback;gatewayUrl;serverId;transportType=null;streamableTransport=null;constructor(t,n={}){super(n);const r=t.replace(/\/$/,"");this.gatewayUrl=n.gatewayUrl,this.serverId=n.serverId,this.gatewayUrl?(this.baseUrl=this.gatewayUrl.replace(/\/$/,""),this.headers={...n.headers??{}},this.headers["X-Target-URL"]=r,this.serverId&&(this.headers["X-Server-Id"]=this.serverId)):(this.baseUrl=r,this.headers={...n.headers??{}}),n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.timeout=n.timeout??1e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1,this.disableSseFallback=n.disableSseFallback??!1}async connect(){if(this.connected){Le.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){Le.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}Le.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{Le.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),Le.info("✅ Successfully connected via streamable HTTP")}catch(n){console.log("error in http connector connect",n);let r="Unknown error",a=!1,o,i=null;if(n instanceof Ni?i=n:n instanceof Error&&n.cause instanceof Ni&&(i=n.cause),i)a=i.code===401,o=i.code,console.log("Captured HTTP status code:",o),i.code===400&&i.message.includes("Missing session ID")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Le.warn(`⚠️ ${r}`)):i.code===404||i.code===405?(r=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,Le.debug(r)):(r=`Server returned ${i.code}: ${i.message}`,Le.debug(r));else if(n instanceof Error){const c=n.toString(),d=n.message||"";a=c.includes("401")||d.includes("Unauthorized"),c.includes("Missing session ID")||c.includes("Bad Request: Missing session ID")||d.includes("FastMCP session ID error")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Le.warn(`⚠️ ${r}`)):c.includes("405 Method Not Allowed")||c.includes("404 Not Found")?(r="Server doesn't support streamable HTTP (405/404)",Le.debug(r)):(r=`Streamable HTTP failed: ${n.message}`,Le.debug(r))}if(a){Le.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const c=new Error("Authentication required");throw c.code=401,c}Le.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(c){if(console.error("Failed to connect with both transports:"),console.error(` Streamable HTTP: ${r}`),console.error(` SSE: ${c}`),await this.cleanupResources(),c?.message?.includes("401")||c?.message?.includes("Unauthorized")){const m=new Error("Authentication required");throw m.code=401,m}const f=new Error(`Could not connect to server with any available transport. Streamable HTTP: ${r}`);throw o!==void 0&&(Object.defineProperty(f,"code",{value:o,writable:!1,enumerable:!0,configurable:!0}),Le.debug(`Preserving HTTP status code ${o} in error for proxy fallback detection`)),f}}}async connectWithStreamableHttp(t){try{console.log("[HttpConnector] Connecting with Streamable HTTP:"),console.log(` Base URL: ${t}`),console.log(` Original URL: ${this.baseUrl}`),console.log(` Gateway URL: ${this.gatewayUrl||"none"}`),console.log(` Auth Provider URL: ${this.opts.authProvider?.serverUrl||"none"}`),console.log(` Headers: ${JSON.stringify(this.headers)}`);const n=new tee(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let r=n;if(this.opts.wrapTransport){const o=this.baseUrl;r=this.opts.wrapTransport(r,o)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};Le.debug("Creating Client with capabilities:",JSON.stringify(a.capabilities,null,2)),this.client=new Aj(this.clientInfo,a),this.setupRootsHandler(),Le.debug("Roots handler registered before connect");try{await this.client.connect(r,{timeout:this.timeout});const o=n.sessionId;o?Le.debug(`Session ID obtained: ${o}`):Le.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(o){if(o instanceof Error){const i=o.message||o.toString();if(i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||i.includes("Mcp-Session-Id header is required")){const c=new Error(`Session ID error: ${i}. The SDK should automatically extract session ID from initialize response.`);throw c.cause=o,c}}throw o}this.streamableTransport=n,this.connectionManager={stop:De(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(o){Le.warn(`Error closing Streamable HTTP transport: ${o}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),Le.debug(`Successfully connected to MCP implementation via streamable HTTP: ${t}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (streamable-http)`})}catch(n){throw await this.cleanupResources(),n}}async connectWithSse(t){try{this.connectionManager=new cee(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const a=this.baseUrl;n=this.opts.wrapTransport(n,a)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};Le.debug("Creating Client with capabilities (SSE):",JSON.stringify(r.capabilities,null,2)),this.client=new Aj(this.clientInfo,r),this.setupRootsHandler(),Le.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),Le.debug(`Successfully connected to MCP implementation via HTTP/SSE: ${t}`),this.trackConnectorInit({serverUrl:this.baseUrl,publicIdentifier:`${this.baseUrl} (sse)`})}catch(n){throw await this.cleanupResources(),n}}get publicIdentifier(){return{type:"http",url:this.baseUrl,transport:this.transportType||"unknown"}}getTransportType(){return this.transportType}},De(Bu,"HttpConnector"),Bu),jl,dee=(jl=class extends iee{static getPackageVersion(){return Ny()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Bs.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>Le.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new jl(t)}createConnectorFromConfig(t){const{url:n,headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:c,onSampling:d,samplingCallback:f,elicitationCallback:m,disableSseFallback:h,preferSse:g,clientInfo:v,gatewayUrl:E,serverId:x}=t;if(!n)throw new Error("Server URL is required");const w=d??f,S={headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:c,onSampling:w,samplingCallback:w,elicitationCallback:m,disableSseFallback:h,preferSse:g,clientInfo:v,gatewayUrl:E,serverId:x};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new uee(n,S)}},De(jl,"BrowserMCPClient"),jl);function nu(e){const t=De(()=>{throw new Error(`Invalid url to pass to open(): ${e}`)},"abort");let n;try{n=new URL(e)}catch{t()}return n.protocol!=="https:"&&n.protocol!=="http:"&&t(),n.hostname!==encodeURIComponent(n.hostname)&&t(),n.username&&(n.username=encodeURIComponent(n.username)),n.password&&(n.password=encodeURIComponent(n.password)),n.pathname=n.pathname.slice(0,1)+encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi,"/"),n.search=n.search.slice(0,1)+Array.from(n.searchParams.entries()).map(a4).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}De(nu,"sanitizeUrl");function a4([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}De(a4,"sanitizeParam");async function s4(e){return typeof e=="string"?e:e instanceof URLSearchParams||e instanceof FormData?Object.fromEntries(e.entries()):e instanceof Blob?await e.text():e}De(s4,"serializeBody");var Hu,ob=(Hu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;oauthProxyUrl;connectionUrl;originalFetch;onPopupWindow;constructor(t,n={}){this.serverUrl=t,this.storageKeyPrefix=n.storageKeyPrefix||"mcp:auth",this.serverUrlHash=this.hashString(t),this.clientName=n.clientName||"mcp-use",this.clientUri=n.clientUri||(typeof window<"u"?window.location.origin:""),this.logoUri=n.logoUri||"https://mcp-use.com/logo.png",this.callbackUrl=nu(n.callbackUrl||(typeof window<"u"?new URL("/oauth/callback",window.location.origin).toString():"/oauth/callback")),this.preventAutoAuth=n.preventAutoAuth,this.useRedirectFlow=n.useRedirectFlow,this.oauthProxyUrl=n.oauthProxyUrl,this.connectionUrl=n.connectionUrl,this.onPopupWindow=n.onPopupWindow}installFetchInterceptor(){if(!this.oauthProxyUrl){console.warn("[BrowserOAuthProvider] No OAuth proxy URL configured, skipping fetch interceptor installation");return}if(!this.originalFetch)this.originalFetch=window.fetch;else{console.warn("[BrowserOAuthProvider] Fetch interceptor already installed");return}const t=this.oauthProxyUrl,n=this.connectionUrl,r=this.originalFetch;console.log(`[BrowserOAuthProvider] Installing fetch interceptor with proxy: ${t}`),window.fetch=De(async function(o,i){const c=typeof o=="string"?o:o instanceof URL?o.toString():o.url;if(!(c.includes("/.well-known/")||c.match(/\/(register|token|authorize)$/)))return await r(o,i);try{const f=new URL(c),m=new URL(t);if(f.origin===m.origin&&(f.pathname.startsWith(m.pathname)||c.includes("/inspector/api/oauth")))return await r(o,i)}catch{}try{const f=c.includes("/.well-known/"),m=f?`${t}/metadata?url=${encodeURIComponent(c)}`:`${t}/proxy`;if(console.log(`[OAuth Proxy] Routing ${f?"metadata":"request"} through: ${m}`),f){const E={...i?.headers?Object.fromEntries(new Headers(i.headers)):{}};return n&&(E["X-Connection-URL"]=n),await r(m,{...i,method:"GET",headers:E})}const h=i?.body?await s4(i.body):void 0,v=await(await r(m,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:c,method:i?.method||"POST",headers:i?.headers?Object.fromEntries(new Headers(i.headers)):{},body:h})})).json();return new Response(JSON.stringify(v.body),{status:v.status,statusText:v.statusText,headers:new Headers(v.headers)})}catch(f){return console.error("[OAuth Proxy] Request failed, falling back to direct fetch:",f),await r(o,i)}},"interceptedFetch")}restoreFetch(){this.originalFetch&&(console.log("[BrowserOAuthProvider] Restoring original fetch"),window.fetch=this.originalFetch,this.originalFetch=void 0)}get redirectUrl(){return nu(this.callbackUrl)}get clientMetadata(){return{redirect_uris:[this.redirectUrl],token_endpoint_auth_method:"none",grant_types:["authorization_code","refresh_token"],response_types:["code"],client_name:this.clientName,client_uri:this.clientUri,logo_uri:this.logoUri}}async clientInformation(){const t=this.getKey("client_info"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,r),localStorage.removeItem(t);return}}async saveClientInformation(t){const n=this.getKey("client_info");localStorage.setItem(n,JSON.stringify(t))}async tokens(){const t=this.getKey("tokens"),n=localStorage.getItem(t);if(n)try{return JSON.parse(n)}catch(r){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,r),localStorage.removeItem(t);return}}async saveTokens(t){const n=this.getKey("tokens");localStorage.setItem(n,JSON.stringify(t)),localStorage.removeItem(this.getKey("code_verifier")),localStorage.removeItem(this.getKey("last_auth_url"))}async saveCodeVerifier(t){const n=this.getKey("code_verifier");localStorage.setItem(n,t)}async codeVerifier(){const t=this.getKey("code_verifier"),n=localStorage.getItem(t);if(!n)throw new Error(`[${this.storageKeyPrefix}] Code verifier not found in storage for key ${t}. Auth flow likely corrupted or timed out.`);return n}async prepareAuthorizationUrl(t){const n=globalThis.crypto.randomUUID(),r=`${this.storageKeyPrefix}:state_${n}`,a={serverUrlHash:this.serverUrlHash,expiry:Date.now()+1e3*60*10,providerOptions:{serverUrl:this.serverUrl,storageKeyPrefix:this.storageKeyPrefix,clientName:this.clientName,clientUri:this.clientUri,callbackUrl:this.callbackUrl},flowType:this.useRedirectFlow?"redirect":"popup",returnUrl:this.useRedirectFlow&&typeof window<"u"?window.location.href:void 0};localStorage.setItem(r,JSON.stringify(a)),t.searchParams.set("state",n);const o=t.toString(),i=nu(o);return localStorage.setItem(this.getKey("last_auth_url"),i),i}async redirectToAuthorization(t){const n=await this.prepareAuthorizationUrl(t);if(this.preventAutoAuth){console.info(`[${this.storageKeyPrefix}] Auto-auth prevented. Authorization URL stored for manual trigger.`);return}if(this.useRedirectFlow){console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL (full-page redirect).`),window.location.href=n;return}const r="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const a=window.open(n,`mcp_auth_${this.serverUrlHash}`,r);this.onPopupWindow&&this.onPopupWindow(n,r,a),!a||a.closed||typeof a.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(a.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(a){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,a)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?nu(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,r=[];let a=0;for(let i=0;i<localStorage.length;i++){const c=localStorage.key(i);if(c){if(c.startsWith(t))r.push(c);else if(c.startsWith(n))try{const d=localStorage.getItem(c);d&&JSON.parse(d).serverUrlHash===this.serverUrlHash&&r.push(c)}catch(d){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${c} during clearStorage:`,d)}}}return[...new Set(r)].forEach(i=>{localStorage.removeItem(i),a++}),a}hashString(t){let n=0;for(let r=0;r<t.length;r++){const a=t.charCodeAt(r);n=(n<<5)-n+a,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},De(Hu,"BrowserOAuthClientProvider"),Hu);async function J_(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),r=e.get("error"),a=e.get("error_description"),o="[mcp-callback]";console.log(`${o} Handling callback...`,{code:t,state:n,error:r,errorDescription:a});let i=null,c=null;const d=n?`mcp:auth:state_${n}`:null;try{if(r)throw new Error(`OAuth error: ${r} - ${a||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!d)throw new Error("State parameter not found or invalid in callback query parameters.");const f=localStorage.getItem(d);if(!f)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{c=JSON.parse(f)}catch{throw new Error("Failed to parse stored OAuth state.")}if(!c.expiry||c.expiry<Date.now())throw localStorage.removeItem(d),new Error("OAuth state has expired. Please try initiating authentication again.");if(!c.providerOptions)throw new Error("Stored state is missing required provider options.");const{serverUrl:m,...h}=c.providerOptions;console.log(`${o} Re-instantiating provider for server: ${m}`),i=new ob(m,h),console.log(`${o} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await Ao(i,{serverUrl:g,authorizationCode:t});if(v==="AUTHORIZED")if(console.log(`${o} Authorization successful via SDK auth().`),c.flowType==="redirect"&&c.returnUrl)console.log(`${o} Redirect flow complete. Returning to: ${c.returnUrl}`),localStorage.removeItem(d),window.location.href=c.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${o} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(d),window.close();else{console.warn(`${o} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(d);const x=window.location.pathname.split("/").filter(Boolean),w=x.length>0&&x[x.length-1]==="callback"?"/"+x.slice(0,-2).join("/"):"/";window.location.href=w||"/"}else throw console.warn(`${o} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(f){console.error(`${o} Error during OAuth callback handling:`,f);const m=f instanceof Error?f.message:String(f);window.opener&&!window.opener.closed&&window.opener.postMessage({type:"mcp_auth_callback",success:!1,error:m},window.location.origin);try{document.body.innerHTML="";const h=document.createElement("div");h.style.fontFamily="sans-serif",h.style.padding="20px";const g=document.createElement("h1");g.textContent="Authentication Error",h.appendChild(g);const v=document.createElement("p");v.style.color="red",v.style.backgroundColor="#ffebeb",v.style.border="1px solid red",v.style.padding="10px",v.style.borderRadius="4px",v.textContent=m,h.appendChild(v);const E=document.createElement("p");E.textContent="You can close this window or ";const x=document.createElement("a");if(x.href="#",x.textContent="click here to close",x.onclick=w=>(w.preventDefault(),window.close(),!1),E.appendChild(x),E.appendChild(document.createTextNode(".")),h.appendChild(E),f instanceof Error&&f.stack){const w=document.createElement("pre");w.style.fontSize="0.8em",w.style.color="#555",w.style.marginTop="20px",w.style.whiteSpace="pre-wrap",w.textContent=f.stack,h.appendChild(w)}document.body.appendChild(h)}catch(h){console.error(`${o} Could not display error in callback window:`,h)}d&&localStorage.removeItem(d),i&&(localStorage.removeItem(i.getKey("code_verifier")),localStorage.removeItem(i.getKey("last_auth_url")))}}De(J_,"onMcpAuthorization");var h0={exports:{}},Ct={};var $j;function fee(){if($j)return Ct;$j=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),i=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(M){return M===null||typeof M!="object"?null:(M=g&&M[g]||M["@@iterator"],typeof M=="function"?M:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function S(M,B,P){this.props=M,this.context=B,this.refs=w,this.updater=P||E}S.prototype.isReactComponent={},S.prototype.setState=function(M,B){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,B,"setState")},S.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function _(){}_.prototype=S.prototype;function T(M,B,P){this.props=M,this.context=B,this.refs=w,this.updater=P||E}var R=T.prototype=new _;R.constructor=T,x(R,S.prototype),R.isPureReactComponent=!0;var C=Array.isArray;function A(){}var I={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function U(M,B,P){var D=P.ref;return{$$typeof:e,type:M,key:B,ref:D!==void 0?D:null,props:P}}function L(M,B){return U(M.type,B,M.props)}function $(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function H(M){var B={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(P){return B[P]})}var Y=/\/+/g;function q(M,B){return typeof M=="object"&&M!==null&&M.key!=null?H(""+M.key):B.toString(36)}function ne(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(A,A):(M.status="pending",M.then(function(B){M.status==="pending"&&(M.status="fulfilled",M.value=B)},function(B){M.status==="pending"&&(M.status="rejected",M.reason=B)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function G(M,B,P,D,j){var V=typeof M;(V==="undefined"||V==="boolean")&&(M=null);var W=!1;if(M===null)W=!0;else switch(V){case"bigint":case"string":case"number":W=!0;break;case"object":switch(M.$$typeof){case e:case t:W=!0;break;case m:return W=M._init,G(W(M._payload),B,P,D,j)}}if(W)return j=j(M),W=D===""?"."+q(M,0):D,C(j)?(P="",W!=null&&(P=W.replace(Y,"$&/")+"/"),G(j,B,P,"",function(fe){return fe})):j!=null&&($(j)&&(j=L(j,P+(j.key==null||M&&M.key===j.key?"":(""+j.key).replace(Y,"$&/")+"/")+W)),B.push(j)),1;W=0;var te=D===""?".":D+":";if(C(M))for(var de=0;de<M.length;de++)D=M[de],V=te+q(D,de),W+=G(D,B,P,V,j);else if(de=v(M),typeof de=="function")for(M=de.call(M),de=0;!(D=M.next()).done;)D=D.value,V=te+q(D,de++),W+=G(D,B,P,V,j);else if(V==="object"){if(typeof M.then=="function")return G(ne(M),B,P,D,j);throw B=String(M),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return W}function K(M,B,P){if(M==null)return M;var D=[],j=0;return G(M,D,"","",function(V){return B.call(P,V,j++)}),D}function F(M){if(M._status===-1){var B=M._result;B=B(),B.then(function(P){(M._status===0||M._status===-1)&&(M._status=1,M._result=P)},function(P){(M._status===0||M._status===-1)&&(M._status=2,M._result=P)}),M._status===-1&&(M._status=0,M._result=B)}if(M._status===1)return M._result.default;throw M._result}var re=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var B=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ee={map:K,forEach:function(M,B,P){K(M,function(){B.apply(this,arguments)},P)},count:function(M){var B=0;return K(M,function(){B++}),B},toArray:function(M){return K(M,function(B){return B})||[]},only:function(M){if(!$(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ct.Activity=h,Ct.Children=ee,Ct.Component=S,Ct.Fragment=n,Ct.Profiler=a,Ct.PureComponent=T,Ct.StrictMode=r,Ct.Suspense=d,Ct.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,Ct.__COMPILER_RUNTIME={__proto__:null,c:function(M){return I.H.useMemoCache(M)}},Ct.cache=function(M){return function(){return M.apply(null,arguments)}},Ct.cacheSignal=function(){return null},Ct.cloneElement=function(M,B,P){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var D=x({},M.props),j=M.key;if(B!=null)for(V in B.key!==void 0&&(j=""+B.key),B)!O.call(B,V)||V==="key"||V==="__self"||V==="__source"||V==="ref"&&B.ref===void 0||(D[V]=B[V]);var V=arguments.length-2;if(V===1)D.children=P;else if(1<V){for(var W=Array(V),te=0;te<V;te++)W[te]=arguments[te+2];D.children=W}return U(M.type,j,D)},Ct.createContext=function(M){return M={$$typeof:i,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:o,_context:M},M},Ct.createElement=function(M,B,P){var D,j={},V=null;if(B!=null)for(D in B.key!==void 0&&(V=""+B.key),B)O.call(B,D)&&D!=="key"&&D!=="__self"&&D!=="__source"&&(j[D]=B[D]);var W=arguments.length-2;if(W===1)j.children=P;else if(1<W){for(var te=Array(W),de=0;de<W;de++)te[de]=arguments[de+2];j.children=te}if(M&&M.defaultProps)for(D in W=M.defaultProps,W)j[D]===void 0&&(j[D]=W[D]);return U(M,V,j)},Ct.createRef=function(){return{current:null}},Ct.forwardRef=function(M){return{$$typeof:c,render:M}},Ct.isValidElement=$,Ct.lazy=function(M){return{$$typeof:m,_payload:{_status:-1,_result:M},_init:F}},Ct.memo=function(M,B){return{$$typeof:f,type:M,compare:B===void 0?null:B}},Ct.startTransition=function(M){var B=I.T,P={};I.T=P;try{var D=M(),j=I.S;j!==null&&j(P,D),typeof D=="object"&&D!==null&&typeof D.then=="function"&&D.then(A,re)}catch(V){re(V)}finally{B!==null&&P.types!==null&&(B.types=P.types),I.T=B}},Ct.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},Ct.use=function(M){return I.H.use(M)},Ct.useActionState=function(M,B,P){return I.H.useActionState(M,B,P)},Ct.useCallback=function(M,B){return I.H.useCallback(M,B)},Ct.useContext=function(M){return I.H.useContext(M)},Ct.useDebugValue=function(){},Ct.useDeferredValue=function(M,B){return I.H.useDeferredValue(M,B)},Ct.useEffect=function(M,B){return I.H.useEffect(M,B)},Ct.useEffectEvent=function(M){return I.H.useEffectEvent(M)},Ct.useId=function(){return I.H.useId()},Ct.useImperativeHandle=function(M,B,P){return I.H.useImperativeHandle(M,B,P)},Ct.useInsertionEffect=function(M,B){return I.H.useInsertionEffect(M,B)},Ct.useLayoutEffect=function(M,B){return I.H.useLayoutEffect(M,B)},Ct.useMemo=function(M,B){return I.H.useMemo(M,B)},Ct.useOptimistic=function(M,B){return I.H.useOptimistic(M,B)},Ct.useReducer=function(M,B,P){return I.H.useReducer(M,B,P)},Ct.useRef=function(M){return I.H.useRef(M)},Ct.useState=function(M){return I.H.useState(M)},Ct.useSyncExternalStore=function(M,B,P){return I.H.useSyncExternalStore(M,B,P)},Ct.useTransition=function(){return I.H.useTransition()},Ct.version="19.2.3",Ct}var Uj;function Q_(){return Uj||(Uj=1,h0.exports=fee()),h0.exports}var y=Q_();const ie=Yp(y),pd=E7({__proto__:null,default:ie},[y]);function HE(e,t){if(!e)throw new Error(t)}De(HE,"assert");var zj=3e3,pee=5e3;function o4(e){return{name:e.name,version:e.version,uri:e.websiteUrl,logo_uri:e.icons?.[0]?.src}}De(o4,"deriveClientConfigFromClientInfo");function i4(e){const n=(e instanceof Error?e.message:String(e)).toLowerCase();return n.includes("oauth discovery failed")||n.includes("oauth-authorization-server")||n.includes("not valid json")||n.includes("404")&&(n.includes("openid-configuration")||n.includes("oauth-protected-resources")||n.includes("oauth-authorization-url")||n.includes("register"))||n.includes("invalid oauth error response")&&n.includes("not found")}De(i4,"isOAuthDiscoveryFailure");function eT(e){const{url:t,enabled:n=!0,callbackUrl:r=typeof window<"u"?nu(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:a="mcp:auth",clientConfig:o={},headers:i,customHeaders:c,proxyConfig:d,autoProxyFallback:f=!0,debug:m=!1,autoRetry:h=!1,autoReconnect:g=zj,transportType:v="auto",preventAutoAuth:E=!1,useRedirectFlow:x=!1,onPopupWindow:w,timeout:S=3e4,sseReadTimeout:_=3e5,wrapTransport:T,onNotification:R,onSampling:C,samplingCallback:A,onElicitation:I}=e,O=i??c??{};c&&!i&&console.warn('[useMcp] The "customHeaders" option is deprecated. Use "headers" instead.');const U=C??A;A&&!C&&console.warn('[useMcp] The "samplingCallback" option is deprecated. Use "onSampling" instead.');const L=y.useMemo(()=>({name:"mcp-use",title:"mcp-use",version:Ny(),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"}),[]),$=y.useMemo(()=>e.clientInfo?{...L,...e.clientInfo}:L,[e.clientInfo,L]),H=y.useMemo(()=>o4($),[$]),Y=y.useMemo(()=>o&&Object.keys(o).length>0?(console.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."),{...H,...o}):H,[o,H]),q=y.useMemo(()=>f?typeof f=="boolean"?{enabled:f,proxyAddress:"https://inspector.mcp-use.com/inspector/api/proxy"}:{enabled:f.enabled!==!1,proxyAddress:f.proxyAddress||"https://inspector.mcp-use.com/inspector/api/proxy"}:{enabled:!1,proxyAddress:void 0},[f]),ne=y.useRef(!1),[G,K]=y.useState(d),{gatewayUrl:F,proxyHeaders:re}=y.useMemo(()=>{const je=b_(t||"",G);return{gatewayUrl:G?.proxyAddress,proxyHeaders:je.headers}},[t,G]),ee=y.useMemo(()=>t||"",[t]),M=y.useMemo(()=>({...re,...O}),[re,O]),[B,P]=y.useState("discovering"),[D,j]=y.useState([]),[V,W]=y.useState([]),[te,de]=y.useState([]),[fe,J]=y.useState([]),[Q,se]=y.useState(),[pe,he]=y.useState(),[Ne,He]=y.useState(void 0),[$e,Pe]=y.useState([]),[ot,Me]=y.useState(void 0),[Je,We]=y.useState(void 0),we=y.useRef(null),Ee=y.useRef(null),oe=y.useRef(null),Se=y.useRef(!1),Re=y.useRef(!0),Ve=y.useRef(0),ct=y.useRef(null),vt=y.useRef(!1),Ge=y.useRef(B),wn=y.useRef(g),pn=y.useRef(null),Fe=y.useRef(null),Ue=y.useRef(null);y.useEffect(()=>{Ge.current=B,wn.current=g},[B,g]);const ce=y.useCallback((je,Be,...Ye)=>{const Qe=Ye.length>0?`${Be} ${Ye.map(gt=>JSON.stringify(gt)).join(" ")}`:Be;console[je](`[useMcp] ${Qe}`),Re.current&&Pe(gt=>[...gt.slice(-100),{level:je,message:Qe,timestamp:Date.now()}])},[]),wt=y.useCallback(async(je=!1)=>{if(je||ce("info","Disconnecting..."),Se.current=!1,ct.current&&clearTimeout(ct.current),ct.current=null,we.current)try{const Be="inspector-server",Ye=we.current.getSession(Be);Ye&&Ye._healthCheckCleanup&&(Ye._healthCheckCleanup(),Ye._healthCheckCleanup=null),Ye&&await we.current.closeSession(Be)}catch(Be){je||ce("warn","Error closing session:",Be)}we.current=null,Re.current&&!je&&(P("discovering"),j([]),W([]),de([]),J([]),He(void 0),Me(void 0))},[ce]),ht=y.useCallback((je,Be)=>{ce("error",je,Be??"");const Ye=Be&&"code"in Be?Be.code:void 0,Qe=q.enabled&&!G?.proxyAddress,gt=je.includes("CORS")||je.includes("blocked by CORS policy")||je.includes("Failed to fetch"),an=Ye===400,xt=typeof Ye=="number"&&Ye>=404&&Ye<500;if(Qe&&(gt||an||xt)&&!(Ye===401||Ye===403))return ce("info",`Direct connection failed with ${gt?"CORS error":an?"HTTP 400 (Bad Request)":"HTTP 4xx error"}. Trying with proxy...`),we.current=null,Ee.current=null,ce("debug","Cleared client and auth provider for proxy fallback"),K({proxyAddress:q.proxyAddress}),Re.current&&P("discovering"),setTimeout(()=>{Re.current&&Fe.current?.()},1e3),!0;if(Re.current){console.log("[useMcp] Setting state to FAILED:",je),P("failed"),He(je);const _t=Ee.current?.getLastAttemptedAuthUrl();_t&&(Me(_t),ce("info","Manual authentication URL may be available.",_t))}return Se.current=!1,t&&Bs.getInstance().trackUseMcpConnection({url:t,transportType:v,success:!1,errorType:Be?.name||"UnknownError",hasOAuth:!!Ee.current,hasSampling:!!U,hasElicitation:!!I}).catch(()=>{}),!1},[ce,t,v,U,I,q,G]),Dt=y.useCallback(async()=>{if(!n||!t){ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(Se.current){ce("debug","Connection attempt already in progress.");return}if(!Re.current){ce("debug","Connect called after unmount, aborting.");return}if(Se.current=!0,Ve.current+=1,He(void 0),Me(void 0),pn.current=null,P("discovering"),ce("info",`Connecting attempt #${Ve.current} to ${t}...`),!Ee.current){let Ye;if(F){const Qe=new URL(F),gt=Qe.pathname.replace(/\/proxy\/?$/,"");Ye=`${Qe.origin}${gt}/oauth`,ce("debug",`OAuth proxy URL derived from gateway: ${Ye}`)}Ee.current=new ob(ee,{storageKeyPrefix:a,clientName:Y.name,clientUri:Y.uri,logoUri:Y.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:E,useRedirectFlow:x,oauthProxyUrl:Ye,onPopupWindow:w}),ce("debug",`BrowserOAuthClientProvider initialized with URL: ${ee}, proxy: ${Ye?"enabled":"disabled"}, gateway: ${F?"enabled":"disabled"}`),Ye&&(Ee.current.installFetchInterceptor(),ce("debug","Installed OAuth fetch interceptor"))}we.current?ce("debug","BrowserMCPClient already exists, reusing."):(we.current=new dee,ce("debug","BrowserMCPClient initialized in connect."));const je=De(async(Ye,Qe=!1)=>{if(!Re.current)return ce("debug","Connection attempt aborted - component unmounted"),"failed";ce("info",`Attempting connection with transport: ${Ye}`),ce("debug",`Client ref status at start of tryConnectWithTransport: ${we.current?"initialized":"NULL"}`);try{const gt="inspector-server",an={url:t,transport:Ye==="sse"?"http":Ye,disableSseFallback:v==="http",preferSse:Ye==="sse",clientInfo:$};if(F&&(an.gatewayUrl=F,console.log(`[useMcp] Using proxy gateway: ${F} for target: ${t}`)),M&&Object.keys(M).length>0&&(an.headers=M),Ee.current){const Ze=await Ee.current.tokens();if(!Re.current)return ce("debug","Connection aborted after token fetch - component unmounted"),"failed";Ze?.access_token&&(an.headers={...an.headers,Authorization:`Bearer ${Ze.access_token}`})}if(!we.current){if(!Re.current)return ce("debug","Connection aborted - component unmounted, client cleaned up"),"failed";const Ze=new Error("Client not initialized - this is a bug in the connection flow");throw ce("error","Client ref is null in tryConnectWithTransport but component is still mounted"),Ze}we.current.addServer(gt,{...an,authProvider:Ee.current,clientOptions:Y,onSampling:U,samplingCallback:U,elicitationCallback:I,wrapTransport:T?Ze=>(console.log("[useMcp] Applying transport wrapper for server:",gt,"url:",t),T(Ze,t)):void 0});const xt=await we.current.createSession(gt,!1);if(!Re.current)return ce("debug","Connection aborted after session creation - component unmounted"),"failed";if(xt.on("notification",Ze=>{R?.(Ze),Ze.method==="notifications/tools/list_changed"?(ce("info","Tools list changed, auto-refreshing..."),Jn().catch(tt=>ce("warn","Auto-refresh tools failed:",tt))):Ze.method==="notifications/resources/list_changed"?(ce("info","Resources list changed, auto-refreshing..."),rn().catch(tt=>ce("warn","Auto-refresh resources failed:",tt))):Ze.method==="notifications/prompts/list_changed"&&(ce("info","Prompts list changed, auto-refreshing..."),Ln().catch(tt=>ce("warn","Auto-refresh prompts failed:",tt)))}),await xt.initialize(),!Re.current)return ce("debug","Connection completed but component unmounted, aborting"),"failed";if(ce("info","✅ Successfully connected to MCP server"),ce("info","Server info:",xt.connector.serverInfo),ce("info","Server capabilities:",xt.connector.serverCapabilities),console.log("[useMcp] Server info:",xt.connector.serverInfo),console.log("[useMcp] Server capabilities:",xt.connector.serverCapabilities),!Re.current)return ce("debug","Skipping state update - component unmounted"),"failed";P("ready"),pn.current=Ye;const Wn=De(()=>{let Ze=null,tt=Date.now();const Lt=1e4,Un=3e4;return Ze=setInterval(De(async()=>{if(!Re.current||Ge.current!=="ready"){Ze&&(clearInterval(Ze),Ze=null);return}try{await xt.connector.listTools(),tt=Date.now()}catch{const kt=Date.now()-tt;kt>Un&&(ce("warn",`Connection appears to be broken (no response for ${Math.round(kt/1e3)}s), attempting to reconnect...`),Ze&&(clearInterval(Ze),Ze=null),wn.current&&Re.current&&(P("discovering"),ce("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{Re.current&&Ge.current==="discovering"&&Dt()},typeof wn.current=="number"?wn.current:zj)))}},"checkConnectionHealth"),Lt),()=>{Ze&&(clearInterval(Ze),Ze=null)}},"setupConnectionMonitoring");if(g){const Ze=Wn();xt._healthCheckCleanup=Ze}Bs.getInstance().trackUseMcpConnection({url:t,transportType:Ye,success:!0,hasOAuth:!!Ee.current,hasSampling:!!U,hasElicitation:!!I}).catch(()=>{}),j(xt.connector.tools||[]);const Ia=await xt.connector.listAllResources();if(!Re.current)return ce("debug","Connection aborted after listing resources - component unmounted"),"failed";W(Ia.resources||[]);const _t=await xt.connector.listPrompts();if(!Re.current)return ce("debug","Connection aborted after listing prompts - component unmounted"),"failed";J(_t.prompts||[]);const Bt=xt.connector.serverInfo,Kt=xt.connector.serverCapabilities;if(Bt){if(console.log("[useMcp] Server info:",Bt),!Re.current)return ce("debug","Skipping state update - component unmounted"),"failed";se(Bt);const Ze=(async()=>{try{const tt=Bt.icons;if(tt&&Array.isArray(tt)&&tt.length>0){const Lt=tt[0].src||tt[0].url;if(Lt){ce("info","Server provided icon:",Lt);const ft=await(await fetch(Lt)).blob(),Cr=await new Promise((kt,Rn)=>{const cn=new FileReader;cn.onloadend=()=>kt(cn.result),cn.onerror=Rn,cn.readAsDataURL(ft)});return Re.current&&(se(kt=>kt?{...kt,icon:Cr}:void 0),ce("debug","Server icon converted to base64")),Cr}}if(t){const Lt=await Yz(t);if(!Re.current)return ce("debug","Connection aborted after favicon detection - component unmounted"),null;if(Lt)return se(Un=>Un?{...Un,icon:Lt}:void 0),ce("debug","Favicon detected and added to serverInfo"),Lt}return null}catch(tt){return ce("debug","Icon loading failed (non-critical):",tt),null}})();oe.current=Ze}if(Kt){if(console.log("[useMcp] Server capabilities:",Kt),!Re.current)return ce("debug","Skipping state update - component unmounted"),"failed";he(Kt)}if(Ee.current){const Ze=await Ee.current.tokens();if(!Re.current)return ce("debug","Connection aborted after token fetch for auth tokens - component unmounted"),"failed";if(Ze?.access_token){const tt=Ze.expires_in?Date.now()+Ze.expires_in*1e3:void 0;if(!Re.current)return ce("debug","Skipping state update - component unmounted"),"failed";We({access_token:Ze.access_token,token_type:Ze.token_type||"Bearer",expires_at:tt,refresh_token:Ze.refresh_token,scope:Ze.scope})}}return"success"}catch(gt){const an=gt,xt=an?.message||String(gt),Wn=i4(gt),Ia=an.code===401||xt.includes("401")||xt.includes("Unauthorized");if(Wn&&O&&Object.keys(O).length>0)return ht("Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct."),"failed";if(Ia){if(Wn)return ht("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed";if(Ee.current){ce("info","Authentication required. OAuth provider available.");try{const{auth:Bt}=await pa(async()=>{const{auth:Ze}=await Promise.resolve().then(()=>Dj);return{auth:Ze}},void 0),Kt=new URL(t).origin;Bt(Ee.current,{serverUrl:Kt}).catch(()=>{}),setTimeout(()=>{if(Re.current){const Ze=Ee.current?.getLastAttemptedAuthUrl();Ze?(Me(Ze),ce("info","Manual authentication URL available:",Ze)):ce("warn","Could not generate authentication URL")}},100)}catch(Bt){ce("warn","Error generating auth URL:",Bt)}return Re.current&&P("pending_auth"),Se.current=!1,"auth_redirect"}return O&&Object.keys(O).length>0?(ht("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(ht("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return ht(xt,an instanceof Error?an:new Error(String(an)))?"auth_redirect":"failed"}},"tryConnectWithTransport");let Be="failed";if(v==="sse")ce("debug","Using SSE-only transport mode"),Be=await je("sse");else if(v==="http")ce("debug","Using HTTP-only transport mode"),Be=await je("http");else{ce("debug","Using auto transport mode (HTTP with SSE fallback)");const Ye=await je("http");Ye==="fallback"&&Re.current&&Ge.current!=="authenticating"?(ce("info","HTTP failed, attempting SSE fallback..."),Be=await je("sse")):Be=Ye}(Be==="success"||Be==="failed"||Be==="auth_redirect")&&(Se.current=!1),ce("debug",`Connection sequence finished with status: ${Be}`)},[ce,ht,wt,t,a,r,Y.name,Y.version,Y.uri,Y.logo_uri,O,v,E,x,w,n,S,_,$,F,M,ee]);y.useEffect(()=>{Fe.current=Dt,Ue.current=ht},[Dt,ht]);const Nt=y.useCallback(async(je,Be,Ye)=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot call tool "${je}".`);ce("info",`Calling tool: ${je}`,Be);const Qe=Date.now();try{const an=we.current.getSession("inspector-server");if(!an)throw new Error("No active session found");const xt=await an.connector.callTool(je,Be||{},Ye);return ce("info",`Tool "${je}" call successful:`,xt),Bs.getInstance().trackUseMcpToolCall({toolName:je,success:!0,executionTimeMs:Date.now()-Qe}).catch(()=>{}),xt}catch(gt){throw ce("error",`Tool "${je}" call failed:`,gt),Bs.getInstance().trackUseMcpToolCall({toolName:je,success:!1,errorType:gt instanceof Error?gt.name:"UnknownError",executionTimeMs:Date.now()-Qe}).catch(()=>{}),gt}},[B]),Wt=y.useCallback(()=>{Ge.current==="failed"?(ce("info","Retry requested..."),Fe.current?.()):ce("warn",`Retry called but state is not 'failed' (state: ${Ge.current}). Ignoring.`)},[ce]),bn=y.useCallback(async()=>{ce("info","Manual authentication requested...");const je=Ge.current;if(je==="failed")ce("info","Attempting to reconnect and authenticate via retry..."),Wt();else if(je==="pending_auth"){ce("info","Proceeding with authentication from pending state...");try{HE(Ee.current,"Auth Provider not available for manual auth"),HE(t,"Server URL is required for authentication"),ce("info","Clearing all OAuth state and initiating fresh flow...");const Be=`${a}:${Ee.current.serverUrlHash}`;Object.keys(localStorage).forEach(xt=>{xt.startsWith(Be)&&(ce("debug",`Removing stale OAuth key: ${xt}`),localStorage.removeItem(xt)),xt.startsWith(`${a}:state_`)&&(ce("debug",`Removing orphaned state: ${xt}`),localStorage.removeItem(xt))}),P("authenticating");let Ye;if(F){const xt=new URL(F),Wn=xt.pathname.replace(/\/proxy\/?$/,"");Ye=`${xt.origin}${Wn}/oauth`}const Qe=new ob(ee,{storageKeyPrefix:a,clientName:Y.name,clientUri:Y.uri,logoUri:Y.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:x,oauthProxyUrl:Ye,onPopupWindow:w});Ye&&!F?(Qe.installFetchInterceptor(),ce("info","Installed OAuth fetch interceptor for manual auth")):Ye&&F&&ce("info","Using MCP gateway proxy for OAuth (no fetch interceptor needed)"),Ee.current=Qe,ce("info","Triggering fresh OAuth authorization...");const{auth:gt}=await pa(async()=>{const{auth:xt}=await Promise.resolve().then(()=>Dj);return{auth:xt}},void 0),an=new URL(t).origin;gt(Qe,{serverUrl:an}).catch(xt=>{ce("info","OAuth flow initiated:",xt instanceof Error?xt.message:"Redirecting...")})}catch(Be){if(!Re.current)return;P("pending_auth"),ce("error",`Manual authentication failed: ${Be instanceof Error?Be.message:String(Be)}`)}}else if(je==="authenticating"){ce("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Be=Ee.current?.getLastAttemptedAuthUrl();Be&&!ot&&(Me(Be),ce("info","Manual authentication URL retrieved:",Be))}else ce("info",`Client not in a state requiring manual authentication trigger (state: ${je}). If needed, try disconnecting and reconnecting.`)},[ce,Wt,ot,t,x,w,a,Y.name,Y.uri,Y.logo_uri,r,$]),et=y.useCallback(()=>{if(Ee.current){const je=Ee.current.clearStorage();ce("info",`Cleared ${je} item(s) from localStorage for ${t}.`),Me(void 0),wt()}else ce("warn","Auth provider not initialized, cannot clear storage.")},[t,ce,wt]),Tt=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot list resources.`);ce("info","Listing resources");try{const Be=we.current.getSession("inspector-server");if(!Be)throw new Error("No active session found");const Ye=await Be.connector.listAllResources();W(Ye.resources||[]),ce("info","Resources listed successfully")}catch(je){throw ce("error","List resources failed:",je),je}},[B]),Ut=y.useCallback(async je=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot read resource.`);ce("info",`Reading resource: ${je}`);try{const Ye=we.current.getSession("inspector-server");if(!Ye)throw new Error("No active session found");const Qe=await Ye.connector.readResource(je);return ce("info","Resource read successful:",Qe),Bs.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!0}).catch(()=>{}),Qe}catch(Be){throw ce("error","Resource read failed:",Be),Bs.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!1,errorType:Be instanceof Error?Be.name:"UnknownError"}).catch(()=>{}),Be}},[B]),zt=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot list prompts.`);ce("info","Listing prompts");try{const Be=we.current.getSession("inspector-server");if(!Be)throw new Error("No active session found");const Ye=await Be.connector.listPrompts();J(Ye.prompts||[]),ce("info","Prompts listed successfully")}catch(je){throw ce("error","List prompts failed:",je),je}},[B]),Jn=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current){ce("debug","Cannot refresh tools - client not ready");return}ce("debug","Refreshing tools list");try{const Be=we.current.getSession("inspector-server");if(!Be){ce("warn","No active session found for tools refresh");return}const Ye=await Be.connector.listTools();j(Ye||[]),ce("info","Tools list refreshed successfully")}catch(je){ce("warn","Failed to refresh tools:",je)}},[ce]),rn=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current){ce("debug","Cannot refresh resources - client not ready");return}ce("debug","Refreshing resources list");try{const Be=we.current.getSession("inspector-server");if(!Be){ce("warn","No active session found for resources refresh");return}const Ye=await Be.connector.listAllResources();W(Ye.resources||[]),ce("info","Resources list refreshed successfully")}catch(je){ce("warn","Failed to refresh resources:",je)}},[ce]),Ln=y.useCallback(async()=>{if(Ge.current!=="ready"||!we.current){ce("debug","Cannot refresh prompts - client not ready");return}ce("debug","Refreshing prompts list");try{const Be=we.current.getSession("inspector-server");if(!Be){ce("warn","No active session found for prompts refresh");return}const Ye=await Be.connector.listPrompts();J(Ye.prompts||[]),ce("info","Prompts list refreshed successfully")}catch(je){ce("warn","Failed to refresh prompts:",je)}},[ce]),Qn=y.useCallback(async()=>{ce("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([Jn(),rn(),Ln()])},[Jn,rn,Ln,ce]),xn=y.useCallback(async(je,Be)=>{if(Ge.current!=="ready"||!we.current)throw new Error(`MCP client is not ready (current state: ${B}). Cannot get prompt.`);ce("info",`Getting prompt: ${je}`,Be);try{const Qe=we.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const gt=await Qe.connector.getPrompt(je,Be||{});return ce("info",`Prompt "${je}" retrieved successfully:`,gt),gt}catch(Ye){throw ce("error",`Prompt "${je}" retrieval failed:`,Ye),Ye}},[B]);y.useEffect(()=>{const je=De(Be=>{Be.origin===window.location.origin&&Be.data?.type==="mcp_auth_callback"&&(ce("info","Received auth callback message.",Be.data),ct.current&&clearTimeout(ct.current),ct.current=null,Be.data.success?(ce("info","Authentication successful via popup. Reconnecting client..."),Se.current&&ce("debug","Connection attempt already in progress, resetting flag to allow reconnection."),Se.current=!1,setTimeout(()=>{Re.current&&(ce("debug","Initiating reconnection after successful auth callback."),Fe.current?.())},100)):Ue.current?.(`Authentication failed in callback: ${Be.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",je),ce("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",je),ce("debug","Auth callback message listener removed."),ct.current&&clearTimeout(ct.current)}},[ce]),y.useEffect(()=>{ne.current=!1,K(d)},[t,d]),y.useEffect(()=>{if(Re.current=!0,!n||!t)return ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),P("discovering"),()=>{Re.current=!1};if(ce("debug","useMcp mounted, initiating connection."),Ve.current=0,!Ee.current||Ee.current.serverUrl!==ee){let je;if(F){const Be=new URL(F),Ye=Be.pathname.replace(/\/proxy\/?$/,"");je=`${Be.origin}${Ye}/oauth`,ce("debug",`OAuth proxy URL derived from gateway: ${je}`)}Ee.current=new ob(ee,{storageKeyPrefix:a,clientName:Y.name,clientUri:Y.uri,logoUri:Y.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:E,useRedirectFlow:x,oauthProxyUrl:je,onPopupWindow:w}),ce("debug",`BrowserOAuthClientProvider initialized/updated with URL: ${ee}, proxy: ${je?"enabled":"disabled"}, gateway: ${F?"enabled":"disabled"}`),je&&(Ee.current.installFetchInterceptor(),ce("debug","Installed OAuth fetch interceptor"))}return Dt(),()=>{if(Re.current=!1,ce("debug","useMcp unmounting, disconnecting."),(Ge.current==="authenticating"||Ge.current==="pending_auth")&&Ee.current)try{const je=Ee.current.clearStorage();je>0&&ce("debug",`Cleared ${je} OAuth state item(s) during unmount to prevent corruption`)}catch(je){ce("debug","Error clearing OAuth state during unmount:",je)}wt(!0)}},[t,n,a,r,Y.name,Y.version,Y.uri,Y.logo_uri,x,$,ee]);const fn=y.useRef(Wt),Mr=y.useRef(ce);y.useEffect(()=>{fn.current=Wt,Mr.current=ce},[Wt,ce]),y.useEffect(()=>{let je=null;if(B==="failed"&&h&&Ve.current>0){if(!vt.current){vt.current=!0;const Be=typeof h=="number"?h:pee;Mr.current("info",`Connection failed, auto-retrying in ${Be}ms...`),je=setTimeout(()=>{vt.current=!1,Re.current&&Ge.current==="failed"&&fn.current()},Be)}}else B!=="failed"&&(vt.current=!1);return()=>{je&&(clearTimeout(je),vt.current=!1)}},[B,h]);const Qt=y.useCallback(async()=>Ge.current!=="ready"?(ce("warn","Cannot ensure icon loaded - not connected"),null):Q?.icon?Q.icon:oe.current?(ce("debug","Waiting for icon to finish loading..."),await oe.current):(ce("debug","No icon available and no loading in progress"),null),[Q,ce]);return{state:B,name:Q?.name||t||"",tools:D,resources:V,resourceTemplates:te,prompts:fe,serverInfo:Q,capabilities:pe,error:Ne,log:$e,authUrl:ot,authTokens:Je,client:we.current,callTool:Nt,readResource:Ut,listResources:Tt,listPrompts:zt,getPrompt:xn,refreshTools:Jn,refreshResources:rn,refreshPrompts:Ln,refreshAll:Qn,retry:Wt,disconnect:wt,authenticate:bn,clearStorage:et,ensureIconLoaded:Qt}}De(eT,"useMcp");var Vu,mee=(Vu=class extends ie.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("Widget Error:",t,n)}render(){return this.state.hasError?ie.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"},ie.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),ie.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},De(Vu,"ErrorBoundary"),Vu),Jf="openai:set_globals";function bs(e){return y.useSyncExternalStore(t=>{const n=De(r=>{r.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(Jf,n),()=>{typeof window<"u"&&window.removeEventListener(Jf,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}De(bs,"useOpenAiGlobal");function md(e){const[t,n]=y.useState(()=>typeof window<"u"&&!!window.openai);y.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const L=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},100),$=De(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(Jf,$);const H=setTimeout(()=>{clearInterval(L),typeof window<"u"&&window.removeEventListener(Jf,$)},5e3);return()=>{clearInterval(L),clearTimeout(H),typeof window<"u"&&window.removeEventListener(Jf,$)}},[]);const r=y.useMemo(()=>t?"openai":"mcp-ui",[t]),a=typeof window<"u"?window.location.search:"",o=y.useMemo(()=>{const L=new URLSearchParams(a);return L.has("mcpUseParams")?JSON.parse(L.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[a]),i=r==="openai"?bs("toolInput"):o.toolInput,c=r==="openai"?bs("toolOutput"):o.toolOutput,d=bs("toolResponseMetadata"),f=y.useMemo(()=>{if(d&&typeof d=="object"){const L=d["mcp-use/props"];if(L)return L}return e||{}},[d,e]),m=bs("widgetState"),h=bs("theme"),g=bs("displayMode"),v=bs("safeArea"),E=bs("maxHeight"),x=bs("userAgent"),w=bs("locale"),S=y.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,T]=y.useState(null);y.useEffect(()=>{m!==void 0&&T(m)},[m]);const R=y.useCallback(async(L,$)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(L,$)},[]),C=y.useCallback(async L=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:L})},[]),A=y.useCallback(L=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:L})},[]),I=y.useCallback(async L=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:L})},[]),O=y.useCallback(async L=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const H=typeof L=="function"?L(m!==void 0?m:_):L;return T(H),window.openai.setWidgetState(H)},[m,_]),U=y.useMemo(()=>r==="openai"&&d===null,[r,d]);return{props:f,toolInput:i||{},output:c??null,metadata:d??null,state:_,setState:O,theme:h||"light",displayMode:g||"inline",safeArea:v||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:E||600,userAgent:x||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:w||"en",mcp_url:S,callTool:R,sendFollowUpMessage:C,openExternal:A,requestDisplayMode:I,isAvailable:t,isPending:U}}De(md,"useWidget");function hee(e){const{props:t}=md(e);return t}De(hee,"useWidgetProps");function gee(){const{theme:e}=md();return e}De(gee,"useWidgetTheme");function bee(e){const{state:t,setState:n}=md();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}De(bee,"useWidgetState");var Fj=De(({children:e})=>{const{theme:t,isAvailable:n}=md();console.log("theme",t);const[r,a]=y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");y.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),c=De(d=>{a(d.matches?"dark":"light")},"handleChange");return i.addEventListener("change",c),()=>i.removeEventListener("change",c)},[]);const o=n?t:r;return y.useLayoutEffect(()=>{typeof document>"u"||(o==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[o]),ie.createElement(ie.Fragment,null,e)},"ThemeProvider");function l4({children:e,className:t="",position:n="top-right",attachTo:r,showLabels:a=!0,debugger:o=!1,viewControls:i=!1}){const{props:c,output:d,metadata:f,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:E,userAgent:x,locale:w,isAvailable:S,callTool:_,sendFollowUpMessage:T,openExternal:R,requestDisplayMode:C,setState:A}=md(),[I,O]=y.useState(!1),[U,L]=y.useState(!1),$=y.useRef(null),H=y.useRef(null),[Y,q]=y.useState([]),[ne,G]=y.useState(""),[K,F]=y.useState("get-my-city"),[re,ee]=y.useState("{}"),[M,B]=y.useState("Test follow-up message"),[P,D]=y.useState("https://docs.mcp-use.com"),j=g==="fullscreen"&&S,V=g==="pip"&&S,W=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const we=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const Ee=Object.keys(window.openai);q(Ee)}catch{q([])}else q([])},100);return()=>{clearTimeout(we)}},[]);const te=h==="dark",de=De(()=>{const we=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",I?"opacity-100":"opacity-0",I?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...we,"top-4","left-4"];case"top-center":return[...we,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...we,"top-4","right-4"];case"center-left":return[...we,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...we,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...we,"bottom-4","left-4"];case"bottom-center":return[...we,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...we,"bottom-4","right-4"];default:return[...we,"top-4","right-4"]}},"getPositionClasses"),fe=De(()=>{const Ee=v?.insets?.top?Math.max(16,v.insets.top+8):16,oe=v?.insets?.right?Math.max(16,v.insets.right+8):16,Se=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Re=v?.insets?.left?Math.max(16,v.insets.left+8):16,Ve={};switch(n){case"top-left":Ve.top=`${Ee}px`,Ve.left=`${Re}px`;break;case"top-center":Ve.top=`${Ee}px`;break;case"top-right":Ve.top=`${Ee}px`,Ve.right=`${oe}px`;break;case"center-left":Ve.left=`${Re}px`;break;case"center-right":Ve.right=`${oe}px`;break;case"bottom-left":Ve.bottom=`${Se}px`,Ve.left=`${Re}px`;break;case"bottom-center":Ve.bottom=`${Se}px`;break;case"bottom-right":Ve.bottom=`${Se}px`,Ve.right=`${oe}px`;break;default:Ve.top=`${Ee}px`,Ve.right=`${oe}px`;break}return Ve},"getPositionOffsetStyles");y.useEffect(()=>{if(!r)return;const we=De(()=>O(!0),"handleMouseEnter"),Ee=De(()=>O(!1),"handleMouseLeave");return r.addEventListener("mouseenter",we),r.addEventListener("mouseleave",Ee),()=>{r.removeEventListener("mouseenter",we),r.removeEventListener("mouseleave",Ee)}},[r]),y.useEffect(()=>{if(!U)return;const we=De(Ee=>{H.current&&!H.current.contains(Ee.target)&&L(!1)},"handleClickOutside");return document.addEventListener("mousedown",we),()=>{document.removeEventListener("mousedown",we)}},[U]),y.useEffect(()=>(U?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[U]);const J=De(()=>{L(!U)},"handleToggleOverlay"),Q=De(async()=>{try{G("Calling tool...");const we=re.trim()?JSON.parse(re):{},Ee=await _(K,we);G(`Success: ${JSON.stringify(Ee,null,2)}`)}catch(we){G(`Error: ${we.message}`)}},"handleCallTool"),se=De(async()=>{try{G("Sending follow-up message..."),await T(M),G("Follow-up message sent successfully")}catch(we){G(`Error: ${we.message}`)}},"handleSendFollowUpMessage"),pe=De(()=>{try{R(P),G(`Opened external link: ${P}`)}catch(we){G(`Error: ${we.message}`)}},"handleOpenExternal"),he=De(async we=>{try{G(`Requesting display mode: ${we}...`);const Ee=await C(we);G(`Display mode granted: ${Ee.mode}`)}catch(Ee){G(`Error: ${Ee.message}`)}},"handleRequestDisplayMode"),Ne=De(async()=>{try{const we=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};G("Setting state..."),await A(we),G(`State updated: ${JSON.stringify(we,null,2)}`)}catch(we){G(`Error: ${we.message}`)}},"handleSetState"),He=De(async()=>{try{await C("fullscreen")}catch(we){console.error("Failed to go fullscreen:",we)}},"handleFullscreen"),$e=De(async()=>{try{await C("pip")}catch(we){console.error("Failed to go pip:",we)}},"handlePip"),Pe=De(()=>{const we=["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[...we,"top-full","right-0","mt-2"];case"top-left":return[...we,"top-full","left-0","mt-2"];case"top-center":return[...we,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...we,"bottom-full","right-0","mb-2"];case"bottom-left":return[...we,"bottom-full","left-0","mb-2"];case"bottom-center":return[...we,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...we,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...we,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...we,"top-full","right-0","mt-2"]}},"getTooltipClasses"),ot=De(({onClick:we,label:Ee,children:oe})=>{const[Se,Re]=y.useState(!1),Ve=Pe();return ie.createElement("button",{className:`p-2 ${te?"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 ${te?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Re(!0),onMouseLeave:()=>Re(!1),onClick:we,"aria-label":Ee},ie.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"},oe),a&&ie.createElement("span",{className:`${Ve.join(" ")} ${Se?"opacity-100":"opacity-0"}`},Ee))},"IconButton"),Me=De(we=>{if(we===null)return"null";if(we===void 0)return"undefined";if(typeof we=="object")try{return JSON.stringify(we,null,2)}catch{return String(we)}return String(we)},"formatValue"),Je=De(we=>we?`${we.device?.type||"unknown"}`:"N/A","formatUserAgent"),We=De(we=>{if(!we?.insets)return"N/A";const{top:Ee,bottom:oe,left:Se,right:Re}=we.insets;return`T:${Ee} B:${oe} L:${Se} R:${Re}`},"formatSafeArea");return ie.createElement(ie.Fragment,null,ie.createElement("div",{ref:$,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&O(!0),onMouseLeave:()=>!r&&O(!1)},ie.createElement("div",{className:de().join(" "),style:fe()},!W&&ie.createElement(ie.Fragment,null,!j&&!V&&ie.createElement(ie.Fragment,null,(i===!0||i==="fullscreen")&&ie.createElement(ot,{onClick:He,label:"Fullscreen"},ie.createElement("path",{d:"M15 3h6v6"}),ie.createElement("path",{d:"m21 3-7 7"}),ie.createElement("path",{d:"m3 21 7-7"}),ie.createElement("path",{d:"M9 21H3v-6"})),(i===!0||i==="pip")&&ie.createElement(ot,{onClick:$e,label:"Picture in Picture"},ie.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),ie.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),o&&ie.createElement(ot,{onClick:J,label:"Debug Info"},ie.createElement("path",{d:"M12 20v-9"}),ie.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),ie.createElement("path",{d:"M14.12 3.88 16 2"}),ie.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),ie.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),ie.createElement("path",{d:"M22 13h-4"}),ie.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),ie.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),ie.createElement("path",{d:"M6 13H2"}),ie.createElement("path",{d:"m8 2 1.88 1.88"}),ie.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),U&&o&&ie.createElement("div",{ref:H,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:we=>{we.target===H.current&&L(!1)}},ie.createElement("button",{onClick:()=>L(!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"},"×"),ie.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},ie.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),ie.createElement("table",{className:"w-full border-collapse border-spacing-0"},ie.createElement("tbody",null,ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),ie.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Me(c))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),ie.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Me(d))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),ie.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Me(f))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),ie.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Me(m))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),ie.createElement("td",{className:"p-2"},h)),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),ie.createElement("td",{className:"p-2"},g)),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),ie.createElement("td",{className:"p-2"},w)),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),ie.createElement("td",{className:"p-2"},E,"px")),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),ie.createElement("td",{className:"p-2"},Je(x))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),ie.createElement("td",{className:"p-2"},We(v))),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),ie.createElement("td",{className:"p-2"},S?"Yes":"No")),ie.createElement("tr",{className:"border-b border-gray-700"},ie.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),ie.createElement("td",{className:"p-2"},Y.length>0?Y.join(", "):"N/A")))),ie.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),ie.createElement("div",{className:"flex flex-col gap-3"},ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("input",{type:"text",value:K,onChange:we=>F(we.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]"}),ie.createElement("input",{type:"text",value:re,onChange:we=>ee(we.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"}),ie.createElement("button",{onClick:Q,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("input",{type:"text",value:M,onChange:we=>B(we.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"}),ie.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")),ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("input",{type:"text",value:P,onChange:we=>D(we.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"}),ie.createElement("button",{onClick:pe,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),ie.createElement("button",{onClick:()=>he("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"),ie.createElement("button",{onClick:()=>he("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"),ie.createElement("button",{onClick:()=>he("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")),ie.createElement("div",{className:"flex gap-2 items-center"},ie.createElement("button",{onClick:Ne,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)")),ne&&ie.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"},ie.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ne,ie.createElement("button",{onClick:()=>G(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}De(l4,"WidgetControls");function c4(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}De(c4,"getBasename");var yee=150,vee=5;function wee({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!1}){const a=c4(),o=y.useRef(null),i=y.useRef(0),c=y.useRef(null),d=y.useRef(!1),[f,m]=y.useState(null),[h,g]=y.useState(null),[v,E]=y.useState(!0);y.useEffect(()=>{let _=!0;return(async()=>{try{const T=await pa(()=>import("./index-BgQZjv_u.js"),[]);_&&(m(()=>T.BrowserRouter),E(!1))}catch{_&&(g(new Error(`❌ react-router not installed!
|
|
36
36
|
|
|
37
37
|
To use MCP widgets with McpUseProvider, you need to install:
|
|
38
38
|
|
|
@@ -88,7 +88,7 @@ Error generating stack: `+b.message+`
|
|
|
88
88
|
`)},EP=function(){var e=parseInt(document.body.getAttribute(bu)||"0",10);return isFinite(e)?e:0},iae=function(){y.useEffect(function(){return document.body.setAttribute(bu,(EP()+1).toString()),function(){var e=EP()-1;e<=0?document.body.removeAttribute(bu):document.body.setAttribute(bu,e.toString())}},[])},lae=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=r===void 0?"margin":r;iae();var o=y.useMemo(function(){return aae(a)},[a]);return y.createElement(sae,{styles:oae(o,!t,a,n?"":"!important")})},qE=!1;if(typeof window<"u")try{var $g=Object.defineProperty({},"passive",{get:function(){return qE=!0,!0}});window.addEventListener("test",$g,$g),window.removeEventListener("test",$g,$g)}catch{qE=!1}var zc=qE?{passive:!1}:!1,cae=function(e){return e.tagName==="TEXTAREA"},y3=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!cae(e)&&n[t]==="visible")},uae=function(e){return y3(e,"overflowY")},dae=function(e){return y3(e,"overflowX")},SP=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=v3(e,r);if(a){var o=w3(e,r),i=o[1],c=o[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},fae=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},pae=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},v3=function(e,t){return e==="v"?uae(t):dae(t)},w3=function(e,t){return e==="v"?fae(t):pae(t)},mae=function(e,t){return e==="h"&&t==="rtl"?-1:1},hae=function(e,t,n,r,a){var o=mae(e,window.getComputedStyle(t).direction),i=o*r,c=n.target,d=t.contains(c),f=!1,m=i>0,h=0,g=0;do{if(!c)break;var v=w3(e,c),E=v[0],x=v[1],w=v[2],S=x-w-o*E;(E||S)&&v3(e,c)&&(h+=S,g+=E);var _=c.parentNode;c=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!d&&c!==document.body||d&&(t.contains(c)||t===c));return(m&&Math.abs(h)<1||!m&&Math.abs(g)<1)&&(f=!0),f},Ug=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},_P=function(e){return[e.deltaX,e.deltaY]},TP=function(e){return e&&"current"in e?e.current:e},gae=function(e,t){return e[0]===t[0]&&e[1]===t[1]},bae=function(e){return`
|
|
89
89
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
90
90
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
91
|
-
`)},yae=0,Fc=[];function vae(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),a=y.useState(yae++)[0],o=y.useState(b3)[0],i=y.useRef(e);y.useEffect(function(){i.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var x=zre([e.lockRef.current],(e.shards||[]).map(TP),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var c=y.useCallback(function(x,w){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var S=Ug(x),_=n.current,T="deltaX"in x?x.deltaX:_[0]-S[0],R="deltaY"in x?x.deltaY:_[1]-S[1],C,A=x.target,I=Math.abs(T)>Math.abs(R)?"h":"v";if("touches"in x&&I==="h"&&A.type==="range")return!1;var O=window.getSelection(),U=O&&O.anchorNode,L=U?U===A||U.contains(A):!1;if(L)return!1;var $=SP(I,A);if(!$)return!0;if($?C=I:(C=I==="v"?"h":"v",$=SP(I,A)),!$)return!1;if(!r.current&&"changedTouches"in x&&(T||R)&&(r.current=C),!C)return!0;var H=r.current||C;return hae(H,w,x,H==="h"?T:R)},[]),d=y.useCallback(function(x){var w=x;if(!(!Fc.length||Fc[Fc.length-1]!==o)){var S="deltaY"in w?_P(w):Ug(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&gae(C.delta,S)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var T=(i.current.shards||[]).map(TP).filter(Boolean).filter(function(C){return C.contains(w.target)}),R=T.length>0?c(w,T[0]):!i.current.noIsolation;R&&w.cancelable&&w.preventDefault()}}},[]),f=y.useCallback(function(x,w,S,_){var T={name:x,delta:w,target:S,should:_,shadowParent:wae(S)};t.current.push(T),setTimeout(function(){t.current=t.current.filter(function(R){return R!==T})},1)},[]),m=y.useCallback(function(x){n.current=Ug(x),r.current=void 0},[]),h=y.useCallback(function(x){f(x.type,_P(x),x.target,c(x,e.lockRef.current))},[]),g=y.useCallback(function(x){f(x.type,Ug(x),x.target,c(x,e.lockRef.current))},[]);y.useEffect(function(){return Fc.push(o),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",d,zc),document.addEventListener("touchmove",d,zc),document.addEventListener("touchstart",m,zc),function(){Fc=Fc.filter(function(x){return x!==o}),document.removeEventListener("wheel",d,zc),document.removeEventListener("touchmove",d,zc),document.removeEventListener("touchstart",m,zc)}},[]);var v=e.removeScrollBar,E=e.inert;return y.createElement(y.Fragment,null,E?y.createElement(o,{styles:bae(a)}):null,v?y.createElement(lae,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function wae(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const xae=Zre(g3,vae);var om=y.forwardRef(function(e,t){return y.createElement(Jy,Hs({},e,{ref:t,sideCar:xae}))});om.classNames=Jy.classNames;var XE=["Enter"," "],Eae=["ArrowDown","PageUp","Home"],x3=["ArrowUp","PageDown","End"],Sae=[...Eae,...x3],_ae={ltr:[...XE,"ArrowRight"],rtl:[...XE,"ArrowLeft"]},Tae={ltr:["ArrowLeft"],rtl:["ArrowRight"]},im="Menu",[yp,Nae,kae]=aT(im),[Zl,E3]=Os(im,[kae,Yi,l3]),Qy=Yi(),S3=l3(),[Cae,ql]=Zl(im),[Rae,lm]=Zl(im),_3=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:o,modal:i=!0}=e,c=Qy(t),[d,f]=y.useState(null),m=y.useRef(!1),h=Xs(o),g=sT(a);return y.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",E,{capture:!0,once:!0}),document.addEventListener("pointermove",E,{capture:!0,once:!0})},E=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",E,{capture:!0}),document.removeEventListener("pointermove",E,{capture:!0})}},[]),u.jsx(Yy,{...c,children:u.jsx(Cae,{scope:t,open:n,onOpenChange:h,content:d,onContentChange:f,children:u.jsx(Rae,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:i,children:r})})})};_3.displayName=im;var Aae="MenuAnchor",hT=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Qy(n);return u.jsx(am,{...a,...r,ref:t})});hT.displayName=Aae;var gT="MenuPortal",[Iae,T3]=Zl(gT,{forceMount:void 0}),N3=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=ql(gT,t);return u.jsx(Iae,{scope:t,forceMount:n,children:u.jsx(Wa,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:r})})})};N3.displayName=gT;var os="MenuContent",[Oae,bT]=Zl(os),k3=y.forwardRef((e,t)=>{const n=T3(os,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=ql(os,e.__scopeMenu),i=lm(os,e.__scopeMenu);return u.jsx(yp.Provider,{scope:e.__scopeMenu,children:u.jsx(Wa,{present:r||o.open,children:u.jsx(yp.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(Dae,{...a,ref:t}):u.jsx(Lae,{...a,ref:t})})})})}),Dae=y.forwardRef((e,t)=>{const n=ql(os,e.__scopeMenu),r=y.useRef(null),a=ln(t,r);return y.useEffect(()=>{const o=r.current;if(o)return Xy(o)},[]),u.jsx(yT,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Xe(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Lae=y.forwardRef((e,t)=>{const n=ql(os,e.__scopeMenu);return u.jsx(yT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Mae=Pl("MenuContent.ScrollLock"),yT=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:E,...x}=e,w=ql(os,n),S=lm(os,n),_=Qy(n),T=S3(n),R=Nae(n),[C,A]=y.useState(null),I=y.useRef(null),O=ln(t,I,w.onContentChange),U=y.useRef(0),L=y.useRef(""),$=y.useRef(0),H=y.useRef(null),Y=y.useRef("right"),q=y.useRef(0),ne=E?om:y.Fragment,G=E?{as:Mae,allowPinchZoom:!0}:void 0,K=re=>{const ee=L.current+re,M=R().filter(W=>!W.disabled),B=document.activeElement,P=M.find(W=>W.ref.current===B)?.textValue,D=M.map(W=>W.textValue),j=Kae(D,ee,P),V=M.find(W=>W.textValue===j)?.ref.current;(function W(te){L.current=te,window.clearTimeout(U.current),te!==""&&(U.current=window.setTimeout(()=>W(""),1e3))})(ee),V&&setTimeout(()=>V.focus())};y.useEffect(()=>()=>window.clearTimeout(U.current),[]),Hy();const F=y.useCallback(re=>Y.current===H.current?.side&&Zae(re,H.current?.area),[]);return u.jsx(Oae,{scope:n,searchRef:L,onItemEnter:y.useCallback(re=>{F(re)&&re.preventDefault()},[F]),onItemLeave:y.useCallback(re=>{F(re)||(I.current?.focus(),A(null))},[F]),onTriggerLeave:y.useCallback(re=>{F(re)&&re.preventDefault()},[F]),pointerGraceTimerRef:$,onPointerGraceIntentChange:y.useCallback(re=>{H.current=re},[]),children:u.jsx(ne,{...G,children:u.jsx(nm,{asChild:!0,trapped:a,onMountAutoFocus:Xe(o,re=>{re.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(yd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:u.jsx(Mre,{asChild:!0,...T,dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:A,onEntryFocus:Xe(d,re=>{S.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(Zy,{role:"menu","aria-orientation":"vertical","data-state":H3(w.open),"data-radix-menu-content":"",dir:S.dir,..._,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:Xe(x.onKeyDown,re=>{const M=re.target.closest("[data-radix-menu-content]")===re.currentTarget,B=re.ctrlKey||re.altKey||re.metaKey,P=re.key.length===1;M&&(re.key==="Tab"&&re.preventDefault(),!B&&P&&K(re.key));const D=I.current;if(re.target!==D||!Sae.includes(re.key))return;re.preventDefault();const V=R().filter(W=>!W.disabled).map(W=>W.ref.current);x3.includes(re.key)&&V.reverse(),Gae(V)}),onBlur:Xe(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(U.current),L.current="")}),onPointerMove:Xe(e.onPointerMove,vp(re=>{const ee=re.target,M=q.current!==re.clientX;if(re.currentTarget.contains(ee)&&M){const B=re.clientX>q.current?"right":"left";Y.current=B,q.current=re.clientX}}))})})})})})})});k3.displayName=os;var jae="MenuGroup",vT=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(jt.div,{role:"group",...r,ref:t})});vT.displayName=jae;var Pae="MenuLabel",C3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(jt.div,{...r,ref:t})});C3.displayName=Pae;var Zb="MenuItem",NP="menu.itemSelect",ev=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,o=y.useRef(null),i=lm(Zb,e.__scopeMenu),c=bT(Zb,e.__scopeMenu),d=ln(t,o),f=y.useRef(!1),m=()=>{const h=o.current;if(!n&&h){const g=new CustomEvent(NP,{bubbles:!0,cancelable:!0});h.addEventListener(NP,v=>r?.(v),{once:!0}),j4(h,g),g.defaultPrevented?f.current=!1:i.onClose()}};return u.jsx(R3,{...a,ref:d,disabled:n,onClick:Xe(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:Xe(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:Xe(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||XE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ev.displayName=Zb;var R3=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...o}=e,i=bT(Zb,n),c=S3(n),d=y.useRef(null),f=ln(t,d),[m,h]=y.useState(!1),[g,v]=y.useState("");return y.useEffect(()=>{const E=d.current;E&&v((E.textContent??"").trim())},[o.children]),u.jsx(yp.ItemSlot,{scope:n,disabled:r,textValue:a??g,children:u.jsx(jre,{asChild:!0,...c,focusable:!r,children:u.jsx(jt.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:f,onPointerMove:Xe(e.onPointerMove,vp(E=>{r?i.onItemLeave(E):(i.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Xe(e.onPointerLeave,vp(E=>i.onItemLeave(E))),onFocus:Xe(e.onFocus,()=>h(!0)),onBlur:Xe(e.onBlur,()=>h(!1))})})})}),$ae="MenuCheckboxItem",A3=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return u.jsx(M3,{scope:e.__scopeMenu,checked:n,children:u.jsx(ev,{role:"menuitemcheckbox","aria-checked":qb(n)?"mixed":n,...a,ref:t,"data-state":xT(n),onSelect:Xe(a.onSelect,()=>r?.(qb(n)?!0:!n),{checkForDefaultPrevented:!1})})})});A3.displayName=$ae;var I3="MenuRadioGroup",[Uae,zae]=Zl(I3,{value:void 0,onValueChange:()=>{}}),O3=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,o=Xs(r);return u.jsx(Uae,{scope:e.__scopeMenu,value:n,onValueChange:o,children:u.jsx(vT,{...a,ref:t})})});O3.displayName=I3;var D3="MenuRadioItem",L3=y.forwardRef((e,t)=>{const{value:n,...r}=e,a=zae(D3,e.__scopeMenu),o=n===a.value;return u.jsx(M3,{scope:e.__scopeMenu,checked:o,children:u.jsx(ev,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":xT(o),onSelect:Xe(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});L3.displayName=D3;var wT="MenuItemIndicator",[M3,Fae]=Zl(wT,{checked:!1}),j3=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,o=Fae(wT,n);return u.jsx(Wa,{present:r||qb(o.checked)||o.checked===!0,children:u.jsx(jt.span,{...a,ref:t,"data-state":xT(o.checked)})})});j3.displayName=wT;var Bae="MenuSeparator",P3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(jt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});P3.displayName=Bae;var Hae="MenuArrow",$3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Qy(n);return u.jsx(qy,{...a,...r,ref:t})});$3.displayName=Hae;var Vae="MenuSub",[Yxe,U3]=Zl(Vae),Bf="MenuSubTrigger",z3=y.forwardRef((e,t)=>{const n=ql(Bf,e.__scopeMenu),r=lm(Bf,e.__scopeMenu),a=U3(Bf,e.__scopeMenu),o=bT(Bf,e.__scopeMenu),i=y.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=o,f={__scopeMenu:e.__scopeMenu},m=y.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return y.useEffect(()=>m,[m]),y.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),d(null)}},[c,d]),u.jsx(hT,{asChild:!0,...f,children:u.jsx(R3,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":H3(n.open),...e,ref:qs(t,a.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Xe(e.onPointerMove,vp(h=>{o.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(o.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:Xe(e.onPointerLeave,vp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,E=v==="right",x=E?-5:5,w=g[E?"left":"right"],S=g[E?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:w,y:g.top},{x:S,y:g.top},{x:S,y:g.bottom},{x:w,y:g.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Xe(e.onKeyDown,h=>{const g=o.searchRef.current!=="";e.disabled||g&&h.key===" "||_ae[r.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});z3.displayName=Bf;var F3="MenuSubContent",B3=y.forwardRef((e,t)=>{const n=T3(os,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=ql(os,e.__scopeMenu),i=lm(os,e.__scopeMenu),c=U3(F3,e.__scopeMenu),d=y.useRef(null),f=ln(t,d);return u.jsx(yp.Provider,{scope:e.__scopeMenu,children:u.jsx(Wa,{present:r||o.open,children:u.jsx(yp.Slot,{scope:e.__scopeMenu,children:u.jsx(yT,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:f,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{i.isUsingKeyboardRef.current&&d.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Xe(e.onFocusOutside,m=>{m.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Xe(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:Xe(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=Tae[i.dir].includes(m.key);h&&g&&(o.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});B3.displayName=F3;function H3(e){return e?"open":"closed"}function qb(e){return e==="indeterminate"}function xT(e){return qb(e)?"indeterminate":e?"checked":"unchecked"}function Gae(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Wae(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Kae(e,t,n){const a=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let i=Wae(e,Math.max(o,0));a.length===1&&(i=i.filter(f=>f!==n));const d=i.find(f=>f.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d:void 0}function Yae(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const c=t[o],d=t[i],f=c.x,m=c.y,h=d.x,g=d.y;m>r!=g>r&&n<(h-f)*(r-m)/(g-m)+f&&(a=!a)}return a}function Zae(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Yae(n,t)}function vp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var qae=_3,Xae=hT,Jae=N3,Qae=k3,ese=vT,tse=C3,nse=ev,rse=A3,ase=O3,sse=L3,ose=j3,ise=P3,lse=$3,cse=z3,use=B3,tv="DropdownMenu",[dse]=Os(tv,[E3]),ba=E3(),[fse,V3]=dse(tv),G3=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:o,onOpenChange:i,modal:c=!0}=e,d=ba(t),f=y.useRef(null),[m,h]=jo({prop:a,defaultProp:o??!1,onChange:i,caller:tv});return u.jsx(fse,{scope:t,triggerId:Xr(),triggerRef:f,contentId:Xr(),open:m,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:c,children:u.jsx(qae,{...d,open:m,onOpenChange:h,dir:r,modal:c,children:n})})};G3.displayName=tv;var W3="DropdownMenuTrigger",K3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,o=V3(W3,n),i=ba(n);return u.jsx(Xae,{asChild:!0,...i,children:u.jsx(jt.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:qs(t,o.triggerRef),onPointerDown:Xe(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(o.onOpenToggle(),o.open||c.preventDefault())}),onKeyDown:Xe(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&o.onOpenToggle(),c.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});K3.displayName=W3;var pse="DropdownMenuPortal",Y3=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ba(t);return u.jsx(Jae,{...r,...n})};Y3.displayName=pse;var Z3="DropdownMenuContent",q3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=V3(Z3,n),o=ba(n),i=y.useRef(!1);return u.jsx(Qae,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...r,ref:t,onCloseAutoFocus:Xe(e.onCloseAutoFocus,c=>{i.current||a.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:Xe(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,m=d.button===2||f;(!a.modal||m)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});q3.displayName=Z3;var mse="DropdownMenuGroup",hse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(ese,{...a,...r,ref:t})});hse.displayName=mse;var gse="DropdownMenuLabel",X3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(tse,{...a,...r,ref:t})});X3.displayName=gse;var bse="DropdownMenuItem",J3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(nse,{...a,...r,ref:t})});J3.displayName=bse;var yse="DropdownMenuCheckboxItem",Q3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(rse,{...a,...r,ref:t})});Q3.displayName=yse;var vse="DropdownMenuRadioGroup",wse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(ase,{...a,...r,ref:t})});wse.displayName=vse;var xse="DropdownMenuRadioItem",eB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(sse,{...a,...r,ref:t})});eB.displayName=xse;var Ese="DropdownMenuItemIndicator",Sse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(ose,{...a,...r,ref:t})});Sse.displayName=Ese;var _se="DropdownMenuSeparator",tB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(ise,{...a,...r,ref:t})});tB.displayName=_se;var Tse="DropdownMenuArrow",Nse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(lse,{...a,...r,ref:t})});Nse.displayName=Tse;var kse="DropdownMenuSubTrigger",nB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(cse,{...a,...r,ref:t})});nB.displayName=kse;var Cse="DropdownMenuSubContent",rB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(use,{...a,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});rB.displayName=Cse;var Rse=G3,Ase=K3,Ise=Y3,aB=q3,sB=X3,oB=J3,Ose=Q3,Dse=eB,iB=tB,Lse=nB,Mse=rB;const Xb=Rse,Jb=Ase;Lse.displayName;Mse.displayName;function wp({ref:e,className:t,sideOffset:n=4,...r}){return u.jsx(Ise,{children:u.jsx(aB,{ref:e,sideOffset:n,className:Oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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",t),...r})})}wp.displayName=aB.displayName;function Vr({ref:e,className:t,inset:n,...r}){return u.jsx(oB,{ref:e,className:Oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...r})}Vr.displayName=oB.displayName;Ose.displayName;Dse.displayName;function JE({ref:e,className:t,inset:n,...r}){return u.jsx(sB,{ref:e,className:Oe("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...r})}JE.displayName=sB.displayName;function ru({ref:e,className:t,...n}){return u.jsx(iB,{ref:e,className:Oe("-mx-1 my-1 h-px bg-muted",t),...n})}ru.displayName=iB.displayName;var jse=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ho=jse.reduce((e,t)=>{const n=b4(`Primitive.${t}`),r=y.forwardRef((a,o)=>{const{asChild:i,...c}=a,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(d,{...c,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Pse="Label",lB=y.forwardRef((e,t)=>u.jsx(Ho.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));lB.displayName=Pse;var $se=lB;function on({className:e,...t}){return u.jsx($se,{"data-slot":"label",className:Oe("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function Ed({message:e,className:t="",vertical:n,noBorder:r}){return u.jsx("div",{className:Oe(`mt-2 rounded-md p-6 ${t}`,!r&&"border"),children:u.jsxs("p",{className:Oe("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[u.jsx("svg",{width:"40",height:"40",viewBox:"0 0 273 273",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:u.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:u.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[u.jsx("path",{d:"M49.953025,-2.10854389 C63.26892,-2.21867124 76.6185256,2.70621155 86.9019463,12.6653164 L86.9019463,12.6653164 L87.505627,13.2592944 C97.5154947,23.2654892 102.640454,36.3074513 102.880738,49.4222247 C103.08932,77.4533067 113.877287,105.391753 135.242867,126.757333 C156.613383,148.127849 184.559216,158.914875 212.568138,159.119313 L212.568138,159.119313 L213.212264,159.134159 C225.843948,159.517566 238.363557,164.434972 248.121998,173.886137 L248.121998,173.886137 L248.725621,174.480088 C258.982114,184.732164 264.11035,198.171134 264.11035,211.6101 C264.11035,225.04592 258.984514,238.481745 248.732867,248.732867 C238.592792,258.872942 225.336706,263.997882 212.046872,264.107794 C198.731075,264.21792 185.381569,259.293085 175.098248,249.334078 L175.098248,249.334078 L174.494602,248.740134 C163.75802,238.008189 158.640853,223.784027 159.143413,209.719372 C158.258245,182.640933 147.489786,155.83332 126.828333,135.171867 C106.351297,114.694831 79.8363505,103.934873 53.0237258,102.891841 L53.0237258,102.891841 L52.2811438,102.865674 C38.4791718,103.347421 24.5325234,98.4328111 13.8776628,88.1140866 L13.8776628,88.1140866 L13.2739843,87.5201168 C3.12895117,77.3789607 -1.9984796,64.1195994 -2.10841888,50.8264755 C-2.21854669,37.5105567 2.70635908,24.1609269 12.6655135,13.8774565 L12.6655135,13.8774565 L13.2594878,13.2737797 C23.4005926,3.12880025 36.659927,-1.99860507 49.953025,-2.10854389 Z"}),u.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),u.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function cB({className:e,color:t,children:n,grayscaled:r=!1}){const a=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return r?0:.2},[t,r]),o=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return r?.3:.4},[t,r]),i=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[2]||"0")}return Math.floor(Math.random()*360)},[t]),c=y.useMemo(()=>t||`oklch(${Math.min(o,1)} ${a} ${i})`,[i,a,o]),d=y.useMemo(()=>`oklch(${Math.min(o*2,1)} ${a} ${i})`,[i,a,o,t]),f=y.useMemo(()=>Math.floor(Math.random()*360),[i]),m=y.useMemo(()=>"1000%",[]);return u.jsx("section",{className:Oe("relative w-full h-full overflow-hidden",e),style:{background:`${d}`},children:u.jsxs("div",{className:"isolate relative w-full h-full",children:[u.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${f}deg, ${c}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${m})`}}),n&&u.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function ET(e){const t=y.useRef({value:e,previous:e});return y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var nv="Switch",[Use]=Os(nv),[zse,Fse]=Use(nv),uB=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:o,required:i,disabled:c,value:d="on",onCheckedChange:f,form:m,...h}=e,[g,v]=y.useState(null),E=ln(t,T=>v(T)),x=y.useRef(!1),w=g?m||!!g.closest("form"):!0,[S,_]=jo({prop:a,defaultProp:o??!1,onChange:f,caller:nv});return u.jsxs(zse,{scope:n,checked:S,disabled:c,children:[u.jsx(jt.button,{type:"button",role:"switch","aria-checked":S,"aria-required":i,"data-state":mB(S),"data-disabled":c?"":void 0,disabled:c,value:d,...h,ref:E,onClick:Xe(e.onClick,T=>{_(R=>!R),w&&(x.current=T.isPropagationStopped(),x.current||T.stopPropagation())})}),w&&u.jsx(pB,{control:g,bubbles:!x.current,name:r,value:d,checked:S,required:i,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});uB.displayName=nv;var dB="SwitchThumb",fB=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Fse(dB,n);return u.jsx(jt.span,{"data-state":mB(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});fB.displayName=dB;var Bse="SwitchBubbleInput",pB=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},o)=>{const i=y.useRef(null),c=ln(i,o),d=ET(n),f=fT(t);return y.useEffect(()=>{const m=i.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(d!==n&&v){const E=new Event("click",{bubbles:r});v.call(m,n),m.dispatchEvent(E)}},[d,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});pB.displayName=Bse;function mB(e){return e?"checked":"unchecked"}var hB=uB,Hse=fB;function rv({ref:e,className:t,...n}){return u.jsx(hB,{className:Oe("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:u.jsx(Hse,{className:Oe("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})}rv.displayName=hB.displayName;var gB=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"}),Vse="VisuallyHidden",bB=y.forwardRef((e,t)=>u.jsx(jt.span,{...e,ref:t,style:{...gB,...e.style}}));bB.displayName=Vse;var Gse=bB,[av]=Os("Tooltip",[Yi]),sv=Yi(),yB="TooltipProvider",Wse=700,QE="tooltip.open",[Kse,ST]=av(yB),vB=e=>{const{__scopeTooltip:t,delayDuration:n=Wse,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:o}=e,i=y.useRef(!0),c=y.useRef(!1),d=y.useRef(0);return y.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),u.jsx(Kse,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(d.current),i.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:y.useCallback(f=>{c.current=f},[]),disableHoverableContent:a,children:o})};vB.displayName=yB;var xp="Tooltip",[Yse,cm]=av(xp),wB=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:a,onOpenChange:o,disableHoverableContent:i,delayDuration:c}=e,d=ST(xp,e.__scopeTooltip),f=sv(t),[m,h]=y.useState(null),g=Xr(),v=y.useRef(0),E=i??d.disableHoverableContent,x=c??d.delayDuration,w=y.useRef(!1),[S,_]=jo({prop:r,defaultProp:a??!1,onChange:I=>{I?(d.onOpen(),document.dispatchEvent(new CustomEvent(QE))):d.onClose(),o?.(I)},caller:xp}),T=y.useMemo(()=>S?w.current?"delayed-open":"instant-open":"closed",[S]),R=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,w.current=!1,_(!0)},[_]),C=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_(!1)},[_]),A=y.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{w.current=!0,_(!0),v.current=0},x)},[x,_]);return y.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),u.jsx(Yy,{...f,children:u.jsx(Yse,{scope:t,contentId:g,open:S,stateAttribute:T,trigger:m,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{d.isOpenDelayedRef.current?A():R()},[d.isOpenDelayedRef,A,R]),onTriggerLeave:y.useCallback(()=>{E?C():(window.clearTimeout(v.current),v.current=0)},[C,E]),onOpen:R,onClose:C,disableHoverableContent:E,children:n})})};wB.displayName=xp;var eS="TooltipTrigger",xB=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=cm(eS,n),o=ST(eS,n),i=sv(n),c=y.useRef(null),d=ln(t,c,a.onTriggerChange),f=y.useRef(!1),m=y.useRef(!1),h=y.useCallback(()=>f.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(am,{asChild:!0,...i,children:u.jsx(jt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:d,onPointerMove:Xe(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),m.current=!0)}),onPointerLeave:Xe(e.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:Xe(e.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Xe(e.onFocus,()=>{f.current||a.onOpen()}),onBlur:Xe(e.onBlur,a.onClose),onClick:Xe(e.onClick,a.onClose)})})});xB.displayName=eS;var _T="TooltipPortal",[Zse,qse]=av(_T,{forceMount:void 0}),EB=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:a}=e,o=cm(_T,t);return u.jsx(Zse,{scope:t,forceMount:n,children:u.jsx(Wa,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:r})})})};EB.displayName=_T;var ed="TooltipContent",SB=y.forwardRef((e,t)=>{const n=qse(ed,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...o}=e,i=cm(ed,e.__scopeTooltip);return u.jsx(Wa,{present:r||i.open,children:i.disableHoverableContent?u.jsx(_B,{side:a,...o,ref:t}):u.jsx(Xse,{side:a,...o,ref:t})})}),Xse=y.forwardRef((e,t)=>{const n=cm(ed,e.__scopeTooltip),r=ST(ed,e.__scopeTooltip),a=y.useRef(null),o=ln(t,a),[i,c]=y.useState(null),{trigger:d,onClose:f}=n,m=a.current,{onPointerInTransitChange:h}=r,g=y.useCallback(()=>{c(null),h(!1)},[h]),v=y.useCallback((E,x)=>{const w=E.currentTarget,S={x:E.clientX,y:E.clientY},_=toe(S,w.getBoundingClientRect()),T=noe(S,_),R=roe(x.getBoundingClientRect()),C=soe([...T,...R]);c(C),h(!0)},[h]);return y.useEffect(()=>()=>g(),[g]),y.useEffect(()=>{if(d&&m){const E=w=>v(w,m),x=w=>v(w,d);return d.addEventListener("pointerleave",E),m.addEventListener("pointerleave",x),()=>{d.removeEventListener("pointerleave",E),m.removeEventListener("pointerleave",x)}}},[d,m,v,g]),y.useEffect(()=>{if(i){const E=x=>{const w=x.target,S={x:x.clientX,y:x.clientY},_=d?.contains(w)||m?.contains(w),T=!aoe(S,i);_?g():T&&(g(),f())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[d,m,i,f,g]),u.jsx(_B,{...e,ref:o})}),[Jse,Qse]=av(xp,{isInside:!1}),eoe=Lte("TooltipContent"),_B=y.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:i,...c}=e,d=cm(ed,n),f=sv(n),{onClose:m}=d;return y.useEffect(()=>(document.addEventListener(QE,m),()=>document.removeEventListener(QE,m)),[m]),y.useEffect(()=>{if(d.trigger){const h=g=>{g.target?.contains(d.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[d.trigger,m]),u.jsx(yd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:u.jsxs(Zy,{"data-state":d.stateAttribute,...f,...c,ref:t,style:{...c.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:[u.jsx(eoe,{children:r}),u.jsx(Jse,{scope:n,isInside:!0,children:u.jsx(Gse,{id:d.contentId,role:"tooltip",children:a||r})})]})})});SB.displayName=ed;var TB="TooltipArrow",NB=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=sv(n);return Qse(TB,n).isInside?null:u.jsx(qy,{...a,...r,ref:t})});NB.displayName=TB;function toe(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,a,o)){case o:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function noe(e,t,n=5){const 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 roe(e){const{top:t,right:n,bottom:r,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:r},{x:a,y:r}]}function aoe(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const c=t[o],d=t[i],f=c.x,m=c.y,h=d.x,g=d.y;m>r!=g>r&&n<(h-f)*(r-m)/(g-m)+f&&(a=!a)}return a}function soe(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),ooe(t)}function ooe(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const a=e[r];for(;t.length>=2;){const o=t[t.length-1],i=t[t.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const a=e[r];for(;n.length>=2;){const o=n[n.length-1],i=n[n.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))n.pop();else break}n.push(a)}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 ioe=vB,loe=wB,coe=xB,uoe=EB,doe=SB,foe=NB;function TT({delayDuration:e=0,...t}){return u.jsx(ioe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function At({...e}){return u.jsx(TT,{children:u.jsx(loe,{"data-slot":"tooltip",...e})})}function It({...e}){return u.jsx(coe,{"data-slot":"tooltip-trigger",...e})}function Ot({className:e,sideOffset:t=0,children:n,...r}){return u.jsx(uoe,{children:u.jsxs(doe,{"data-slot":"tooltip-content",sideOffset:t,className:Oe("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,u.jsx(foe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class poe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class kP{name="mcp_tool_execution";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId,success:t.success,duration:t.duration,error:t.error}}}class CP{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class RP{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class AP{name="mcp_chat_message";properties;constructor(t){this.properties={server_id:t.serverId,provider:t.provider,model:t.model,message_count:t.messageCount,tool_calls_count:t.toolCallsCount,success:t.success,execution_mode:t.executionMode,duration:t.duration,error:t.error}}}class moe{name="mcp_server_added";properties;constructor(t){this.properties={server_id:t.serverId,server_url:t.serverUrl,connection_type:t.connectionType,via_proxy:t.viaProxy}}}class hoe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class goe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function O0(){try{return"0.14.2-canary.2"}catch{return"0.0.0"}}var boe={};function D0(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class IP{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout),a=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(r),!a.ok)throw new Error(`HTTP error! status: ${a.status}`)}catch{}}}function vi(e){return`mcp_inspector_telemetry_${e}`}class Zr{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(){const t=D0(),n=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||"inspector",n)this._posthogClient=null,this._scarfClient=null;else if(!t)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new IP(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new IP(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(vi("disabled"))==="true"||typeof process<"u"&&boe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(vi("source")):null}static getInstance(){return Zr.instance||(Zr.instance=new Zr),Zr.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(vi("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!D0())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(vi("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(vi("user_id"),n),this._currUserId=n}this.trackPackageDownload({triggered_by:"user_id_property"}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){const t=window.crypto;if(t){const n=new Uint8Array(16);t.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("");return r.slice(0,8)+"-"+r.slice(8,12)+"-"+r.slice(12,16)+"-"+r.slice(16,20)+"-"+r.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=Math.random()*16|0;return(n==="x"?r:r&3|8).toString(16)})}async capture(t){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{const n={event:t.name,user_id:this.userId,properties:{...t.properties,mcp_use_version:O0(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=O0(),n.user_id=this.userId,n.event=t.name,n.language="typescript",n.source=this._source,n.package="inspector",await this._scarfClient.logEvent(n)}catch{}}}async trackPackageDownload(t){if(this._scarfClient&&D0())try{const n=O0();let r=!1,a=!1;const o=localStorage.getItem(vi("download_version"));if(o?n>o&&(r=!0,a=!1,localStorage.setItem(vi("download_version"),n)):(r=!0,a=!0,localStorage.setItem(vi("download_version"),n)),r){const i={...t||{}};i.mcp_use_version=n,i.user_id=this.userId,i.event="package_download",i.first_download=a,i.language="typescript",i.source=this._source,i.package="inspector",await this._scarfClient.logEvent(i)}}catch{}}async trackInspectorOpen(t){const n=new poe(t);await this.capture(n)}}const yoe="0.14.1-canary.1";function voe(){return yoe}const woe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),xoe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),OP=e=>{const t=xoe(e);return t.charAt(0).toUpperCase()+t.slice(1)},kB=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Eoe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Soe={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"};const _oe=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:o,iconNode:i,...c},d)=>y.createElement("svg",{ref:d,...Soe,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:kB("lucide",a),...!o&&!Eoe(c)&&{"aria-hidden":"true"},...c},[...i.map(([f,m])=>y.createElement(f,m)),...Array.isArray(o)?o:[o]]));const st=(e,t)=>{const n=y.forwardRef(({className:r,...a},o)=>y.createElement(_oe,{ref:o,iconNode:t,className:kB(`lucide-${woe(OP(e))}`,`lucide-${e}`,r),...a}));return n.displayName=OP(e),n};const Toe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],Noe=st("arrow-down-to-line",Toe);const koe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Coe=st("arrow-up-from-line",koe);const Roe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Aoe=st("arrow-up",Roe);const Ioe=[["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"}]],NT=st("bell",Ioe);const Ooe=[["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"}]],CB=st("brush",Ooe);const Doe=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],Loe=st("bug",Doe);const Moe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Er=st("check",Moe);const joe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Qs=st("chevron-down",joe);const Poe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ov=st("chevron-left",Poe);const $oe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],RB=st("chevron-right",$oe);const Uoe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],zoe=st("chevron-up",Uoe);const Foe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Boe=st("chevrons-up-down",Foe);const Hoe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],DP=st("circle-minus",Hoe);const Voe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ep=st("clock",Voe);const Goe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],kT=st("code",Goe);const Woe=[["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"}]],Koe=st("cog",Woe);const Yoe=[["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"}]],Zoe=st("command",Yoe);const qoe=[["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"}]],dr=st("copy",qoe);const Xoe=[["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"}]],iv=st("database",Xoe);const Joe=[["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"}]],um=st("download",Joe);const Qoe=[["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"}]],eie=st("ellipsis-vertical",Qoe);const tie=[["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"}]],tS=st("external-link",tie);const nie=[["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"}]],AB=st("eye-off",nie);const rie=[["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"}]],nS=st("eye",rie);const aie=[["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"}]],sie=st("file-code",aie);const oie=[["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"}]],iie=st("file-image",oie);const lie=[["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"}]],CT=st("file-text",lie);const cie=[["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"}]],uie=st("file",cie);const die=[["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"}]],fie=st("folder-open",die);const pie=[["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"}]],mie=st("globe",pie);const hie=[["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"}]],gie=st("grip-vertical",hie);const bie=[["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"}]],IB=st("hash",bie);const yie=[["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"}]],Sp=st("history",yie);const vie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Qf=st("info",vie);const wie=[["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"}]],OB=st("key",wie);const xie=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Bi=st("loader-circle",xie);const Eie=[["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"}]],RT=st("maximize-2",Eie);const Sie=[["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"}]],_p=st("maximize",Sie);const _ie=[["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"}]],Tie=st("message-circle",_ie);const Nie=[["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=st("message-square",Nie);const kie=[["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"}]],DB=st("minimize",kie);const Cie=[["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"}]],LP=st("monitor",Cie);const Rie=[["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"}]],Aie=st("moon",Rie);const Iie=[["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"}]],Oie=st("picture-in-picture",Iie);const Die=[["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"}]],LB=st("play",Die);const Lie=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Np=st("plus",Lie);const Mie=[["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"}]],MP=st("rotate-ccw",Mie);const jie=[["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"}]],AT=st("save",jie);const Pie=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Sd=st("search",Pie);const $ie=[["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"}]],Uie=st("send",$ie);const zie=[["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"}]],MB=st("server",zie);const Fie=[["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"}]],yu=st("settings",Fie);const Bie=[["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"}]],Hie=st("shield",Bie);const Vie=[["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"}]],Gie=st("sparkles",Vie);const Wie=[["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"}]],jB=st("square-check-big",Wie);const Kie=[["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"}]],Yie=st("square-pen",Kie);const Zie=[["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"}]],qie=st("sun-dim",Zie);const Xie=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],L0=st("terminal",Xie);const Jie=[["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"}]],Uo=st("trash-2",Jie);const Qie=[["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"}]],ele=st("trash",Qie);const tle=[["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"}]],Ul=st("wrench",tle);const nle=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ro=st("x",nle);const rle=[["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"}]],kp=st("zap",rle);var jP="popstate";function ale(e={}){function t(r,a){let{pathname:o,search:i,hash:c}=r.location;return rS("",{pathname:o,search:i,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:Cp(a)}return ole(t,n,null,e)}function rr(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ks(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function sle(){return Math.random().toString(36).substring(2,10)}function PP(e,t){return{usr:e.state,key:e.key,idx:t}}function rS(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?_d(t):t,state:n,key:t&&t.key||r||sle()}}function Cp({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 _d(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 ole(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:o=!1}=r,i=a.history,c="POP",d=null,f=m();f==null&&(f=0,i.replaceState({...i.state,idx:f},""));function m(){return(i.state||{idx:null}).idx}function h(){c="POP";let w=m(),S=w==null?null:w-f;f=w,d&&d({action:c,location:x.location,delta:S})}function g(w,S){c="PUSH";let _=rS(x.location,w,S);f=m()+1;let T=PP(_,f),R=x.createHref(_);try{i.pushState(T,"",R)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;a.location.assign(R)}o&&d&&d({action:c,location:x.location,delta:1})}function v(w,S){c="REPLACE";let _=rS(x.location,w,S);f=m();let T=PP(_,f),R=x.createHref(_);i.replaceState(T,"",R),o&&d&&d({action:c,location:x.location,delta:0})}function E(w){return ile(w)}let x={get action(){return c},get location(){return e(a,i)},listen(w){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(jP,h),d=w,()=>{a.removeEventListener(jP,h),d=null}},createHref(w){return t(a,w)},createURL:E,encodeLocation(w){let S=E(w);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:g,replace:v,go(w){return i.go(w)}};return x}function ile(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),rr(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Cp(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function PB(e,t,n="/"){return lle(e,t,n,!1)}function lle(e,t,n,r){let a=typeof t=="string"?_d(t):t,o=zo(a.pathname||"/",n);if(o==null)return null;let i=$B(e);cle(i);let c=null;for(let d=0;c==null&&d<i.length;++d){let f=wle(o);c=yle(i[d],f,r)}return c}function $B(e,t=[],n=[],r="",a=!1){let o=(i,c,d=a,f)=>{let m={relativePath:f===void 0?i.path||"":f,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(r)&&d)return;rr(m.relativePath.startsWith(r),`Absolute route path "${m.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(r.length)}let h=Io([r,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(rr(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),$B(i.children,t,g,h,d)),!(i.path==null&&!i.index)&&t.push({path:h,score:gle(h,i.index),routesMeta:g})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))o(i,c);else for(let d of UB(i.path))o(i,c,!0,d)}),t}function UB(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return a?[o,""]:[o];let i=UB(r.join("/")),c=[];return c.push(...i.map(d=>d===""?o:[o,d].join("/"))),a&&c.push(...i),c.map(d=>e.startsWith("/")&&d===""?"/":d)}function cle(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:ble(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var ule=/^:[\w-]+$/,dle=3,fle=2,ple=1,mle=10,hle=-2,$P=e=>e==="*";function gle(e,t){let n=e.split("/"),r=n.length;return n.some($P)&&(r+=hle),t&&(r+=fle),n.filter(a=>!$P(a)).reduce((a,o)=>a+(ule.test(o)?dle:o===""?ple:mle),r)}function ble(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function yle(e,t,n=!1){let{routesMeta:r}=e,a={},o="/",i=[];for(let c=0;c<r.length;++c){let d=r[c],f=c===r.length-1,m=o==="/"?t:t.slice(o.length)||"/",h=Qb({path:d.relativePath,caseSensitive:d.caseSensitive,end:f},m),g=d.route;if(!h&&f&&n&&!r[r.length-1].route.index&&(h=Qb({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},m)),!h)return null;Object.assign(a,h.params),i.push({params:a,pathname:Io([o,h.pathname]),pathnameBase:Tle(Io([o,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(o=Io([o,h.pathnameBase]))}return i}function Qb(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=vle(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),c=a.slice(1);return{params:r.reduce((f,{paramName:m,isOptional:h},g)=>{if(m==="*"){let E=c[g]||"";i=o.slice(0,o.length-E.length).replace(/(.)\/+$/,"$1")}const v=c[g];return h&&!v?f[m]=void 0:f[m]=(v||"").replace(/%2F/g,"/"),f},{}),pathname:o,pathnameBase:i,pattern:e}}function vle(e,t=!1,n=!0){ks(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=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,c,d)=>(r.push({paramName:c,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function wle(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ks(!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 zo(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 xle=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ele=e=>xle.test(e);function Sle(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?_d(e):e,o;if(n)if(Ele(n))o=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),ks(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?o=UP(n.substring(1),"/"):o=UP(n,t)}else o=t;return{pathname:o,search:Nle(r),hash:kle(a)}}function UP(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function M0(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 _le(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function zB(e){let t=_le(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function FB(e,t,n,r=!1){let a;typeof e=="string"?a=_d(e):(a={...e},rr(!a.pathname||!a.pathname.includes("?"),M0("?","pathname","search",a)),rr(!a.pathname||!a.pathname.includes("#"),M0("#","pathname","hash",a)),rr(!a.search||!a.search.includes("#"),M0("#","search","hash",a)));let o=e===""||a.pathname==="",i=o?"/":a.pathname,c;if(i==null)c=n;else{let h=t.length-1;if(!r&&i.startsWith("..")){let g=i.split("/");for(;g[0]==="..";)g.shift(),h-=1;a.pathname=g.join("/")}c=h>=0?t[h]:"/"}let d=Sle(a,c),f=i&&i!=="/"&&i.endsWith("/"),m=(o||i===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(f||m)&&(d.pathname+="/"),d}var Io=e=>e.join("/").replace(/\/\/+/g,"/"),Tle=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Nle=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,kle=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Cle(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Rle(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var BB=["POST","PUT","PATCH","DELETE"];new Set(BB);var Ale=["GET",...BB];new Set(Ale);var Td=y.createContext(null);Td.displayName="DataRouter";var lv=y.createContext(null);lv.displayName="DataRouterState";y.createContext(!1);var HB=y.createContext({isTransitioning:!1});HB.displayName="ViewTransition";var Ile=y.createContext(new Map);Ile.displayName="Fetchers";var Ole=y.createContext(null);Ole.displayName="Await";var Ds=y.createContext(null);Ds.displayName="Navigation";var dm=y.createContext(null);dm.displayName="Location";var Vo=y.createContext({outlet:null,matches:[],isDataRoute:!1});Vo.displayName="Route";var IT=y.createContext(null);IT.displayName="RouteError";function Dle(e,{relative:t}={}){rr(fm(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=y.useContext(Ds),{hash:a,pathname:o,search:i}=pm(e,{relative:t}),c=o;return n!=="/"&&(c=o==="/"?n:Io([n,o])),r.createHref({pathname:c,search:i,hash:a})}function fm(){return y.useContext(dm)!=null}function Go(){return rr(fm(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(dm).location}var VB="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function GB(e){y.useContext(Ds).static||y.useLayoutEffect(e)}function Nd(){let{isDataRoute:e}=y.useContext(Vo);return e?Wle():Lle()}function Lle(){rr(fm(),"useNavigate() may be used only in the context of a <Router> component.");let e=y.useContext(Td),{basename:t,navigator:n}=y.useContext(Ds),{matches:r}=y.useContext(Vo),{pathname:a}=Go(),o=JSON.stringify(zB(r)),i=y.useRef(!1);return GB(()=>{i.current=!0}),y.useCallback((d,f={})=>{if(ks(i.current,VB),!i.current)return;if(typeof d=="number"){n.go(d);return}let m=FB(d,JSON.parse(o),a,f.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Io([t,m.pathname])),(f.replace?n.replace:n.push)(m,f.state,f)},[t,n,o,a,e])}y.createContext(null);function pm(e,{relative:t}={}){let{matches:n}=y.useContext(Vo),{pathname:r}=Go(),a=JSON.stringify(zB(n));return y.useMemo(()=>FB(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Mle(e,t){return WB(e,t)}function WB(e,t,n,r,a){rr(fm(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=y.useContext(Ds),{matches:i}=y.useContext(Vo),c=i[i.length-1],d=c?c.params:{},f=c?c.pathname:"/",m=c?c.pathnameBase:"/",h=c&&c.route;{let _=h&&h.path||"";KB(f,!h||_.endsWith("*")||_.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (under <Route path="${_}">) 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.
|
|
91
|
+
`)},yae=0,Fc=[];function vae(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),a=y.useState(yae++)[0],o=y.useState(b3)[0],i=y.useRef(e);y.useEffect(function(){i.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var x=zre([e.lockRef.current],(e.shards||[]).map(TP),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var c=y.useCallback(function(x,w){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!i.current.allowPinchZoom;var S=Ug(x),_=n.current,T="deltaX"in x?x.deltaX:_[0]-S[0],R="deltaY"in x?x.deltaY:_[1]-S[1],C,A=x.target,I=Math.abs(T)>Math.abs(R)?"h":"v";if("touches"in x&&I==="h"&&A.type==="range")return!1;var O=window.getSelection(),U=O&&O.anchorNode,L=U?U===A||U.contains(A):!1;if(L)return!1;var $=SP(I,A);if(!$)return!0;if($?C=I:(C=I==="v"?"h":"v",$=SP(I,A)),!$)return!1;if(!r.current&&"changedTouches"in x&&(T||R)&&(r.current=C),!C)return!0;var H=r.current||C;return hae(H,w,x,H==="h"?T:R)},[]),d=y.useCallback(function(x){var w=x;if(!(!Fc.length||Fc[Fc.length-1]!==o)){var S="deltaY"in w?_P(w):Ug(w),_=t.current.filter(function(C){return C.name===w.type&&(C.target===w.target||w.target===C.shadowParent)&&gae(C.delta,S)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var T=(i.current.shards||[]).map(TP).filter(Boolean).filter(function(C){return C.contains(w.target)}),R=T.length>0?c(w,T[0]):!i.current.noIsolation;R&&w.cancelable&&w.preventDefault()}}},[]),f=y.useCallback(function(x,w,S,_){var T={name:x,delta:w,target:S,should:_,shadowParent:wae(S)};t.current.push(T),setTimeout(function(){t.current=t.current.filter(function(R){return R!==T})},1)},[]),m=y.useCallback(function(x){n.current=Ug(x),r.current=void 0},[]),h=y.useCallback(function(x){f(x.type,_P(x),x.target,c(x,e.lockRef.current))},[]),g=y.useCallback(function(x){f(x.type,Ug(x),x.target,c(x,e.lockRef.current))},[]);y.useEffect(function(){return Fc.push(o),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",d,zc),document.addEventListener("touchmove",d,zc),document.addEventListener("touchstart",m,zc),function(){Fc=Fc.filter(function(x){return x!==o}),document.removeEventListener("wheel",d,zc),document.removeEventListener("touchmove",d,zc),document.removeEventListener("touchstart",m,zc)}},[]);var v=e.removeScrollBar,E=e.inert;return y.createElement(y.Fragment,null,E?y.createElement(o,{styles:bae(a)}):null,v?y.createElement(lae,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function wae(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const xae=Zre(g3,vae);var om=y.forwardRef(function(e,t){return y.createElement(Jy,Hs({},e,{ref:t,sideCar:xae}))});om.classNames=Jy.classNames;var XE=["Enter"," "],Eae=["ArrowDown","PageUp","Home"],x3=["ArrowUp","PageDown","End"],Sae=[...Eae,...x3],_ae={ltr:[...XE,"ArrowRight"],rtl:[...XE,"ArrowLeft"]},Tae={ltr:["ArrowLeft"],rtl:["ArrowRight"]},im="Menu",[yp,Nae,kae]=aT(im),[Zl,E3]=Os(im,[kae,Yi,l3]),Qy=Yi(),S3=l3(),[Cae,ql]=Zl(im),[Rae,lm]=Zl(im),_3=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:o,modal:i=!0}=e,c=Qy(t),[d,f]=y.useState(null),m=y.useRef(!1),h=Xs(o),g=sT(a);return y.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",E,{capture:!0,once:!0}),document.addEventListener("pointermove",E,{capture:!0,once:!0})},E=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",E,{capture:!0}),document.removeEventListener("pointermove",E,{capture:!0})}},[]),u.jsx(Yy,{...c,children:u.jsx(Cae,{scope:t,open:n,onOpenChange:h,content:d,onContentChange:f,children:u.jsx(Rae,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:i,children:r})})})};_3.displayName=im;var Aae="MenuAnchor",hT=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Qy(n);return u.jsx(am,{...a,...r,ref:t})});hT.displayName=Aae;var gT="MenuPortal",[Iae,T3]=Zl(gT,{forceMount:void 0}),N3=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=ql(gT,t);return u.jsx(Iae,{scope:t,forceMount:n,children:u.jsx(Wa,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:r})})})};N3.displayName=gT;var os="MenuContent",[Oae,bT]=Zl(os),k3=y.forwardRef((e,t)=>{const n=T3(os,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=ql(os,e.__scopeMenu),i=lm(os,e.__scopeMenu);return u.jsx(yp.Provider,{scope:e.__scopeMenu,children:u.jsx(Wa,{present:r||o.open,children:u.jsx(yp.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(Dae,{...a,ref:t}):u.jsx(Lae,{...a,ref:t})})})})}),Dae=y.forwardRef((e,t)=>{const n=ql(os,e.__scopeMenu),r=y.useRef(null),a=ln(t,r);return y.useEffect(()=>{const o=r.current;if(o)return Xy(o)},[]),u.jsx(yT,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Xe(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Lae=y.forwardRef((e,t)=>{const n=ql(os,e.__scopeMenu);return u.jsx(yT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Mae=Pl("MenuContent.ScrollLock"),yT=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:E,...x}=e,w=ql(os,n),S=lm(os,n),_=Qy(n),T=S3(n),R=Nae(n),[C,A]=y.useState(null),I=y.useRef(null),O=ln(t,I,w.onContentChange),U=y.useRef(0),L=y.useRef(""),$=y.useRef(0),H=y.useRef(null),Y=y.useRef("right"),q=y.useRef(0),ne=E?om:y.Fragment,G=E?{as:Mae,allowPinchZoom:!0}:void 0,K=re=>{const ee=L.current+re,M=R().filter(W=>!W.disabled),B=document.activeElement,P=M.find(W=>W.ref.current===B)?.textValue,D=M.map(W=>W.textValue),j=Kae(D,ee,P),V=M.find(W=>W.textValue===j)?.ref.current;(function W(te){L.current=te,window.clearTimeout(U.current),te!==""&&(U.current=window.setTimeout(()=>W(""),1e3))})(ee),V&&setTimeout(()=>V.focus())};y.useEffect(()=>()=>window.clearTimeout(U.current),[]),Hy();const F=y.useCallback(re=>Y.current===H.current?.side&&Zae(re,H.current?.area),[]);return u.jsx(Oae,{scope:n,searchRef:L,onItemEnter:y.useCallback(re=>{F(re)&&re.preventDefault()},[F]),onItemLeave:y.useCallback(re=>{F(re)||(I.current?.focus(),A(null))},[F]),onTriggerLeave:y.useCallback(re=>{F(re)&&re.preventDefault()},[F]),pointerGraceTimerRef:$,onPointerGraceIntentChange:y.useCallback(re=>{H.current=re},[]),children:u.jsx(ne,{...G,children:u.jsx(nm,{asChild:!0,trapped:a,onMountAutoFocus:Xe(o,re=>{re.preventDefault(),I.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:u.jsx(yd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:u.jsx(Mre,{asChild:!0,...T,dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:A,onEntryFocus:Xe(d,re=>{S.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(Zy,{role:"menu","aria-orientation":"vertical","data-state":H3(w.open),"data-radix-menu-content":"",dir:S.dir,..._,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:Xe(x.onKeyDown,re=>{const M=re.target.closest("[data-radix-menu-content]")===re.currentTarget,B=re.ctrlKey||re.altKey||re.metaKey,P=re.key.length===1;M&&(re.key==="Tab"&&re.preventDefault(),!B&&P&&K(re.key));const D=I.current;if(re.target!==D||!Sae.includes(re.key))return;re.preventDefault();const V=R().filter(W=>!W.disabled).map(W=>W.ref.current);x3.includes(re.key)&&V.reverse(),Gae(V)}),onBlur:Xe(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(U.current),L.current="")}),onPointerMove:Xe(e.onPointerMove,vp(re=>{const ee=re.target,M=q.current!==re.clientX;if(re.currentTarget.contains(ee)&&M){const B=re.clientX>q.current?"right":"left";Y.current=B,q.current=re.clientX}}))})})})})})})});k3.displayName=os;var jae="MenuGroup",vT=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(jt.div,{role:"group",...r,ref:t})});vT.displayName=jae;var Pae="MenuLabel",C3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(jt.div,{...r,ref:t})});C3.displayName=Pae;var Zb="MenuItem",NP="menu.itemSelect",ev=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,o=y.useRef(null),i=lm(Zb,e.__scopeMenu),c=bT(Zb,e.__scopeMenu),d=ln(t,o),f=y.useRef(!1),m=()=>{const h=o.current;if(!n&&h){const g=new CustomEvent(NP,{bubbles:!0,cancelable:!0});h.addEventListener(NP,v=>r?.(v),{once:!0}),j4(h,g),g.defaultPrevented?f.current=!1:i.onClose()}};return u.jsx(R3,{...a,ref:d,disabled:n,onClick:Xe(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:Xe(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:Xe(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||XE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});ev.displayName=Zb;var R3=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...o}=e,i=bT(Zb,n),c=S3(n),d=y.useRef(null),f=ln(t,d),[m,h]=y.useState(!1),[g,v]=y.useState("");return y.useEffect(()=>{const E=d.current;E&&v((E.textContent??"").trim())},[o.children]),u.jsx(yp.ItemSlot,{scope:n,disabled:r,textValue:a??g,children:u.jsx(jre,{asChild:!0,...c,focusable:!r,children:u.jsx(jt.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:f,onPointerMove:Xe(e.onPointerMove,vp(E=>{r?i.onItemLeave(E):(i.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Xe(e.onPointerLeave,vp(E=>i.onItemLeave(E))),onFocus:Xe(e.onFocus,()=>h(!0)),onBlur:Xe(e.onBlur,()=>h(!1))})})})}),$ae="MenuCheckboxItem",A3=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return u.jsx(M3,{scope:e.__scopeMenu,checked:n,children:u.jsx(ev,{role:"menuitemcheckbox","aria-checked":qb(n)?"mixed":n,...a,ref:t,"data-state":xT(n),onSelect:Xe(a.onSelect,()=>r?.(qb(n)?!0:!n),{checkForDefaultPrevented:!1})})})});A3.displayName=$ae;var I3="MenuRadioGroup",[Uae,zae]=Zl(I3,{value:void 0,onValueChange:()=>{}}),O3=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,o=Xs(r);return u.jsx(Uae,{scope:e.__scopeMenu,value:n,onValueChange:o,children:u.jsx(vT,{...a,ref:t})})});O3.displayName=I3;var D3="MenuRadioItem",L3=y.forwardRef((e,t)=>{const{value:n,...r}=e,a=zae(D3,e.__scopeMenu),o=n===a.value;return u.jsx(M3,{scope:e.__scopeMenu,checked:o,children:u.jsx(ev,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":xT(o),onSelect:Xe(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});L3.displayName=D3;var wT="MenuItemIndicator",[M3,Fae]=Zl(wT,{checked:!1}),j3=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,o=Fae(wT,n);return u.jsx(Wa,{present:r||qb(o.checked)||o.checked===!0,children:u.jsx(jt.span,{...a,ref:t,"data-state":xT(o.checked)})})});j3.displayName=wT;var Bae="MenuSeparator",P3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(jt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});P3.displayName=Bae;var Hae="MenuArrow",$3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Qy(n);return u.jsx(qy,{...a,...r,ref:t})});$3.displayName=Hae;var Vae="MenuSub",[Yxe,U3]=Zl(Vae),Bf="MenuSubTrigger",z3=y.forwardRef((e,t)=>{const n=ql(Bf,e.__scopeMenu),r=lm(Bf,e.__scopeMenu),a=U3(Bf,e.__scopeMenu),o=bT(Bf,e.__scopeMenu),i=y.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=o,f={__scopeMenu:e.__scopeMenu},m=y.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return y.useEffect(()=>m,[m]),y.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),d(null)}},[c,d]),u.jsx(hT,{asChild:!0,...f,children:u.jsx(R3,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":H3(n.open),...e,ref:qs(t,a.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Xe(e.onPointerMove,vp(h=>{o.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(o.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:Xe(e.onPointerLeave,vp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,E=v==="right",x=E?-5:5,w=g[E?"left":"right"],S=g[E?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:w,y:g.top},{x:S,y:g.top},{x:S,y:g.bottom},{x:w,y:g.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Xe(e.onKeyDown,h=>{const g=o.searchRef.current!=="";e.disabled||g&&h.key===" "||_ae[r.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});z3.displayName=Bf;var F3="MenuSubContent",B3=y.forwardRef((e,t)=>{const n=T3(os,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=ql(os,e.__scopeMenu),i=lm(os,e.__scopeMenu),c=U3(F3,e.__scopeMenu),d=y.useRef(null),f=ln(t,d);return u.jsx(yp.Provider,{scope:e.__scopeMenu,children:u.jsx(Wa,{present:r||o.open,children:u.jsx(yp.Slot,{scope:e.__scopeMenu,children:u.jsx(yT,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:f,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{i.isUsingKeyboardRef.current&&d.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Xe(e.onFocusOutside,m=>{m.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Xe(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:Xe(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=Tae[i.dir].includes(m.key);h&&g&&(o.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});B3.displayName=F3;function H3(e){return e?"open":"closed"}function qb(e){return e==="indeterminate"}function xT(e){return qb(e)?"indeterminate":e?"checked":"unchecked"}function Gae(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Wae(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Kae(e,t,n){const a=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let i=Wae(e,Math.max(o,0));a.length===1&&(i=i.filter(f=>f!==n));const d=i.find(f=>f.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d:void 0}function Yae(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const c=t[o],d=t[i],f=c.x,m=c.y,h=d.x,g=d.y;m>r!=g>r&&n<(h-f)*(r-m)/(g-m)+f&&(a=!a)}return a}function Zae(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Yae(n,t)}function vp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var qae=_3,Xae=hT,Jae=N3,Qae=k3,ese=vT,tse=C3,nse=ev,rse=A3,ase=O3,sse=L3,ose=j3,ise=P3,lse=$3,cse=z3,use=B3,tv="DropdownMenu",[dse]=Os(tv,[E3]),ba=E3(),[fse,V3]=dse(tv),G3=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:o,onOpenChange:i,modal:c=!0}=e,d=ba(t),f=y.useRef(null),[m,h]=jo({prop:a,defaultProp:o??!1,onChange:i,caller:tv});return u.jsx(fse,{scope:t,triggerId:Xr(),triggerRef:f,contentId:Xr(),open:m,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:c,children:u.jsx(qae,{...d,open:m,onOpenChange:h,dir:r,modal:c,children:n})})};G3.displayName=tv;var W3="DropdownMenuTrigger",K3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,o=V3(W3,n),i=ba(n);return u.jsx(Xae,{asChild:!0,...i,children:u.jsx(jt.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:qs(t,o.triggerRef),onPointerDown:Xe(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(o.onOpenToggle(),o.open||c.preventDefault())}),onKeyDown:Xe(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&o.onOpenToggle(),c.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});K3.displayName=W3;var pse="DropdownMenuPortal",Y3=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ba(t);return u.jsx(Jae,{...r,...n})};Y3.displayName=pse;var Z3="DropdownMenuContent",q3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=V3(Z3,n),o=ba(n),i=y.useRef(!1);return u.jsx(Qae,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...r,ref:t,onCloseAutoFocus:Xe(e.onCloseAutoFocus,c=>{i.current||a.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:Xe(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,m=d.button===2||f;(!a.modal||m)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});q3.displayName=Z3;var mse="DropdownMenuGroup",hse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(ese,{...a,...r,ref:t})});hse.displayName=mse;var gse="DropdownMenuLabel",X3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(tse,{...a,...r,ref:t})});X3.displayName=gse;var bse="DropdownMenuItem",J3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(nse,{...a,...r,ref:t})});J3.displayName=bse;var yse="DropdownMenuCheckboxItem",Q3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(rse,{...a,...r,ref:t})});Q3.displayName=yse;var vse="DropdownMenuRadioGroup",wse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(ase,{...a,...r,ref:t})});wse.displayName=vse;var xse="DropdownMenuRadioItem",eB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(sse,{...a,...r,ref:t})});eB.displayName=xse;var Ese="DropdownMenuItemIndicator",Sse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(ose,{...a,...r,ref:t})});Sse.displayName=Ese;var _se="DropdownMenuSeparator",tB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(ise,{...a,...r,ref:t})});tB.displayName=_se;var Tse="DropdownMenuArrow",Nse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(lse,{...a,...r,ref:t})});Nse.displayName=Tse;var kse="DropdownMenuSubTrigger",nB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(cse,{...a,...r,ref:t})});nB.displayName=kse;var Cse="DropdownMenuSubContent",rB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ba(n);return u.jsx(use,{...a,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});rB.displayName=Cse;var Rse=G3,Ase=K3,Ise=Y3,aB=q3,sB=X3,oB=J3,Ose=Q3,Dse=eB,iB=tB,Lse=nB,Mse=rB;const Xb=Rse,Jb=Ase;Lse.displayName;Mse.displayName;function wp({ref:e,className:t,sideOffset:n=4,...r}){return u.jsx(Ise,{children:u.jsx(aB,{ref:e,sideOffset:n,className:Oe("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-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",t),...r})})}wp.displayName=aB.displayName;function Vr({ref:e,className:t,inset:n,...r}){return u.jsx(oB,{ref:e,className:Oe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...r})}Vr.displayName=oB.displayName;Ose.displayName;Dse.displayName;function JE({ref:e,className:t,inset:n,...r}){return u.jsx(sB,{ref:e,className:Oe("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...r})}JE.displayName=sB.displayName;function ru({ref:e,className:t,...n}){return u.jsx(iB,{ref:e,className:Oe("-mx-1 my-1 h-px bg-muted",t),...n})}ru.displayName=iB.displayName;var jse=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ho=jse.reduce((e,t)=>{const n=b4(`Primitive.${t}`),r=y.forwardRef((a,o)=>{const{asChild:i,...c}=a,d=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(d,{...c,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Pse="Label",lB=y.forwardRef((e,t)=>u.jsx(Ho.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));lB.displayName=Pse;var $se=lB;function on({className:e,...t}){return u.jsx($se,{"data-slot":"label",className:Oe("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function Ed({message:e,className:t="",vertical:n,noBorder:r}){return u.jsx("div",{className:Oe(`mt-2 rounded-md p-6 ${t}`,!r&&"border"),children:u.jsxs("p",{className:Oe("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[u.jsx("svg",{width:"40",height:"40",viewBox:"0 0 273 273",version:"1.1",xmlns:"http://www.w3.org/2000/svg",className:"flex-shrink-0",children:u.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:u.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[u.jsx("path",{d:"M49.953025,-2.10854389 C63.26892,-2.21867124 76.6185256,2.70621155 86.9019463,12.6653164 L86.9019463,12.6653164 L87.505627,13.2592944 C97.5154947,23.2654892 102.640454,36.3074513 102.880738,49.4222247 C103.08932,77.4533067 113.877287,105.391753 135.242867,126.757333 C156.613383,148.127849 184.559216,158.914875 212.568138,159.119313 L212.568138,159.119313 L213.212264,159.134159 C225.843948,159.517566 238.363557,164.434972 248.121998,173.886137 L248.121998,173.886137 L248.725621,174.480088 C258.982114,184.732164 264.11035,198.171134 264.11035,211.6101 C264.11035,225.04592 258.984514,238.481745 248.732867,248.732867 C238.592792,258.872942 225.336706,263.997882 212.046872,264.107794 C198.731075,264.21792 185.381569,259.293085 175.098248,249.334078 L175.098248,249.334078 L174.494602,248.740134 C163.75802,238.008189 158.640853,223.784027 159.143413,209.719372 C158.258245,182.640933 147.489786,155.83332 126.828333,135.171867 C106.351297,114.694831 79.8363505,103.934873 53.0237258,102.891841 L53.0237258,102.891841 L52.2811438,102.865674 C38.4791718,103.347421 24.5325234,98.4328111 13.8776628,88.1140866 L13.8776628,88.1140866 L13.2739843,87.5201168 C3.12895117,77.3789607 -1.9984796,64.1195994 -2.10841888,50.8264755 C-2.21854669,37.5105567 2.70635908,24.1609269 12.6655135,13.8774565 L12.6655135,13.8774565 L13.2594878,13.2737797 C23.4005926,3.12880025 36.659927,-1.99860507 49.953025,-2.10854389 Z"}),u.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),u.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function cB({className:e,color:t,children:n,grayscaled:r=!1}){const a=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return r?0:.2},[t,r]),o=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return r?.3:.4},[t,r]),i=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[2]||"0")}return Math.floor(Math.random()*360)},[t]),c=y.useMemo(()=>t||`oklch(${Math.min(o,1)} ${a} ${i})`,[i,a,o]),d=y.useMemo(()=>`oklch(${Math.min(o*2,1)} ${a} ${i})`,[i,a,o,t]),f=y.useMemo(()=>Math.floor(Math.random()*360),[i]),m=y.useMemo(()=>"1000%",[]);return u.jsx("section",{className:Oe("relative w-full h-full overflow-hidden",e),style:{background:`${d}`},children:u.jsxs("div",{className:"isolate relative w-full h-full",children:[u.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${f}deg, ${c}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${m})`}}),n&&u.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function ET(e){const t=y.useRef({value:e,previous:e});return y.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var nv="Switch",[Use]=Os(nv),[zse,Fse]=Use(nv),uB=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:o,required:i,disabled:c,value:d="on",onCheckedChange:f,form:m,...h}=e,[g,v]=y.useState(null),E=ln(t,T=>v(T)),x=y.useRef(!1),w=g?m||!!g.closest("form"):!0,[S,_]=jo({prop:a,defaultProp:o??!1,onChange:f,caller:nv});return u.jsxs(zse,{scope:n,checked:S,disabled:c,children:[u.jsx(jt.button,{type:"button",role:"switch","aria-checked":S,"aria-required":i,"data-state":mB(S),"data-disabled":c?"":void 0,disabled:c,value:d,...h,ref:E,onClick:Xe(e.onClick,T=>{_(R=>!R),w&&(x.current=T.isPropagationStopped(),x.current||T.stopPropagation())})}),w&&u.jsx(pB,{control:g,bubbles:!x.current,name:r,value:d,checked:S,required:i,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});uB.displayName=nv;var dB="SwitchThumb",fB=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Fse(dB,n);return u.jsx(jt.span,{"data-state":mB(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});fB.displayName=dB;var Bse="SwitchBubbleInput",pB=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},o)=>{const i=y.useRef(null),c=ln(i,o),d=ET(n),f=fT(t);return y.useEffect(()=>{const m=i.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(d!==n&&v){const E=new Event("click",{bubbles:r});v.call(m,n),m.dispatchEvent(E)}},[d,n,r]),u.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});pB.displayName=Bse;function mB(e){return e?"checked":"unchecked"}var hB=uB,Hse=fB;function rv({ref:e,className:t,...n}){return u.jsx(hB,{className:Oe("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:u.jsx(Hse,{className:Oe("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})}rv.displayName=hB.displayName;var gB=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"}),Vse="VisuallyHidden",bB=y.forwardRef((e,t)=>u.jsx(jt.span,{...e,ref:t,style:{...gB,...e.style}}));bB.displayName=Vse;var Gse=bB,[av]=Os("Tooltip",[Yi]),sv=Yi(),yB="TooltipProvider",Wse=700,QE="tooltip.open",[Kse,ST]=av(yB),vB=e=>{const{__scopeTooltip:t,delayDuration:n=Wse,skipDelayDuration:r=300,disableHoverableContent:a=!1,children:o}=e,i=y.useRef(!0),c=y.useRef(!1),d=y.useRef(0);return y.useEffect(()=>{const f=d.current;return()=>window.clearTimeout(f)},[]),u.jsx(Kse,{scope:t,isOpenDelayedRef:i,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(d.current),i.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:y.useCallback(f=>{c.current=f},[]),disableHoverableContent:a,children:o})};vB.displayName=yB;var xp="Tooltip",[Yse,cm]=av(xp),wB=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:a,onOpenChange:o,disableHoverableContent:i,delayDuration:c}=e,d=ST(xp,e.__scopeTooltip),f=sv(t),[m,h]=y.useState(null),g=Xr(),v=y.useRef(0),E=i??d.disableHoverableContent,x=c??d.delayDuration,w=y.useRef(!1),[S,_]=jo({prop:r,defaultProp:a??!1,onChange:I=>{I?(d.onOpen(),document.dispatchEvent(new CustomEvent(QE))):d.onClose(),o?.(I)},caller:xp}),T=y.useMemo(()=>S?w.current?"delayed-open":"instant-open":"closed",[S]),R=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,w.current=!1,_(!0)},[_]),C=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_(!1)},[_]),A=y.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{w.current=!0,_(!0),v.current=0},x)},[x,_]);return y.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),u.jsx(Yy,{...f,children:u.jsx(Yse,{scope:t,contentId:g,open:S,stateAttribute:T,trigger:m,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{d.isOpenDelayedRef.current?A():R()},[d.isOpenDelayedRef,A,R]),onTriggerLeave:y.useCallback(()=>{E?C():(window.clearTimeout(v.current),v.current=0)},[C,E]),onOpen:R,onClose:C,disableHoverableContent:E,children:n})})};wB.displayName=xp;var eS="TooltipTrigger",xB=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=cm(eS,n),o=ST(eS,n),i=sv(n),c=y.useRef(null),d=ln(t,c,a.onTriggerChange),f=y.useRef(!1),m=y.useRef(!1),h=y.useCallback(()=>f.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),u.jsx(am,{asChild:!0,...i,children:u.jsx(jt.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:d,onPointerMove:Xe(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),m.current=!0)}),onPointerLeave:Xe(e.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:Xe(e.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Xe(e.onFocus,()=>{f.current||a.onOpen()}),onBlur:Xe(e.onBlur,a.onClose),onClick:Xe(e.onClick,a.onClose)})})});xB.displayName=eS;var _T="TooltipPortal",[Zse,qse]=av(_T,{forceMount:void 0}),EB=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:a}=e,o=cm(_T,t);return u.jsx(Zse,{scope:t,forceMount:n,children:u.jsx(Wa,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:r})})})};EB.displayName=_T;var ed="TooltipContent",SB=y.forwardRef((e,t)=>{const n=qse(ed,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...o}=e,i=cm(ed,e.__scopeTooltip);return u.jsx(Wa,{present:r||i.open,children:i.disableHoverableContent?u.jsx(_B,{side:a,...o,ref:t}):u.jsx(Xse,{side:a,...o,ref:t})})}),Xse=y.forwardRef((e,t)=>{const n=cm(ed,e.__scopeTooltip),r=ST(ed,e.__scopeTooltip),a=y.useRef(null),o=ln(t,a),[i,c]=y.useState(null),{trigger:d,onClose:f}=n,m=a.current,{onPointerInTransitChange:h}=r,g=y.useCallback(()=>{c(null),h(!1)},[h]),v=y.useCallback((E,x)=>{const w=E.currentTarget,S={x:E.clientX,y:E.clientY},_=toe(S,w.getBoundingClientRect()),T=noe(S,_),R=roe(x.getBoundingClientRect()),C=soe([...T,...R]);c(C),h(!0)},[h]);return y.useEffect(()=>()=>g(),[g]),y.useEffect(()=>{if(d&&m){const E=w=>v(w,m),x=w=>v(w,d);return d.addEventListener("pointerleave",E),m.addEventListener("pointerleave",x),()=>{d.removeEventListener("pointerleave",E),m.removeEventListener("pointerleave",x)}}},[d,m,v,g]),y.useEffect(()=>{if(i){const E=x=>{const w=x.target,S={x:x.clientX,y:x.clientY},_=d?.contains(w)||m?.contains(w),T=!aoe(S,i);_?g():T&&(g(),f())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[d,m,i,f,g]),u.jsx(_B,{...e,ref:o})}),[Jse,Qse]=av(xp,{isInside:!1}),eoe=Lte("TooltipContent"),_B=y.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:i,...c}=e,d=cm(ed,n),f=sv(n),{onClose:m}=d;return y.useEffect(()=>(document.addEventListener(QE,m),()=>document.removeEventListener(QE,m)),[m]),y.useEffect(()=>{if(d.trigger){const h=g=>{g.target?.contains(d.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[d.trigger,m]),u.jsx(yd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:u.jsxs(Zy,{"data-state":d.stateAttribute,...f,...c,ref:t,style:{...c.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:[u.jsx(eoe,{children:r}),u.jsx(Jse,{scope:n,isInside:!0,children:u.jsx(Gse,{id:d.contentId,role:"tooltip",children:a||r})})]})})});SB.displayName=ed;var TB="TooltipArrow",NB=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=sv(n);return Qse(TB,n).isInside?null:u.jsx(qy,{...a,...r,ref:t})});NB.displayName=TB;function toe(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,a,o)){case o:return"left";case a:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function noe(e,t,n=5){const 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 roe(e){const{top:t,right:n,bottom:r,left:a}=e;return[{x:a,y:t},{x:n,y:t},{x:n,y:r},{x:a,y:r}]}function aoe(e,t){const{x:n,y:r}=e;let a=!1;for(let o=0,i=t.length-1;o<t.length;i=o++){const c=t[o],d=t[i],f=c.x,m=c.y,h=d.x,g=d.y;m>r!=g>r&&n<(h-f)*(r-m)/(g-m)+f&&(a=!a)}return a}function soe(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),ooe(t)}function ooe(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const a=e[r];for(;t.length>=2;){const o=t[t.length-1],i=t[t.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))t.pop();else break}t.push(a)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const a=e[r];for(;n.length>=2;){const o=n[n.length-1],i=n[n.length-2];if((o.x-i.x)*(a.y-i.y)>=(o.y-i.y)*(a.x-i.x))n.pop();else break}n.push(a)}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 ioe=vB,loe=wB,coe=xB,uoe=EB,doe=SB,foe=NB;function TT({delayDuration:e=0,...t}){return u.jsx(ioe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function At({...e}){return u.jsx(TT,{children:u.jsx(loe,{"data-slot":"tooltip",...e})})}function It({...e}){return u.jsx(coe,{"data-slot":"tooltip-trigger",...e})}function Ot({className:e,sideOffset:t=0,children:n,...r}){return u.jsx(uoe,{children:u.jsxs(doe,{"data-slot":"tooltip-content",sideOffset:t,className:Oe("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,u.jsx(foe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class poe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class kP{name="mcp_tool_execution";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId,success:t.success,duration:t.duration,error:t.error}}}class CP{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class RP{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class AP{name="mcp_chat_message";properties;constructor(t){this.properties={server_id:t.serverId,provider:t.provider,model:t.model,message_count:t.messageCount,tool_calls_count:t.toolCallsCount,success:t.success,execution_mode:t.executionMode,duration:t.duration,error:t.error}}}class moe{name="mcp_server_added";properties;constructor(t){this.properties={server_id:t.serverId,server_url:t.serverUrl,connection_type:t.connectionType,via_proxy:t.viaProxy}}}class hoe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class goe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function O0(){try{return"0.14.2"}catch{return"0.0.0"}}var boe={};function D0(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class IP{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,r=setTimeout(()=>n.abort(),this.timeout),a=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(r),!a.ok)throw new Error(`HTTP error! status: ${a.status}`)}catch{}}}function vi(e){return`mcp_inspector_telemetry_${e}`}class Zr{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(){const t=D0(),n=this.isTelemetryDisabled();if(this._source=this.getStoredSource()||"inspector",n)this._posthogClient=null,this._scarfClient=null;else if(!t)this._posthogClient=null,this._scarfClient=null;else{try{this._posthogClient=new IP(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new IP(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(vi("disabled"))==="true"||typeof process<"u"&&boe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(vi("source")):null}static getInstance(){return Zr.instance||(Zr.instance=new Zr),Zr.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(vi("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!D0())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(vi("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(vi("user_id"),n),this._currUserId=n}this.trackPackageDownload({triggered_by:"user_id_property"}).catch(()=>{})}catch{this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}generateUserId(){const t=window.crypto;if(t){const n=new Uint8Array(16);t.getRandomValues(n),n[6]=n[6]&15|64,n[8]=n[8]&63|128;const r=Array.from(n).map(a=>a.toString(16).padStart(2,"0")).join("");return r.slice(0,8)+"-"+r.slice(8,12)+"-"+r.slice(12,16)+"-"+r.slice(16,20)+"-"+r.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const r=Math.random()*16|0;return(n==="x"?r:r&3|8).toString(16)})}async capture(t){if(!(!this._posthogClient&&!this._scarfClient)){if(this._posthogClient)try{const n={event:t.name,user_id:this.userId,properties:{...t.properties,mcp_use_version:O0(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=O0(),n.user_id=this.userId,n.event=t.name,n.language="typescript",n.source=this._source,n.package="inspector",await this._scarfClient.logEvent(n)}catch{}}}async trackPackageDownload(t){if(this._scarfClient&&D0())try{const n=O0();let r=!1,a=!1;const o=localStorage.getItem(vi("download_version"));if(o?n>o&&(r=!0,a=!1,localStorage.setItem(vi("download_version"),n)):(r=!0,a=!0,localStorage.setItem(vi("download_version"),n)),r){const i={...t||{}};i.mcp_use_version=n,i.user_id=this.userId,i.event="package_download",i.first_download=a,i.language="typescript",i.source=this._source,i.package="inspector",await this._scarfClient.logEvent(i)}}catch{}}async trackInspectorOpen(t){const n=new poe(t);await this.capture(n)}}const yoe="0.14.1-canary.1";function voe(){return yoe}const woe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),xoe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),OP=e=>{const t=xoe(e);return t.charAt(0).toUpperCase()+t.slice(1)},kB=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Eoe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Soe={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"};const _oe=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a="",children:o,iconNode:i,...c},d)=>y.createElement("svg",{ref:d,...Soe,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:kB("lucide",a),...!o&&!Eoe(c)&&{"aria-hidden":"true"},...c},[...i.map(([f,m])=>y.createElement(f,m)),...Array.isArray(o)?o:[o]]));const st=(e,t)=>{const n=y.forwardRef(({className:r,...a},o)=>y.createElement(_oe,{ref:o,iconNode:t,className:kB(`lucide-${woe(OP(e))}`,`lucide-${e}`,r),...a}));return n.displayName=OP(e),n};const Toe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],Noe=st("arrow-down-to-line",Toe);const koe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Coe=st("arrow-up-from-line",koe);const Roe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Aoe=st("arrow-up",Roe);const Ioe=[["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"}]],NT=st("bell",Ioe);const Ooe=[["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"}]],CB=st("brush",Ooe);const Doe=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],Loe=st("bug",Doe);const Moe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Er=st("check",Moe);const joe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Qs=st("chevron-down",joe);const Poe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ov=st("chevron-left",Poe);const $oe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],RB=st("chevron-right",$oe);const Uoe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],zoe=st("chevron-up",Uoe);const Foe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Boe=st("chevrons-up-down",Foe);const Hoe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],DP=st("circle-minus",Hoe);const Voe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ep=st("clock",Voe);const Goe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],kT=st("code",Goe);const Woe=[["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"}]],Koe=st("cog",Woe);const Yoe=[["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"}]],Zoe=st("command",Yoe);const qoe=[["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"}]],dr=st("copy",qoe);const Xoe=[["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"}]],iv=st("database",Xoe);const Joe=[["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"}]],um=st("download",Joe);const Qoe=[["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"}]],eie=st("ellipsis-vertical",Qoe);const tie=[["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"}]],tS=st("external-link",tie);const nie=[["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"}]],AB=st("eye-off",nie);const rie=[["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"}]],nS=st("eye",rie);const aie=[["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"}]],sie=st("file-code",aie);const oie=[["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"}]],iie=st("file-image",oie);const lie=[["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"}]],CT=st("file-text",lie);const cie=[["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"}]],uie=st("file",cie);const die=[["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"}]],fie=st("folder-open",die);const pie=[["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"}]],mie=st("globe",pie);const hie=[["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"}]],gie=st("grip-vertical",hie);const bie=[["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"}]],IB=st("hash",bie);const yie=[["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"}]],Sp=st("history",yie);const vie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Qf=st("info",vie);const wie=[["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"}]],OB=st("key",wie);const xie=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Bi=st("loader-circle",xie);const Eie=[["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"}]],RT=st("maximize-2",Eie);const Sie=[["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"}]],_p=st("maximize",Sie);const _ie=[["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"}]],Tie=st("message-circle",_ie);const Nie=[["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=st("message-square",Nie);const kie=[["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"}]],DB=st("minimize",kie);const Cie=[["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"}]],LP=st("monitor",Cie);const Rie=[["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"}]],Aie=st("moon",Rie);const Iie=[["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"}]],Oie=st("picture-in-picture",Iie);const Die=[["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"}]],LB=st("play",Die);const Lie=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Np=st("plus",Lie);const Mie=[["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"}]],MP=st("rotate-ccw",Mie);const jie=[["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"}]],AT=st("save",jie);const Pie=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Sd=st("search",Pie);const $ie=[["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"}]],Uie=st("send",$ie);const zie=[["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"}]],MB=st("server",zie);const Fie=[["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"}]],yu=st("settings",Fie);const Bie=[["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"}]],Hie=st("shield",Bie);const Vie=[["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"}]],Gie=st("sparkles",Vie);const Wie=[["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"}]],jB=st("square-check-big",Wie);const Kie=[["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"}]],Yie=st("square-pen",Kie);const Zie=[["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"}]],qie=st("sun-dim",Zie);const Xie=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],L0=st("terminal",Xie);const Jie=[["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"}]],Uo=st("trash-2",Jie);const Qie=[["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"}]],ele=st("trash",Qie);const tle=[["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"}]],Ul=st("wrench",tle);const nle=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ro=st("x",nle);const rle=[["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"}]],kp=st("zap",rle);var jP="popstate";function ale(e={}){function t(r,a){let{pathname:o,search:i,hash:c}=r.location;return rS("",{pathname:o,search:i,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:Cp(a)}return ole(t,n,null,e)}function rr(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ks(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function sle(){return Math.random().toString(36).substring(2,10)}function PP(e,t){return{usr:e.state,key:e.key,idx:t}}function rS(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?_d(t):t,state:n,key:t&&t.key||r||sle()}}function Cp({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 _d(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 ole(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:o=!1}=r,i=a.history,c="POP",d=null,f=m();f==null&&(f=0,i.replaceState({...i.state,idx:f},""));function m(){return(i.state||{idx:null}).idx}function h(){c="POP";let w=m(),S=w==null?null:w-f;f=w,d&&d({action:c,location:x.location,delta:S})}function g(w,S){c="PUSH";let _=rS(x.location,w,S);f=m()+1;let T=PP(_,f),R=x.createHref(_);try{i.pushState(T,"",R)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;a.location.assign(R)}o&&d&&d({action:c,location:x.location,delta:1})}function v(w,S){c="REPLACE";let _=rS(x.location,w,S);f=m();let T=PP(_,f),R=x.createHref(_);i.replaceState(T,"",R),o&&d&&d({action:c,location:x.location,delta:0})}function E(w){return ile(w)}let x={get action(){return c},get location(){return e(a,i)},listen(w){if(d)throw new Error("A history only accepts one active listener");return a.addEventListener(jP,h),d=w,()=>{a.removeEventListener(jP,h),d=null}},createHref(w){return t(a,w)},createURL:E,encodeLocation(w){let S=E(w);return{pathname:S.pathname,search:S.search,hash:S.hash}},push:g,replace:v,go(w){return i.go(w)}};return x}function ile(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),rr(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Cp(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function PB(e,t,n="/"){return lle(e,t,n,!1)}function lle(e,t,n,r){let a=typeof t=="string"?_d(t):t,o=zo(a.pathname||"/",n);if(o==null)return null;let i=$B(e);cle(i);let c=null;for(let d=0;c==null&&d<i.length;++d){let f=wle(o);c=yle(i[d],f,r)}return c}function $B(e,t=[],n=[],r="",a=!1){let o=(i,c,d=a,f)=>{let m={relativePath:f===void 0?i.path||"":f,caseSensitive:i.caseSensitive===!0,childrenIndex:c,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(r)&&d)return;rr(m.relativePath.startsWith(r),`Absolute route path "${m.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(r.length)}let h=Io([r,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(rr(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),$B(i.children,t,g,h,d)),!(i.path==null&&!i.index)&&t.push({path:h,score:gle(h,i.index),routesMeta:g})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))o(i,c);else for(let d of UB(i.path))o(i,c,!0,d)}),t}function UB(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return a?[o,""]:[o];let i=UB(r.join("/")),c=[];return c.push(...i.map(d=>d===""?o:[o,d].join("/"))),a&&c.push(...i),c.map(d=>e.startsWith("/")&&d===""?"/":d)}function cle(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:ble(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var ule=/^:[\w-]+$/,dle=3,fle=2,ple=1,mle=10,hle=-2,$P=e=>e==="*";function gle(e,t){let n=e.split("/"),r=n.length;return n.some($P)&&(r+=hle),t&&(r+=fle),n.filter(a=>!$P(a)).reduce((a,o)=>a+(ule.test(o)?dle:o===""?ple:mle),r)}function ble(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function yle(e,t,n=!1){let{routesMeta:r}=e,a={},o="/",i=[];for(let c=0;c<r.length;++c){let d=r[c],f=c===r.length-1,m=o==="/"?t:t.slice(o.length)||"/",h=Qb({path:d.relativePath,caseSensitive:d.caseSensitive,end:f},m),g=d.route;if(!h&&f&&n&&!r[r.length-1].route.index&&(h=Qb({path:d.relativePath,caseSensitive:d.caseSensitive,end:!1},m)),!h)return null;Object.assign(a,h.params),i.push({params:a,pathname:Io([o,h.pathname]),pathnameBase:Tle(Io([o,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(o=Io([o,h.pathnameBase]))}return i}function Qb(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=vle(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),c=a.slice(1);return{params:r.reduce((f,{paramName:m,isOptional:h},g)=>{if(m==="*"){let E=c[g]||"";i=o.slice(0,o.length-E.length).replace(/(.)\/+$/,"$1")}const v=c[g];return h&&!v?f[m]=void 0:f[m]=(v||"").replace(/%2F/g,"/"),f},{}),pathname:o,pathnameBase:i,pattern:e}}function vle(e,t=!1,n=!0){ks(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=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,c,d)=>(r.push({paramName:c,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function wle(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ks(!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 zo(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 xle=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ele=e=>xle.test(e);function Sle(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?_d(e):e,o;if(n)if(Ele(n))o=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),ks(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${n}`)}n.startsWith("/")?o=UP(n.substring(1),"/"):o=UP(n,t)}else o=t;return{pathname:o,search:Nle(r),hash:kle(a)}}function UP(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function M0(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 _le(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function zB(e){let t=_le(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function FB(e,t,n,r=!1){let a;typeof e=="string"?a=_d(e):(a={...e},rr(!a.pathname||!a.pathname.includes("?"),M0("?","pathname","search",a)),rr(!a.pathname||!a.pathname.includes("#"),M0("#","pathname","hash",a)),rr(!a.search||!a.search.includes("#"),M0("#","search","hash",a)));let o=e===""||a.pathname==="",i=o?"/":a.pathname,c;if(i==null)c=n;else{let h=t.length-1;if(!r&&i.startsWith("..")){let g=i.split("/");for(;g[0]==="..";)g.shift(),h-=1;a.pathname=g.join("/")}c=h>=0?t[h]:"/"}let d=Sle(a,c),f=i&&i!=="/"&&i.endsWith("/"),m=(o||i===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(f||m)&&(d.pathname+="/"),d}var Io=e=>e.join("/").replace(/\/\/+/g,"/"),Tle=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Nle=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,kle=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Cle(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Rle(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var BB=["POST","PUT","PATCH","DELETE"];new Set(BB);var Ale=["GET",...BB];new Set(Ale);var Td=y.createContext(null);Td.displayName="DataRouter";var lv=y.createContext(null);lv.displayName="DataRouterState";y.createContext(!1);var HB=y.createContext({isTransitioning:!1});HB.displayName="ViewTransition";var Ile=y.createContext(new Map);Ile.displayName="Fetchers";var Ole=y.createContext(null);Ole.displayName="Await";var Ds=y.createContext(null);Ds.displayName="Navigation";var dm=y.createContext(null);dm.displayName="Location";var Vo=y.createContext({outlet:null,matches:[],isDataRoute:!1});Vo.displayName="Route";var IT=y.createContext(null);IT.displayName="RouteError";function Dle(e,{relative:t}={}){rr(fm(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=y.useContext(Ds),{hash:a,pathname:o,search:i}=pm(e,{relative:t}),c=o;return n!=="/"&&(c=o==="/"?n:Io([n,o])),r.createHref({pathname:c,search:i,hash:a})}function fm(){return y.useContext(dm)!=null}function Go(){return rr(fm(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(dm).location}var VB="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function GB(e){y.useContext(Ds).static||y.useLayoutEffect(e)}function Nd(){let{isDataRoute:e}=y.useContext(Vo);return e?Wle():Lle()}function Lle(){rr(fm(),"useNavigate() may be used only in the context of a <Router> component.");let e=y.useContext(Td),{basename:t,navigator:n}=y.useContext(Ds),{matches:r}=y.useContext(Vo),{pathname:a}=Go(),o=JSON.stringify(zB(r)),i=y.useRef(!1);return GB(()=>{i.current=!0}),y.useCallback((d,f={})=>{if(ks(i.current,VB),!i.current)return;if(typeof d=="number"){n.go(d);return}let m=FB(d,JSON.parse(o),a,f.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Io([t,m.pathname])),(f.replace?n.replace:n.push)(m,f.state,f)},[t,n,o,a,e])}y.createContext(null);function pm(e,{relative:t}={}){let{matches:n}=y.useContext(Vo),{pathname:r}=Go(),a=JSON.stringify(zB(n));return y.useMemo(()=>FB(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Mle(e,t){return WB(e,t)}function WB(e,t,n,r,a){rr(fm(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=y.useContext(Ds),{matches:i}=y.useContext(Vo),c=i[i.length-1],d=c?c.params:{},f=c?c.pathname:"/",m=c?c.pathnameBase:"/",h=c&&c.route;{let _=h&&h.path||"";KB(f,!h||_.endsWith("*")||_.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (under <Route path="${_}">) 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.
|
|
92
92
|
|
|
93
93
|
Please change the parent <Route path="${_}"> to <Route path="${_==="/"?"*":`${_}/*`}">.`)}let g=Go(),v;if(t){let _=typeof t=="string"?_d(t):t;rr(m==="/"||_.pathname?.startsWith(m),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${_.pathname}" was given in the \`location\` prop.`),v=_}else v=g;let E=v.pathname||"/",x=E;if(m!=="/"){let _=m.replace(/^\//,"").split("/");x="/"+E.replace(/^\//,"").split("/").slice(_.length).join("/")}let w=PB(e,{pathname:x});ks(h||w!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),ks(w==null||w[w.length-1].route.element!==void 0||w[w.length-1].route.Component!==void 0||w[w.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=zle(w&&w.map(_=>Object.assign({},_,{params:Object.assign({},d,_.params),pathname:Io([m,o.encodeLocation?o.encodeLocation(_.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathname]),pathnameBase:_.pathnameBase==="/"?m:Io([m,o.encodeLocation?o.encodeLocation(_.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathnameBase])})),i,n,r,a);return t&&S?y.createElement(dm.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...v},navigationType:"POP"}},S):S}function jle(){let e=Gle(),t=Cle(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=y.createElement(y.Fragment,null,y.createElement("p",null,"💿 Hey developer 👋"),y.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",y.createElement("code",{style:o},"ErrorBoundary")," or"," ",y.createElement("code",{style:o},"errorElement")," prop on your route.")),y.createElement(y.Fragment,null,y.createElement("h2",null,"Unexpected Application Error!"),y.createElement("h3",{style:{fontStyle:"italic"}},t),n?y.createElement("pre",{style:a},n):null,i)}var Ple=y.createElement(jle,null),$le=class extends y.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?y.createElement(Vo.Provider,{value:this.props.routeContext},y.createElement(IT.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Ule({routeContext:e,match:t,children:n}){let r=y.useContext(Td);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),y.createElement(Vo.Provider,{value:e},n)}function zle(e,t=[],n=null,r=null,a=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,i=n?.errors;if(i!=null){let m=o.findIndex(h=>h.route.id&&i?.[h.route.id]!==void 0);rr(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,m+1))}let c=!1,d=-1;if(n)for(let m=0;m<o.length;m++){let h=o[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(d=m),h.route.id){let{loaderData:g,errors:v}=n,E=h.route.loader&&!g.hasOwnProperty(h.route.id)&&(!v||v[h.route.id]===void 0);if(h.route.lazy||E){c=!0,d>=0?o=o.slice(0,d+1):o=[o[0]];break}}}let f=n&&r?(m,h)=>{r(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:Rle(n.matches),errorInfo:h})}:void 0;return o.reduceRight((m,h,g)=>{let v,E=!1,x=null,w=null;n&&(v=i&&h.route.id?i[h.route.id]:void 0,x=h.route.errorElement||Ple,c&&(d<0&&g===0?(KB("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,w=null):d===g&&(E=!0,w=h.route.hydrateFallbackElement||null)));let S=t.concat(o.slice(0,g+1)),_=()=>{let T;return v?T=x:E?T=w:h.route.Component?T=y.createElement(h.route.Component,null):h.route.element?T=h.route.element:T=m,y.createElement(Ule,{match:h,routeContext:{outlet:m,matches:S,isDataRoute:n!=null},children:T})};return n&&(h.route.ErrorBoundary||h.route.errorElement||g===0)?y.createElement($le,{location:n.location,revalidation:n.revalidation,component:x,error:v,children:_(),routeContext:{outlet:null,matches:S,isDataRoute:!0},onError:f}):_()},null)}function OT(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Fle(e){let t=y.useContext(Td);return rr(t,OT(e)),t}function Ble(e){let t=y.useContext(lv);return rr(t,OT(e)),t}function Hle(e){let t=y.useContext(Vo);return rr(t,OT(e)),t}function DT(e){let t=Hle(e),n=t.matches[t.matches.length-1];return rr(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Vle(){return DT("useRouteId")}function Gle(){let e=y.useContext(IT),t=Ble("useRouteError"),n=DT("useRouteError");return e!==void 0?e:t.errors?.[n]}function Wle(){let{router:e}=Fle("useNavigate"),t=DT("useNavigate"),n=y.useRef(!1);return GB(()=>{n.current=!0}),y.useCallback(async(a,o={})=>{ks(n.current,VB),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}var zP={};function KB(e,t,n){!t&&!zP[e]&&(zP[e]=!0,ks(!1,n))}y.memo(Kle);function Kle({routes:e,future:t,state:n,unstable_onError:r}){return WB(e,void 0,n,r,t)}function aS(e){rr(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function Yle({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:o=!1,unstable_useTransitions:i}){rr(!fm(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),d=y.useMemo(()=>({basename:c,navigator:a,static:o,unstable_useTransitions:i,future:{}}),[c,a,o,i]);typeof n=="string"&&(n=_d(n));let{pathname:f="/",search:m="",hash:h="",state:g=null,key:v="default"}=n,E=y.useMemo(()=>{let x=zo(f,c);return x==null?null:{location:{pathname:x,search:m,hash:h,state:g,key:v},navigationType:r}},[c,f,m,h,g,v,r]);return ks(E!=null,`<Router basename="${c}"> is not able to match the URL "${f}${m}${h}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:y.createElement(Ds.Provider,{value:d},y.createElement(dm.Provider,{children:t,value:E}))}function Zle({children:e,location:t}){return Mle(sS(e),t)}function sS(e,t=[]){let n=[];return y.Children.forEach(e,(r,a)=>{if(!y.isValidElement(r))return;let o=[...t,a];if(r.type===y.Fragment){n.push.apply(n,sS(r.props.children,o));return}rr(r.type===aS,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),rr(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=sS(r.props.children,o)),n.push(i)}),n}var ub="get",db="application/x-www-form-urlencoded";function cv(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function qle(e){return cv(e)&&e.tagName.toLowerCase()==="button"}function Xle(e){return cv(e)&&e.tagName.toLowerCase()==="form"}function Jle(e){return cv(e)&&e.tagName.toLowerCase()==="input"}function Qle(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ece(e,t){return e.button===0&&(!t||t==="_self")&&!Qle(e)}var zg=null;function tce(){if(zg===null)try{new FormData(document.createElement("form"),0),zg=!1}catch{zg=!0}return zg}var nce=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function j0(e){return e!=null&&!nce.has(e)?(ks(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${db}"`),null):e}function rce(e,t){let n,r,a,o,i;if(Xle(e)){let c=e.getAttribute("action");r=c?zo(c,t):null,n=e.getAttribute("method")||ub,a=j0(e.getAttribute("enctype"))||db,o=new FormData(e)}else if(qle(e)||Jle(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let d=e.getAttribute("formaction")||c.getAttribute("action");if(r=d?zo(d,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||ub,a=j0(e.getAttribute("formenctype"))||j0(c.getAttribute("enctype"))||db,o=new FormData(c,e),!tce()){let{name:f,type:m,value:h}=e;if(m==="image"){let g=f?`${f}.`:"";o.append(`${g}x`,"0"),o.append(`${g}y`,"0")}else f&&o.append(f,h)}}else{if(cv(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=ub,r=null,a=db,i=e}return o&&a==="text/plain"&&(i=o,o=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:o,body:i}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function LT(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ace(e,t,n){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r.pathname==="/"?r.pathname=`_root.${n}`:t&&zo(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function sce(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function oce(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function ice(e,t,n){let r=await Promise.all(e.map(async a=>{let o=t.routes[a.route.id];if(o){let i=await sce(o,n);return i.links?i.links():[]}return[]}));return dce(r.flat(1).filter(oce).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function FP(e,t,n,r,a,o){let i=(d,f)=>n[f]?d.route.id!==n[f].route.id:!0,c=(d,f)=>n[f].pathname!==d.pathname||n[f].route.path?.endsWith("*")&&n[f].params["*"]!==d.params["*"];return o==="assets"?t.filter((d,f)=>i(d,f)||c(d,f)):o==="data"?t.filter((d,f)=>{let m=r.routes[d.route.id];if(!m||!m.hasLoader)return!1;if(i(d,f)||c(d,f))return!0;if(d.route.shouldRevalidate){let h=d.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:d.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function lce(e,t,{includeHydrateFallback:n}={}){return cce(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let o=[a.module];return a.clientActionModule&&(o=o.concat(a.clientActionModule)),a.clientLoaderModule&&(o=o.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(o=o.concat(a.hydrateFallbackModule)),a.imports&&(o=o.concat(a.imports)),o}).flat(1))}function cce(e){return[...new Set(e)]}function uce(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function dce(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let o=JSON.stringify(uce(a));return n.has(o)||(n.add(o),r.push({key:o,link:a})),r},[])}function YB(){let e=y.useContext(Td);return LT(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function fce(){let e=y.useContext(lv);return LT(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var MT=y.createContext(void 0);MT.displayName="FrameworkContext";function ZB(){let e=y.useContext(MT);return LT(e,"You must render this element inside a <HydratedRouter> element"),e}function pce(e,t){let n=y.useContext(MT),[r,a]=y.useState(!1),[o,i]=y.useState(!1),{onFocus:c,onBlur:d,onMouseEnter:f,onMouseLeave:m,onTouchStart:h}=t,g=y.useRef(null);y.useEffect(()=>{if(e==="render"&&i(!0),e==="viewport"){let x=S=>{S.forEach(_=>{i(_.isIntersecting)})},w=new IntersectionObserver(x,{threshold:.5});return g.current&&w.observe(g.current),()=>{w.disconnect()}}},[e]),y.useEffect(()=>{if(r){let x=setTimeout(()=>{i(!0)},100);return()=>{clearTimeout(x)}}},[r]);let v=()=>{a(!0)},E=()=>{a(!1),i(!1)};return n?e!=="intent"?[o,g,{}]:[o,g,{onFocus:Lf(c,v),onBlur:Lf(d,E),onMouseEnter:Lf(f,v),onMouseLeave:Lf(m,E),onTouchStart:Lf(h,v)}]:[!1,g,{}]}function Lf(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function mce({page:e,...t}){let{router:n}=YB(),r=y.useMemo(()=>PB(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?y.createElement(gce,{page:e,matches:r,...t}):null}function hce(e){let{manifest:t,routeModules:n}=ZB(),[r,a]=y.useState([]);return y.useEffect(()=>{let o=!1;return ice(e,t,n).then(i=>{o||a(i)}),()=>{o=!0}},[e,t,n]),r}function gce({page:e,matches:t,...n}){let r=Go(),{manifest:a,routeModules:o}=ZB(),{basename:i}=YB(),{loaderData:c,matches:d}=fce(),f=y.useMemo(()=>FP(e,t,d,a,r,"data"),[e,t,d,a,r]),m=y.useMemo(()=>FP(e,t,d,a,r,"assets"),[e,t,d,a,r]),h=y.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let E=new Set,x=!1;if(t.forEach(S=>{let _=a.routes[S.route.id];!_||!_.hasLoader||(!f.some(T=>T.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||_.hasClientLoader?x=!0:E.add(S.route.id))}),E.size===0)return[];let w=ace(e,i,"data");return x&&E.size>0&&w.searchParams.set("_routes",t.filter(S=>E.has(S.route.id)).map(S=>S.route.id).join(",")),[w.pathname+w.search]},[i,c,r,a,f,t,e,o]),g=y.useMemo(()=>lce(m,a),[m,a]),v=hce(m);return y.createElement(y.Fragment,null,h.map(E=>y.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...n})),g.map(E=>y.createElement("link",{key:E,rel:"modulepreload",href:E,...n})),v.map(({key:E,link:x})=>y.createElement("link",{key:E,nonce:n.nonce,...x})))}function bce(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var qB=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{qB&&(window.__reactRouterVersion="7.10.1")}catch{}function yce({basename:e,children:t,unstable_useTransitions:n,window:r}){let a=y.useRef();a.current==null&&(a.current=ale({window:r,v5Compat:!0}));let o=a.current,[i,c]=y.useState({action:o.action,location:o.location}),d=y.useCallback(f=>{n===!1?c(f):y.startTransition(()=>c(f))},[n]);return y.useLayoutEffect(()=>o.listen(d),[o,d]),y.createElement(Yle,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o,unstable_useTransitions:n===!0})}var XB=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,JB=y.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:o,replace:i,state:c,target:d,to:f,preventScrollReset:m,viewTransition:h,...g},v){let{basename:E,unstable_useTransitions:x}=y.useContext(Ds),w=typeof f=="string"&&XB.test(f),S,_=!1;if(typeof f=="string"&&w&&(S=f,qB))try{let L=new URL(window.location.href),$=f.startsWith("//")?new URL(L.protocol+f):new URL(f),H=zo($.pathname,E);$.origin===L.origin&&H!=null?f=H+$.search+$.hash:_=!0}catch{ks(!1,`<Link to="${f}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let T=Dle(f,{relative:a}),[R,C,A]=pce(r,g),I=Ece(f,{replace:i,state:c,target:d,preventScrollReset:m,relative:a,viewTransition:h,unstable_useTransitions:x});function O(L){t&&t(L),L.defaultPrevented||I(L)}let U=y.createElement("a",{...g,...A,href:S||T,onClick:_||o?t:O,ref:bce(v,C),target:d,"data-discover":!w&&n==="render"?"true":void 0});return R&&!w?y.createElement(y.Fragment,null,U,y.createElement(mce,{page:T})):U});JB.displayName="Link";var vce=y.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:o,to:i,viewTransition:c,children:d,...f},m){let h=pm(i,{relative:f.relative}),g=Go(),v=y.useContext(lv),{navigator:E,basename:x}=y.useContext(Ds),w=v!=null&&kce(h)&&c===!0,S=E.encodeLocation?E.encodeLocation(h).pathname:h.pathname,_=g.pathname,T=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;n||(_=_.toLowerCase(),T=T?T.toLowerCase():null,S=S.toLowerCase()),T&&x&&(T=zo(T,x)||T);const R=S!=="/"&&S.endsWith("/")?S.length-1:S.length;let C=_===S||!a&&_.startsWith(S)&&_.charAt(R)==="/",A=T!=null&&(T===S||!a&&T.startsWith(S)&&T.charAt(S.length)==="/"),I={isActive:C,isPending:A,isTransitioning:w},O=C?t:void 0,U;typeof r=="function"?U=r(I):U=[r,C?"active":null,A?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let L=typeof o=="function"?o(I):o;return y.createElement(JB,{...f,"aria-current":O,className:U,ref:m,style:L,to:i,viewTransition:c},typeof d=="function"?d(I):d)});vce.displayName="NavLink";var wce=y.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:o,method:i=ub,action:c,onSubmit:d,relative:f,preventScrollReset:m,viewTransition:h,...g},v)=>{let{unstable_useTransitions:E}=y.useContext(Ds),x=Tce(),w=Nce(c,{relative:f}),S=i.toLowerCase()==="get"?"get":"post",_=typeof c=="string"&&XB.test(c),T=R=>{if(d&&d(R),R.defaultPrevented)return;R.preventDefault();let C=R.nativeEvent.submitter,A=C?.getAttribute("formmethod")||i,I=()=>x(C||R.currentTarget,{fetcherKey:t,method:A,navigate:n,replace:a,state:o,relative:f,preventScrollReset:m,viewTransition:h});E&&n!==!1?y.startTransition(()=>I()):I()};return y.createElement("form",{ref:v,method:S,action:w,onSubmit:r?d:T,...g,"data-discover":!_&&e==="render"?"true":void 0})});wce.displayName="Form";function xce(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function QB(e){let t=y.useContext(Td);return rr(t,xce(e)),t}function Ece(e,{target:t,replace:n,state:r,preventScrollReset:a,relative:o,viewTransition:i,unstable_useTransitions:c}={}){let d=Nd(),f=Go(),m=pm(e,{relative:o});return y.useCallback(h=>{if(ece(h,t)){h.preventDefault();let g=n!==void 0?n:Cp(f)===Cp(m),v=()=>d(e,{replace:g,state:r,preventScrollReset:a,relative:o,viewTransition:i});c?y.startTransition(()=>v()):v()}},[f,d,m,n,r,t,e,a,o,i,c])}var Sce=0,_ce=()=>`__${String(++Sce)}__`;function Tce(){let{router:e}=QB("useSubmit"),{basename:t}=y.useContext(Ds),n=Vle(),r=e.fetch,a=e.navigate;return y.useCallback(async(o,i={})=>{let{action:c,method:d,encType:f,formData:m,body:h}=rce(o,t);if(i.navigate===!1){let g=i.fetcherKey||_ce();await r(g,n,i.action||c,{preventScrollReset:i.preventScrollReset,formData:m,body:h,formMethod:i.method||d,formEncType:i.encType||f,flushSync:i.flushSync})}else await a(i.action||c,{preventScrollReset:i.preventScrollReset,formData:m,body:h,formMethod:i.method||d,formEncType:i.encType||f,replace:i.replace,state:i.state,fromRouteId:n,flushSync:i.flushSync,viewTransition:i.viewTransition})},[r,a,t,n])}function Nce(e,{relative:t}={}){let{basename:n}=y.useContext(Ds),r=y.useContext(Vo);rr(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),o={...pm(e||".",{relative:t})},i=Go();if(e==null){o.search=i.search;let c=new URLSearchParams(o.search),d=c.getAll("index");if(d.some(m=>m==="")){c.delete("index"),d.filter(h=>h).forEach(h=>c.append("index",h));let m=c.toString();o.search=m?`?${m}`:""}}return(!e||e===".")&&a.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(o.pathname=o.pathname==="/"?n:Io([n,o.pathname])),Cp(o)}function kce(e,{relative:t}={}){let n=y.useContext(HB);rr(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=QB("useViewTransitionState"),a=pm(e,{relative:t});if(!n.isTransitioning)return!1;let o=zo(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=zo(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Qb(a.pathname,i)!=null||Qb(a.pathname,o)!=null}function Cce(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const Rce=e=>{switch(e){case"success":return Oce;case"info":return Lce;case"warning":return Dce;case"error":return Mce;default:return null}},Ace=Array(12).fill(0),Ice=({visible:e,className:t})=>ie.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ie.createElement("div",{className:"sonner-spinner"},Ace.map((n,r)=>ie.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),Oce=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),Dce=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Lce=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Mce=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ie.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),jce=ie.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ie.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ie.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Pce=()=>{const[e,t]=ie.useState(document.hidden);return ie.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let oS=1;class $ce{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...a}=t,o=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:oS++,i=this.toasts.find(d=>d.id===o),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),i?this.toasts=this.toasts.map(d=>d.id===o?(this.publish({...d,...t,id:o,title:r}),{...d,...t,id:o,dismissible:c,title:r}):d):this.addToast({title:r,...a,dismissible:c,id:o}),o},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const a=Promise.resolve(t instanceof Function?t():t);let o=r!==void 0,i;const c=a.then(async f=>{if(i=["resolve",f],ie.isValidElement(f))o=!1,this.create({id:r,type:"default",message:f});else if(zce(f)&&!f.ok){o=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${f.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${f.status}`):n.description,E=typeof h=="object"&&!ie.isValidElement(h)?h:{message:h};this.create({id:r,type:"error",description:g,...E})}else if(f instanceof Error){o=!1;const h=typeof n.error=="function"?await n.error(f):n.error,g=typeof n.description=="function"?await n.description(f):n.description,E=typeof h=="object"&&!ie.isValidElement(h)?h:{message:h};this.create({id:r,type:"error",description:g,...E})}else if(n.success!==void 0){o=!1;const h=typeof n.success=="function"?await n.success(f):n.success,g=typeof n.description=="function"?await n.description(f):n.description,E=typeof h=="object"&&!ie.isValidElement(h)?h:{message:h};this.create({id:r,type:"success",description:g,...E})}}).catch(async f=>{if(i=["reject",f],n.error!==void 0){o=!1;const m=typeof n.error=="function"?await n.error(f):n.error,h=typeof n.description=="function"?await n.description(f):n.description,v=typeof m=="object"&&!ie.isValidElement(m)?m:{message:m};this.create({id:r,type:"error",description:h,...v})}}).finally(()=>{o&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),d=()=>new Promise((f,m)=>c.then(()=>i[0]==="reject"?m(i[1]):f(i[1])).catch(m));return typeof r!="string"&&typeof r!="number"?{unwrap:d}:Object.assign(r,{unwrap:d})},this.custom=(t,n)=>{const r=n?.id||oS++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Ta=new $ce,Uce=(e,t)=>{const n=t?.id||oS++;return Ta.addToast({title:e,...t,id:n}),n},zce=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",Fce=Uce,Bce=()=>Ta.toasts,Hce=()=>Ta.getActiveToasts(),pt=Object.assign(Fce,{success:Ta.success,info:Ta.info,warning:Ta.warning,error:Ta.error,custom:Ta.custom,message:Ta.message,promise:Ta.promise,dismiss:Ta.dismiss,loading:Ta.loading},{getHistory:Bce,getToasts:Hce});Cce("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Fg(e){return e.label!==void 0}const Vce=3,Gce="24px",Wce="16px",BP=4e3,Kce=356,Yce=14,Zce=45,qce=200;function Fs(...e){return e.filter(Boolean).join(" ")}function Xce(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const Jce=e=>{var t,n,r,a,o,i,c,d,f;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:E,visibleToasts:x,heights:w,index:S,toasts:_,expanded:T,removeToast:R,defaultRichColors:C,closeButton:A,style:I,cancelButtonStyle:O,actionButtonStyle:U,className:L="",descriptionClassName:$="",duration:H,position:Y,gap:q,expandByDefault:ne,classNames:G,icons:K,closeButtonAriaLabel:F="Close toast"}=e,[re,ee]=ie.useState(null),[M,B]=ie.useState(null),[P,D]=ie.useState(!1),[j,V]=ie.useState(!1),[W,te]=ie.useState(!1),[de,fe]=ie.useState(!1),[J,Q]=ie.useState(!1),[se,pe]=ie.useState(0),[he,Ne]=ie.useState(0),He=ie.useRef(h.duration||H||BP),$e=ie.useRef(null),Pe=ie.useRef(null),ot=S===0,Me=S+1<=x,Je=h.type,We=h.dismissible!==!1,we=h.className||"",Ee=h.descriptionClassName||"",oe=ie.useMemo(()=>w.findIndex(et=>et.toastId===h.id)||0,[w,h.id]),Se=ie.useMemo(()=>{var et;return(et=h.closeButton)!=null?et:A},[h.closeButton,A]),Re=ie.useMemo(()=>h.duration||H||BP,[h.duration,H]),Ve=ie.useRef(0),ct=ie.useRef(0),vt=ie.useRef(0),Ge=ie.useRef(null),[wn,pn]=Y.split("-"),Fe=ie.useMemo(()=>w.reduce((et,Tt,Ut)=>Ut>=oe?et:et+Tt.height,0),[w,oe]),Ue=Pce(),ce=h.invert||m,wt=Je==="loading";ct.current=ie.useMemo(()=>oe*q+Fe,[oe,Fe]),ie.useEffect(()=>{He.current=Re},[Re]),ie.useEffect(()=>{D(!0)},[]),ie.useEffect(()=>{const et=Pe.current;if(et){const Tt=et.getBoundingClientRect().height;return Ne(Tt),E(Ut=>[{toastId:h.id,height:Tt,position:h.position},...Ut]),()=>E(Ut=>Ut.filter(zt=>zt.toastId!==h.id))}},[E,h.id]),ie.useLayoutEffect(()=>{if(!P)return;const et=Pe.current,Tt=et.style.height;et.style.height="auto";const Ut=et.getBoundingClientRect().height;et.style.height=Tt,Ne(Ut),E(zt=>zt.find(rn=>rn.toastId===h.id)?zt.map(rn=>rn.toastId===h.id?{...rn,height:Ut}:rn):[{toastId:h.id,height:Ut,position:h.position},...zt])},[P,h.title,h.description,E,h.id,h.jsx,h.action,h.cancel]);const ht=ie.useCallback(()=>{V(!0),pe(ct.current),E(et=>et.filter(Tt=>Tt.toastId!==h.id)),setTimeout(()=>{R(h)},qce)},[h,R,E,ct]);ie.useEffect(()=>{if(h.promise&&Je==="loading"||h.duration===1/0||h.type==="loading")return;let et;return T||v||Ue?(()=>{if(vt.current<Ve.current){const zt=new Date().getTime()-Ve.current;He.current=He.current-zt}vt.current=new Date().getTime()})():He.current!==1/0&&(Ve.current=new Date().getTime(),et=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),ht()},He.current)),()=>clearTimeout(et)},[T,v,h,Je,Ue,ht]),ie.useEffect(()=>{h.delete&&(ht(),h.onDismiss==null||h.onDismiss.call(h,h))},[ht,h.delete]);function Dt(){var et;if(K?.loading){var Tt;return ie.createElement("div",{className:Fs(G?.loader,h==null||(Tt=h.classNames)==null?void 0:Tt.loader,"sonner-loader"),"data-visible":Je==="loading"},K.loading)}return ie.createElement(Ice,{className:Fs(G?.loader,h==null||(et=h.classNames)==null?void 0:et.loader),visible:Je==="loading"})}const Nt=h.icon||K?.[Je]||Rce(Je);var Wt,bn;return ie.createElement("li",{tabIndex:0,ref:Pe,className:Fs(L,we,G?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,G?.default,G?.[Je],h==null||(n=h.classNames)==null?void 0:n[Je]),"data-sonner-toast":"","data-rich-colors":(Wt=h.richColors)!=null?Wt:C,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":P,"data-promise":!!h.promise,"data-swiped":J,"data-removed":j,"data-visible":Me,"data-y-position":wn,"data-x-position":pn,"data-index":S,"data-front":ot,"data-swiping":W,"data-dismissible":We,"data-type":Je,"data-invert":ce,"data-swipe-out":de,"data-swipe-direction":M,"data-expanded":!!(T||ne&&P),"data-testid":h.testId,style:{"--index":S,"--toasts-before":S,"--z-index":_.length-S,"--offset":`${j?se:ct.current}px`,"--initial-height":ne?"auto":`${he}px`,...I,...h.style},onDragEnd:()=>{te(!1),ee(null),Ge.current=null},onPointerDown:et=>{et.button!==2&&(wt||!We||($e.current=new Date,pe(ct.current),et.target.setPointerCapture(et.pointerId),et.target.tagName!=="BUTTON"&&(te(!0),Ge.current={x:et.clientX,y:et.clientY})))},onPointerUp:()=>{var et,Tt,Ut;if(de||!We)return;Ge.current=null;const zt=Number(((et=Pe.current)==null?void 0:et.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Jn=Number(((Tt=Pe.current)==null?void 0:Tt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),rn=new Date().getTime()-((Ut=$e.current)==null?void 0:Ut.getTime()),Ln=re==="x"?zt:Jn,Qn=Math.abs(Ln)/rn;if(Math.abs(Ln)>=Zce||Qn>.11){pe(ct.current),h.onDismiss==null||h.onDismiss.call(h,h),B(re==="x"?zt>0?"right":"left":Jn>0?"down":"up"),ht(),fe(!0);return}else{var xn,fn;(xn=Pe.current)==null||xn.style.setProperty("--swipe-amount-x","0px"),(fn=Pe.current)==null||fn.style.setProperty("--swipe-amount-y","0px")}Q(!1),te(!1),ee(null)},onPointerMove:et=>{var Tt,Ut,zt;if(!Ge.current||!We||((Tt=window.getSelection())==null?void 0:Tt.toString().length)>0)return;const rn=et.clientY-Ge.current.y,Ln=et.clientX-Ge.current.x;var Qn;const xn=(Qn=e.swipeDirections)!=null?Qn:Xce(Y);!re&&(Math.abs(Ln)>1||Math.abs(rn)>1)&&ee(Math.abs(Ln)>Math.abs(rn)?"x":"y");let fn={x:0,y:0};const Mr=Qt=>1/(1.5+Math.abs(Qt)/20);if(re==="y"){if(xn.includes("top")||xn.includes("bottom"))if(xn.includes("top")&&rn<0||xn.includes("bottom")&&rn>0)fn.y=rn;else{const Qt=rn*Mr(rn);fn.y=Math.abs(Qt)<Math.abs(rn)?Qt:rn}}else if(re==="x"&&(xn.includes("left")||xn.includes("right")))if(xn.includes("left")&&Ln<0||xn.includes("right")&&Ln>0)fn.x=Ln;else{const Qt=Ln*Mr(Ln);fn.x=Math.abs(Qt)<Math.abs(Ln)?Qt:Ln}(Math.abs(fn.x)>0||Math.abs(fn.y)>0)&&Q(!0),(Ut=Pe.current)==null||Ut.style.setProperty("--swipe-amount-x",`${fn.x}px`),(zt=Pe.current)==null||zt.style.setProperty("--swipe-amount-y",`${fn.y}px`)}},Se&&!h.jsx&&Je!=="loading"?ie.createElement("button",{"aria-label":F,"data-disabled":wt,"data-close-button":!0,onClick:wt||!We?()=>{}:()=>{ht(),h.onDismiss==null||h.onDismiss.call(h,h)},className:Fs(G?.closeButton,h==null||(r=h.classNames)==null?void 0:r.closeButton)},(bn=K?.close)!=null?bn:jce):null,(Je||h.icon||h.promise)&&h.icon!==null&&(K?.[Je]!==null||h.icon)?ie.createElement("div",{"data-icon":"",className:Fs(G?.icon,h==null||(a=h.classNames)==null?void 0:a.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||Dt():null,h.type!=="loading"?Nt:null):null,ie.createElement("div",{"data-content":"",className:Fs(G?.content,h==null||(o=h.classNames)==null?void 0:o.content)},ie.createElement("div",{"data-title":"",className:Fs(G?.title,h==null||(i=h.classNames)==null?void 0:i.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?ie.createElement("div",{"data-description":"",className:Fs($,Ee,G?.description,h==null||(c=h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),ie.isValidElement(h.cancel)?h.cancel:h.cancel&&Fg(h.cancel)?ie.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:et=>{Fg(h.cancel)&&We&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,et),ht())},className:Fs(G?.cancelButton,h==null||(d=h.classNames)==null?void 0:d.cancelButton)},h.cancel.label):null,ie.isValidElement(h.action)?h.action:h.action&&Fg(h.action)?ie.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||U,onClick:et=>{Fg(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,et),!et.defaultPrevented&&ht())},className:Fs(G?.actionButton,h==null||(f=h.classNames)==null?void 0:f.actionButton)},h.action.label):null)};function HP(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function Qce(e,t){const n={};return[e,t].forEach((r,a)=>{const o=a===1,i=o?"--mobile-offset":"--offset",c=o?Wce:Gce;function d(f){["top","right","bottom","left"].forEach(m=>{n[`${i}-${m}`]=typeof f=="number"?`${f}px`:f})}typeof r=="number"||typeof r=="string"?d(r):typeof r=="object"?["top","right","bottom","left"].forEach(f=>{r[f]===void 0?n[`${i}-${f}`]=c:n[`${i}-${f}`]=typeof r[f]=="number"?`${r[f]}px`:r[f]}):d(c)}),n}const eue=ie.forwardRef(function(t,n){const{id:r,invert:a,position:o="bottom-right",hotkey:i=["altKey","KeyT"],expand:c,closeButton:d,className:f,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:E,style:x,visibleToasts:w=Vce,toastOptions:S,dir:_=HP(),gap:T=Yce,icons:R,containerAriaLabel:C="Notifications"}=t,[A,I]=ie.useState([]),O=ie.useMemo(()=>r?A.filter(P=>P.toasterId===r):A.filter(P=>!P.toasterId),[A,r]),U=ie.useMemo(()=>Array.from(new Set([o].concat(O.filter(P=>P.position).map(P=>P.position)))),[O,o]),[L,$]=ie.useState([]),[H,Y]=ie.useState(!1),[q,ne]=ie.useState(!1),[G,K]=ie.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=ie.useRef(null),re=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),ee=ie.useRef(null),M=ie.useRef(!1),B=ie.useCallback(P=>{I(D=>{var j;return(j=D.find(V=>V.id===P.id))!=null&&j.delete||Ta.dismiss(P.id),D.filter(({id:V})=>V!==P.id)})},[]);return ie.useEffect(()=>Ta.subscribe(P=>{if(P.dismiss){requestAnimationFrame(()=>{I(D=>D.map(j=>j.id===P.id?{...j,delete:!0}:j))});return}setTimeout(()=>{L4.flushSync(()=>{I(D=>{const j=D.findIndex(V=>V.id===P.id);return j!==-1?[...D.slice(0,j),{...D[j],...P},...D.slice(j+1)]:[P,...D]})})})}),[A]),ie.useEffect(()=>{if(g!=="system"){K(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;const P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:D})=>{K(D?"dark":"light")})}catch{P.addListener(({matches:j})=>{try{K(j?"dark":"light")}catch(V){console.error(V)}})}},[g]),ie.useEffect(()=>{A.length<=1&&Y(!1)},[A]),ie.useEffect(()=>{const P=D=>{var j;if(i.every(te=>D[te]||D.code===te)){var W;Y(!0),(W=F.current)==null||W.focus()}D.code==="Escape"&&(document.activeElement===F.current||(j=F.current)!=null&&j.contains(document.activeElement))&&Y(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[i]),ie.useEffect(()=>{if(F.current)return()=>{ee.current&&(ee.current.focus({preventScroll:!0}),ee.current=null,M.current=!1)}},[F.current]),ie.createElement("section",{ref:n,"aria-label":`${C} ${re}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},U.map((P,D)=>{var j;const[V,W]=P.split("-");return O.length?ie.createElement("ol",{key:P,dir:_==="auto"?HP():_,tabIndex:-1,ref:F,className:f,"data-sonner-toaster":!0,"data-sonner-theme":G,"data-y-position":V,"data-x-position":W,style:{"--front-toast-height":`${((j=L[0])==null?void 0:j.height)||0}px`,"--width":`${Kce}px`,"--gap":`${T}px`,...x,...Qce(m,h)},onBlur:te=>{M.current&&!te.currentTarget.contains(te.relatedTarget)&&(M.current=!1,ee.current&&(ee.current.focus({preventScroll:!0}),ee.current=null))},onFocus:te=>{te.target instanceof HTMLElement&&te.target.dataset.dismissible==="false"||M.current||(M.current=!0,ee.current=te.relatedTarget)},onMouseEnter:()=>Y(!0),onMouseMove:()=>Y(!0),onMouseLeave:()=>{q||Y(!1)},onDragEnd:()=>Y(!1),onPointerDown:te=>{te.target instanceof HTMLElement&&te.target.dataset.dismissible==="false"||ne(!0)},onPointerUp:()=>ne(!1)},O.filter(te=>!te.position&&D===0||te.position===P).map((te,de)=>{var fe,J;return ie.createElement(Jce,{key:te.id,icons:R,index:de,toast:te,defaultRichColors:v,duration:(fe=S?.duration)!=null?fe:E,className:S?.className,descriptionClassName:S?.descriptionClassName,invert:a,visibleToasts:w,closeButton:(J=S?.closeButton)!=null?J:d,interacting:q,position:P,style:S?.style,unstyled:S?.unstyled,classNames:S?.classNames,cancelButtonStyle:S?.cancelButtonStyle,actionButtonStyle:S?.actionButtonStyle,closeButtonAriaLabel:S?.closeButtonAriaLabel,removeToast:B,toasts:O.filter(Q=>Q.position==te.position),heights:L.filter(Q=>Q.position==te.position),setHeights:$,expandByDefault:c,gap:T,expanded:H,swipeDirections:t.swipeDirections})})):null}))});var uv="Dialog",[e5]=Os(uv),[tue,Ls]=e5(uv),t5=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:o,modal:i=!0}=e,c=y.useRef(null),d=y.useRef(null),[f,m]=jo({prop:r,defaultProp:a??!1,onChange:o,caller:uv});return u.jsx(tue,{scope:t,triggerRef:c,contentRef:d,contentId:Xr(),titleId:Xr(),descriptionId:Xr(),open:f,onOpenChange:m,onOpenToggle:y.useCallback(()=>m(h=>!h),[m]),modal:i,children:n})};t5.displayName=uv;var n5="DialogTrigger",r5=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ls(n5,n),o=ln(t,a.triggerRef);return u.jsx(jt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":$T(a.open),...r,ref:o,onClick:Xe(e.onClick,a.onOpenToggle)})});r5.displayName=n5;var jT="DialogPortal",[nue,a5]=e5(jT,{forceMount:void 0}),s5=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,o=Ls(jT,t);return u.jsx(nue,{scope:t,forceMount:n,children:y.Children.map(r,i=>u.jsx(Wa,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:i})}))})};s5.displayName=jT;var ey="DialogOverlay",o5=y.forwardRef((e,t)=>{const n=a5(ey,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,o=Ls(ey,e.__scopeDialog);return o.modal?u.jsx(Wa,{present:r||o.open,children:u.jsx(aue,{...a,ref:t})}):null});o5.displayName=ey;var rue=Pl("DialogOverlay.RemoveScroll"),aue=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ls(ey,n);return u.jsx(om,{as:rue,allowPinchZoom:!0,shards:[a.contentRef],children:u.jsx(jt.div,{"data-state":$T(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),zl="DialogContent",i5=y.forwardRef((e,t)=>{const n=a5(zl,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,o=Ls(zl,e.__scopeDialog);return u.jsx(Wa,{present:r||o.open,children:o.modal?u.jsx(sue,{...a,ref:t}):u.jsx(oue,{...a,ref:t})})});i5.displayName=zl;var sue=y.forwardRef((e,t)=>{const n=Ls(zl,e.__scopeDialog),r=y.useRef(null),a=ln(t,n.contentRef,r);return y.useEffect(()=>{const o=r.current;if(o)return Xy(o)},[]),u.jsx(l5,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Xe(e.onCloseAutoFocus,o=>{o.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Xe(e.onPointerDownOutside,o=>{const i=o.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&o.preventDefault()}),onFocusOutside:Xe(e.onFocusOutside,o=>o.preventDefault())})}),oue=y.forwardRef((e,t)=>{const n=Ls(zl,e.__scopeDialog),r=y.useRef(!1),a=y.useRef(!1);return u.jsx(l5,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||n.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const i=o.target;n.triggerRef.current?.contains(i)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),l5=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:o,...i}=e,c=Ls(zl,n),d=y.useRef(null),f=ln(t,d);return Hy(),u.jsxs(u.Fragment,{children:[u.jsx(nm,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:o,children:u.jsx(yd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":$T(c.open),...i,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),u.jsxs(u.Fragment,{children:[u.jsx(iue,{titleId:c.titleId}),u.jsx(cue,{contentRef:d,descriptionId:c.descriptionId})]})]})}),PT="DialogTitle",c5=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ls(PT,n);return u.jsx(jt.h2,{id:a.titleId,...r,ref:t})});c5.displayName=PT;var u5="DialogDescription",d5=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ls(u5,n);return u.jsx(jt.p,{id:a.descriptionId,...r,ref:t})});d5.displayName=u5;var f5="DialogClose",p5=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ls(f5,n);return u.jsx(jt.button,{type:"button",...r,ref:t,onClick:Xe(e.onClick,()=>a.onOpenChange(!1))})});p5.displayName=f5;function $T(e){return e?"open":"closed"}var m5="DialogTitleWarning",[Zxe,h5]=Cte(m5,{contentName:zl,titleName:PT,docsSlug:"dialog"}),iue=({titleId:e})=>{const t=h5(m5),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
94
94
|
|
|
@@ -1720,7 +1720,7 @@ print(f"Available resources: {[resource.name for resource in resources]}")
|
|
|
1720
1720
|
<\/script>
|
|
1721
1721
|
</body>
|
|
1722
1722
|
</html>`,T8=1,JU=2,N8=3,QU=4,k8=5,ez=Symbol.for("quilt.threads.serialize"),Yve=Symbol.for("quilt.threads.transferable");class Zve extends AbortController{constructor(...t){super();const n=t.find(r=>r.aborted);if(n)this.abort(n.reason);else{const r=o=>this.abort(o.target.reason),a={signal:this.signal};for(const o of t)o.addEventListener("abort",r,a)}}}class tz extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let qve="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function C8(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let r=0;r<e;r++)t+=qve[63&n[r]];return t}var Wf,qc,Kf,Sb,u_,R8;class Xve{constructor(){xs(this,u_),xs(this,Wf,new Map),xs(this,qc,new Map),xs(this,Kf,new Map),xs(this,Sb,new WeakMap)}get(t){return Zn(this,qc).get(t)}release(t){const n=Zn(this,qc).get(t);return n&&(Zn(this,qc).delete(t),Zn(this,Wf).delete(n)),!!n}serialize(t){let n=Zn(this,Wf).get(t);return n==null&&(n=C8(),Zn(this,Wf).set(t,n),Zn(this,qc).set(n,t)),n}deserialize(t,n){var r,a;let o=(r=Zn(this,Kf).get(t))==null?void 0:r.deref();return o||(o=(...i)=>{if(!Zn(this,Kf).has(t))throw new Error("You attempted to call a function that was already revoked.");return n.call((c,d,f)=>{n.messages.send([N8,c,t,d],f)},i)},(a=Br(this,u_,R8).call(this,n))==null||a.register(o,t),Zn(this,Kf).set(t,new WeakRef(o)),o)}}Wf=new WeakMap,qc=new WeakMap,Kf=new WeakMap,Sb=new WeakMap,u_=new WeakSet,R8=function(e){let t=Zn(this,Sb).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([k8,n])}),Zn(this,Sb).set(e,t)),t};function Jve(e){return e!=null&&(Symbol.asyncIterator in e||Symbol.iterator in e)&&typeof e.next=="function"}function nz(e){if(e==null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t==null||t===Object.prototype}const uE="_@f",rz="_@i";var up,dp,ns,_b,Si;class Qve{constructor(t){xs(this,ns),xs(this,up),xs(this,dp),l_(this,up,t?.serialize),l_(this,dp,t?.deserialize)}serialize(t,n,r){return Br(this,ns,_b).call(this,t,n,r)}deserialize(t,n){return Br(this,ns,Si).call(this,t,n)}}up=new WeakMap,dp=new WeakMap,ns=new WeakSet,_b=function(e,t,n,r=new Map,a=!1){if(e==null)return e;if(r.has(e))return r.get(e);if(r.set(e,void 0),typeof e=="object"){if(Zn(this,up)&&!a){const c=Zn(this,up).call(this,e,d=>Br(this,ns,_b).call(this,d,t,n,r,!0),t,n);if(c!==void 0)return r.set(e,c),c}if(e[Yve])return n?.push(e),r.set(e,e),e;const o=c=>Br(this,ns,_b).call(this,c,t,n,r);if(typeof e[ez]=="function"){const c=e[ez]({serialize:o});return r.set(e,c),c}if(Array.isArray(e)){const c=e.map(d=>o(d));return r.set(e,c),c}if(e instanceof Map){const c=[...e.entries()].map(([f,m])=>[o(f),o(m)]),d=new Map(c);return r.set(e,d),d}if(e instanceof Set){const c=[...e].map(f=>o(f)),d=new Set(c);return r.set(e,d),d}const i=Jve(e);if(nz(e)||i){const c={};for(const d of Object.keys(e))c[d]=o(e[d]);return i&&(c.next??(c.next=o(e.next.bind(e))),c.return??(c.return=o(e.return.bind(e))),c.throw??(c.throw=o(e.throw.bind(e))),c[rz]=!0),r.set(e,c),c}}if(typeof e=="function"){const o=t.functions.serialize(e,t,n),i={[uE]:o};return r.set(e,i),i}return r.set(e,e),e},Si=function(e,t,n=!1){if(e==null)return e;if(typeof e=="object"){if(Zn(this,dp)&&!n){const a=Zn(this,dp).call(this,e,o=>Br(this,ns,Si).call(this,o,t,!0),t);if(a!==void 0)return a}if(e==null)return e;if(Array.isArray(e))return e.map(a=>Br(this,ns,Si).call(this,a,t));if(e instanceof Map)return new Map([...e].map(([a,o])=>[Br(this,ns,Si).call(this,a,t),Br(this,ns,Si).call(this,o,t)]));if(e instanceof Set)return new Set([...e].map(a=>Br(this,ns,Si).call(this,a,t)));if(uE in e)return t.functions.deserialize(e[uE],t);if(!nz(e))return e;const r={};for(const a of Object.keys(e))a===rz?r[Symbol.asyncIterator]=()=>r:r[a]=Br(this,ns,Si).call(this,e[a],t);return r}return e};var Xc,Ol,_i,d_,A8,f_,I8;class ewe{constructor(t,{imports:n,exports:r,functions:a=new Xve,serialization:o=new Qve,signal:i}={}){xs(this,_i),xs(this,Xc),xs(this,Ol,new Map);var c,d,f,m;this.messages=t,l_(this,Xc,i?new Zve(i):new AbortController),this.exports=r??{},this.imports=twe(Br(this,_i,A8).bind(this),n),this.functions=a,this.serialization=o,(d=(c=this.functions).start)==null||d.call(c,this),(m=(f=this.serialization).start)==null||m.call(f,this),this.signal.addEventListener("abort",()=>{for(const h of Zn(this,Ol).keys())Br(this,_i,f_).call(this,h,void 0,new tz);Zn(this,Ol).clear()},{once:!0}),t.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case T8:{const[,v,E,x]=g,w=this.exports[E]??(()=>{throw new Error(`No '${E}' method is exported from this thread`)});await Br(this,_i,d_).call(this,w,x,(S,_,T)=>{this.messages.send([JU,v,S,_],T)});break}case N8:{const[,v,E,x]=g,w=this.functions.get(E,this)??nwe;await Br(this,_i,d_).call(this,w,x,(S,_,T)=>{this.messages.send([QU,v,S,_],T)});break}case JU:case QU:{Br(this,_i,f_).call(this,...g.slice(1));break}case k8:{const v=g[1];this.functions.release(v,this);break}}},{signal:this.signal})}get signal(){return Zn(this,Xc).signal}get closed(){return Zn(this,Xc).signal.aborted}close(){Zn(this,Xc).abort()}call(t,n){if(this.closed)return Promise.reject(new tz);const r=[],a=this.serialization.serialize(n,this,r),o=C8(),i=Br(this,_i,I8).call(this,o);return t(o,a,r),i}}Xc=new WeakMap,Ol=new WeakMap,_i=new WeakSet,d_=async function(e,t,n){try{const r=this.functions.call?await this.functions.call(e,t,this):await e(...this.serialization.deserialize(t,this)),a=[],o=this.serialization.serialize(r,this,a);n(o,void 0,a)}catch(r){n(void 0,this.serialization.serialize(r,this))}},A8=function(e){return(...t)=>{try{if(typeof e!="string"&&typeof e!="number")throw new Error(`Can’t call a symbol method on a thread: ${e.toString()}`);return this.call((n,r,a)=>{this.messages.send([T8,n,e,r],a)},t)}catch(n){return Promise.reject(n)}}},f_=function(...e){const t=e[0],n=Zn(this,Ol).get(t);n&&(n(...e),Zn(this,Ol).delete(t))},I8=function(e){const t=new Promise((n,r)=>{Zn(this,Ol).set(e,(a,o,i)=>{i==null?n(this.serialization.deserialize(o,this)):r(this.serialization.deserialize(i,this))})});return Object.defineProperty(t,Symbol.asyncIterator,{async*value(){const n=await t;Object.defineProperty(n,Symbol.asyncIterator,{value:()=>n}),yield*n}}),t};function twe(e,t){let n;if(t==null){if(typeof Proxy!="function")throw new Error("You must pass an array of callable methods in environments without Proxies.");const r=new Map;n=new Proxy({},{get(a,o){if(r.has(o))return r.get(o);const i=e(o);return r.set(o,i),i}})}else{n={};for(const r of t)Object.defineProperty(n,r,{value:e(r),writable:!1,configurable:!0,enumerable:!0})}return n}function nwe(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const rwe="quilt.threads.ping",az="quilt.threads.pong";function awe(e,{targetOrigin:t="*"}={}){let n=!1;const r=function(o,i){e.postMessage(o,t,i)},a=new Promise(o=>{const i=new AbortController;globalThis.window.addEventListener("message",c=>{c.source===e&&c.data===az&&(n=!0,i.abort(),o())},{signal:i.signal}),i.signal.addEventListener("abort",()=>o(),{once:!0}),r(rwe)});return{send(o,i){return n?r(o,i):a.then(()=>{if(n)return r(o,i)})},listen(o,{signal:i}){self.addEventListener("message",c=>{c.source===e&&c.data!==az&&o(c.data)},{signal:i})}}}class swe extends ewe{constructor(t,{targetOrigin:n="*",...r}={}){super(awe(t.contentWindow,{targetOrigin:n}),r),this.iframe=t}}const O8=ie.forwardRef(({content:e,children:t,...n},r)=>u.jsx("span",{ref:r,...n,children:e||t}));O8.displayName="UIText";const D8=ie.forwardRef(({label:e,onPress:t,onClick:n,children:r,...a},o)=>u.jsx("button",{ref:o,onClick:i=>{t&&t(),n&&n(i)},style:{padding:"8px 16px",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},...a,children:e||r}));D8.displayName="UIButton";const L8=ie.forwardRef(({direction:e="vertical",spacing:t="8",align:n="stretch",justify:r="flex-start",children:a,...o},i)=>u.jsx("div",{ref:i,style:{display:"flex",flexDirection:e==="horizontal"?"row":"column",gap:`${t}px`,alignItems:n,justifyContent:r},...o,children:a}));L8.displayName="UIStack";const M8=ie.forwardRef(({src:e,alt:t,width:n,height:r,children:a,...o},i)=>u.jsx("img",{ref:i,src:e,alt:t,width:n,height:r,style:{maxWidth:"100%",height:"auto",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)"},...o}));M8.displayName="UIImage";const Q1={name:"basic",elements:[{tagName:"ui-text",component:O8,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:D8,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:L8,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:M8,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},owe=({receiver:e})=>{const t=y.useRef(null);return y.useEffect(()=>{if(t.current)return e.connect(t.current),()=>{e.disconnect()}},[e]),u.jsx("div",{ref:t,"data-testid":"standard-dom-renderer-container"})},iwe=({resource:e,library:t,remoteElements:n=[],onUIAction:r})=>{const a=y.useRef(null),o=y.useRef(null),[i,c]=y.useState(null),d=y.useMemo(()=>(e.mimeType||"").includes("framework=react")?"react":"webcomponents",[e.mimeType]),f=`${t?.name}-${d}`,{receiver:m,components:h}=y.useMemo(()=>{switch(d){case"react":{const v=new $ve,E=t||Q1,x=new Map;return E&&E.elements.forEach(w=>{const S=Vve(w.component);x.set(w.tagName,S)}),{receiver:v,components:x}}case"webcomponents":default:return{receiver:new Uve,components:null}}},[e,t,n]);y.useEffect(()=>{function v(E){var x;if(a.current&&E.source===a.current.contentWindow){const w=E.data;if(!w)return;(x=r?.(w))==null||x.catch(S=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",S)})}}return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[r]),y.useEffect(()=>{const v=o.current;return o.current=null,()=>{v?.close()}},[f]);const g=()=>{const v=a.current;if(!v||o.current)return;const E=new swe(v);o.current=E;const{code:x,error:w}=Rve(e);if(w){c(w);return}if(x&&m!=null&&m.connection){const S={code:x,remoteElements:n,useReactRenderer:d==="react",componentLibrary:t?.name};E.imports.render(S,m.connection).catch(_=>console.error("Error calling remote render:",_))}};return i?u.jsx("p",{className:"text-red-500",children:i}):u.jsxs(u.Fragment,{children:[u.jsx("iframe",{ref:a,srcDoc:Kve,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},f),d==="react"&&h?u.jsx(Wve,{receiver:m,components:h}):u.jsx(owe,{receiver:m})]})};function lwe(e){var t;if(e.contentType)return e.contentType;if(e.mimeType==="text/html")return"rawHtml";if(e.mimeType==="text/uri-list")return"externalUrl";if((t=e.mimeType)!=null&&t.startsWith("application/vnd.mcp-ui.remote-dom"))return"remoteDom"}const eI=e=>{const{resource:t,onUIAction:n,supportedContentTypes:r,htmlProps:a,remoteDomProps:o}=e,i=lwe(t);if(r&&i&&!r.includes(i))return u.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",i,"."]});switch(i){case"rawHtml":case"externalUrl":return u.jsx(v8,{resource:t,onUIAction:n,...a});case"remoteDom":return u.jsx(iwe,{resource:t,onUIAction:n,library:o?.library||Q1,...o});default:return u.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};eI.displayName="UIResourceRenderer";const cwe={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},uwe={tagName:"ui-text",remoteAttributes:["content"]},dwe={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},fwe={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},pwe=y.memo(({resource:e})=>{const t=async n=>(n.type==="tool"||n.type==="prompt"||(n.type==="link"?n.payload.url&&window.open(n.payload.url,"_blank"):n.type==="intent"||n.type),{status:"Action received"});return e.uri?.startsWith("ui://")?u.jsx("div",{className:"my-4 p-0 border h-[350px] rounded-2xl border-zinc-200 overflow-hidden bg-card",children:u.jsx(eI,{resource:e,onUIAction:t,htmlProps:{style:{maxWidth:"100%",height:"100%",overflow:"auto"},autoResizeIframe:!0,sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"}})}):null});function sz({toolName:e,toolArgs:t,result:n,serverId:r,readResource:a,toolMeta:o}){const[i,c]=y.useState(null);y.useEffect(()=>{console.log("[ToolResultRenderer] Rendering:",{toolName:e,hasToolMeta:!!o,outputTemplate:o?.["openai/outputTemplate"],hasResult:!!n,hasServerId:!!r,hasReadResource:!!a})},[e,o,n,r,a]);const d=y.useMemo(()=>{if(typeof n=="string")try{return JSON.parse(n)}catch(v){return console.error("[ToolResultRenderer] Failed to parse result:",v),n}return n},[n]),f=y.useMemo(()=>!!o?.["openai/outputTemplate"],[o]),m=y.useMemo(()=>!!(d?.content&&Array.isArray(d.content)&&d.content.some(v=>v.type==="resource"&&v.resource?.uri?.startsWith("ui://")&&v.resource?.mimeType==="text/html+skybridge")),[d]),h=y.useMemo(()=>m&&d.content.find(E=>E.type==="resource"&&E.resource?.uri?.startsWith("ui://")&&E.resource?.mimeType==="text/html+skybridge")?.resource||null,[m,d]);if(y.useEffect(()=>{if(h){c(h);return}if(f&&o&&a){const v=o["openai/outputTemplate"];console.log("[ToolResultRenderer] Fetching resource for Apps SDK tool:",v),a(v).then(E=>{console.log("[ToolResultRenderer] Resource fetched:",E),E?.contents&&Array.isArray(E.contents)&&E.contents.length>0?c(E.contents[0]):console.warn("[ToolResultRenderer] No contents in fetched resource:",E)}).catch(E=>{console.error("[ToolResultRenderer] Failed to fetch resource:",E)})}},[h,f,o,a]),(f||m)&&i&&r&&a)return u.jsx(Y1,{componentUrl:i.uri,toolName:e,toolArgs:t,toolResult:d,serverId:r,readResource:a,noWrapper:!0,className:"my-4",showConsole:!1});if((f||m)&&!i)return u.jsx("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:u.jsx(eo,{className:"size-5"})});if(f&&(!r||!a))return console.error("[ToolResultRenderer] Apps SDK tool but missing serverId or readResource:",{toolName:e,hasServerId:!!r,hasReadResource:!!a}),u.jsx("div",{className:"my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg",children:u.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:"Cannot render widget: Missing required props (serverId or readResource)"})});const g=[];if(d?.content&&Array.isArray(d.content))for(const v of d.content)v.type==="resource"&&v.resource?.uri?.startsWith("ui://")&&v.resource?.mimeType!=="text/html+skybridge"&&g.push(v.resource);return g.length>0?u.jsx(u.Fragment,{children:g.map(v=>u.jsx(pwe,{resource:v},`${e}-mcp-ui-${v.uri}`))}):(console.log("[ToolResultRenderer] Not rendering (no UI resources found):",{toolName:e,isAppsSdkTool:f,hasAppsSdkComponent:m,hasResourceData:!!i,contentLength:d?.content?.length}),null)}function mwe({content:e,timestamp:t}){return!e||e.length===0?null:u.jsx("div",{className:"flex items-start gap-3 justify-end group/user-message",children:u.jsxs("div",{className:"flex-1 min-w-0 flex flex-col items-end",children:[u.jsx("div",{className:"bg-zinc-200 dark:bg-zinc-800 text-primary rounded-3xl px-4 py-2 max-w-[80%] break-words",children:u.jsx("p",{className:"text-base leading-7 font-sans text-start break-words",children:e})}),t&&u.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:new Date(t).toLocaleTimeString()})]})})}const hwe=y.memo(({messages:e,isLoading:t,serverId:n,readResource:r,tools:a})=>{const o=y.useRef(null),i=f=>a?.find(h=>h.name===f)?._meta;y.useEffect(()=>{e.length>0&&o.current&&o.current.scrollIntoView({behavior:t?"auto":"smooth",block:"start"})},[e.length,t]);const c=t&&(()=>{if(e.length===0)return!0;const f=e[e.length-1];if(f.role==="user")return!0;if(f.role==="assistant"){const m=typeof f.content=="string"?f.content:Array.isArray(f.content)?f.content.map(g=>typeof g=="string"?g:g.text||JSON.stringify(g)).join(""):JSON.stringify(f.content);return!(m&&m.trim().length>0)}return!1})(),d=f=>{if(!t)return!1;const m=e[e.length-1];return f.id===m.id&&m.role==="assistant"};return u.jsxs("div",{className:"space-y-6 max-w-3xl mx-auto px-2",children:[e.map(f=>{const m=typeof f.content=="string"?f.content:Array.isArray(f.content)?f.content.map(h=>typeof h=="string"?h:h.text||JSON.stringify(h)).join(""):JSON.stringify(f.content);return f.role==="user"?u.jsx(mwe,{content:m,timestamp:f.timestamp},f.id):f.role==="assistant"?u.jsx("div",{className:"space-y-4",children:f.parts&&f.parts.length>0?f.parts.map((h,g)=>{const v=h.type==="text"?`${f.id}-text-${g}-${h.text?.slice(0,20)}`:`${f.id}-tool-${h.toolInvocation?.toolName}-${g}`;return h.type==="text"?u.jsx(BU,{content:h.text||"",timestamp:g===f.parts.length-1?f.timestamp:void 0,_isStreaming:d(f)},v):h.type==="tool-invocation"&&h.toolInvocation?u.jsxs("div",{children:[u.jsx(HU,{toolName:h.toolInvocation.toolName,args:h.toolInvocation.args,result:h.toolInvocation.result,state:h.toolInvocation.result?"result":"call"}),h.toolInvocation.result&&u.jsx(sz,{toolName:h.toolInvocation.toolName,toolArgs:h.toolInvocation.args,result:h.toolInvocation.result,serverId:n,readResource:r,toolMeta:i(h.toolInvocation.toolName)})]},v):null}):u.jsxs(u.Fragment,{children:[u.jsx(BU,{content:m,timestamp:f.timestamp,_isStreaming:d(f)}),f.toolCalls&&f.toolCalls.length>0&&u.jsx("div",{className:"space-y-2",children:f.toolCalls.map(h=>{const g=`${f.id}-${h.toolName}-${JSON.stringify(h.args).slice(0,50)}`;return u.jsxs("div",{children:[u.jsx(HU,{toolName:h.toolName,args:h.args,result:h.result,state:h.result?"result":"call"}),h.result&&u.jsx(sz,{toolName:h.toolName,toolArgs:h.args,result:h.result,serverId:n,readResource:r,toolMeta:i(h.toolName)})]},g)})})]})},f.id):null}),c&&u.jsx("div",{className:"flex items-start gap-3",children:u.jsx("div",{className:"flex-1",children:u.jsx("div",{className:"rounded-lg p-4 max-w-fit",children:u.jsx("div",{className:"flex items-center gap-2",children:u.jsx("span",{className:"text-sm",children:u.jsx(Ybe,{duration:2,spread:1,children:"Thinking..."})})})})})}),u.jsx("div",{ref:o})]})});function j8(e){let t=0;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);t=(t<<5)-t+r,t=t&t}return Math.abs(t).toString(16)}function gwe({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:r}){const[a,o]=y.useState([]),[i,c]=y.useState(!1),d=y.useCallback(async m=>{if(!m.trim()||!t||!r)return;const h={id:`user-${Date.now()}`,role:"user",content:m.trim(),timestamp:Date.now()};o(g=>[...g,h]),c(!0);try{let g=n;if(n?.type==="oauth")try{const R="mcp:auth",C=j8(e),A=`${R}_${C}_tokens`,I=localStorage.getItem(A);if(I){const O=JSON.parse(I);g={...n,oauthTokens:O}}else console.warn("No OAuth tokens found in localStorage for key:",A)}catch(R){console.warn("Failed to retrieve OAuth tokens:",R)}const v=await fetch("/inspector/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mcpServerUrl:e,llmConfig:t,authConfig:g,messages:[...a,h].map(R=>({role:R.role,content:R.content}))})});if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);const E=`assistant-${Date.now()}`;let x="";const w=[];o(R=>[...R,{id:E,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);const S=v.body?.getReader(),_=new TextDecoder;if(!S)throw new Error("No response body");let T="";for(;;){const{done:R,value:C}=await S.read();if(R)break;T+=_.decode(C,{stream:!0});const A=T.split(`
|
|
1723
|
-
`);T=A.pop()||"";for(const I of A)if(I.trim()&&I.startsWith("data: "))try{const O=JSON.parse(I.slice(6));if(console.log("[Client received event]",O.type,O.toolName||O.content?.slice?.(0,30)),O.type==="message")console.log("[Message started]",O.id);else if(O.type==="text"){x+=O.content;const U=w[w.length-1];U&&U.type==="text"?U.text=x:w.push({type:"text",text:x}),console.log("[Parts after text]",w.length,"parts, text length:",x.length),o(L=>L.map($=>$.id===E?{...$,parts:[...w]}:$))}else if(O.type==="tool-call")x&&(x=""),w.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",w.length,"parts, tool:",O.toolName),o(U=>U.map(L=>L.id===E?{...L,parts:[...w]}:L));else if(O.type==="tool-result"){const U=w.find(L=>L.type==="tool-invocation"&&L.toolInvocation?.toolName===O.toolName&&!L.toolInvocation?.result);U&&U.toolInvocation?(U.toolInvocation.result=O.result,U.toolInvocation.state="result",console.log("[Parts after tool-result]",w.length,"parts, updated:",O.toolName),o(L=>L.map($=>$.id===E?{...$,parts:[...w]}:$))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",w.length),o(U=>U.map(L=>L.id===E?{...L,parts:[...w],content:""}:L));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,I)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const x=g;x.status&&(v=`HTTP ${x.status}: ${v}`),(x.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const E={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};o(x=>[...x,E])}finally{c(!1)}},[t,r,e,a,n]),f=y.useCallback(()=>{o([])},[]);return{messages:a,isLoading:i,sendMessage:d,clearMessages:f}}function bwe({connection:e,llmConfig:t,isConnected:n,readResource:r}){const[a,o]=y.useState([]),[i,c]=y.useState(!1),d=y.useRef(null),f=y.useRef(null),m=y.useRef(null),h=y.useCallback(async v=>{if(!v.trim()||!t||!n)return;const E={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};o(S=>[...S,E]),c(!0),d.current=new AbortController;const x=Date.now();let w=0;try{const S=`assistant-${Date.now()}`;let _="";const T=[];if(o(R=>[...R,{id:S,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 R;if(t.provider==="openai"){const{ChatOpenAI:C}=await pa(async()=>{const{ChatOpenAI:A}=await import("./index-CtIyN4y7.js");return{ChatOpenAI:A}},__vite__mapDeps([0,1,2,3,4,5]));R=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:C}=await pa(async()=>{const{ChatAnthropic:A}=await import("./index-Bey-QuvV.js");return{ChatAnthropic:A}},__vite__mapDeps([6,2,1,5]));R=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:C}=await pa(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-Cpg-k5c6.js");return{ChatGoogleGenerativeAI:A}},__vite__mapDeps([7,2,1,4]));R=new C({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:R,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!f.current||f.current.llm!==m.current.instance){const{MCPAgent:R}=await pa(async()=>{const{MCPAgent:C}=await import("./browser-DQo0fId8.js");return{MCPAgent:C}},__vite__mapDeps([8,5,1,2,4,3]));f.current=new R({llm:m.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await f.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",f.current.conversationHistory?.length);for await(const R of f.current.streamEvents(v,10,!1,void 0)){if(d.current?.signal.aborted)break;if(R.event==="on_chat_model_stream"&&R.data?.chunk?.text){const C=R.data.chunk.text;if(typeof C=="string"&&C.length>0){_+=C;const A=T[T.length-1];A&&A.type==="text"?A.text=_:T.push({type:"text",text:_}),o(I=>I.map(O=>O.id===S?{...O,parts:[...T]}:O))}}else if(R.event==="on_tool_start"){_&&(_="");let C={};R.data?.input?C=R.data.input:R.data?.tool_input?C=R.data.tool_input:R.data&&(C=R.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:R.name,eventData:R.data,extractedArgs:C}),w++,T.push({type:"tool-invocation",toolInvocation:{toolName:R.name||"unknown",args:C,state:"pending"}}),o(A=>A.map(I=>I.id===S?{...I,parts:[...T]}:I))}else if(R.event==="on_tool_end"){const C=T.find(A=>A.type==="tool-invocation"&&A.toolInvocation?.toolName===R.name&&!A.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:R.name,hasToolPart:!!C,output:R.data?.output}),C&&C.toolInvocation){let A=R.data?.output;if(A?.kwargs?.content&&typeof A.kwargs.content=="string")try{A=JSON.parse(A.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),A=A.kwargs.content}else if(A?.content&&typeof A.content=="string")try{A=JSON.parse(A.content)}catch{A=A.content}C.toolInvocation.result=A,C.toolInvocation.state="result";const I=A?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:R.name,hasMeta:!!A?._meta,hasStructuredContent:!!A?.structuredContent,appsSdkUri:I}),I&&typeof I=="string"&&r){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",I);try{const O=await r(I);console.log("[useChatMessagesClientSide] Resource fetched:",O);const U=A?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const L=O.contents.map(H=>({type:"resource",resource:H}));console.log("[useChatMessagesClientSide] Created MCP resources:",L);const $={...A,content:[...A.content||[],...L],structuredContent:U};C.toolInvocation.result=$,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}o(O=>O.map(U=>U.id===S?{...U,parts:[...T]}:U))}}}o(R=>R.map(C=>C.id===S?{...C,parts:[...T],content:""}:C)),t&&Zr.getInstance().capture(new AP({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:w,success:!0,executionMode:"client-side",duration:Date.now()-x})).catch(()=>{})}catch(S){console.error("Client-side agent error:",S);let _="Unknown error occurred";if(S instanceof Error){_=S.message;const R=S;R.status&&(_=`HTTP ${R.status}: ${_}`),(R.code===401||_.includes("401")||_.includes("Unauthorized"))&&(_="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&Zr.getInstance().capture(new AP({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:w,success:!1,executionMode:"client-side",duration:Date.now()-x,error:_})).catch(()=>{});const T={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${_}`,timestamp:Date.now()};o(R=>[...R,T])}finally{c(!1),d.current=null}},[e,t,n,a,r]),g=y.useCallback(()=>{o([]),f.current&&f.current.clearConversationHistory()},[]);return{messages:a,isLoading:i,sendMessage:h,clearMessages:g}}const oz={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function P8({mcpServerUrl:e}){const[t,n]=y.useState(null),[r,a]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState("openai"),[f,m]=y.useState(""),[h,g]=y.useState(oz.openai),v=y.useCallback(()=>{const U=localStorage.getItem("mcp-inspector-api-keys");if(U)try{return JSON.parse(U)}catch(L){return console.error("Failed to load API keys:",L),{}}return{}},[]),E=y.useCallback(U=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(U))},[]),[x,w]=y.useState("none"),[S,_]=y.useState(""),[T,R]=y.useState(""),[C,A]=y.useState("");y.useEffect(()=>{const U=localStorage.getItem("mcp-inspector-llm-config"),L=v();if(U)try{const $=JSON.parse(U);n($),d($.provider),m(L[$.provider]||$.apiKey||""),g($.model)}catch($){console.error("Failed to load LLM config:",$)}},[v]),y.useEffect(()=>{const U=localStorage.getItem("mcp-inspector-auth-config");if(U)try{const L=JSON.parse(U);a(L),w(L.type),L.username&&_(L.username),L.password&&R(L.password),L.token&&A(L.token)}catch(L){console.error("Failed to load auth config:",L)}else try{const L="mcp:auth",$=j8(e),H=`${L}_${$}_tokens`;localStorage.getItem(H)&&(a({type:"oauth"}),w("oauth"))}catch(L){console.error("Failed to check for OAuth tokens:",L)}},[e]),y.useEffect(()=>{g(oz[c]);const U=v();m(U[c]||"")},[c,v]);const I=y.useCallback(()=>{if(!f.trim())return;const U=v();U[c]=f,E(U);const L={provider:c,apiKey:f,model:h},$={type:x,...x==="basic"&&{username:S.trim(),password:T.trim()},...x==="bearer"&&{token:C.trim()}};n(L),a($),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(L)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify($)),i(!1)},[c,f,h,x,S,T,C,v,E]),O=y.useCallback(()=>{n(null),a(null);const U=v();delete U[c],E(U),m(""),_(""),R(""),A(""),w("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,E]);return{llmConfig:t,authConfig:r,configDialogOpen:o,setConfigDialogOpen:i,tempProvider:c,setTempProvider:d,tempApiKey:f,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:I,clearConfig:O}}function ywe({connection:e,isConnected:t,useClientSide:n=!0,readResource:r}){const[a,o]=y.useState(""),i=y.useRef(null),{llmConfig:c,authConfig:d,configDialogOpen:f,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:E,tempModel:x,setTempModel:w,saveLLMConfig:S,clearConfig:_}=P8({mcpServerUrl:e.url}),T={connection:e,llmConfig:c,isConnected:t,readResource:r},R=gwe({mcpServerUrl:e.url,llmConfig:c,authConfig:d,isConnected:t}),C=bwe(T),{messages:A,isLoading:I,sendMessage:O,clearMessages:U}=n?C:R;ZV({onNewChat:U}),y.useEffect(()=>{c&&A.length===0&&i.current&&i.current.focus()},[c,A.length]),y.useEffect(()=>{!I&&A.length>0&&i.current&&i.current.focus()},[I,A.length]);const L=y.useCallback(()=>{a.trim()&&(O(a),o(""))},[a,O]),$=y.useCallback(Y=>{Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),L())},[L]),H=y.useCallback(()=>{_(),U()},[_,U]);return c&&A.length===0?u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsx("div",{className:"absolute top-4 right-4 z-10",children:u.jsx(WS,{open:f,onOpenChange:m,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSave:S,onClear:H,showClearButton:!0,buttonLabel:"Change API Key"})}),u.jsx(Wbe,{mcpServerUrl:e.url,inputValue:a,isConnected:t,isLoading:I,textareaRef:i,llmConfig:c,onInputChange:o,onKeyDown:$,onSubmit:Y=>{Y.preventDefault(),L()},onConfigDialogOpenChange:m})]}):u.jsxs("div",{className:"flex flex-col h-full relative",children:[u.jsx(Hbe,{llmConfig:c,hasMessages:A.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:U,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSaveConfig:S,onClearConfig:H}),u.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?u.jsx(hwe,{messages:A,isLoading:I,serverId:e.url,readResource:r,tools:e.tools}):u.jsx(Kbe,{onConfigureClick:()=>m(!0)})}),c&&u.jsx(Vbe,{inputValue:a,isConnected:t,isLoading:I,textareaRef:i,onInputChange:o,onKeyDown:$,onSendMessage:L})]})}const jv=y.createContext(null);jv.displayName="PanelGroupContext";const lr={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},tI=10,Ml=y.useLayoutEffect,iz=pd.useId,vwe=typeof iz=="function"?iz:()=>null;let wwe=0;function nI(e=null){const t=vwe(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+wwe++),e??n.current}function $8({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:a,forwardedRef:o,id:i,maxSize:c,minSize:d,onCollapse:f,onExpand:m,onResize:h,order:g,style:v,tagName:E="div",...x}){const w=y.useContext(jv);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:S,expandPanel:_,getPanelSize:T,getPanelStyle:R,groupId:C,isPanelCollapsed:A,reevaluatePanelConstraints:I,registerPanel:O,resizePanel:U,unregisterPanel:L}=w,$=nI(i),H=y.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:a,maxSize:c,minSize:d},id:$,idIsFromProps:i!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),Ml(()=>{const{callbacks:q,constraints:ne}=H.current,G={...ne};H.current.id=$,H.current.idIsFromProps=i!==void 0,H.current.order=g,q.onCollapse=f,q.onExpand=m,q.onResize=h,ne.collapsedSize=n,ne.collapsible=r,ne.defaultSize=a,ne.maxSize=c,ne.minSize=d,(G.collapsedSize!==ne.collapsedSize||G.collapsible!==ne.collapsible||G.maxSize!==ne.maxSize||G.minSize!==ne.minSize)&&I(H.current,G)}),Ml(()=>{const q=H.current;return O(q),()=>{L(q)}},[g,$,O,L]),y.useImperativeHandle(o,()=>({collapse:()=>{S(H.current)},expand:q=>{_(H.current,q)},getId(){return $},getSize(){return T(H.current)},isCollapsed(){return A(H.current)},isExpanded(){return!A(H.current)},resize:q=>{U(H.current,q)}}),[S,_,T,A,$,U]);const Y=R(H.current,a);return y.createElement(E,{...x,children:e,className:t,id:$,style:{...Y,...v},[lr.groupId]:C,[lr.panel]:"",[lr.panelCollapsible]:r||void 0,[lr.panelId]:$,[lr.panelSize]:parseFloat(""+Y.flexGrow).toFixed(1)})}const U8=y.forwardRef((e,t)=>y.createElement($8,{...e,forwardedRef:t}));$8.displayName="Panel";U8.displayName="forwardRef(Panel)";let p_=null,Tb=-1,Ri=null;function xwe(e,t,n){const r=(t&V8)!==0,a=(t&G8)!==0,o=(t&W8)!==0,i=(t&K8)!==0;if(t){if(r)return o?"se-resize":i?"ne-resize":"e-resize";if(a)return o?"sw-resize":i?"nw-resize":"w-resize";if(o)return"s-resize";if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Ewe(){Ri!==null&&(document.head.removeChild(Ri),p_=null,Ri=null,Tb=-1)}function dE(e,t,n){var r,a;const o=xwe(e,t);if(p_!==o){if(p_=o,Ri===null&&(Ri=document.createElement("style"),document.head.appendChild(Ri)),Tb>=0){var i;(i=Ri.sheet)===null||i===void 0||i.removeRule(Tb)}Tb=(r=(a=Ri.sheet)===null||a===void 0?void 0:a.insertRule(`*{cursor: ${o} !important;}`))!==null&&r!==void 0?r:-1}}function z8(e){return e.type==="keydown"}function F8(e){return e.type.startsWith("pointer")}function B8(e){return e.type.startsWith("mouse")}function Pv(e){if(F8(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(B8(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Swe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function _we(e,t,n){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 Twe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:uz(e),b:uz(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ft(r,"Stacking order can only be calculated for elements with a common ancestor");const a={a:cz(lz(n.a)),b:cz(lz(n.b))};if(a.a===a.b){const o=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let c=o.length;for(;c--;){const d=o[c];if(d===i.a)return 1;if(d===i.b)return-1}}return Math.sign(a.a-a.b)}const Nwe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function kwe(e){var t;const n=getComputedStyle((t=H8(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Cwe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||kwe(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"||Nwe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function lz(e){let t=e.length;for(;t--;){const n=e[t];if(Ft(n,"Missing node"),Cwe(n))return n}return null}function cz(e){return e&&Number(getComputedStyle(e).zIndex)||0}function uz(e){const t=[];for(;e;)t.push(e),e=H8(e);return t}function H8(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const V8=1,G8=2,W8=4,K8=8,Rwe=Swe()==="coarse";let Ss=[],Eu=!1,Ai=new Map,$v=new Map;const Wp=new Set;function Awe(e,t,n,r,a){var o;const{ownerDocument:i}=t,c={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:a},d=(o=Ai.get(i))!==null&&o!==void 0?o:0;return Ai.set(i,d+1),Wp.add(c),Sy(),function(){var m;$v.delete(e),Wp.delete(c);const h=(m=Ai.get(i))!==null&&m!==void 0?m:1;if(Ai.set(i,h-1),Sy(),h===1&&Ai.delete(i),Ss.includes(c)){const g=Ss.indexOf(c);g>=0&&Ss.splice(g,1),Uv(),a("up",!0,null)}}}function Iwe(e){const{target:t}=e,{x:n,y:r}=Pv(e);Eu=!0,rI({target:t,x:n,y:r}),Sy(),Ss.length>0&&(_y("down",e),Uv(),e.preventDefault(),Y8(t)||e.stopImmediatePropagation())}function fE(e){const{x:t,y:n}=Pv(e);if(Eu&&e.type!=="pointerleave"&&e.buttons===0&&(Eu=!1,_y("up",e)),!Eu){const{target:r}=e;rI({target:r,x:t,y:n})}_y("move",e),Uv(),Ss.length>0&&e.preventDefault()}function pE(e){const{target:t}=e,{x:n,y:r}=Pv(e);$v.clear(),Eu=!1,Ss.length>0&&(e.preventDefault(),Y8(t)||e.stopImmediatePropagation()),_y("up",e),rI({target:t,x:n,y:r}),Uv(),Sy()}function Y8(e){let t=e;for(;t;){if(t.hasAttribute(lr.resizeHandle))return!0;t=t.parentElement}return!1}function rI({target:e,x:t,y:n}){Ss.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Wp.forEach(a=>{const{element:o,hitAreaMargins:i}=a,c=o.getBoundingClientRect(),{bottom:d,left:f,right:m,top:h}=c,g=Rwe?i.coarse:i.fine;if(t>=f-g&&t<=m+g&&n>=h-g&&n<=d+g){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&Twe(r,o)>0){let E=r,x=!1;for(;E&&!E.contains(o);){if(_we(E.getBoundingClientRect(),c)){x=!0;break}E=E.parentElement}if(x)return}Ss.push(a)}})}function mE(e,t){$v.set(e,t)}function Uv(){let e=!1,t=!1;Ss.forEach(r=>{const{direction:a}=r;a==="horizontal"?e=!0:t=!0});let n=0;$v.forEach(r=>{n|=r}),e&&t?dE("intersection",n):e?dE("horizontal",n):t?dE("vertical",n):Ewe()}let hE;function Sy(){var e;(e=hE)===null||e===void 0||e.abort(),hE=new AbortController;const t={capture:!0,signal:hE.signal};Wp.size&&(Eu?(Ss.length>0&&Ai.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("contextmenu",pE,t),a.addEventListener("pointerleave",fE,t),a.addEventListener("pointermove",fE,t))}),Ai.forEach((n,r)=>{const{body:a}=r;a.addEventListener("pointerup",pE,t),a.addEventListener("pointercancel",pE,t)})):Ai.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("pointerdown",Iwe,t),a.addEventListener("pointermove",fE,t))}))}function _y(e,t){Wp.forEach(n=>{const{setResizeHandlerState:r}=n,a=Ss.includes(n);r(e,a,t)})}function Owe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function Ft(e,t){if(!e)throw console.error(t),Error(t)}function Wl(e,t,n=tI){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Ro(e,t,n=tI){return Wl(e,t,n)===0}function Fa(e,t,n){return Wl(e,t,n)===0}function Dwe(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const a=e[r],o=t[r];if(!Fa(a,o,n))return!1}return!0}function pu({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ft(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:o,maxSize:i=100,minSize:c=0}=r;if(Wl(n,c)<0)if(o){const d=(a+c)/2;Wl(n,d)<0?n=a:n=c}else n=c;return n=Math.min(i,n),n=parseFloat(n.toFixed(tI)),n}function Yf({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:a,trigger:o}){if(Fa(e,0))return t;const i=[...t],[c,d]=r;Ft(c!=null,"Invalid first pivot index"),Ft(d!=null,"Invalid second pivot index");let f=0;if(o==="keyboard"){{const h=e<0?d:c,g=n[h];Ft(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if(Ft(w!=null,`Previous layout not found for panel index ${h}`),Fa(w,v)){const S=x-w;Wl(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const h=e<0?c:d,g=n[h];Ft(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if(Ft(w!=null,`Previous layout not found for panel index ${h}`),Fa(w,x)){const S=w-v;Wl(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}}{const h=e<0?1:-1;let g=e<0?d:c,v=0;for(;;){const x=t[g];Ft(x!=null,`Previous layout not found for panel index ${g}`);const S=pu({panelConstraints:n,panelIndex:g,size:100})-x;if(v+=S,g+=h,g<0||g>=n.length)break}const E=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-E:E}{let g=e<0?c:d;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(f),E=t[g];Ft(E!=null,`Previous layout not found for panel index ${g}`);const x=E-v,w=pu({panelConstraints:n,panelIndex:g,size:x});if(!Fa(E,w)&&(f+=E-w,i[g]=w,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(Dwe(a,i))return a;{const h=e<0?d:c,g=t[h];Ft(g!=null,`Previous layout not found for panel index ${h}`);const v=g+f,E=pu({panelConstraints:n,panelIndex:h,size:v});if(i[h]=E,!Fa(E,v)){let x=v-E,S=e<0?d:c;for(;S>=0&&S<n.length;){const _=i[S];Ft(_!=null,`Previous layout not found for panel index ${S}`);const T=_+x,R=pu({panelConstraints:n,panelIndex:S,size:T});if(Fa(_,R)||(x-=R-_,i[S]=R),Fa(x,0))break;e>0?S--:S++}}}const m=i.reduce((h,g)=>g+h,0);return Fa(m,100)?i:a}function Lwe({layout:e,panelsArray:t,pivotIndices:n}){let r=0,a=100,o=0,i=0;const c=n[0];Ft(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:E=100,minSize:x=0}=v;g===c?(r=x,a=E):(o+=x,i+=E)});const d=Math.min(a,100-o),f=Math.max(r,100-i),m=e[c];return{valueMax:d,valueMin:f,valueNow:m}}function Kp(e,t=document){return Array.from(t.querySelectorAll(`[${lr.resizeHandleId}][data-panel-group-id="${e}"]`))}function Z8(e,t,n=document){const a=Kp(e,n).findIndex(o=>o.getAttribute(lr.resizeHandleId)===t);return a??null}function q8(e,t,n){const r=Z8(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Mwe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function X8(e,t=document){if(Mwe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function zv(e,t=document){const n=t.querySelector(`[${lr.resizeHandleId}="${e}"]`);return n||null}function jwe(e,t,n,r=document){var a,o,i,c;const d=zv(t,r),f=Kp(e,r),m=d?f.indexOf(d):-1,h=(a=(o=n[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,g=(i=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&i!==void 0?i:null;return[h,g]}function Pwe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:a,panelGroupElement:o,setLayout:i}){y.useRef({didWarnAboutMissingResizeHandle:!1}),Ml(()=>{if(!o)return;const c=Kp(n,o);for(let d=0;d<a.length-1;d++){const{valueMax:f,valueMin:m,valueNow:h}=Lwe({layout:r,panelsArray:a,pivotIndices:[d,d+1]}),g=c[d];if(g!=null){const v=a[d];Ft(v,`No panel data found for index "${d}"`),g.setAttribute("aria-controls",v.id),g.setAttribute("aria-valuemax",""+Math.round(f)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{c.forEach((d,f)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,r,a,o]),y.useEffect(()=>{if(!o)return;const c=t.current;Ft(c,"Eager values not found");const{panelDataArray:d}=c,f=X8(n,o);Ft(f!=null,`No group found for id "${n}"`);const m=Kp(n,o);Ft(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(lr.resizeHandleId);Ft(v,"Resize handle element has no handle id attribute");const[E,x]=jwe(n,v,d,o);if(E==null||x==null)return()=>{};const w=S=>{if(!S.defaultPrevented)switch(S.key){case"Enter":{S.preventDefault();const _=d.findIndex(T=>T.id===E);if(_>=0){const T=d[_];Ft(T,`No panel data found for index ${_}`);const R=r[_],{collapsedSize:C=0,collapsible:A,minSize:I=0}=T.constraints;if(R!=null&&A){const O=Yf({delta:Fa(R,C)?I-C:C-R,initialLayout:r,panelConstraints:d.map(U=>U.constraints),pivotIndices:q8(n,v,o),prevLayout:r,trigger:"keyboard"});r!==O&&i(O)}}break}}};return g.addEventListener("keydown",w),()=>{g.removeEventListener("keydown",w)}});return()=>{h.forEach(g=>g())}},[o,e,t,n,r,a,i])}function dz(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 J8(e,t){const n=e==="horizontal",{x:r,y:a}=Pv(t);return n?r:a}function $we(e,t,n,r,a){const o=n==="horizontal",i=zv(t,a);Ft(i,`No resize handle element found for id "${t}"`);const c=i.getAttribute(lr.groupId);Ft(c,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=r;const f=J8(n,e),m=X8(c,a);Ft(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=o?h.width:h.height;return(f-d)/g*100}function Uwe(e,t,n,r,a,o){if(z8(e)){const i=n==="horizontal";let c=0;e.shiftKey?c=100:a!=null?c=a:c=10;let d=0;switch(e.key){case"ArrowDown":d=i?0:c;break;case"ArrowLeft":d=i?-c:0;break;case"ArrowRight":d=i?c:0;break;case"ArrowUp":d=i?0:-c;break;case"End":d=100;break;case"Home":d=-100;break}return d}else return r==null?0:$we(e,t,n,r,o)}function zwe({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,a=100;for(let o=0;o<e.length;o++){const i=n[o];Ft(i,`Panel constraints not found for index ${o}`);const{defaultSize:c}=i;c!=null&&(r++,t[o]=c,a-=c)}for(let o=0;o<e.length;o++){const i=n[o];Ft(i,`Panel constraints not found for index ${o}`);const{defaultSize:c}=i;if(c!=null)continue;const d=e.length-r,f=a/d;r++,t[o]=f,a-=f}return t}function Hc(e,t,n){t.forEach((r,a)=>{const o=e[a];Ft(o,`Panel data not found for index ${a}`);const{callbacks:i,constraints:c,id:d}=o,{collapsedSize:f=0,collapsible:m}=c,h=n[d];if(h==null||r!==h){n[d]=r;const{onCollapse:g,onExpand:v,onResize:E}=i;E&&E(r,h),m&&(g||v)&&(v&&(h==null||Ro(h,f))&&!Ro(r,f)&&v(),g&&(h==null||!Ro(h,f))&&Ro(r,f)&&g())}})}function Jg(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 Fwe({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:a,precision:o=3}){const i=n[a];let c;return i==null?c=e!=null?e.toFixed(o):"1":r.length===1?c="1":c=i.toFixed(o),{flexBasis:0,flexGrow:c,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Bwe(e,t=10){let n=null;return(...a)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...a)},t)}}function fz(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Q8(e){return`react-resizable-panels:${e}`}function e9(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:a,order:o}=t;return a?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function t9(e,t){try{const n=Q8(e),r=t.getItem(n);if(r){const a=JSON.parse(r);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function Hwe(e,t,n){var r,a;const o=(r=t9(e,n))!==null&&r!==void 0?r:{},i=e9(t);return(a=o[i])!==null&&a!==void 0?a:null}function Vwe(e,t,n,r,a){var o;const i=Q8(e),c=e9(t),d=(o=t9(e,a))!==null&&o!==void 0?o:{};d[c]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{a.setItem(i,JSON.stringify(d))}catch(f){console.error(f)}}function pz({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,i)=>o+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Fa(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const i=n[o];Ft(i!=null,`No layout data found for index ${o}`);const c=100/r*i;n[o]=c}let a=0;for(let o=0;o<t.length;o++){const i=n[o];Ft(i!=null,`No layout data found for index ${o}`);const c=pu({panelConstraints:t,panelIndex:o,size:i});i!=c&&(a+=i-c,n[o]=c)}if(!Fa(a,0))for(let o=0;o<t.length;o++){const i=n[o];Ft(i!=null,`No layout data found for index ${o}`);const c=i+a,d=pu({panelConstraints:t,panelIndex:o,size:c});if(i!==d&&(a-=d-i,n[o]=d,Fa(a,0)))break}return n}const Gwe=100,Zf={getItem:e=>(fz(Zf),Zf.getItem(e)),setItem:(e,t)=>{fz(Zf),Zf.setItem(e,t)}},mz={};function n9({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:a,id:o=null,onLayout:i=null,keyboardResizeBy:c=null,storage:d=Zf,style:f,tagName:m="div",...h}){const g=nI(o),v=y.useRef(null),[E,x]=y.useState(null),[w,S]=y.useState([]),_=Owe(),T=y.useRef({}),R=y.useRef(new Map),C=y.useRef(0),A=y.useRef({autoSaveId:e,direction:r,dragState:E,id:g,keyboardResizeBy:c,onLayout:i,storage:d}),I=y.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});y.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),y.useImperativeHandle(a,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:P}=I.current;return P},setLayout:P=>{const{onLayout:D}=A.current,{layout:j,panelDataArray:V}=I.current,W=pz({layout:P,panelConstraints:V.map(te=>te.constraints)});dz(j,W)||(S(W),I.current.layout=W,D&&D(W),Hc(V,W,T.current))}}),[]),Ml(()=>{A.current.autoSaveId=e,A.current.direction=r,A.current.dragState=E,A.current.id=g,A.current.onLayout=i,A.current.storage=d}),Pwe({committedValuesRef:A,eagerValuesRef:I,groupId:g,layout:w,panelDataArray:I.current.panelDataArray,setLayout:S,panelGroupElement:v.current}),y.useEffect(()=>{const{panelDataArray:P}=I.current;if(e){if(w.length===0||w.length!==P.length)return;let D=mz[e];D==null&&(D=Bwe(Vwe,Gwe),mz[e]=D);const j=[...P],V=new Map(R.current);D(e,j,V,w,d)}},[e,w,d]),y.useEffect(()=>{});const O=y.useCallback(P=>{const{onLayout:D}=A.current,{layout:j,panelDataArray:V}=I.current;if(P.constraints.collapsible){const W=V.map(J=>J.constraints),{collapsedSize:te=0,panelSize:de,pivotIndices:fe}=Sl(V,P,j);if(Ft(de!=null,`Panel size not found for panel "${P.id}"`),!Ro(de,te)){R.current.set(P.id,de);const Q=Jc(V,P)===V.length-1?de-te:te-de,se=Yf({delta:Q,initialLayout:j,panelConstraints:W,pivotIndices:fe,prevLayout:j,trigger:"imperative-api"});Jg(j,se)||(S(se),I.current.layout=se,D&&D(se),Hc(V,se,T.current))}}},[]),U=y.useCallback((P,D)=>{const{onLayout:j}=A.current,{layout:V,panelDataArray:W}=I.current;if(P.constraints.collapsible){const te=W.map(pe=>pe.constraints),{collapsedSize:de=0,panelSize:fe=0,minSize:J=0,pivotIndices:Q}=Sl(W,P,V),se=D??J;if(Ro(fe,de)){const pe=R.current.get(P.id),he=pe!=null&&pe>=se?pe:se,He=Jc(W,P)===W.length-1?fe-he:he-fe,$e=Yf({delta:He,initialLayout:V,panelConstraints:te,pivotIndices:Q,prevLayout:V,trigger:"imperative-api"});Jg(V,$e)||(S($e),I.current.layout=$e,j&&j($e),Hc(W,$e,T.current))}}},[]),L=y.useCallback(P=>{const{layout:D,panelDataArray:j}=I.current,{panelSize:V}=Sl(j,P,D);return Ft(V!=null,`Panel size not found for panel "${P.id}"`),V},[]),$=y.useCallback((P,D)=>{const{panelDataArray:j}=I.current,V=Jc(j,P);return Fwe({defaultSize:D,dragState:E,layout:w,panelData:j,panelIndex:V})},[E,w]),H=y.useCallback(P=>{const{layout:D,panelDataArray:j}=I.current,{collapsedSize:V=0,collapsible:W,panelSize:te}=Sl(j,P,D);return Ft(te!=null,`Panel size not found for panel "${P.id}"`),W===!0&&Ro(te,V)},[]),Y=y.useCallback(P=>{const{layout:D,panelDataArray:j}=I.current,{collapsedSize:V=0,collapsible:W,panelSize:te}=Sl(j,P,D);return Ft(te!=null,`Panel size not found for panel "${P.id}"`),!W||Wl(te,V)>0},[]),q=y.useCallback(P=>{const{panelDataArray:D}=I.current;D.push(P),D.sort((j,V)=>{const W=j.order,te=V.order;return W==null&&te==null?0:W==null?-1:te==null?1:W-te}),I.current.panelDataArrayChanged=!0,_()},[_]);Ml(()=>{if(I.current.panelDataArrayChanged){I.current.panelDataArrayChanged=!1;const{autoSaveId:P,onLayout:D,storage:j}=A.current,{layout:V,panelDataArray:W}=I.current;let te=null;if(P){const fe=Hwe(P,W,j);fe&&(R.current=new Map(Object.entries(fe.expandToSizes)),te=fe.layout)}te==null&&(te=zwe({panelDataArray:W}));const de=pz({layout:te,panelConstraints:W.map(fe=>fe.constraints)});dz(V,de)||(S(de),I.current.layout=de,D&&D(de),Hc(W,de,T.current))}}),Ml(()=>{const P=I.current;return()=>{P.layout=[]}},[]);const ne=y.useCallback(P=>{let D=!1;const j=v.current;return j&&window.getComputedStyle(j,null).getPropertyValue("direction")==="rtl"&&(D=!0),function(W){W.preventDefault();const te=v.current;if(!te)return()=>null;const{direction:de,dragState:fe,id:J,keyboardResizeBy:Q,onLayout:se}=A.current,{layout:pe,panelDataArray:he}=I.current,{initialLayout:Ne}=fe??{},He=q8(J,P,te);let $e=Uwe(W,P,de,fe,Q,te);const Pe=de==="horizontal";Pe&&D&&($e=-$e);const ot=he.map(We=>We.constraints),Me=Yf({delta:$e,initialLayout:Ne??pe,panelConstraints:ot,pivotIndices:He,prevLayout:pe,trigger:z8(W)?"keyboard":"mouse-or-touch"}),Je=!Jg(pe,Me);(F8(W)||B8(W))&&C.current!=$e&&(C.current=$e,!Je&&$e!==0?Pe?mE(P,$e<0?V8:G8):mE(P,$e<0?W8:K8):mE(P,0)),Je&&(S(Me),I.current.layout=Me,se&&se(Me),Hc(he,Me,T.current))}},[]),G=y.useCallback((P,D)=>{const{onLayout:j}=A.current,{layout:V,panelDataArray:W}=I.current,te=W.map(pe=>pe.constraints),{panelSize:de,pivotIndices:fe}=Sl(W,P,V);Ft(de!=null,`Panel size not found for panel "${P.id}"`);const Q=Jc(W,P)===W.length-1?de-D:D-de,se=Yf({delta:Q,initialLayout:V,panelConstraints:te,pivotIndices:fe,prevLayout:V,trigger:"imperative-api"});Jg(V,se)||(S(se),I.current.layout=se,j&&j(se),Hc(W,se,T.current))},[]),K=y.useCallback((P,D)=>{const{layout:j,panelDataArray:V}=I.current,{collapsedSize:W=0,collapsible:te}=D,{collapsedSize:de=0,collapsible:fe,maxSize:J=100,minSize:Q=0}=P.constraints,{panelSize:se}=Sl(V,P,j);se!=null&&(te&&fe&&Ro(se,W)?Ro(W,de)||G(P,de):se<Q?G(P,Q):se>J&&G(P,J))},[G]),F=y.useCallback((P,D)=>{const{direction:j}=A.current,{layout:V}=I.current;if(!v.current)return;const W=zv(P,v.current);Ft(W,`Drag handle element not found for id "${P}"`);const te=J8(j,D);x({dragHandleId:P,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:te,initialLayout:V})},[]),re=y.useCallback(()=>{x(null)},[]),ee=y.useCallback(P=>{const{panelDataArray:D}=I.current,j=Jc(D,P);j>=0&&(D.splice(j,1),delete T.current[P.id],I.current.panelDataArrayChanged=!0,_())},[_]),M=y.useMemo(()=>({collapsePanel:O,direction:r,dragState:E,expandPanel:U,getPanelSize:L,getPanelStyle:$,groupId:g,isPanelCollapsed:H,isPanelExpanded:Y,reevaluatePanelConstraints:K,registerPanel:q,registerResizeHandle:ne,resizePanel:G,startDragging:F,stopDragging:re,unregisterPanel:ee,panelGroupElement:v.current}),[O,E,r,U,L,$,g,H,Y,K,q,ne,G,F,re,ee]),B={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return y.createElement(jv.Provider,{value:M},y.createElement(m,{...h,children:t,className:n,id:o,ref:v,style:{...B,...f},[lr.group]:"",[lr.groupDirection]:r,[lr.groupId]:g}))}const r9=y.forwardRef((e,t)=>y.createElement(n9,{...e,forwardedRef:t}));n9.displayName="PanelGroup";r9.displayName="forwardRef(PanelGroup)";function Jc(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Sl(e,t,n){const r=Jc(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:o}}function Wwe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){y.useEffect(()=>{if(e||n==null||r==null)return;const a=zv(t,r);if(a==null)return;const o=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const c=a.getAttribute(lr.groupId);Ft(c,`No group element found for id "${c}"`);const d=Kp(c,r),f=Z8(c,t,r);Ft(f!==null,`No resize element found for id "${t}"`);const m=i.shiftKey?f>0?f-1:d.length-1:f+1<d.length?f+1:0;d[m].focus();break}}};return a.addEventListener("keydown",o),()=>{a.removeEventListener("keydown",o)}},[r,e,t,n])}function a9({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:a,onBlur:o,onClick:i,onDragging:c,onFocus:d,onPointerDown:f,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...E}){var x,w;const S=y.useRef(null),_=y.useRef({onClick:i,onDragging:c,onPointerDown:f,onPointerUp:m});y.useEffect(()=>{_.current.onClick=i,_.current.onDragging=c,_.current.onPointerDown=f,_.current.onPointerUp=m});const T=y.useContext(jv);if(T===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:R,groupId:C,registerResizeHandle:A,startDragging:I,stopDragging:O,panelGroupElement:U}=T,L=nI(a),[$,H]=y.useState("inactive"),[Y,q]=y.useState(!1),[ne,G]=y.useState(null),K=y.useRef({state:$});Ml(()=>{K.current.state=$}),y.useEffect(()=>{if(n)G(null);else{const M=A(L);G(()=>M)}},[n,L,A]);const F=(x=r?.coarse)!==null&&x!==void 0?x:15,re=(w=r?.fine)!==null&&w!==void 0?w:5;y.useEffect(()=>{if(n||ne==null)return;const M=S.current;Ft(M,"Element ref not attached");let B=!1;return Awe(L,M,R,{coarse:F,fine:re},(D,j,V)=>{if(!j){H("inactive");return}switch(D){case"down":{H("drag"),B=!1,Ft(V,'Expected event to be defined for "down" action'),I(L,V);const{onDragging:W,onPointerDown:te}=_.current;W?.(!0),te?.();break}case"move":{const{state:W}=K.current;B=!0,W!=="drag"&&H("hover"),Ft(V,'Expected event to be defined for "move" action'),ne(V);break}case"up":{H("hover"),O();const{onClick:W,onDragging:te,onPointerUp:de}=_.current;te?.(!1),de?.(),B||W?.();break}}})},[F,R,n,re,A,L,ne,I,O]),Wwe({disabled:n,handleId:L,resizeHandler:ne,panelGroupElement:U});const ee={touchAction:"none",userSelect:"none"};return y.createElement(v,{...E,children:e,className:t,id:a,onBlur:()=>{q(!1),o?.()},onFocus:()=>{q(!0),d?.()},ref:S,role:"separator",style:{...ee,...h},tabIndex:g,[lr.groupDirection]:R,[lr.groupId]:C,[lr.resizeHandle]:"",[lr.resizeHandleActive]:$==="drag"?"pointer":Y?"keyboard":void 0,[lr.resizeHandleEnabled]:!n,[lr.resizeHandleId]:L,[lr.resizeHandleState]:$})}a9.displayName="PanelResizeHandle";function ha({className:e,...t}){return u.jsx(r9,{"data-slot":"resizable-panel-group",className:Oe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Pn({...e}){return u.jsx(U8,{"data-slot":"resizable-panel",...e})}function _s({withHandle:e,className:t,...n}){return u.jsx(a9,{"data-slot":"resizable-handle",className:Oe("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&u.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:u.jsx(gie,{className:"size-2.5"})})})}function Im({className:e,...t}){return u.jsx("kbd",{"data-slot":"kbd",className:Oe("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 Kwe({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onClearAll:c,searchInputRef:d}){return u.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[u.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?u.jsx(In,{ref:d,placeholder:"Search notifications...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):u.jsxs(u.Fragment,{children:[u.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),u.jsx(kr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(Ot,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx(Uo,{className:"h-4 w-4"})})}),u.jsx(Ot,{side:"bottom",children:"Clear all"})]})})]})}function Qi({id:e,isSelected:t,isFocused:n,icon:r,title:a,description:o,metadata:i,onClick:c,className:d}){return u.jsx("button",{id:e,type:"button",onClick:c,className:Oe("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",d),children:u.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[r&&u.jsx("div",{className:"flex-shrink-0 mt-1",children:u.jsx("div",{className:Oe("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})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"flex items-center gap-2 mb-1",children:u.jsx("h3",{className:Oe("font-medium truncate font-mono text-sm"),children:a})}),o&&u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:o})]})]})})}function Ywe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx(Ed,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):u.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,c)=>u.jsx(Qi,{id:`notification-${i.id}`,isSelected:t?.id===i.id,isFocused:r===c,title:u.jsxs("span",{className:"flex items-center gap-3",children:[i.method,!i.read&&u.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const d=a(i.timestamp),f=i.params&&Object.keys(i.params).length>0?Object.keys(i.params).length:0,m=f>0?` | ${f} param${f>1?"s":""}`:"";return d+m})(),onClick:()=>n(i)},i.id))})}function Zwe({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:a,onFullscreen:o,isCopied:i=!1,onClose:c}){return e?u.jsxs("div",{className:"flex flex-col h-full",children:[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:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ep,{className:"h-3 w-3 text-gray-400"}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(Ae,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?u.jsx(kT,{className:"h-4 w-4 mr-1"}):u.jsx(CB,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:r,children:i?u.jsx(Er,{className:"h-4 w-4"}):u.jsx(dr,{className:"h-4 w-4"})}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,children:u.jsx(um,{className:"h-4 w-4"})}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:o,children:u.jsx(_p,{className:"h-4 w-4"})}),c&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,children:u.jsx(ro,{className:"h-4 w-4"})})]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto",children:u.jsx("div",{className:"px-4 pt-4",children:u.jsx(cr,{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`})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(NT,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function Ty(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),o=Math.floor(a/60),i=Math.floor(o/24);return r<60?"just now":a<60?`${a}m ago`:o<24?`${o}h ago`:i<7?`${i}d ago`:new Date(e).toLocaleDateString()}function qwe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:a,serverId:o,isConnected:i}){const[c,d]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,E]=y.useState(!0),[x,w]=y.useState(!1),[S,_]=y.useState(!0),[T,R]=y.useState(!1),C=y.useRef(null),A=y.useRef(null),I=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const K=C.current;if(!K)return;const F=()=>{K.scrollTop>0&&(O.current=!0,E(!1))};return K.addEventListener("scroll",F),()=>K.removeEventListener("scroll",F)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const U=y.useCallback(()=>{f.trim()||w(!1)},[f]),L=y.useMemo(()=>{if(!f.trim())return e;const K=f.toLowerCase();return e.filter(F=>F.method.toLowerCase().includes(K)||JSON.stringify(F.params||{}).toLowerCase().includes(K))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const K=F=>{const re=F.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||F.metaKey||F.ctrlKey||F.altKey)return;const M=L;if(F.key==="ArrowDown")F.preventDefault(),g(B=>{const P=B+1;return P>=M.length?0:P});else if(F.key==="ArrowUp")F.preventDefault(),g(B=>{const P=B-1;return P<0?M.length-1:P});else if(F.key==="Enter"&&h>=0){F.preventDefault();const B=L[h];B&&$(B)}};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[h,L]),y.useEffect(()=>{if(h>=0){const K=`notification-${L[h]?.id}`,F=document.getElementById(K);F&&F.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const $=y.useCallback(K=>{d(K)},[]),H=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(a(),d(null))},[a]),Y=y.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)),R(!0),setTimeout(()=>R(!1),2e3)}catch(K){console.error("[NotificationsTab] Failed to copy notification:",K)}},[c]),q=y.useCallback(()=>{if(c)try{const K=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),F=URL.createObjectURL(K),re=document.createElement("a");re.href=F,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(F)}catch(K){console.error("[NotificationsTab] Failed to download notification:",K)}},[c]),ne=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(K){console.error("[NotificationsTab] Failed to toggle fullscreen:",K)}},[]),G=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:Ty}:null;return i?u.jsxs(ha,{direction:"horizontal",className:"h-full",children:[u.jsx(Pn,{defaultSize:40,minSize:30,children:u.jsx(ha,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(Pn,{defaultSize:75,minSize:30,children:[u.jsx(Kwe,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:L.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:U,onClearAll:H,searchInputRef:I}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(Ywe,{notifications:L,selectedNotification:c,onNotificationSelect:$,focusedIndex:h,formatRelativeTime:Ty,listRef:C})})]})})}),u.jsx(_s,{}),u.jsx(Pn,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(Zwe,{notification:G,previewMode:S,onTogglePreview:()=>_(!S),onCopy:Y,onDownload:q,onFullscreen:ne,onClose:()=>d(null),isCopied:T})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(NT,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function aI({serverIds:e,onCountChange:t,onClearRef:n}={}){const[r,a]=y.useState([]),o=y.useRef(null),[i,c]=y.useState(new Set),[d]=y.useState(""),f=v=>{c(E=>{const x=new Set(E);return x.has(v)?x.delete(v):x.add(v),x})},m=async()=>{a([]),c(new Set),t?.(0),e&&e.length>0?e.forEach(v=>Bb(v)):Bb()},h=y.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);y.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),y.useEffect(()=>{t?.(r.length)},[r.length,t]),y.useEffect(()=>{console.log("[RPC Logger] Subscribing to RPC logs for servers:",e);const v=tT(),x=(e&&e.length>0?v.filter(S=>e.includes(S.serverId)):v).map(S=>{const _=S.message,T=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown";return{id:`${S.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:S.serverId,direction:S.direction.toUpperCase(),method:T,timestamp:S.timestamp,payload:S.message}}).reverse();a(x),t?.(x.length);const w=nT(S=>{if(e&&e.length>0&&!e.includes(S.serverId))return;const _=S.message,T=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown",R={id:`${S.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:S.serverId,direction:S.direction.toUpperCase(),method:T,timestamp:S.timestamp,payload:S.message};console.log("[RPC Logger] New RPC log:",{method:T,direction:S.direction,serverId:S.serverId}),a(C=>{const A=[R,...C].slice(0,1e3);return t?.(A.length),A})});return()=>{w(),console.log("[RPC Logger] Unsubscribed from RPC logs")}},[h,t]);const g=y.useMemo(()=>{let v=r;if(e&&e.length>0){const E=new Set(e);v=v.filter(x=>E.has(x.serverId))}if(d.trim()){const E=d.toLowerCase();v=v.filter(x=>x.serverId.toLowerCase().includes(E)||x.method.toLowerCase().includes(E)||x.direction.toLowerCase().includes(E)||JSON.stringify(x.payload).toLowerCase().includes(E))}return v=[...v].sort((E,x)=>new Date(x.timestamp).getTime()-new Date(E.timestamp).getTime()),v},[r,d,e]);return u.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:u.jsx("div",{ref:o,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?u.jsxs("div",{className:"text-center py-8",children:[u.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),u.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const E=i.has(v.id);return u.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[u.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f(v.id),children:[u.jsx("div",{className:"flex-shrink-0",children:E?u.jsx(Qs,{className:"h-3 w-3 text-muted-foreground transition-transform"}):u.jsx(RB,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),u.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[u.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),u.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${v.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:v.direction==="RECEIVE"?"Incoming":"Outgoing",children:v.direction==="RECEIVE"?u.jsx(Noe,{className:"h-3 w-3"}):u.jsx(Coe,{className:"h-3 w-3"})}),u.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),E&&u.jsx("div",{className:"border-t bg-muted/20",children:u.jsx("div",{className:"p-3",children:u.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:u.jsx(cr,{data:v.payload})})})})]},v.id)})})})}function s9({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:a,primaryCount:o,secondaryCount:i,secondaryIcon:c,primaryIcon:d,searchPlaceholder:f="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:E,primaryTabName:x}){const w=e===x;return u.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[u.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?u.jsx(In,{ref:E,placeholder:f,value:n,onChange:S=>h(S.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):u.jsxs(u.Fragment,{children:[u.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:w?r:a}),w&&u.jsxs(u.Fragment,{children:[u.jsx(kr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:o}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(Ot,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})]})}),u.jsxs(Ae,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[w?u.jsx(c,{}):u.jsx(d,{}),u.jsx("span",{className:"hidden sm:inline",children:w?a:r}),w&&i>0&&u.jsx(kr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:i})]})]})}function hz({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(Tp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):u.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((a,o)=>u.jsx(Qi,{id:`prompt-${a.name}`,isSelected:t?.name===a.name,isFocused:r===o,icon:u.jsx(Tp,{className:"h-4 w-4"}),title:a.name,description:a.description,metadata:a.arguments&&a.arguments.length>0&&u.jsxs(kr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[a.arguments.length," args"]}),onClick:()=>n(a)},a.name))})}function gz({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:a,onSearchExpand:o,onSearchChange:i,onSearchBlur:c,onTabSwitch:d,searchInputRef:f}){return u.jsx(s9,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:r,secondaryCount:a,primaryIcon:Tp,secondaryIcon:Ep,searchPlaceholder:"Search prompts...",onSearchExpand:o,onSearchChange:i,onSearchBlur:c,onTabSwitch:d,searchInputRef:f})}function bz({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:a}){return e.length===0?u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(Ep,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),u.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):u.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((o,i)=>u.jsx(Qi,{id:`saved-prompt-${o.id}`,isSelected:t?.id===o.id,isFocused:a===i,icon:u.jsx(Ep,{className:"h-4 w-4"}),title:o.name,description:`${o.promptName} - ${new Date(o.savedAt).toLocaleString()}`,onClick:()=>n(o)},o.id))})}function Xwe({selectedPrompt:e,promptArgs:t,onArgChange:n}){const r=e?.arguments||[];if(!(r.length>0))return u.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const o=i=>{const c=i.name,d=t[c],f=typeof d=="string"?d:JSON.stringify(d);return i.type==="boolean"?u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx("input",{id:c,type:"checkbox",checked:!!d,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),u.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:i.description})]})]},c):i.type==="number"?u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(In,{id:c,type:"number",value:Number(d)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:i.description||`Enter ${c}`}),i.description&&u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},c):i.type==="array"||i.type==="object"?u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(Vl,{id:c,value:f,onChange:m=>{try{const h=JSON.parse(m.target.value);n(c,h)}catch{n(c,m.target.value)}},placeholder:i.description||`Enter ${c} as JSON`,className:"font-mono text-sm min-h-[100px]"}),i.description&&u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},c):u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(In,{id:c,value:f,onChange:m=>n(c,m.target.value),placeholder:i.description||`Enter ${c}`}),i.description&&u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},c)};return u.jsx("div",{className:"space-y-4",children:r.map(i=>o(i))})}function yz({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:a,onExecute:o,onSave:i}){return y.useEffect(()=>{const c=d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&e&&!n&&r&&(d.preventDefault(),o())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,r,o]),e?u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:u.jsxs("div",{children:[u.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[u.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),u.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[u.jsx(Ae,{onClick:o,disabled:n||!r,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?u.jsxs(u.Fragment,{children:[u.jsx(eo,{className:"mr-2"}),u.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):u.jsxs(u.Fragment,{children:[u.jsx(LB,{className:"h-4 w-4 sm:mr-2"}),u.jsx("span",{className:"hidden sm:inline",children:"Execute"}),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:"⌘↵"})]})}),u.jsxs(Ae,{variant:"outline",onClick:i,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[u.jsx(AT,{className:"h-4 w-4"}),u.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),u.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:u.jsx(Xwe,{selectedPrompt:e,promptArgs:t,onArgChange:a})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),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 Jwe(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function Qwe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function exe(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 txe({message:e,index:t}){const[n,r]=y.useState(!1),a=async()=>{const i=exe(e.content);await navigator.clipboard.writeText(i),r(!0),setTimeout(()=>r(!1),2e3)},o=()=>{const i=e.content;return typeof i=="string"?u.jsx(Eb,{content:i}):i.type==="text"&&i.text?u.jsx(Eb,{content:i.text}):i.type==="image"?u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsxs("span",{className:"font-mono bg-muted px-2 py-1 rounded",children:["Image: ",i.mimeType||"unknown type"]}),i.data&&u.jsx("img",{src:`data:${i.mimeType};base64,${i.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):i.type==="resource"&&i.resource?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[u.jsx("span",{className:"text-muted-foreground font-medium",children:"Resource:"}),u.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs font-mono",children:i.resource.uri})]}),i.resource.text&&u.jsx("div",{className:"mt-2",children:u.jsx(Eb,{content:i.resource.text})})]}):u.jsx("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:u.jsx("code",{children:JSON.stringify(i,null,2)})})};return u.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[u.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border",children:[u.jsx(kr,{variant:Jwe(e.role),children:Qwe(e.role)}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,className:"h-6 px-2",title:"Copy message content",children:n?u.jsx(Er,{className:"h-3.5 w-3.5"}):u.jsx(dr,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"px-4 py-3",children:o()})]})}function nxe(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),o=Math.floor(a/60),i=Math.floor(o/24);return r<10?"now":r<60?`${r}s ago`:a<60?`${a}m ago`:o<24?`${o}h ago`:`${i}d ago`}function rxe(e){return"isError"in e&&!e.isError?null:"error"in e&&e.error?e.error:"isError"in e&&e.isError?"An error occurred":null}function vz({results:e,copiedResult:t,previewMode:n=!0,onCopy:r,onDelete:a,onFullscreen:o,onTogglePreview:i,onMaximize:c,isMaximized:d=!1}){const[f,m]=y.useState(0),[h,g]=y.useState(""),[v,E]=y.useState(!0),x=e[0],w=x?e.filter(C=>C.promptName===x.promptName):[],S=w[f]||w[0],_=e.findIndex(C=>C===S);if(y.useEffect(()=>{w.length>0&&f>=w.length&&m(0)},[w.length,f]),y.useEffect(()=>{const C=()=>{S&&g(nxe(S.timestamp))};C();const A=setInterval(C,1e3);return()=>clearInterval(A)},[S]),e.length===0)return u.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:u.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsx("div",{className:"text-center",children:u.jsx(Ed,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const T=S.error||rxe(S.result),R="messages"in S.result&&Array.isArray(S.result.messages);return u.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:u.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:u.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[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:[u.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),S.duration!==void 0&&u.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[u.jsx(kp,{className:"h-3 w-3 text-gray-400"}),u.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[S.duration,"ms"]})]}),R&&u.jsx("div",{className:"flex items-center gap-4 sm:ml-4",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{onClick:()=>E(!0),className:`text-xs font-medium ${v?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),u.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),u.jsx("button",{onClick:()=>E(!1),className:`text-xs font-medium ${v?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]})}),u.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[w.length>1&&u.jsxs("div",{className:"flex items-center gap-2 mr-2",children:[u.jsx(Sp,{className:"h-3 w-3 text-gray-400"}),u.jsxs(Oo,{value:f.toString(),onValueChange:C=>m(parseInt(C)),children:[u.jsx(Lo,{className:"h-7 w-[120px] text-xs",children:u.jsx(Do,{})}),u.jsx(Mo,{children:w.map((C,A)=>u.jsx(ra,{value:A.toString(),children:A===0?"Latest":`${A+1} call ago`},A))})]})]}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-2",children:h}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>r(_,S.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?u.jsx(Er,{className:"h-4 w-4"}):u.jsx(dr,{className:"h-4 w-4"})}),a&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>a(_),className:"h-7 w-7 p-0",title:"Delete result",children:u.jsx(Uo,{className:"h-4 w-4"})}),o&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>o(_),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:u.jsx(_p,{className:"h-4 w-4"})}),c&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,className:"h-7 w-7 p-0 hidden sm:flex",title:d?"Restore":"Maximize",children:d?u.jsx(DB,{className:"h-4 w-4"}):u.jsx(_p,{className:"h-4 w-4"})})]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T?u.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[u.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),u.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:T})]}):v&&R?u.jsx("div",{className:"space-y-3",children:S.result.messages.map((C,A)=>u.jsx(txe,{message:C,index:A},A))}):u.jsx(cr,{data:S.result,filename:`prompt-result-${S.promptName}-${Date.now()}.json`})})]})})})}const wz="mcp-inspector-saved-prompts";function o9({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:a}){const[o,i]=y.useState(null),[c,d]=y.useState(null),{selectedPromptName:f,setSelectedPromptName:m}=Ql(),[h,g]=y.useState({}),[v,E]=y.useState([]),[x,w]=y.useState(!1),[S,_]=y.useState(null),[T,R]=y.useState(""),[C,A]=y.useState("prompts"),[I,O]=y.useState([]),[U,L]=y.useState(!1),[$,H]=y.useState(""),[Y,q]=y.useState(!1),[ne,G]=y.useState(-1),K=y.useRef(null),[F,re]=y.useState(!1),[ee,M]=y.useState("list"),[B,P]=y.useState(0),[D,j]=y.useState(!0),[V,W]=y.useState(!1),te=y.useRef(null),de=y.useRef(null),fe=y.useRef(null),J=y.useRef(null);y.useEffect(()=>{const Ee=()=>{re(window.innerWidth<1024)};return Ee(),window.addEventListener("resize",Ee),()=>window.removeEventListener("resize",Ee)},[]),y.useEffect(()=>{M(o?"detail":"list")},[o]),y.useEffect(()=>{F&&v.length>0&&!x&&M("response")},[v,x,F]),y.useImperativeHandle(e,()=>({focusSearch:()=>{q(!0),setTimeout(()=>{K.current&&K.current.focus()},0)},blurSearch:()=>{R(""),q(!1),K.current&&K.current.blur()}})),y.useEffect(()=>{try{const Ee=localStorage.getItem(wz);if(Ee){const oe=JSON.parse(Ee);O(oe)}}catch(Ee){console.error("[PromptsTab] Failed to load saved prompts:",Ee)}},[]);const Q=y.useCallback(Ee=>{try{localStorage.setItem(wz,JSON.stringify(Ee))}catch(oe){console.error("[PromptsTab] Failed to save prompts:",oe)}},[]);y.useEffect(()=>{Y&&K.current&&K.current.focus()},[Y]);const se=y.useCallback(()=>{T.trim()||q(!1)},[T]),pe=y.useMemo(()=>{if(!T.trim())return t;const Ee=T.toLowerCase();return t.filter(oe=>oe.name.toLowerCase().includes(Ee)||oe.description?.toLowerCase().includes(Ee))},[t,T]),he=y.useCallback(Ee=>{i(Ee);const oe={};Ee.arguments&&Ee.arguments.forEach(Se=>{oe[Se.name]=""}),g(oe)},[]),Ne=y.useCallback(Ee=>{const oe=t.find(Se=>Se.name===Ee.promptName);oe&&(i(oe),g(Ee.args),d(Ee))},[t]);y.useEffect(()=>{G(-1)},[T,C]),y.useEffect(()=>{const Ee=oe=>{const Se=oe.target;if(Se.tagName==="INPUT"||Se.tagName==="TEXTAREA"||Se.contentEditable==="true"||oe.metaKey||oe.ctrlKey||oe.altKey)return;const Ve=C==="prompts"?pe:I;if(oe.key==="ArrowDown")oe.preventDefault(),G(ct=>{const vt=ct+1;return vt>=Ve.length?0:vt});else if(oe.key==="ArrowUp")oe.preventDefault(),G(ct=>{const vt=ct-1;return vt<0?Ve.length-1:vt});else if(oe.key==="Enter"&&ne>=0)if(oe.preventDefault(),C==="prompts"){const ct=pe[ne];ct&&he(ct)}else{const ct=I[ne];ct&&Ne(ct)}};return document.addEventListener("keydown",Ee),()=>document.removeEventListener("keydown",Ee)},[ne,pe,I,C,he,Ne]),y.useEffect(()=>{if(ne>=0){const Ee=C==="prompts"?`prompt-${pe[ne]?.name}`:`saved-prompt-${I[ne]?.id}`,oe=document.getElementById(Ee);oe&&oe.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,pe,I,C]),y.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:f,promptsCount:t.length,currentSelectedPrompt:o?.name}),f&&t.length>0){const Ee=t.find(oe=>oe.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!Ee,promptName:Ee?.name,shouldSelect:Ee&&o?.name!==Ee.name}),Ee&&o?.name!==Ee.name){console.warn("[PromptsTab] Selecting prompt:",Ee.name),m(null);const oe=setTimeout(()=>{he(Ee);const Se=document.getElementById(`prompt-${Ee.name}`);Se&&(console.warn("[PromptsTab] Scrolling to prompt element"),Se.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(oe)}}},[f,t,o,he,m]);const He=y.useCallback((Ee,oe)=>{g(Se=>({...Se,[Ee]:oe}))},[]),$e=y.useCallback(async()=>{if(!o||x)return;w(!0);const Ee=Date.now();try{const oe=await n(o.name,h),Se=Date.now()-Ee;Zr.getInstance().capture(new RP({promptName:o.name,serverId:r,success:!0})).catch(()=>{}),E(Ve=>[{promptName:o.name,args:h,result:oe,timestamp:Ee,duration:Se},...Ve])}catch(oe){Zr.getInstance().capture(new RP({promptName:o.name,serverId:r,success:!1,error:oe instanceof Error?oe.message:"Unknown error"})).catch(()=>{});const Re={promptName:o.name,args:h,result:null,error:oe instanceof Error?oe.message:String(oe),timestamp:Ee,duration:Date.now()-Ee};E(Ve=>[...Ve,{...Re,result:{messages:[]}}])}finally{w(!1)}},[o,h,x,n,r]),Pe=y.useCallback(async(Ee,oe)=>{try{await navigator.clipboard.writeText(JSON.stringify(oe,null,2)),_(Ee),setTimeout(()=>_(null),2e3)}catch(Se){console.error("[PromptsTab] Failed to copy result:",Se)}},[]),ot=y.useCallback(Ee=>{E(oe=>oe.filter((Se,Re)=>Re!==Ee))},[]),Me=y.useCallback(Ee=>{if(F)M("response");else{const oe=v[Ee];if(oe){const Se=window.open("","_blank","width=800,height=600");if(Se){const Re=oe.result;Se.document.write(`
|
|
1723
|
+
`);T=A.pop()||"";for(const I of A)if(I.trim()&&I.startsWith("data: "))try{const O=JSON.parse(I.slice(6));if(console.log("[Client received event]",O.type,O.toolName||O.content?.slice?.(0,30)),O.type==="message")console.log("[Message started]",O.id);else if(O.type==="text"){x+=O.content;const U=w[w.length-1];U&&U.type==="text"?U.text=x:w.push({type:"text",text:x}),console.log("[Parts after text]",w.length,"parts, text length:",x.length),o(L=>L.map($=>$.id===E?{...$,parts:[...w]}:$))}else if(O.type==="tool-call")x&&(x=""),w.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",w.length,"parts, tool:",O.toolName),o(U=>U.map(L=>L.id===E?{...L,parts:[...w]}:L));else if(O.type==="tool-result"){const U=w.find(L=>L.type==="tool-invocation"&&L.toolInvocation?.toolName===O.toolName&&!L.toolInvocation?.result);U&&U.toolInvocation?(U.toolInvocation.result=O.result,U.toolInvocation.state="result",console.log("[Parts after tool-result]",w.length,"parts, updated:",O.toolName),o(L=>L.map($=>$.id===E?{...$,parts:[...w]}:$))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",w.length),o(U=>U.map(L=>L.id===E?{...L,parts:[...w],content:""}:L));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,I)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const x=g;x.status&&(v=`HTTP ${x.status}: ${v}`),(x.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const E={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};o(x=>[...x,E])}finally{c(!1)}},[t,r,e,a,n]),f=y.useCallback(()=>{o([])},[]);return{messages:a,isLoading:i,sendMessage:d,clearMessages:f}}function bwe({connection:e,llmConfig:t,isConnected:n,readResource:r}){const[a,o]=y.useState([]),[i,c]=y.useState(!1),d=y.useRef(null),f=y.useRef(null),m=y.useRef(null),h=y.useCallback(async v=>{if(!v.trim()||!t||!n)return;const E={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};o(S=>[...S,E]),c(!0),d.current=new AbortController;const x=Date.now();let w=0;try{const S=`assistant-${Date.now()}`;let _="";const T=[];if(o(R=>[...R,{id:S,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 R;if(t.provider==="openai"){const{ChatOpenAI:C}=await pa(async()=>{const{ChatOpenAI:A}=await import("./index-BDlTOMS5.js");return{ChatOpenAI:A}},__vite__mapDeps([0,1,2,3,4,5]));R=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:C}=await pa(async()=>{const{ChatAnthropic:A}=await import("./index-DdkxcTE2.js");return{ChatAnthropic:A}},__vite__mapDeps([6,2,1,5]));R=new C({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:C}=await pa(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-D7_719w8.js");return{ChatGoogleGenerativeAI:A}},__vite__mapDeps([7,2,1,4]));R=new C({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:R,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!f.current||f.current.llm!==m.current.instance){const{MCPAgent:R}=await pa(async()=>{const{MCPAgent:C}=await import("./browser-BLnflEDD.js");return{MCPAgent:C}},__vite__mapDeps([8,5,1,2,4,3]));f.current=new R({llm:m.current.instance,client:e.client,memoryEnabled:!0,systemPrompt:"You are a helpful assistant with access to MCP tools, prompts, and resources. Help users interact with the MCP server."}),await f.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",f.current.conversationHistory?.length);for await(const R of f.current.streamEvents(v,10,!1,void 0)){if(d.current?.signal.aborted)break;if(R.event==="on_chat_model_stream"&&R.data?.chunk?.text){const C=R.data.chunk.text;if(typeof C=="string"&&C.length>0){_+=C;const A=T[T.length-1];A&&A.type==="text"?A.text=_:T.push({type:"text",text:_}),o(I=>I.map(O=>O.id===S?{...O,parts:[...T]}:O))}}else if(R.event==="on_tool_start"){_&&(_="");let C={};R.data?.input?C=R.data.input:R.data?.tool_input?C=R.data.tool_input:R.data&&(C=R.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:R.name,eventData:R.data,extractedArgs:C}),w++,T.push({type:"tool-invocation",toolInvocation:{toolName:R.name||"unknown",args:C,state:"pending"}}),o(A=>A.map(I=>I.id===S?{...I,parts:[...T]}:I))}else if(R.event==="on_tool_end"){const C=T.find(A=>A.type==="tool-invocation"&&A.toolInvocation?.toolName===R.name&&!A.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:R.name,hasToolPart:!!C,output:R.data?.output}),C&&C.toolInvocation){let A=R.data?.output;if(A?.kwargs?.content&&typeof A.kwargs.content=="string")try{A=JSON.parse(A.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),A=A.kwargs.content}else if(A?.content&&typeof A.content=="string")try{A=JSON.parse(A.content)}catch{A=A.content}C.toolInvocation.result=A,C.toolInvocation.state="result";const I=A?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:R.name,hasMeta:!!A?._meta,hasStructuredContent:!!A?.structuredContent,appsSdkUri:I}),I&&typeof I=="string"&&r){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",I);try{const O=await r(I);console.log("[useChatMessagesClientSide] Resource fetched:",O);const U=A?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const L=O.contents.map(H=>({type:"resource",resource:H}));console.log("[useChatMessagesClientSide] Created MCP resources:",L);const $={...A,content:[...A.content||[],...L],structuredContent:U};C.toolInvocation.result=$,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}o(O=>O.map(U=>U.id===S?{...U,parts:[...T]}:U))}}}o(R=>R.map(C=>C.id===S?{...C,parts:[...T],content:""}:C)),t&&Zr.getInstance().capture(new AP({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:w,success:!0,executionMode:"client-side",duration:Date.now()-x})).catch(()=>{})}catch(S){console.error("Client-side agent error:",S);let _="Unknown error occurred";if(S instanceof Error){_=S.message;const R=S;R.status&&(_=`HTTP ${R.status}: ${_}`),(R.code===401||_.includes("401")||_.includes("Unauthorized"))&&(_="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&Zr.getInstance().capture(new AP({serverId:e.url,provider:t.provider,model:t.model,messageCount:a.length+1,toolCallsCount:w,success:!1,executionMode:"client-side",duration:Date.now()-x,error:_})).catch(()=>{});const T={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${_}`,timestamp:Date.now()};o(R=>[...R,T])}finally{c(!1),d.current=null}},[e,t,n,a,r]),g=y.useCallback(()=>{o([]),f.current&&f.current.clearConversationHistory()},[]);return{messages:a,isLoading:i,sendMessage:h,clearMessages:g}}const oz={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function P8({mcpServerUrl:e}){const[t,n]=y.useState(null),[r,a]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState("openai"),[f,m]=y.useState(""),[h,g]=y.useState(oz.openai),v=y.useCallback(()=>{const U=localStorage.getItem("mcp-inspector-api-keys");if(U)try{return JSON.parse(U)}catch(L){return console.error("Failed to load API keys:",L),{}}return{}},[]),E=y.useCallback(U=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(U))},[]),[x,w]=y.useState("none"),[S,_]=y.useState(""),[T,R]=y.useState(""),[C,A]=y.useState("");y.useEffect(()=>{const U=localStorage.getItem("mcp-inspector-llm-config"),L=v();if(U)try{const $=JSON.parse(U);n($),d($.provider),m(L[$.provider]||$.apiKey||""),g($.model)}catch($){console.error("Failed to load LLM config:",$)}},[v]),y.useEffect(()=>{const U=localStorage.getItem("mcp-inspector-auth-config");if(U)try{const L=JSON.parse(U);a(L),w(L.type),L.username&&_(L.username),L.password&&R(L.password),L.token&&A(L.token)}catch(L){console.error("Failed to load auth config:",L)}else try{const L="mcp:auth",$=j8(e),H=`${L}_${$}_tokens`;localStorage.getItem(H)&&(a({type:"oauth"}),w("oauth"))}catch(L){console.error("Failed to check for OAuth tokens:",L)}},[e]),y.useEffect(()=>{g(oz[c]);const U=v();m(U[c]||"")},[c,v]);const I=y.useCallback(()=>{if(!f.trim())return;const U=v();U[c]=f,E(U);const L={provider:c,apiKey:f,model:h},$={type:x,...x==="basic"&&{username:S.trim(),password:T.trim()},...x==="bearer"&&{token:C.trim()}};n(L),a($),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(L)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify($)),i(!1)},[c,f,h,x,S,T,C,v,E]),O=y.useCallback(()=>{n(null),a(null);const U=v();delete U[c],E(U),m(""),_(""),R(""),A(""),w("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,E]);return{llmConfig:t,authConfig:r,configDialogOpen:o,setConfigDialogOpen:i,tempProvider:c,setTempProvider:d,tempApiKey:f,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:I,clearConfig:O}}function ywe({connection:e,isConnected:t,useClientSide:n=!0,readResource:r}){const[a,o]=y.useState(""),i=y.useRef(null),{llmConfig:c,authConfig:d,configDialogOpen:f,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:E,tempModel:x,setTempModel:w,saveLLMConfig:S,clearConfig:_}=P8({mcpServerUrl:e.url}),T={connection:e,llmConfig:c,isConnected:t,readResource:r},R=gwe({mcpServerUrl:e.url,llmConfig:c,authConfig:d,isConnected:t}),C=bwe(T),{messages:A,isLoading:I,sendMessage:O,clearMessages:U}=n?C:R;ZV({onNewChat:U}),y.useEffect(()=>{c&&A.length===0&&i.current&&i.current.focus()},[c,A.length]),y.useEffect(()=>{!I&&A.length>0&&i.current&&i.current.focus()},[I,A.length]);const L=y.useCallback(()=>{a.trim()&&(O(a),o(""))},[a,O]),$=y.useCallback(Y=>{Y.key==="Enter"&&!Y.shiftKey&&(Y.preventDefault(),L())},[L]),H=y.useCallback(()=>{_(),U()},[_,U]);return c&&A.length===0?u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsx("div",{className:"absolute top-4 right-4 z-10",children:u.jsx(WS,{open:f,onOpenChange:m,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSave:S,onClear:H,showClearButton:!0,buttonLabel:"Change API Key"})}),u.jsx(Wbe,{mcpServerUrl:e.url,inputValue:a,isConnected:t,isLoading:I,textareaRef:i,llmConfig:c,onInputChange:o,onKeyDown:$,onSubmit:Y=>{Y.preventDefault(),L()},onConfigDialogOpenChange:m})]}):u.jsxs("div",{className:"flex flex-col h-full relative",children:[u.jsx(Hbe,{llmConfig:c,hasMessages:A.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:U,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:E,onSaveConfig:S,onClearConfig:H}),u.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?u.jsx(hwe,{messages:A,isLoading:I,serverId:e.url,readResource:r,tools:e.tools}):u.jsx(Kbe,{onConfigureClick:()=>m(!0)})}),c&&u.jsx(Vbe,{inputValue:a,isConnected:t,isLoading:I,textareaRef:i,onInputChange:o,onKeyDown:$,onSendMessage:L})]})}const jv=y.createContext(null);jv.displayName="PanelGroupContext";const lr={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},tI=10,Ml=y.useLayoutEffect,iz=pd.useId,vwe=typeof iz=="function"?iz:()=>null;let wwe=0;function nI(e=null){const t=vwe(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+wwe++),e??n.current}function $8({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:a,forwardedRef:o,id:i,maxSize:c,minSize:d,onCollapse:f,onExpand:m,onResize:h,order:g,style:v,tagName:E="div",...x}){const w=y.useContext(jv);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:S,expandPanel:_,getPanelSize:T,getPanelStyle:R,groupId:C,isPanelCollapsed:A,reevaluatePanelConstraints:I,registerPanel:O,resizePanel:U,unregisterPanel:L}=w,$=nI(i),H=y.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:a,maxSize:c,minSize:d},id:$,idIsFromProps:i!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),Ml(()=>{const{callbacks:q,constraints:ne}=H.current,G={...ne};H.current.id=$,H.current.idIsFromProps=i!==void 0,H.current.order=g,q.onCollapse=f,q.onExpand=m,q.onResize=h,ne.collapsedSize=n,ne.collapsible=r,ne.defaultSize=a,ne.maxSize=c,ne.minSize=d,(G.collapsedSize!==ne.collapsedSize||G.collapsible!==ne.collapsible||G.maxSize!==ne.maxSize||G.minSize!==ne.minSize)&&I(H.current,G)}),Ml(()=>{const q=H.current;return O(q),()=>{L(q)}},[g,$,O,L]),y.useImperativeHandle(o,()=>({collapse:()=>{S(H.current)},expand:q=>{_(H.current,q)},getId(){return $},getSize(){return T(H.current)},isCollapsed(){return A(H.current)},isExpanded(){return!A(H.current)},resize:q=>{U(H.current,q)}}),[S,_,T,A,$,U]);const Y=R(H.current,a);return y.createElement(E,{...x,children:e,className:t,id:$,style:{...Y,...v},[lr.groupId]:C,[lr.panel]:"",[lr.panelCollapsible]:r||void 0,[lr.panelId]:$,[lr.panelSize]:parseFloat(""+Y.flexGrow).toFixed(1)})}const U8=y.forwardRef((e,t)=>y.createElement($8,{...e,forwardedRef:t}));$8.displayName="Panel";U8.displayName="forwardRef(Panel)";let p_=null,Tb=-1,Ri=null;function xwe(e,t,n){const r=(t&V8)!==0,a=(t&G8)!==0,o=(t&W8)!==0,i=(t&K8)!==0;if(t){if(r)return o?"se-resize":i?"ne-resize":"e-resize";if(a)return o?"sw-resize":i?"nw-resize":"w-resize";if(o)return"s-resize";if(i)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Ewe(){Ri!==null&&(document.head.removeChild(Ri),p_=null,Ri=null,Tb=-1)}function dE(e,t,n){var r,a;const o=xwe(e,t);if(p_!==o){if(p_=o,Ri===null&&(Ri=document.createElement("style"),document.head.appendChild(Ri)),Tb>=0){var i;(i=Ri.sheet)===null||i===void 0||i.removeRule(Tb)}Tb=(r=(a=Ri.sheet)===null||a===void 0?void 0:a.insertRule(`*{cursor: ${o} !important;}`))!==null&&r!==void 0?r:-1}}function z8(e){return e.type==="keydown"}function F8(e){return e.type.startsWith("pointer")}function B8(e){return e.type.startsWith("mouse")}function Pv(e){if(F8(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(B8(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Swe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function _we(e,t,n){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 Twe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:uz(e),b:uz(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;Ft(r,"Stacking order can only be calculated for elements with a common ancestor");const a={a:cz(lz(n.a)),b:cz(lz(n.b))};if(a.a===a.b){const o=r.childNodes,i={a:n.a.at(-1),b:n.b.at(-1)};let c=o.length;for(;c--;){const d=o[c];if(d===i.a)return 1;if(d===i.b)return-1}}return Math.sign(a.a-a.b)}const Nwe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function kwe(e){var t;const n=getComputedStyle((t=H8(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Cwe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||kwe(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"||Nwe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function lz(e){let t=e.length;for(;t--;){const n=e[t];if(Ft(n,"Missing node"),Cwe(n))return n}return null}function cz(e){return e&&Number(getComputedStyle(e).zIndex)||0}function uz(e){const t=[];for(;e;)t.push(e),e=H8(e);return t}function H8(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const V8=1,G8=2,W8=4,K8=8,Rwe=Swe()==="coarse";let Ss=[],Eu=!1,Ai=new Map,$v=new Map;const Wp=new Set;function Awe(e,t,n,r,a){var o;const{ownerDocument:i}=t,c={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:a},d=(o=Ai.get(i))!==null&&o!==void 0?o:0;return Ai.set(i,d+1),Wp.add(c),Sy(),function(){var m;$v.delete(e),Wp.delete(c);const h=(m=Ai.get(i))!==null&&m!==void 0?m:1;if(Ai.set(i,h-1),Sy(),h===1&&Ai.delete(i),Ss.includes(c)){const g=Ss.indexOf(c);g>=0&&Ss.splice(g,1),Uv(),a("up",!0,null)}}}function Iwe(e){const{target:t}=e,{x:n,y:r}=Pv(e);Eu=!0,rI({target:t,x:n,y:r}),Sy(),Ss.length>0&&(_y("down",e),Uv(),e.preventDefault(),Y8(t)||e.stopImmediatePropagation())}function fE(e){const{x:t,y:n}=Pv(e);if(Eu&&e.type!=="pointerleave"&&e.buttons===0&&(Eu=!1,_y("up",e)),!Eu){const{target:r}=e;rI({target:r,x:t,y:n})}_y("move",e),Uv(),Ss.length>0&&e.preventDefault()}function pE(e){const{target:t}=e,{x:n,y:r}=Pv(e);$v.clear(),Eu=!1,Ss.length>0&&(e.preventDefault(),Y8(t)||e.stopImmediatePropagation()),_y("up",e),rI({target:t,x:n,y:r}),Uv(),Sy()}function Y8(e){let t=e;for(;t;){if(t.hasAttribute(lr.resizeHandle))return!0;t=t.parentElement}return!1}function rI({target:e,x:t,y:n}){Ss.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),Wp.forEach(a=>{const{element:o,hitAreaMargins:i}=a,c=o.getBoundingClientRect(),{bottom:d,left:f,right:m,top:h}=c,g=Rwe?i.coarse:i.fine;if(t>=f-g&&t<=m+g&&n>=h-g&&n<=d+g){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&Twe(r,o)>0){let E=r,x=!1;for(;E&&!E.contains(o);){if(_we(E.getBoundingClientRect(),c)){x=!0;break}E=E.parentElement}if(x)return}Ss.push(a)}})}function mE(e,t){$v.set(e,t)}function Uv(){let e=!1,t=!1;Ss.forEach(r=>{const{direction:a}=r;a==="horizontal"?e=!0:t=!0});let n=0;$v.forEach(r=>{n|=r}),e&&t?dE("intersection",n):e?dE("horizontal",n):t?dE("vertical",n):Ewe()}let hE;function Sy(){var e;(e=hE)===null||e===void 0||e.abort(),hE=new AbortController;const t={capture:!0,signal:hE.signal};Wp.size&&(Eu?(Ss.length>0&&Ai.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("contextmenu",pE,t),a.addEventListener("pointerleave",fE,t),a.addEventListener("pointermove",fE,t))}),Ai.forEach((n,r)=>{const{body:a}=r;a.addEventListener("pointerup",pE,t),a.addEventListener("pointercancel",pE,t)})):Ai.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("pointerdown",Iwe,t),a.addEventListener("pointermove",fE,t))}))}function _y(e,t){Wp.forEach(n=>{const{setResizeHandlerState:r}=n,a=Ss.includes(n);r(e,a,t)})}function Owe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function Ft(e,t){if(!e)throw console.error(t),Error(t)}function Wl(e,t,n=tI){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Ro(e,t,n=tI){return Wl(e,t,n)===0}function Fa(e,t,n){return Wl(e,t,n)===0}function Dwe(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const a=e[r],o=t[r];if(!Fa(a,o,n))return!1}return!0}function pu({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];Ft(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:a=0,collapsible:o,maxSize:i=100,minSize:c=0}=r;if(Wl(n,c)<0)if(o){const d=(a+c)/2;Wl(n,d)<0?n=a:n=c}else n=c;return n=Math.min(i,n),n=parseFloat(n.toFixed(tI)),n}function Yf({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:a,trigger:o}){if(Fa(e,0))return t;const i=[...t],[c,d]=r;Ft(c!=null,"Invalid first pivot index"),Ft(d!=null,"Invalid second pivot index");let f=0;if(o==="keyboard"){{const h=e<0?d:c,g=n[h];Ft(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if(Ft(w!=null,`Previous layout not found for panel index ${h}`),Fa(w,v)){const S=x-w;Wl(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const h=e<0?c:d,g=n[h];Ft(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:E,minSize:x=0}=g;if(E){const w=t[h];if(Ft(w!=null,`Previous layout not found for panel index ${h}`),Fa(w,x)){const S=w-v;Wl(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}}{const h=e<0?1:-1;let g=e<0?d:c,v=0;for(;;){const x=t[g];Ft(x!=null,`Previous layout not found for panel index ${g}`);const S=pu({panelConstraints:n,panelIndex:g,size:100})-x;if(v+=S,g+=h,g<0||g>=n.length)break}const E=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-E:E}{let g=e<0?c:d;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(f),E=t[g];Ft(E!=null,`Previous layout not found for panel index ${g}`);const x=E-v,w=pu({panelConstraints:n,panelIndex:g,size:x});if(!Fa(E,w)&&(f+=E-w,i[g]=w,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(Dwe(a,i))return a;{const h=e<0?d:c,g=t[h];Ft(g!=null,`Previous layout not found for panel index ${h}`);const v=g+f,E=pu({panelConstraints:n,panelIndex:h,size:v});if(i[h]=E,!Fa(E,v)){let x=v-E,S=e<0?d:c;for(;S>=0&&S<n.length;){const _=i[S];Ft(_!=null,`Previous layout not found for panel index ${S}`);const T=_+x,R=pu({panelConstraints:n,panelIndex:S,size:T});if(Fa(_,R)||(x-=R-_,i[S]=R),Fa(x,0))break;e>0?S--:S++}}}const m=i.reduce((h,g)=>g+h,0);return Fa(m,100)?i:a}function Lwe({layout:e,panelsArray:t,pivotIndices:n}){let r=0,a=100,o=0,i=0;const c=n[0];Ft(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:E=100,minSize:x=0}=v;g===c?(r=x,a=E):(o+=x,i+=E)});const d=Math.min(a,100-o),f=Math.max(r,100-i),m=e[c];return{valueMax:d,valueMin:f,valueNow:m}}function Kp(e,t=document){return Array.from(t.querySelectorAll(`[${lr.resizeHandleId}][data-panel-group-id="${e}"]`))}function Z8(e,t,n=document){const a=Kp(e,n).findIndex(o=>o.getAttribute(lr.resizeHandleId)===t);return a??null}function q8(e,t,n){const r=Z8(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Mwe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function X8(e,t=document){if(Mwe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function zv(e,t=document){const n=t.querySelector(`[${lr.resizeHandleId}="${e}"]`);return n||null}function jwe(e,t,n,r=document){var a,o,i,c;const d=zv(t,r),f=Kp(e,r),m=d?f.indexOf(d):-1,h=(a=(o=n[m])===null||o===void 0?void 0:o.id)!==null&&a!==void 0?a:null,g=(i=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&i!==void 0?i:null;return[h,g]}function Pwe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:a,panelGroupElement:o,setLayout:i}){y.useRef({didWarnAboutMissingResizeHandle:!1}),Ml(()=>{if(!o)return;const c=Kp(n,o);for(let d=0;d<a.length-1;d++){const{valueMax:f,valueMin:m,valueNow:h}=Lwe({layout:r,panelsArray:a,pivotIndices:[d,d+1]}),g=c[d];if(g!=null){const v=a[d];Ft(v,`No panel data found for index "${d}"`),g.setAttribute("aria-controls",v.id),g.setAttribute("aria-valuemax",""+Math.round(f)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{c.forEach((d,f)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,r,a,o]),y.useEffect(()=>{if(!o)return;const c=t.current;Ft(c,"Eager values not found");const{panelDataArray:d}=c,f=X8(n,o);Ft(f!=null,`No group found for id "${n}"`);const m=Kp(n,o);Ft(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(lr.resizeHandleId);Ft(v,"Resize handle element has no handle id attribute");const[E,x]=jwe(n,v,d,o);if(E==null||x==null)return()=>{};const w=S=>{if(!S.defaultPrevented)switch(S.key){case"Enter":{S.preventDefault();const _=d.findIndex(T=>T.id===E);if(_>=0){const T=d[_];Ft(T,`No panel data found for index ${_}`);const R=r[_],{collapsedSize:C=0,collapsible:A,minSize:I=0}=T.constraints;if(R!=null&&A){const O=Yf({delta:Fa(R,C)?I-C:C-R,initialLayout:r,panelConstraints:d.map(U=>U.constraints),pivotIndices:q8(n,v,o),prevLayout:r,trigger:"keyboard"});r!==O&&i(O)}}break}}};return g.addEventListener("keydown",w),()=>{g.removeEventListener("keydown",w)}});return()=>{h.forEach(g=>g())}},[o,e,t,n,r,a,i])}function dz(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 J8(e,t){const n=e==="horizontal",{x:r,y:a}=Pv(t);return n?r:a}function $we(e,t,n,r,a){const o=n==="horizontal",i=zv(t,a);Ft(i,`No resize handle element found for id "${t}"`);const c=i.getAttribute(lr.groupId);Ft(c,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=r;const f=J8(n,e),m=X8(c,a);Ft(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=o?h.width:h.height;return(f-d)/g*100}function Uwe(e,t,n,r,a,o){if(z8(e)){const i=n==="horizontal";let c=0;e.shiftKey?c=100:a!=null?c=a:c=10;let d=0;switch(e.key){case"ArrowDown":d=i?0:c;break;case"ArrowLeft":d=i?-c:0;break;case"ArrowRight":d=i?c:0;break;case"ArrowUp":d=i?0:-c;break;case"End":d=100;break;case"Home":d=-100;break}return d}else return r==null?0:$we(e,t,n,r,o)}function zwe({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,a=100;for(let o=0;o<e.length;o++){const i=n[o];Ft(i,`Panel constraints not found for index ${o}`);const{defaultSize:c}=i;c!=null&&(r++,t[o]=c,a-=c)}for(let o=0;o<e.length;o++){const i=n[o];Ft(i,`Panel constraints not found for index ${o}`);const{defaultSize:c}=i;if(c!=null)continue;const d=e.length-r,f=a/d;r++,t[o]=f,a-=f}return t}function Hc(e,t,n){t.forEach((r,a)=>{const o=e[a];Ft(o,`Panel data not found for index ${a}`);const{callbacks:i,constraints:c,id:d}=o,{collapsedSize:f=0,collapsible:m}=c,h=n[d];if(h==null||r!==h){n[d]=r;const{onCollapse:g,onExpand:v,onResize:E}=i;E&&E(r,h),m&&(g||v)&&(v&&(h==null||Ro(h,f))&&!Ro(r,f)&&v(),g&&(h==null||!Ro(h,f))&&Ro(r,f)&&g())}})}function Jg(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 Fwe({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:a,precision:o=3}){const i=n[a];let c;return i==null?c=e!=null?e.toFixed(o):"1":r.length===1?c="1":c=i.toFixed(o),{flexBasis:0,flexGrow:c,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function Bwe(e,t=10){let n=null;return(...a)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...a)},t)}}function fz(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Q8(e){return`react-resizable-panels:${e}`}function e9(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:a,order:o}=t;return a?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function t9(e,t){try{const n=Q8(e),r=t.getItem(n);if(r){const a=JSON.parse(r);if(typeof a=="object"&&a!=null)return a}}catch{}return null}function Hwe(e,t,n){var r,a;const o=(r=t9(e,n))!==null&&r!==void 0?r:{},i=e9(t);return(a=o[i])!==null&&a!==void 0?a:null}function Vwe(e,t,n,r,a){var o;const i=Q8(e),c=e9(t),d=(o=t9(e,a))!==null&&o!==void 0?o:{};d[c]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{a.setItem(i,JSON.stringify(d))}catch(f){console.error(f)}}function pz({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,i)=>o+i,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!Fa(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const i=n[o];Ft(i!=null,`No layout data found for index ${o}`);const c=100/r*i;n[o]=c}let a=0;for(let o=0;o<t.length;o++){const i=n[o];Ft(i!=null,`No layout data found for index ${o}`);const c=pu({panelConstraints:t,panelIndex:o,size:i});i!=c&&(a+=i-c,n[o]=c)}if(!Fa(a,0))for(let o=0;o<t.length;o++){const i=n[o];Ft(i!=null,`No layout data found for index ${o}`);const c=i+a,d=pu({panelConstraints:t,panelIndex:o,size:c});if(i!==d&&(a-=d-i,n[o]=d,Fa(a,0)))break}return n}const Gwe=100,Zf={getItem:e=>(fz(Zf),Zf.getItem(e)),setItem:(e,t)=>{fz(Zf),Zf.setItem(e,t)}},mz={};function n9({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:a,id:o=null,onLayout:i=null,keyboardResizeBy:c=null,storage:d=Zf,style:f,tagName:m="div",...h}){const g=nI(o),v=y.useRef(null),[E,x]=y.useState(null),[w,S]=y.useState([]),_=Owe(),T=y.useRef({}),R=y.useRef(new Map),C=y.useRef(0),A=y.useRef({autoSaveId:e,direction:r,dragState:E,id:g,keyboardResizeBy:c,onLayout:i,storage:d}),I=y.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});y.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),y.useImperativeHandle(a,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:P}=I.current;return P},setLayout:P=>{const{onLayout:D}=A.current,{layout:j,panelDataArray:V}=I.current,W=pz({layout:P,panelConstraints:V.map(te=>te.constraints)});dz(j,W)||(S(W),I.current.layout=W,D&&D(W),Hc(V,W,T.current))}}),[]),Ml(()=>{A.current.autoSaveId=e,A.current.direction=r,A.current.dragState=E,A.current.id=g,A.current.onLayout=i,A.current.storage=d}),Pwe({committedValuesRef:A,eagerValuesRef:I,groupId:g,layout:w,panelDataArray:I.current.panelDataArray,setLayout:S,panelGroupElement:v.current}),y.useEffect(()=>{const{panelDataArray:P}=I.current;if(e){if(w.length===0||w.length!==P.length)return;let D=mz[e];D==null&&(D=Bwe(Vwe,Gwe),mz[e]=D);const j=[...P],V=new Map(R.current);D(e,j,V,w,d)}},[e,w,d]),y.useEffect(()=>{});const O=y.useCallback(P=>{const{onLayout:D}=A.current,{layout:j,panelDataArray:V}=I.current;if(P.constraints.collapsible){const W=V.map(J=>J.constraints),{collapsedSize:te=0,panelSize:de,pivotIndices:fe}=Sl(V,P,j);if(Ft(de!=null,`Panel size not found for panel "${P.id}"`),!Ro(de,te)){R.current.set(P.id,de);const Q=Jc(V,P)===V.length-1?de-te:te-de,se=Yf({delta:Q,initialLayout:j,panelConstraints:W,pivotIndices:fe,prevLayout:j,trigger:"imperative-api"});Jg(j,se)||(S(se),I.current.layout=se,D&&D(se),Hc(V,se,T.current))}}},[]),U=y.useCallback((P,D)=>{const{onLayout:j}=A.current,{layout:V,panelDataArray:W}=I.current;if(P.constraints.collapsible){const te=W.map(pe=>pe.constraints),{collapsedSize:de=0,panelSize:fe=0,minSize:J=0,pivotIndices:Q}=Sl(W,P,V),se=D??J;if(Ro(fe,de)){const pe=R.current.get(P.id),he=pe!=null&&pe>=se?pe:se,He=Jc(W,P)===W.length-1?fe-he:he-fe,$e=Yf({delta:He,initialLayout:V,panelConstraints:te,pivotIndices:Q,prevLayout:V,trigger:"imperative-api"});Jg(V,$e)||(S($e),I.current.layout=$e,j&&j($e),Hc(W,$e,T.current))}}},[]),L=y.useCallback(P=>{const{layout:D,panelDataArray:j}=I.current,{panelSize:V}=Sl(j,P,D);return Ft(V!=null,`Panel size not found for panel "${P.id}"`),V},[]),$=y.useCallback((P,D)=>{const{panelDataArray:j}=I.current,V=Jc(j,P);return Fwe({defaultSize:D,dragState:E,layout:w,panelData:j,panelIndex:V})},[E,w]),H=y.useCallback(P=>{const{layout:D,panelDataArray:j}=I.current,{collapsedSize:V=0,collapsible:W,panelSize:te}=Sl(j,P,D);return Ft(te!=null,`Panel size not found for panel "${P.id}"`),W===!0&&Ro(te,V)},[]),Y=y.useCallback(P=>{const{layout:D,panelDataArray:j}=I.current,{collapsedSize:V=0,collapsible:W,panelSize:te}=Sl(j,P,D);return Ft(te!=null,`Panel size not found for panel "${P.id}"`),!W||Wl(te,V)>0},[]),q=y.useCallback(P=>{const{panelDataArray:D}=I.current;D.push(P),D.sort((j,V)=>{const W=j.order,te=V.order;return W==null&&te==null?0:W==null?-1:te==null?1:W-te}),I.current.panelDataArrayChanged=!0,_()},[_]);Ml(()=>{if(I.current.panelDataArrayChanged){I.current.panelDataArrayChanged=!1;const{autoSaveId:P,onLayout:D,storage:j}=A.current,{layout:V,panelDataArray:W}=I.current;let te=null;if(P){const fe=Hwe(P,W,j);fe&&(R.current=new Map(Object.entries(fe.expandToSizes)),te=fe.layout)}te==null&&(te=zwe({panelDataArray:W}));const de=pz({layout:te,panelConstraints:W.map(fe=>fe.constraints)});dz(V,de)||(S(de),I.current.layout=de,D&&D(de),Hc(W,de,T.current))}}),Ml(()=>{const P=I.current;return()=>{P.layout=[]}},[]);const ne=y.useCallback(P=>{let D=!1;const j=v.current;return j&&window.getComputedStyle(j,null).getPropertyValue("direction")==="rtl"&&(D=!0),function(W){W.preventDefault();const te=v.current;if(!te)return()=>null;const{direction:de,dragState:fe,id:J,keyboardResizeBy:Q,onLayout:se}=A.current,{layout:pe,panelDataArray:he}=I.current,{initialLayout:Ne}=fe??{},He=q8(J,P,te);let $e=Uwe(W,P,de,fe,Q,te);const Pe=de==="horizontal";Pe&&D&&($e=-$e);const ot=he.map(We=>We.constraints),Me=Yf({delta:$e,initialLayout:Ne??pe,panelConstraints:ot,pivotIndices:He,prevLayout:pe,trigger:z8(W)?"keyboard":"mouse-or-touch"}),Je=!Jg(pe,Me);(F8(W)||B8(W))&&C.current!=$e&&(C.current=$e,!Je&&$e!==0?Pe?mE(P,$e<0?V8:G8):mE(P,$e<0?W8:K8):mE(P,0)),Je&&(S(Me),I.current.layout=Me,se&&se(Me),Hc(he,Me,T.current))}},[]),G=y.useCallback((P,D)=>{const{onLayout:j}=A.current,{layout:V,panelDataArray:W}=I.current,te=W.map(pe=>pe.constraints),{panelSize:de,pivotIndices:fe}=Sl(W,P,V);Ft(de!=null,`Panel size not found for panel "${P.id}"`);const Q=Jc(W,P)===W.length-1?de-D:D-de,se=Yf({delta:Q,initialLayout:V,panelConstraints:te,pivotIndices:fe,prevLayout:V,trigger:"imperative-api"});Jg(V,se)||(S(se),I.current.layout=se,j&&j(se),Hc(W,se,T.current))},[]),K=y.useCallback((P,D)=>{const{layout:j,panelDataArray:V}=I.current,{collapsedSize:W=0,collapsible:te}=D,{collapsedSize:de=0,collapsible:fe,maxSize:J=100,minSize:Q=0}=P.constraints,{panelSize:se}=Sl(V,P,j);se!=null&&(te&&fe&&Ro(se,W)?Ro(W,de)||G(P,de):se<Q?G(P,Q):se>J&&G(P,J))},[G]),F=y.useCallback((P,D)=>{const{direction:j}=A.current,{layout:V}=I.current;if(!v.current)return;const W=zv(P,v.current);Ft(W,`Drag handle element not found for id "${P}"`);const te=J8(j,D);x({dragHandleId:P,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:te,initialLayout:V})},[]),re=y.useCallback(()=>{x(null)},[]),ee=y.useCallback(P=>{const{panelDataArray:D}=I.current,j=Jc(D,P);j>=0&&(D.splice(j,1),delete T.current[P.id],I.current.panelDataArrayChanged=!0,_())},[_]),M=y.useMemo(()=>({collapsePanel:O,direction:r,dragState:E,expandPanel:U,getPanelSize:L,getPanelStyle:$,groupId:g,isPanelCollapsed:H,isPanelExpanded:Y,reevaluatePanelConstraints:K,registerPanel:q,registerResizeHandle:ne,resizePanel:G,startDragging:F,stopDragging:re,unregisterPanel:ee,panelGroupElement:v.current}),[O,E,r,U,L,$,g,H,Y,K,q,ne,G,F,re,ee]),B={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return y.createElement(jv.Provider,{value:M},y.createElement(m,{...h,children:t,className:n,id:o,ref:v,style:{...B,...f},[lr.group]:"",[lr.groupDirection]:r,[lr.groupId]:g}))}const r9=y.forwardRef((e,t)=>y.createElement(n9,{...e,forwardedRef:t}));n9.displayName="PanelGroup";r9.displayName="forwardRef(PanelGroup)";function Jc(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function Sl(e,t,n){const r=Jc(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],i=n[r];return{...t.constraints,panelSize:i,pivotIndices:o}}function Wwe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){y.useEffect(()=>{if(e||n==null||r==null)return;const a=zv(t,r);if(a==null)return;const o=i=>{if(!i.defaultPrevented)switch(i.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{i.preventDefault(),n(i);break}case"F6":{i.preventDefault();const c=a.getAttribute(lr.groupId);Ft(c,`No group element found for id "${c}"`);const d=Kp(c,r),f=Z8(c,t,r);Ft(f!==null,`No resize element found for id "${t}"`);const m=i.shiftKey?f>0?f-1:d.length-1:f+1<d.length?f+1:0;d[m].focus();break}}};return a.addEventListener("keydown",o),()=>{a.removeEventListener("keydown",o)}},[r,e,t,n])}function a9({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:a,onBlur:o,onClick:i,onDragging:c,onFocus:d,onPointerDown:f,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...E}){var x,w;const S=y.useRef(null),_=y.useRef({onClick:i,onDragging:c,onPointerDown:f,onPointerUp:m});y.useEffect(()=>{_.current.onClick=i,_.current.onDragging=c,_.current.onPointerDown=f,_.current.onPointerUp=m});const T=y.useContext(jv);if(T===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:R,groupId:C,registerResizeHandle:A,startDragging:I,stopDragging:O,panelGroupElement:U}=T,L=nI(a),[$,H]=y.useState("inactive"),[Y,q]=y.useState(!1),[ne,G]=y.useState(null),K=y.useRef({state:$});Ml(()=>{K.current.state=$}),y.useEffect(()=>{if(n)G(null);else{const M=A(L);G(()=>M)}},[n,L,A]);const F=(x=r?.coarse)!==null&&x!==void 0?x:15,re=(w=r?.fine)!==null&&w!==void 0?w:5;y.useEffect(()=>{if(n||ne==null)return;const M=S.current;Ft(M,"Element ref not attached");let B=!1;return Awe(L,M,R,{coarse:F,fine:re},(D,j,V)=>{if(!j){H("inactive");return}switch(D){case"down":{H("drag"),B=!1,Ft(V,'Expected event to be defined for "down" action'),I(L,V);const{onDragging:W,onPointerDown:te}=_.current;W?.(!0),te?.();break}case"move":{const{state:W}=K.current;B=!0,W!=="drag"&&H("hover"),Ft(V,'Expected event to be defined for "move" action'),ne(V);break}case"up":{H("hover"),O();const{onClick:W,onDragging:te,onPointerUp:de}=_.current;te?.(!1),de?.(),B||W?.();break}}})},[F,R,n,re,A,L,ne,I,O]),Wwe({disabled:n,handleId:L,resizeHandler:ne,panelGroupElement:U});const ee={touchAction:"none",userSelect:"none"};return y.createElement(v,{...E,children:e,className:t,id:a,onBlur:()=>{q(!1),o?.()},onFocus:()=>{q(!0),d?.()},ref:S,role:"separator",style:{...ee,...h},tabIndex:g,[lr.groupDirection]:R,[lr.groupId]:C,[lr.resizeHandle]:"",[lr.resizeHandleActive]:$==="drag"?"pointer":Y?"keyboard":void 0,[lr.resizeHandleEnabled]:!n,[lr.resizeHandleId]:L,[lr.resizeHandleState]:$})}a9.displayName="PanelResizeHandle";function ha({className:e,...t}){return u.jsx(r9,{"data-slot":"resizable-panel-group",className:Oe("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Pn({...e}){return u.jsx(U8,{"data-slot":"resizable-panel",...e})}function _s({withHandle:e,className:t,...n}){return u.jsx(a9,{"data-slot":"resizable-handle",className:Oe("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&u.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:u.jsx(gie,{className:"size-2.5"})})})}function Im({className:e,...t}){return u.jsx("kbd",{"data-slot":"kbd",className:Oe("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 Kwe({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onClearAll:c,searchInputRef:d}){return u.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[u.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?u.jsx(In,{ref:d,placeholder:"Search notifications...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):u.jsxs(u.Fragment,{children:[u.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),u.jsx(kr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(Ot,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx(Uo,{className:"h-4 w-4"})})}),u.jsx(Ot,{side:"bottom",children:"Clear all"})]})})]})}function Qi({id:e,isSelected:t,isFocused:n,icon:r,title:a,description:o,metadata:i,onClick:c,className:d}){return u.jsx("button",{id:e,type:"button",onClick:c,className:Oe("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",d),children:u.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[r&&u.jsx("div",{className:"flex-shrink-0 mt-1",children:u.jsx("div",{className:Oe("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})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"flex items-center gap-2 mb-1",children:u.jsx("h3",{className:Oe("font-medium truncate font-mono text-sm"),children:a})}),o&&u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:o})]})]})})}function Ywe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx(Ed,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):u.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,c)=>u.jsx(Qi,{id:`notification-${i.id}`,isSelected:t?.id===i.id,isFocused:r===c,title:u.jsxs("span",{className:"flex items-center gap-3",children:[i.method,!i.read&&u.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const d=a(i.timestamp),f=i.params&&Object.keys(i.params).length>0?Object.keys(i.params).length:0,m=f>0?` | ${f} param${f>1?"s":""}`:"";return d+m})(),onClick:()=>n(i)},i.id))})}function Zwe({notification:e,previewMode:t,onTogglePreview:n,onCopy:r,onDownload:a,onFullscreen:o,isCopied:i=!1,onClose:c}){return e?u.jsxs("div",{className:"flex flex-col h-full",children:[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:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ep,{className:"h-3 w-3 text-gray-400"}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(Ae,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?u.jsx(kT,{className:"h-4 w-4 mr-1"}):u.jsx(CB,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:r,children:i?u.jsx(Er,{className:"h-4 w-4"}):u.jsx(dr,{className:"h-4 w-4"})}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,children:u.jsx(um,{className:"h-4 w-4"})}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:o,children:u.jsx(_p,{className:"h-4 w-4"})}),c&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,children:u.jsx(ro,{className:"h-4 w-4"})})]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto",children:u.jsx("div",{className:"px-4 pt-4",children:u.jsx(cr,{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`})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(NT,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function Ty(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),o=Math.floor(a/60),i=Math.floor(o/24);return r<60?"just now":a<60?`${a}m ago`:o<24?`${o}h ago`:i<7?`${i}d ago`:new Date(e).toLocaleDateString()}function qwe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:a,serverId:o,isConnected:i}){const[c,d]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,E]=y.useState(!0),[x,w]=y.useState(!1),[S,_]=y.useState(!0),[T,R]=y.useState(!1),C=y.useRef(null),A=y.useRef(null),I=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const K=C.current;if(!K)return;const F=()=>{K.scrollTop>0&&(O.current=!0,E(!1))};return K.addEventListener("scroll",F),()=>K.removeEventListener("scroll",F)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const U=y.useCallback(()=>{f.trim()||w(!1)},[f]),L=y.useMemo(()=>{if(!f.trim())return e;const K=f.toLowerCase();return e.filter(F=>F.method.toLowerCase().includes(K)||JSON.stringify(F.params||{}).toLowerCase().includes(K))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const K=F=>{const re=F.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||F.metaKey||F.ctrlKey||F.altKey)return;const M=L;if(F.key==="ArrowDown")F.preventDefault(),g(B=>{const P=B+1;return P>=M.length?0:P});else if(F.key==="ArrowUp")F.preventDefault(),g(B=>{const P=B-1;return P<0?M.length-1:P});else if(F.key==="Enter"&&h>=0){F.preventDefault();const B=L[h];B&&$(B)}};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[h,L]),y.useEffect(()=>{if(h>=0){const K=`notification-${L[h]?.id}`,F=document.getElementById(K);F&&F.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const $=y.useCallback(K=>{d(K)},[]),H=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(a(),d(null))},[a]),Y=y.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)),R(!0),setTimeout(()=>R(!1),2e3)}catch(K){console.error("[NotificationsTab] Failed to copy notification:",K)}},[c]),q=y.useCallback(()=>{if(c)try{const K=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),F=URL.createObjectURL(K),re=document.createElement("a");re.href=F,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(F)}catch(K){console.error("[NotificationsTab] Failed to download notification:",K)}},[c]),ne=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(K){console.error("[NotificationsTab] Failed to toggle fullscreen:",K)}},[]),G=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:Ty}:null;return i?u.jsxs(ha,{direction:"horizontal",className:"h-full",children:[u.jsx(Pn,{defaultSize:40,minSize:30,children:u.jsx(ha,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(Pn,{defaultSize:75,minSize:30,children:[u.jsx(Kwe,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:L.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:U,onClearAll:H,searchInputRef:I}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(Ywe,{notifications:L,selectedNotification:c,onNotificationSelect:$,focusedIndex:h,formatRelativeTime:Ty,listRef:C})})]})})}),u.jsx(_s,{}),u.jsx(Pn,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(Zwe,{notification:G,previewMode:S,onTogglePreview:()=>_(!S),onCopy:Y,onDownload:q,onFullscreen:ne,onClose:()=>d(null),isCopied:T})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(NT,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function aI({serverIds:e,onCountChange:t,onClearRef:n}={}){const[r,a]=y.useState([]),o=y.useRef(null),[i,c]=y.useState(new Set),[d]=y.useState(""),f=v=>{c(E=>{const x=new Set(E);return x.has(v)?x.delete(v):x.add(v),x})},m=async()=>{a([]),c(new Set),t?.(0),e&&e.length>0?e.forEach(v=>Bb(v)):Bb()},h=y.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);y.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),y.useEffect(()=>{t?.(r.length)},[r.length,t]),y.useEffect(()=>{console.log("[RPC Logger] Subscribing to RPC logs for servers:",e);const v=tT(),x=(e&&e.length>0?v.filter(S=>e.includes(S.serverId)):v).map(S=>{const _=S.message,T=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown";return{id:`${S.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:S.serverId,direction:S.direction.toUpperCase(),method:T,timestamp:S.timestamp,payload:S.message}}).reverse();a(x),t?.(x.length);const w=nT(S=>{if(e&&e.length>0&&!e.includes(S.serverId))return;const _=S.message,T=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown",R={id:`${S.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:S.serverId,direction:S.direction.toUpperCase(),method:T,timestamp:S.timestamp,payload:S.message};console.log("[RPC Logger] New RPC log:",{method:T,direction:S.direction,serverId:S.serverId}),a(C=>{const A=[R,...C].slice(0,1e3);return t?.(A.length),A})});return()=>{w(),console.log("[RPC Logger] Unsubscribed from RPC logs")}},[h,t]);const g=y.useMemo(()=>{let v=r;if(e&&e.length>0){const E=new Set(e);v=v.filter(x=>E.has(x.serverId))}if(d.trim()){const E=d.toLowerCase();v=v.filter(x=>x.serverId.toLowerCase().includes(E)||x.method.toLowerCase().includes(E)||x.direction.toLowerCase().includes(E)||JSON.stringify(x.payload).toLowerCase().includes(E))}return v=[...v].sort((E,x)=>new Date(x.timestamp).getTime()-new Date(E.timestamp).getTime()),v},[r,d,e]);return u.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:u.jsx("div",{ref:o,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?u.jsxs("div",{className:"text-center py-8",children:[u.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),u.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const E=i.has(v.id);return u.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[u.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f(v.id),children:[u.jsx("div",{className:"flex-shrink-0",children:E?u.jsx(Qs,{className:"h-3 w-3 text-muted-foreground transition-transform"}):u.jsx(RB,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),u.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[u.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),u.jsx("span",{className:`flex items-center justify-center px-1 py-0.5 rounded ${v.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:v.direction==="RECEIVE"?"Incoming":"Outgoing",children:v.direction==="RECEIVE"?u.jsx(Noe,{className:"h-3 w-3"}):u.jsx(Coe,{className:"h-3 w-3"})}),u.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),E&&u.jsx("div",{className:"border-t bg-muted/20",children:u.jsx("div",{className:"p-3",children:u.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:u.jsx(cr,{data:v.payload})})})})]},v.id)})})})}function s9({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:r,secondaryTabTitle:a,primaryCount:o,secondaryCount:i,secondaryIcon:c,primaryIcon:d,searchPlaceholder:f="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:E,primaryTabName:x}){const w=e===x;return u.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[u.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?u.jsx(In,{ref:E,placeholder:f,value:n,onChange:S=>h(S.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):u.jsxs(u.Fragment,{children:[u.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:w?r:a}),w&&u.jsxs(u.Fragment,{children:[u.jsx(kr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:o}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(Ot,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})]})}),u.jsxs(Ae,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[w?u.jsx(c,{}):u.jsx(d,{}),u.jsx("span",{className:"hidden sm:inline",children:w?a:r}),w&&i>0&&u.jsx(kr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:i})]})]})}function hz({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:r}){return e.length===0?u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(Tp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):u.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((a,o)=>u.jsx(Qi,{id:`prompt-${a.name}`,isSelected:t?.name===a.name,isFocused:r===o,icon:u.jsx(Tp,{className:"h-4 w-4"}),title:a.name,description:a.description,metadata:a.arguments&&a.arguments.length>0&&u.jsxs(kr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[a.arguments.length," args"]}),onClick:()=>n(a)},a.name))})}function gz({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:r,savedPromptsCount:a,onSearchExpand:o,onSearchChange:i,onSearchBlur:c,onTabSwitch:d,searchInputRef:f}){return u.jsx(s9,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:r,secondaryCount:a,primaryIcon:Tp,secondaryIcon:Ep,searchPlaceholder:"Search prompts...",onSearchExpand:o,onSearchChange:i,onSearchBlur:c,onTabSwitch:d,searchInputRef:f})}function bz({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:r,focusedIndex:a}){return e.length===0?u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(Ep,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),u.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):u.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((o,i)=>u.jsx(Qi,{id:`saved-prompt-${o.id}`,isSelected:t?.id===o.id,isFocused:a===i,icon:u.jsx(Ep,{className:"h-4 w-4"}),title:o.name,description:`${o.promptName} - ${new Date(o.savedAt).toLocaleString()}`,onClick:()=>n(o)},o.id))})}function Xwe({selectedPrompt:e,promptArgs:t,onArgChange:n}){const r=e?.arguments||[];if(!(r.length>0))return u.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const o=i=>{const c=i.name,d=t[c],f=typeof d=="string"?d:JSON.stringify(d);return i.type==="boolean"?u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx("input",{id:c,type:"checkbox",checked:!!d,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),u.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:i.description})]})]},c):i.type==="number"?u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(In,{id:c,type:"number",value:Number(d)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:i.description||`Enter ${c}`}),i.description&&u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},c):i.type==="array"||i.type==="object"?u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(Vl,{id:c,value:f,onChange:m=>{try{const h=JSON.parse(m.target.value);n(c,h)}catch{n(c,m.target.value)}},placeholder:i.description||`Enter ${c} as JSON`,className:"font-mono text-sm min-h-[100px]"}),i.description&&u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},c):u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(In,{id:c,value:f,onChange:m=>n(c,m.target.value),placeholder:i.description||`Enter ${c}`}),i.description&&u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:i.description})]},c)};return u.jsx("div",{className:"space-y-4",children:r.map(i=>o(i))})}function yz({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:r,onArgChange:a,onExecute:o,onSave:i}){return y.useEffect(()=>{const c=d=>{(d.metaKey||d.ctrlKey)&&d.key==="Enter"&&e&&!n&&r&&(d.preventDefault(),o())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,r,o]),e?u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:u.jsxs("div",{children:[u.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[u.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),u.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[u.jsx(Ae,{onClick:o,disabled:n||!r,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?u.jsxs(u.Fragment,{children:[u.jsx(eo,{className:"mr-2"}),u.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):u.jsxs(u.Fragment,{children:[u.jsx(LB,{className:"h-4 w-4 sm:mr-2"}),u.jsx("span",{className:"hidden sm:inline",children:"Execute"}),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:"⌘↵"})]})}),u.jsxs(Ae,{variant:"outline",onClick:i,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[u.jsx(AT,{className:"h-4 w-4"}),u.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),u.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:u.jsx(Xwe,{selectedPrompt:e,promptArgs:t,onArgChange:a})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),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 Jwe(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function Qwe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function exe(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 txe({message:e,index:t}){const[n,r]=y.useState(!1),a=async()=>{const i=exe(e.content);await navigator.clipboard.writeText(i),r(!0),setTimeout(()=>r(!1),2e3)},o=()=>{const i=e.content;return typeof i=="string"?u.jsx(Eb,{content:i}):i.type==="text"&&i.text?u.jsx(Eb,{content:i.text}):i.type==="image"?u.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[u.jsxs("span",{className:"font-mono bg-muted px-2 py-1 rounded",children:["Image: ",i.mimeType||"unknown type"]}),i.data&&u.jsx("img",{src:`data:${i.mimeType};base64,${i.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):i.type==="resource"&&i.resource?u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[u.jsx("span",{className:"text-muted-foreground font-medium",children:"Resource:"}),u.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs font-mono",children:i.resource.uri})]}),i.resource.text&&u.jsx("div",{className:"mt-2",children:u.jsx(Eb,{content:i.resource.text})})]}):u.jsx("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:u.jsx("code",{children:JSON.stringify(i,null,2)})})};return u.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[u.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border",children:[u.jsx(kr,{variant:Jwe(e.role),children:Qwe(e.role)}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,className:"h-6 px-2",title:"Copy message content",children:n?u.jsx(Er,{className:"h-3.5 w-3.5"}):u.jsx(dr,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"px-4 py-3",children:o()})]})}function nxe(e){const n=Date.now()-e,r=Math.floor(n/1e3),a=Math.floor(r/60),o=Math.floor(a/60),i=Math.floor(o/24);return r<10?"now":r<60?`${r}s ago`:a<60?`${a}m ago`:o<24?`${o}h ago`:`${i}d ago`}function rxe(e){return"isError"in e&&!e.isError?null:"error"in e&&e.error?e.error:"isError"in e&&e.isError?"An error occurred":null}function vz({results:e,copiedResult:t,previewMode:n=!0,onCopy:r,onDelete:a,onFullscreen:o,onTogglePreview:i,onMaximize:c,isMaximized:d=!1}){const[f,m]=y.useState(0),[h,g]=y.useState(""),[v,E]=y.useState(!0),x=e[0],w=x?e.filter(C=>C.promptName===x.promptName):[],S=w[f]||w[0],_=e.findIndex(C=>C===S);if(y.useEffect(()=>{w.length>0&&f>=w.length&&m(0)},[w.length,f]),y.useEffect(()=>{const C=()=>{S&&g(nxe(S.timestamp))};C();const A=setInterval(C,1e3);return()=>clearInterval(A)},[S]),e.length===0)return u.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:u.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsx("div",{className:"text-center",children:u.jsx(Ed,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const T=S.error||rxe(S.result),R="messages"in S.result&&Array.isArray(S.result.messages);return u.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:u.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:u.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[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:[u.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),S.duration!==void 0&&u.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[u.jsx(kp,{className:"h-3 w-3 text-gray-400"}),u.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[S.duration,"ms"]})]}),R&&u.jsx("div",{className:"flex items-center gap-4 sm:ml-4",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("button",{onClick:()=>E(!0),className:`text-xs font-medium ${v?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),u.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),u.jsx("button",{onClick:()=>E(!1),className:`text-xs font-medium ${v?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]})}),u.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[w.length>1&&u.jsxs("div",{className:"flex items-center gap-2 mr-2",children:[u.jsx(Sp,{className:"h-3 w-3 text-gray-400"}),u.jsxs(Oo,{value:f.toString(),onValueChange:C=>m(parseInt(C)),children:[u.jsx(Lo,{className:"h-7 w-[120px] text-xs",children:u.jsx(Do,{})}),u.jsx(Mo,{children:w.map((C,A)=>u.jsx(ra,{value:A.toString(),children:A===0?"Latest":`${A+1} call ago`},A))})]})]}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-2",children:h}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>r(_,S.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?u.jsx(Er,{className:"h-4 w-4"}):u.jsx(dr,{className:"h-4 w-4"})}),a&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>a(_),className:"h-7 w-7 p-0",title:"Delete result",children:u.jsx(Uo,{className:"h-4 w-4"})}),o&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>o(_),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:u.jsx(_p,{className:"h-4 w-4"})}),c&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,className:"h-7 w-7 p-0 hidden sm:flex",title:d?"Restore":"Maximize",children:d?u.jsx(DB,{className:"h-4 w-4"}):u.jsx(_p,{className:"h-4 w-4"})})]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T?u.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[u.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),u.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:T})]}):v&&R?u.jsx("div",{className:"space-y-3",children:S.result.messages.map((C,A)=>u.jsx(txe,{message:C,index:A},A))}):u.jsx(cr,{data:S.result,filename:`prompt-result-${S.promptName}-${Date.now()}.json`})})]})})})}const wz="mcp-inspector-saved-prompts";function o9({ref:e,prompts:t,callPrompt:n,serverId:r,isConnected:a}){const[o,i]=y.useState(null),[c,d]=y.useState(null),{selectedPromptName:f,setSelectedPromptName:m}=Ql(),[h,g]=y.useState({}),[v,E]=y.useState([]),[x,w]=y.useState(!1),[S,_]=y.useState(null),[T,R]=y.useState(""),[C,A]=y.useState("prompts"),[I,O]=y.useState([]),[U,L]=y.useState(!1),[$,H]=y.useState(""),[Y,q]=y.useState(!1),[ne,G]=y.useState(-1),K=y.useRef(null),[F,re]=y.useState(!1),[ee,M]=y.useState("list"),[B,P]=y.useState(0),[D,j]=y.useState(!0),[V,W]=y.useState(!1),te=y.useRef(null),de=y.useRef(null),fe=y.useRef(null),J=y.useRef(null);y.useEffect(()=>{const Ee=()=>{re(window.innerWidth<1024)};return Ee(),window.addEventListener("resize",Ee),()=>window.removeEventListener("resize",Ee)},[]),y.useEffect(()=>{M(o?"detail":"list")},[o]),y.useEffect(()=>{F&&v.length>0&&!x&&M("response")},[v,x,F]),y.useImperativeHandle(e,()=>({focusSearch:()=>{q(!0),setTimeout(()=>{K.current&&K.current.focus()},0)},blurSearch:()=>{R(""),q(!1),K.current&&K.current.blur()}})),y.useEffect(()=>{try{const Ee=localStorage.getItem(wz);if(Ee){const oe=JSON.parse(Ee);O(oe)}}catch(Ee){console.error("[PromptsTab] Failed to load saved prompts:",Ee)}},[]);const Q=y.useCallback(Ee=>{try{localStorage.setItem(wz,JSON.stringify(Ee))}catch(oe){console.error("[PromptsTab] Failed to save prompts:",oe)}},[]);y.useEffect(()=>{Y&&K.current&&K.current.focus()},[Y]);const se=y.useCallback(()=>{T.trim()||q(!1)},[T]),pe=y.useMemo(()=>{if(!T.trim())return t;const Ee=T.toLowerCase();return t.filter(oe=>oe.name.toLowerCase().includes(Ee)||oe.description?.toLowerCase().includes(Ee))},[t,T]),he=y.useCallback(Ee=>{i(Ee);const oe={};Ee.arguments&&Ee.arguments.forEach(Se=>{oe[Se.name]=""}),g(oe)},[]),Ne=y.useCallback(Ee=>{const oe=t.find(Se=>Se.name===Ee.promptName);oe&&(i(oe),g(Ee.args),d(Ee))},[t]);y.useEffect(()=>{G(-1)},[T,C]),y.useEffect(()=>{const Ee=oe=>{const Se=oe.target;if(Se.tagName==="INPUT"||Se.tagName==="TEXTAREA"||Se.contentEditable==="true"||oe.metaKey||oe.ctrlKey||oe.altKey)return;const Ve=C==="prompts"?pe:I;if(oe.key==="ArrowDown")oe.preventDefault(),G(ct=>{const vt=ct+1;return vt>=Ve.length?0:vt});else if(oe.key==="ArrowUp")oe.preventDefault(),G(ct=>{const vt=ct-1;return vt<0?Ve.length-1:vt});else if(oe.key==="Enter"&&ne>=0)if(oe.preventDefault(),C==="prompts"){const ct=pe[ne];ct&&he(ct)}else{const ct=I[ne];ct&&Ne(ct)}};return document.addEventListener("keydown",Ee),()=>document.removeEventListener("keydown",Ee)},[ne,pe,I,C,he,Ne]),y.useEffect(()=>{if(ne>=0){const Ee=C==="prompts"?`prompt-${pe[ne]?.name}`:`saved-prompt-${I[ne]?.id}`,oe=document.getElementById(Ee);oe&&oe.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,pe,I,C]),y.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:f,promptsCount:t.length,currentSelectedPrompt:o?.name}),f&&t.length>0){const Ee=t.find(oe=>oe.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!Ee,promptName:Ee?.name,shouldSelect:Ee&&o?.name!==Ee.name}),Ee&&o?.name!==Ee.name){console.warn("[PromptsTab] Selecting prompt:",Ee.name),m(null);const oe=setTimeout(()=>{he(Ee);const Se=document.getElementById(`prompt-${Ee.name}`);Se&&(console.warn("[PromptsTab] Scrolling to prompt element"),Se.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(oe)}}},[f,t,o,he,m]);const He=y.useCallback((Ee,oe)=>{g(Se=>({...Se,[Ee]:oe}))},[]),$e=y.useCallback(async()=>{if(!o||x)return;w(!0);const Ee=Date.now();try{const oe=await n(o.name,h),Se=Date.now()-Ee;Zr.getInstance().capture(new RP({promptName:o.name,serverId:r,success:!0})).catch(()=>{}),E(Ve=>[{promptName:o.name,args:h,result:oe,timestamp:Ee,duration:Se},...Ve])}catch(oe){Zr.getInstance().capture(new RP({promptName:o.name,serverId:r,success:!1,error:oe instanceof Error?oe.message:"Unknown error"})).catch(()=>{});const Re={promptName:o.name,args:h,result:null,error:oe instanceof Error?oe.message:String(oe),timestamp:Ee,duration:Date.now()-Ee};E(Ve=>[...Ve,{...Re,result:{messages:[]}}])}finally{w(!1)}},[o,h,x,n,r]),Pe=y.useCallback(async(Ee,oe)=>{try{await navigator.clipboard.writeText(JSON.stringify(oe,null,2)),_(Ee),setTimeout(()=>_(null),2e3)}catch(Se){console.error("[PromptsTab] Failed to copy result:",Se)}},[]),ot=y.useCallback(Ee=>{E(oe=>oe.filter((Se,Re)=>Re!==Ee))},[]),Me=y.useCallback(Ee=>{if(F)M("response");else{const oe=v[Ee];if(oe){const Se=window.open("","_blank","width=800,height=600");if(Se){const Re=oe.result;Se.document.write(`
|
|
1724
1724
|
<html>
|
|
1725
1725
|
<head>
|
|
1726
1726
|
<title>${oe.promptName} Result</title>
|
|
@@ -1750,4 +1750,4 @@ print(f"Available resources: {[resource.name for resource in resources]}")
|
|
|
1750
1750
|
<pre>${JSON.stringify(Ue.result,null,2)}</pre>
|
|
1751
1751
|
</body>
|
|
1752
1752
|
</html>
|
|
1753
|
-
`),ce.document.close())}},[E]),vt=y.useCallback(()=>{W?(he.current&&he.current.expand(),Ne.current&&Ne.current.expand(),te(!1)):(he.current&&he.current.collapse(),Ne.current&&Ne.current.collapse(),te(!0))},[W]),Ge=y.useCallback(()=>{i&&(ne(""),Y(!0))},[i]),wn=y.useCallback(()=>{if(!i)return;const Fe={id:`${Date.now()}-${Math.random()}`,name:q.trim()||`${i.name} - ${new Date().toLocaleString()}`,toolName:i.name,args:g,savedAt:Date.now(),serverId:i._serverId,serverName:i._serverName};ot([...L,Fe]),Zr.getInstance().capture(new goe({toolName:i.name,serverId:a})).catch(()=>{}),Y(!1),ne("")},[i,q,g,L,ot,a]),pn=y.useCallback(Fe=>{ot(L.filter(Ue=>Ue.id!==Fe)),d?.id===Fe&&f(null)},[L,ot,d]);return P?u.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[j!=="list"&&u.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[u.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{j==="response"?V("detail"):(c(null),V("list"))},className:"p-0 h-8 w-8",children:u.jsx(ov,{className:"h-4 w-4"})}),u.jsxs("div",{className:"flex items-center text-sm font-medium",children:[u.jsx("button",{onClick:()=>{c(null),V("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),j==="detail"&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),u.jsx("button",{onClick:()=>{V("response")},className:j==="detail"?"text-foreground hover:underline":j==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),j==="response"&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),u.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),u.jsx("div",{className:"flex-1 relative overflow-hidden",children:u.jsxs(Tv,{initial:!1,mode:"popLayout",children:[j==="list"&&u.jsxs(Ca.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:[u.jsx(Iz,{activeTab:O,isSearchExpanded:F,searchQuery:A,filteredToolsCount:Me.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:I,onSearchBlur:we,onTabSwitch:()=>U(O==="tools"?"saved":"tools"),searchInputRef:B}),O==="tools"?u.jsx(Az,{tools:Me,selectedTool:i,onToolSelect:Je,focusedIndex:ee}):u.jsx(_z,{savedRequests:L,selectedRequest:d,onLoadRequest:We,onDeleteRequest:pn,focusedIndex:ee})]},"list"),j==="detail"&&u.jsx(Ca.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:u.jsx(kz,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:Ee,onExecute:oe,onSave:Ge})},"detail"),j==="response"&&u.jsx(Ca.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:u.jsx(Rz,{results:Ve,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:Se,onDelete:Re,onFullscreen:ct,onTogglePreview:()=>K(!G)})},"response")]})}),u.jsx(Tz,{isOpen:H,requestName:q,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:wn,onCancel:()=>Y(!1)})]}):u.jsxs(ha,{direction:"horizontal",className:"h-full",children:[u.jsx(Pn,{ref:he,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:u.jsxs(ha,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[u.jsx(Pn,{defaultSize:75,minSize:30,children:u.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[u.jsx(Iz,{activeTab:O,isSearchExpanded:F,searchQuery:A,filteredToolsCount:Me.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:I,onSearchBlur:we,onTabSwitch:()=>U(O==="tools"?"saved":"tools"),searchInputRef:B}),O==="tools"?u.jsx(Az,{tools:Me,selectedTool:i,onToolSelect:Je,focusedIndex:ee}):u.jsx(_z,{savedRequests:L,selectedRequest:d,onLoadRequest:We,onDeleteRequest:pn,focusedIndex:ee})]})}),u.jsx(_s,{withHandle:!0}),u.jsxs(Pn,{ref:$e,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,style:{minHeight:45},onCollapse:()=>{Q(!0)},onExpand:()=>{Q(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[u.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),J?($e.current?.resize(25),Q(!1)):($e.current?.resize(5),Q(!0))},children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),de>0&&u.jsx(kr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:de}),de>0&&!J&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),Pe.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:u.jsx(Uo,{className:"h-3.5 w-3.5"})})]}),u.jsx(Qs,{className:`h-4 w-4 text-muted-foreground transition-transform ${J?"":"rotate-180"}`})]}),u.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${J?"hidden":""}`,children:u.jsx(aI,{serverIds:[a],onCountChange:fe,onClearRef:Pe})})]})]})}),u.jsx(_s,{withHandle:!0}),u.jsx(Pn,{defaultSize:67,children:u.jsxs(ha,{direction:"vertical",children:[u.jsx(Pn,{ref:Ne,defaultSize:40,collapsible:!0,children:u.jsx(kz,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:Ee,onExecute:oe,onSave:Ge,onCancel:()=>{R&&R.abort()}})}),u.jsx(_s,{withHandle:!0}),u.jsx(Pn,{ref:He,defaultSize:60,children:u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(Rz,{results:Ve,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:Se,onDelete:Re,onFullscreen:ct,onTogglePreview:()=>K(!G),onMaximize:vt,isMaximized:W})})})]})}),u.jsx(Tz,{isOpen:H,requestName:q,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:wn,onCancel:()=>Y(!1)})]})}u9.displayName="ToolsTab";function fxe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onRejectAll:c,searchInputRef:d}){return u.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[u.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?u.jsx(In,{ref:d,placeholder:"Search requests...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):u.jsxs(u.Fragment,{children:[u.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),u.jsx(kr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(Ot,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx(Uo,{className:"h-4 w-4"})})}),u.jsx(Ot,{side:"bottom",children:"Reject all"})]})})]})}function pxe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx(Ed,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):u.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,c)=>{const d=i.request.params?.messages?.length||0,f=i.request.params?.maxTokens;return u.jsx(Qi,{id:`sampling-request-${i.id}`,isSelected:t?.id===i.id,isFocused:r===c,title:u.jsxs("span",{className:"flex items-center gap-3",children:[i.serverName,u.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=a(i.timestamp),h=[];d>0&&h.push(`${d} message${d>1?"s":""}`),f&&h.push(`max ${f} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(i)},i.id)})})}function mxe({llmConfig:e}){const t=y.useRef(null);return{generateResponse:y.useCallback(async({request:r})=>{if(!e)throw new Error("LLM config is not available");const a=r.params||{},o=a.maxTokens,i=a.temperature;a.modelPreferences;const c=a.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!a,messagesCount:c.length,messages:c,params:a}),c.length===0)throw new Error("No messages found in sampling request");const d=[],{HumanMessage:f,AIMessage:m}=await pa(async()=>{const{HumanMessage:E,AIMessage:x}=await import("./index-sxfbjETB.js").then(w=>w.bI);return{HumanMessage:E,AIMessage:x}},[]);for(const E of c){if(!E||!E.role){console.warn("Skipping invalid message:",E);continue}const x=Array.isArray(E.content)?E.content[0]:E.content;if(!x){console.warn("Skipping message with no content:",E);continue}x.type==="text"&&x.text?E.role==="user"?d.push(new f(x.text)):E.role==="assistant"&&d.push(new m(x.text)):console.warn("Skipping message with unsupported content type:",x)}if(d.length===0)throw new 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 E;const x={model:e.model,apiKey:e.apiKey};if(o!==void 0&&(x.maxTokens=o),i!==void 0?x.temperature=i:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:w}=await pa(async()=>{const{ChatOpenAI:S}=await import("./index-CtIyN4y7.js");return{ChatOpenAI:S}},__vite__mapDeps([0,1,2,3,4,5]));E=new w(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:w}=await pa(async()=>{const{ChatAnthropic:S}=await import("./index-Bey-QuvV.js");return{ChatAnthropic:S}},__vite__mapDeps([6,2,1,5]));E=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await pa(async()=>{const{ChatGoogleGenerativeAI:S}=await import("./index-Cpg-k5c6.js");return{ChatGoogleGenerativeAI:S}},__vite__mapDeps([7,2,1,4]));E=new w(x)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:E,provider:e.provider,model:e.model,apiKey:e.apiKey}}const h=await t.current.instance.invoke(d);return{role:"assistant",content:{type:"text",text:h.content||h.text||""},model:e.model,stopReason:"endTurn"}},[e]),isAvailable:e!==null}}function hxe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:o,isCopied:i,onCopy:c,onDownload:d,onFullscreen:f,llmConfig:m}){const[h,g]=y.useState("manual"),[v,E]=y.useState("stub-model"),[x,w]=y.useState("endTurn"),[S,_]=y.useState("assistant"),[T,R]=y.useState("text"),[C,A]=y.useState("positive"),[I,O]=y.useState(""),[U,L]=y.useState("image/png"),[$,H]=y.useState(!1),[Y,q]=y.useState(null),{generateResponse:ne,isAvailable:G}=mxe({llmConfig:m});y.useEffect(()=>{e&&(E("stub-model"),w("endTurn"),_("assistant"),R("text"),A("positive"),O(""),L("image/png"),q(null))},[e?.id]);const K=async()=>{if(!(!e||!G)){H(!0),q(null);try{const M=await ne({request:e.request});E(M.model||m?.model||"stub-model"),w(M.stopReason||"endTurn"),_(M.role||"assistant");const B=Array.isArray(M.content)?M.content[0]:M.content;B.type==="text"?(R("text"),A(B.text||"")):B.type==="image"&&(R("image"),O(B.data||""),L(B.mimeType||"image/png"))}catch(M){const B=M instanceof Error?M.message:"Failed to generate response";q(B),pt.error("LLM Generation Failed",{description:B})}finally{H(!1)}}},F=y.useMemo(()=>{const M={model:v,stopReason:x,role:S,content:{type:T}};return T==="text"?M.content.text=C:T==="image"&&(M.content.data=I,M.content.mimeType=U),M},[v,x,S,T,C,I,U]),re=()=>{if(!e)return;const M=H_.safeParse(F);if(!M.success){pt.error("Invalid response",{description:`Validation failed: ${M.error.message}`});return}t(e.id,M.data),r(),pa(()=>Promise.resolve().then(()=>pd),void 0).then(B=>{const P=pt(B.createElement("div",{className:"space-y-3"},B.createElement("div",null,B.createElement("strong",null,"Sampling Response Sent"),B.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),B.createElement("div",{className:"flex gap-2"},B.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const D=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(D),pt.dismiss(P)}},"View Tool Result"))),{duration:5e3})})},ee=()=>{e&&(n(e.id,"User rejected sampling request"),r())};return e?u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),u.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:i?u.jsx(Er,{className:"h-4 w-4 text-green-600"}):u.jsx(dr,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Copy request"})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:u.jsx(um,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Download request"})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:u.jsx(RT,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Fullscreen"})]}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:u.jsx(ro,{className:"h-4 w-4"})})]})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),u.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:u.jsx(cr,{data:e.request})})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(on,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),u.jsxs(Oo,{value:h,onValueChange:M=>g(M),children:[u.jsx(Lo,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:u.jsx(Do,{})}),u.jsxs(Mo,{children:[u.jsx(ra,{value:"manual",children:"Manual"}),u.jsx(ra,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&u.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[G?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Ae,{onClick:K,disabled:$,size:"sm",className:"flex items-center gap-2",children:$?u.jsxs(u.Fragment,{children:[u.jsx(Bi,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):u.jsxs(u.Fragment,{children:[u.jsx(Gie,{className:"h-4 w-4"}),"Generate with LLM"]})}),u.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):u.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),Y&&u.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:Y})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`model-${e.id}`,children:"Model"}),u.jsx(In,{id:`model-${e.id}`,value:v,onChange:M=>E(M.target.value),placeholder:"stub-model",disabled:h==="llm"&&$})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),u.jsx(In,{id:`stopReason-${e.id}`,value:x,onChange:M=>w(M.target.value),placeholder:"endTurn",disabled:h==="llm"&&$})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`role-${e.id}`,children:"Role"}),u.jsxs(Oo,{value:S,onValueChange:M=>_(M),disabled:h==="llm"&&$,children:[u.jsx(Lo,{id:`role-${e.id}`,children:u.jsx(Do,{})}),u.jsxs(Mo,{children:[u.jsx(ra,{value:"assistant",children:"assistant"}),u.jsx(ra,{value:"user",children:"user"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),u.jsxs(Oo,{value:T,onValueChange:M=>R(M),disabled:h==="llm"&&$,children:[u.jsx(Lo,{id:`contentType-${e.id}`,children:u.jsx(Do,{})}),u.jsxs(Mo,{children:[u.jsx(ra,{value:"text",children:"text"}),u.jsx(ra,{value:"image",children:"image"})]})]})]}),T==="text"&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`text-${e.id}`,children:"Text Content"}),u.jsx(Vl,{id:`text-${e.id}`,value:C,onChange:M=>A(M.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&$})]}),T==="image"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),u.jsx(Vl,{id:`imageData-${e.id}`,value:I,onChange:M=>O(M.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&$})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),u.jsx(In,{id:`mimeType-${e.id}`,value:U,onChange:M=>L(M.target.value),placeholder:"image/png",disabled:h==="llm"&&$})]})]})]})]}),u.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[u.jsx(Ae,{onClick:re,className:"flex-1",disabled:h==="llm"&&$,children:"Approve"}),u.jsx(Ae,{onClick:ee,variant:"outline",className:"flex-1",disabled:h==="llm"&&$,children:"Reject"})]})]}):u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}const gxe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function bxe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:a}){return u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx("strong",{children:"Sampling Request Received"}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),n()},children:"View Details"}),u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),r(gxe)},children:"Approve"}),u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),a()},children:"Deny"})]})]})}function yxe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:a,mcpServerUrl:o}){const{selectedSamplingRequestId:i,setSelectedSamplingRequestId:c}=Ql(),{llmConfig:d}=P8({mcpServerUrl:o}),[f,m]=y.useState(null),[h,g]=y.useState(""),[v,E]=y.useState(-1),[x,w]=y.useState(!0),[S,_]=y.useState(!1),[T,R]=y.useState(!0),[C,A]=y.useState(!1),I=y.useRef(null),O=y.useRef(null),U=y.useRef(null),L=y.useRef(!1);y.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:i,pendingRequestsCount:e.length,currentSelectedId:f?.id}),i&&e.length>0){const F=e.find(re=>re.id===i);console.log("[SamplingTab] Found request for auto-selection:",!!F,F?.id),F&&(console.log("[SamplingTab] Auto-selecting request:",F.id),c(null),m(F),setTimeout(()=>{const re=document.getElementById(`sampling-request-${F.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,c]),y.useEffect(()=>{const F=re=>{const M=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",M);const B=e.find(P=>P.id===M);B&&(console.log("[SamplingTab] Selecting request from event:",M),m(B),setTimeout(()=>{const P=document.getElementById(`sampling-request-${M}`);P&&P.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",F),()=>window.removeEventListener("navigate-to-sampling",F)},[e]),y.useEffect(()=>{x&&e.length>0&&I.current&&!L.current&&(I.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const F=I.current;if(!F)return;const re=()=>{F.scrollTop>0&&(L.current=!0,w(!1))};return F.addEventListener("scroll",re),()=>F.removeEventListener("scroll",re)},[]),y.useEffect(()=>{e.length===0&&(L.current=!1,w(!0))},[e.length]),y.useEffect(()=>{S&&U.current&&U.current.focus()},[S]);const $=y.useCallback(()=>{h.trim()||_(!1)},[h]),H=y.useMemo(()=>{if(!h.trim())return e;const F=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(F)||JSON.stringify(re.request||{}).toLowerCase().includes(F))},[e,h]);y.useEffect(()=>{E(-1)},[h]),y.useEffect(()=>{const F=re=>{const ee=re.target;if(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const B=H;if(re.key==="ArrowDown")re.preventDefault(),E(P=>{const D=P+1;return D>=B.length?0:D});else if(re.key==="ArrowUp")re.preventDefault(),E(P=>{const D=P-1;return D<0?B.length-1:D});else if(re.key==="Enter"&&v>=0){re.preventDefault();const P=H[v];P&&Y(P)}};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[v,H]),y.useEffect(()=>{if(v>=0){const F=`sampling-request-${H[v]?.id}`,re=document.getElementById(F);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,H]);const Y=y.useCallback(F=>{m(F)},[]),q=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(F=>{n(F.id,"User rejected all requests")}),m(null))},[e,n]),ne=y.useCallback(async()=>{if(f)try{await navigator.clipboard.writeText(JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(F){console.error("[SamplingTab] Failed to copy request:",F)}},[f]),G=y.useCallback(()=>{if(f)try{const F=new globalThis.Blob([JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)],{type:"application/json"}),re=URL.createObjectURL(F),ee=document.createElement("a");ee.href=re,ee.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(re)}catch(F){console.error("[SamplingTab] Failed to download request:",F)}},[f]),K=y.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(F){console.error("[SamplingTab] Failed to toggle fullscreen:",F)}},[]);return a?u.jsxs(ha,{direction:"horizontal",className:"h-full",children:[u.jsx(Pn,{defaultSize:40,minSize:30,children:u.jsx(ha,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(Pn,{defaultSize:75,minSize:30,children:[u.jsx(fxe,{isSearchExpanded:S,searchQuery:h,filteredRequestsCount:H.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:$,onRejectAll:q,searchInputRef:U}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(pxe,{requests:H,selectedRequest:f,onRequestSelect:Y,focusedIndex:v,formatRelativeTime:Ty,listRef:I})})]})})}),u.jsx(_s,{}),u.jsx(Pn,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(hxe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:T,onTogglePreview:()=>R(!T),isCopied:C,onCopy:ne,onDownload:G,onFullscreen:K,llmConfig:d})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(IB,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function vxe({requestId:e,serverName:t,mode:n,message:r,url:a,onViewDetails:o,onOpenUrl:i,onCancel:c}){return u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx("strong",{children:"Elicitation Request Received"}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",r]}),n==="url"&&a&&u.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:a})]}),u.jsxs("div",{className:"flex gap-2 flex-wrap",children:[u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:d=>{d.stopPropagation(),o()},children:"View Details"}),n==="url"&&i&&u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:d=>{d.stopPropagation(),i()},children:"Open URL"}),u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:d=>{d.stopPropagation(),c()},children:"Cancel"})]})]})}function wxe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onCancelAll:c,searchInputRef:d}){return u.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[u.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?u.jsx(In,{ref:d,placeholder:"Search requests...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):u.jsxs(u.Fragment,{children:[u.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),u.jsx(kr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(Ot,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx(ro,{className:"h-4 w-4"})})}),u.jsx(Ot,{side:"bottom",children:"Cancel all"})]})})]})}function xxe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx(Ed,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):u.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,c)=>{const d=i.request.mode||"form",f=d==="form"&&"requestedSchema"in i.request&&i.request.requestedSchema;return u.jsx(Qi,{id:`elicitation-request-${i.id}`,isSelected:t?.id===i.id,isFocused:r===c,title:u.jsxs("span",{className:"flex items-center gap-3",children:[i.serverName,u.jsx(kr,{variant:"outline",className:d==="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:d})]}),description:(()=>{const m=a(i.timestamp),h=[];f&&h.push("with schema"),d==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(i)},i.id)})})}function Exe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:o,isCopied:i,onCopy:c,onDownload:d,onFullscreen:f}){const[m,h]=y.useState({}),[g,v]=y.useState(!1),E=e?.request.mode||"form",x=E==="form",w=E==="url";y.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const I=e.request.requestedSchema,O={};if(I?.type==="object"&&I.properties)for(const[U,L]of Object.entries(I.properties)){const $=L;$.default!==void 0?O[U]=$.default:$.type==="boolean"?O[U]=!1:$.type==="number"||$.type==="integer"?O[U]=0:O[U]=""}h(O)}v(!1)},[e?.id,x]);const S=(I,O)=>{h(U=>({...U,[I]:O}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const I=e.request.requestedSchema;if(I?.required){const O=I.required.filter(U=>m[U]===void 0||m[U]===""||m[U]===null);if(O.length>0){pt.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else w&&t(e.id,{action:"accept"});r(),pa(()=>Promise.resolve().then(()=>pd),void 0).then(I=>{const O=pt(I.createElement("div",{className:"space-y-3"},I.createElement("div",null,I.createElement("strong",null,"Elicitation Response Sent"),I.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),I.createElement("div",{className:"flex gap-2"},I.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const U=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent(U),pt.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},T=()=>{e&&(t(e.id,{action:"decline"}),r())},R=()=>{e&&(n(e.id,"User cancelled elicitation request"),r())},C=()=>{e&&w&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},A=y.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const I=e.request.requestedSchema;if(!I||I.type!=="object"||!I.properties)return u.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=I.properties,U=I.required||[];return u.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([L,$])=>{const H=$,Y=U.includes(L),q=H.type||"string",ne=H.title||L,G=H.description;return u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:`field-${L}`,children:[ne,Y&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),G&&u.jsx("p",{className:"text-xs text-muted-foreground",children:G}),q==="boolean"?u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Vp,{id:`field-${L}`,checked:m[L]||!1,onCheckedChange:K=>S(L,K)}),u.jsx(on,{htmlFor:`field-${L}`,className:"text-sm font-normal cursor-pointer",children:H.title||L})]}):q==="number"||q==="integer"?u.jsx(In,{id:`field-${L}`,type:"number",value:m[L]||"",onChange:K=>S(L,q==="integer"?parseInt(K.target.value,10):parseFloat(K.target.value)),placeholder:H.default?.toString()||""}):H.enum?u.jsxs("select",{id:`field-${L}`,value:m[L]||"",onChange:K=>S(L,K.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:[u.jsx("option",{value:"",children:"Select..."}),H.enum.map(K=>u.jsx("option",{value:K,children:K},K))]}):q==="string"&&(H.format==="textarea"||H.maxLength>100)?u.jsx(Vl,{id:`field-${L}`,value:m[L]||"",onChange:K=>S(L,K.target.value),placeholder:H.default||"",rows:4}):u.jsx(In,{id:`field-${L}`,type:"text",value:m[L]||"",onChange:K=>S(L,K.target.value),placeholder:H.default||""})]},L)})})},[e,m,x]);return e?u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),u.jsx(kr,{variant:"outline",className:w?"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:E}),u.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:i?u.jsx(Er,{className:"h-4 w-4 text-green-600"}):u.jsx(dr,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Copy request"})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:u.jsx(um,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Download request"})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:u.jsx(RT,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Fullscreen"})]}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:u.jsx(ro,{className:"h-4 w-4"})})]})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),u.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),w&&"url"in e.request&&u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),u.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[u.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[u.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),u.jsxs(Ae,{size:"sm",variant:"outline",onClick:C,className:"flex items-center gap-2",children:[u.jsx(tS,{className:"h-4 w-4"}),"Open URL"]})]}),u.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[u.jsx(Vp,{id:"url-completed",checked:g,onCheckedChange:I=>v(!!I)}),u.jsx(on,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),x&&u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),A]}),x&&"requestedSchema"in e.request&&e.request.requestedSchema&&u.jsxs("details",{className:"space-y-2",children:[u.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),u.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:u.jsx(cr,{data:e.request.requestedSchema})})]})]}),u.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[u.jsx(Ae,{onClick:_,className:"flex-1",children:"Accept"}),u.jsx(Ae,{onClick:T,variant:"outline",className:"flex-1",children:"Decline"}),u.jsx(Ae,{onClick:R,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function Sxe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:a}){const{selectedElicitationRequestId:o,setSelectedElicitationRequestId:i}=Ql(),[c,d]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,E]=y.useState(!0),[x,w]=y.useState(!1),[S,_]=y.useState(!0),[T,R]=y.useState(!1),C=y.useRef(null),A=y.useRef(null),I=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:o,pendingRequestsCount:e.length,currentSelectedId:c?.id}),o&&e.length>0){const G=e.find(K=>K.id===o);console.log("[ElicitationTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[ElicitationTab] Auto-selecting request:",G.id),i(null),d(G),setTimeout(()=>{const K=document.getElementById(`elicitation-request-${G.id}`);console.log("[ElicitationTab] Scrolling to element:",!!K),K&&K.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[o,e,i]),y.useEffect(()=>{const G=K=>{const re=K.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",re);const ee=e.find(M=>M.id===re);ee&&(console.log("[ElicitationTab] Selecting request from event:",re),d(ee),setTimeout(()=>{const M=document.getElementById(`elicitation-request-${re}`);M&&M.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",G),()=>window.removeEventListener("navigate-to-elicitation",G)},[e]),y.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const G=C.current;if(!G)return;const K=()=>{G.scrollTop>0&&(O.current=!0,E(!1))};return G.addEventListener("scroll",K),()=>G.removeEventListener("scroll",K)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const U=y.useCallback(()=>{f.trim()||w(!1)},[f]),L=y.useMemo(()=>{if(!f.trim())return e;const G=f.toLowerCase();return e.filter(K=>K.serverName.toLowerCase().includes(G)||K.request.message.toLowerCase().includes(G)||JSON.stringify(K.request||{}).toLowerCase().includes(G))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const G=K=>{const F=K.target;if(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.contentEditable==="true"||K.metaKey||K.ctrlKey||K.altKey)return;const ee=L;if(K.key==="ArrowDown")K.preventDefault(),g(M=>{const B=M+1;return B>=ee.length?0:B});else if(K.key==="ArrowUp")K.preventDefault(),g(M=>{const B=M-1;return B<0?ee.length-1:B});else if(K.key==="Enter"&&h>=0){K.preventDefault();const M=L[h];M&&$(M)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[h,L]),y.useEffect(()=>{if(h>=0){const G=`elicitation-request-${L[h]?.id}`,K=document.getElementById(G);K&&K.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const $=y.useCallback(G=>{d(G)},[]),H=y.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(G=>{n(G.id,"User cancelled all requests")}),d(null))},[e,n]),Y=y.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)),R(!0),setTimeout(()=>R(!1),2e3)}catch(G){console.error("[ElicitationTab] Failed to copy request:",G)}},[c]),q=y.useCallback(()=>{if(c)try{const G=new globalThis.Blob([JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)],{type:"application/json"}),K=URL.createObjectURL(G),F=document.createElement("a");F.href=K,F.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(K)}catch(G){console.error("[ElicitationTab] Failed to download request:",G)}},[c]),ne=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(G){console.error("[ElicitationTab] Failed to toggle fullscreen:",G)}},[]);return a?u.jsxs(ha,{direction:"horizontal",className:"h-full",children:[u.jsx(Pn,{defaultSize:40,minSize:30,children:u.jsx(ha,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(Pn,{defaultSize:75,minSize:30,children:[u.jsx(wxe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:L.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:U,onCancelAll:H,searchInputRef:I}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(xxe,{requests:L,selectedRequest:c,onRequestSelect:$,focusedIndex:h,formatRelativeTime:Ty,listRef:C})})]})})}),u.jsx(_s,{}),u.jsx(Pn,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(Exe,{request:c,onApprove:t,onReject:n,onClose:()=>d(null),previewMode:S,onTogglePreview:()=>_(!S),isCopied:T,onCopy:Y,onDownload:q,onFullscreen:ne})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(jB,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function _xe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:a,children:o}){return e?u.jsxs(u.Fragment,{children:[u.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:u.jsx(u9,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),u.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:u.jsx(o9,{ref:r,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),u.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:u.jsx(l9,{ref:a,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),u.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:u.jsx(ywe,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),u.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:u.jsx(yxe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),u.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:u.jsx(Sxe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),u.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:u.jsx(qwe,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state==="ready"})}),t!=="tools"&&t!=="prompts"&&t!=="resources"&&t!=="chat"&&t!=="sampling"&&t!=="elicitation"&&t!=="notifications"&&u.jsx(u.Fragment,{children:o})]}):u.jsx(u.Fragment,{children:o})}function Dz({className:e}){return u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentcolor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[u.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),u.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const d9=y.createContext(void 0);function f9(){const e=y.use(d9);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const p9=y.createContext(void 0);function Txe(){return y.use(p9)}function m_({ref:e,children:t,defaultValue:n,value:r,onValueChange:a,className:o,collapsed:i,onCollapsedChange:c,...d}){const[f,m]=y.useState(n||""),h=r!==void 0,g=i!==void 0,[v,E]=y.useState(!1),x=y.useCallback(T=>{h||m(T),a?.(T)},[h,a]),w=h?r:f,S=g?i:v,_=y.useCallback(T=>{g||E(T),c?.(T)},[g,c]);return u.jsx(d9,{value:{activeValue:w,handleValueChange:x,collapsed:S,handleCollapsedChange:_},children:u.jsx("div",{ref:e,className:Oe("flex flex-col gap-2",o),...d,children:t})})}m_.displayName="Tabs";function h_({ref:e,children:t,className:n,variant:r="default",collapsible:a=!1,...o}){const{activeValue:i,collapsed:c,handleCollapsedChange:d}=f9(),[f,m]=y.useState({width:0,left:0}),h=y.useRef(null),g=y.useRef(null),v=y.useRef(null),E=y.useCallback(()=>{const S=h.current;if(!S)return;const _=S.querySelector("div:first-child");if(!_)return;const T=_.querySelector(`button[data-tab-value="${i}"]`);if(T&&i){const R=_.getBoundingClientRect(),C=T.getBoundingClientRect();m({width:C.width,left:C.left-R.left})}else m({width:0,left:0})},[i]),x=y.useCallback(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(E,16)},[E]);y.useEffect(()=>{const S=setTimeout(E,10);return()=>clearTimeout(S)},[E,c]),y.useEffect(()=>{const S=h.current;if(!S)return;g.current=new ResizeObserver(()=>{x()}),g.current.observe(S);const _=S.querySelector("div:first-child");return _&&_.querySelectorAll("button[data-tab-value]").forEach(R=>{g.current&&g.current.observe(R)}),()=>{g.current&&g.current.disconnect(),v.current&&clearTimeout(v.current)}},[x]),y.useEffect(()=>{const S=()=>{x()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[x]);const w=y.useRef(null);return y.useEffect(()=>{w.current&&(w.current.style.width=`${f.width}px`,w.current.style.left=`${f.left}px`)},[f]),u.jsx(p9,{value:{variant:r,collapsed:c,handleCollapsedChange:d},children:u.jsx("div",{ref:h,className:Oe("relative flex items-center bg-none gap-1",r==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",r==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...o,children:u.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,u.jsx("span",{ref:w,className:Oe("absolute transition-all duration-500 ease-in-out z-0",r==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",r==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}h_.displayName="TabsList";const Nxe=({children:e,title:t,collapsed:n})=>!t||!n?e:u.jsx(TT,{children:u.jsxs(At,{children:[u.jsx(It,{children:e}),u.jsx(Ot,{children:t})]})}),g_=y.forwardRef(({children:e,value:t,className:n,disabled:r,icon:a,title:o,showDot:i=!1,...c},d)=>{const{activeValue:f,handleValueChange:m,collapsed:h}=f9(),v=Txe()?.variant||"default",E=f===t,x=h&&o?o:void 0;return u.jsx(Nxe,{title:o,collapsed:h,children:u.jsxs("button",{ref:d,disabled:r,onClick:()=>m(t),"data-tab-value":t,"data-tab-active":E,role:"tab","aria-selected":E?"true":"false",title:x,className:Oe("relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-all duration-500 ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer",v==="default"&&"py-2.5",v==="default"&&"rounded-md px-4",v==="underline"&&"px-6 py-3 border-b-2 border-transparent",E&&"text-foreground",!E&&"text-muted-foreground hover:text-foreground",n),...c,children:[a&&u.jsx(a,{className:Oe("h-4 w-4 transition-all duration-500 ease-in-out",!h&&"mr-2",h&&"mr-0!")}),i&&u.jsx("span",{className:"absolute top-1.5 right-1.5 w-2 h-2 bg-orange-500 dark:bg-orange-400 border-2 border-white dark:border-zinc-900 rounded-full transition-opacity duration-300 z-10 animate-status-pulse-orange"}),u.jsx("span",{className:Oe("transition-all duration-500 ease-in-out overflow-hidden",h?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});g_.displayName="TabsTrigger";function Lz({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:r="",onSuccess:a,onError:o,trigger:i}){const[c,d]=y.useState(!1),[f,m]=y.useState(null),[h,g]=y.useState(!1),{url:v,name:E,headers:x}=e,w=()=>{try{const L=s6(v,E,x);window.location.href=L,a?.("Cursor")}catch(L){console.error("Failed to generate Cursor deep link:",L),o?.(L)}},S=()=>{try{const L=o6(v,E,x);window.location.href=L,a?.("VS Code")}catch(L){console.error("Failed to generate VS Code deep link:",L),o?.(L)}},_=()=>{try{i6(v,E,x),a?.("Claude Desktop")}catch(L){console.error("Failed to download .mcpb file:",L),o?.(L)}},T=()=>{m("claude-code"),d(!0)},R=()=>{m("gemini-cli"),d(!0)},C=()=>{m("codex-cli"),d(!0)},A=async L=>{try{await navigator.clipboard.writeText(L),g(!0),setTimeout(()=>g(!1),2e3)}catch($){console.error("Failed to copy:",$),o?.($)}},I=()=>{if(f==="claude-code"){const{command:L,envVars:$}=l6(v,E,x),H=SU($);return u.jsxs(u.Fragment,{children:[u.jsxs(Ws,{children:[u.jsx(Ks,{children:"Add to Claude Code"}),u.jsx(ep,{children:"Execute the following command in your shell to add this server to Claude Code."})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),u.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"1."}),u.jsx("span",{children:"Ensure the Claude Code executable is available in your path"})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"2."}),u.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{className:"absolute top-2 right-2 z-10",children:u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})}),u.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:L})})]}),H&&u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"After installation, set these environment variables in your shell:"}),u.jsx("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:H})})]}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["The MCP configuration supports environment variable expansion using ",u.jsx("code",{className:"text-foreground",children:"${VAR}"})," ","syntax."]})]})]})}if(f==="gemini-cli"){const{command:L,envVars:$}=c6(v,E,x),H=SU($);return u.jsxs(u.Fragment,{children:[u.jsxs(Ws,{children:[u.jsx(Ks,{children:"Add to Gemini CLI"}),u.jsx(ep,{children:"Execute the following command in your shell to add this server to Gemini CLI."})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),u.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"1."}),u.jsx("span",{children:"Ensure the Gemini CLI executable is available in your path"})]}),H&&u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"2."}),u.jsx("span",{children:"Set these environment variables in your shell before running the command:"})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:H?"3.":"2."}),u.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),H&&u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),u.jsx("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:H})})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{className:"absolute top-2 right-2 z-10",children:u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})}),u.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:L})})]}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Gemini CLI to load the new configuration."})]})]})}if(f==="codex-cli"){const{config:L,envVars:$}=u6(v,E,x);return u.jsxs(u.Fragment,{children:[u.jsxs(Ws,{children:[u.jsx(Ks,{children:"Add to Codex CLI"}),u.jsxs(ep,{children:["Add this configuration to your"," ",u.jsx("code",{className:"text-foreground",children:"~/.codex/config.toml"})," ","file."]})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Add this configuration to your"," ",u.jsx("code",{className:"text-foreground",children:"~/.codex/config.toml"}),":"]})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{className:"absolute top-2 right-2 z-10",children:u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})}),u.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:L})})]}),$.length>0&&u.jsx("div",{children:u.jsxs("p",{className:"text-xs text-muted-foreground",children:["(optional) If you would rather use variables from your system's environment, replace the"," ",u.jsx("code",{className:"text-foreground",children:"http_headers"})," key with the ",u.jsx("code",{className:"text-foreground",children:"env_http_headers"})," ","key as shown in the commented section above."]})}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Codex CLI to load the new configuration."})]})]})}return null},O=u.jsxs(Ae,{variant:"ghost",className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${r}`,children:[u.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[u.jsx(Np,{className:"size-3"}),"Client"]}),u.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",u.jsx(Qs,{className:"size-3"})]})]}),U=i?typeof i=="function"?i({isOpen:!1,onClick:()=>{}}):i:O;return u.jsxs(u.Fragment,{children:[u.jsxs(Xb,{children:[u.jsx(Jb,{asChild:!0,children:U}),u.jsxs(wp,{align:"end",className:"w-auto min-w-[300px]",children:[t.map(L=>u.jsxs(Vr,{onClick:async()=>{await L.onClick()},className:"flex items-center gap-2",children:[L.icon,u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:L.label})]},L.id)),t.length>0&&u.jsx(ru,{}),n.cursor&&u.jsxs(Vr,{onClick:w,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Cursor"})]}),n.claudeCode&&u.jsxs(Vr,{onClick:T,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Code"})]}),n.claudeDesktop&&u.jsxs(Vr,{onClick:_,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Desktop"})]}),n.vsCode&&u.jsxs(Vr,{onClick:S,className:"flex items-center gap-2",children:[u.jsx(a6,{className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code"})]}),n.geminiCli&&u.jsxs(Vr,{onClick:R,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Gemini CLI"})]}),n.codexCli&&u.jsxs(Vr,{onClick:C,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://inspector-cdn.mcp-use.com/providers/openai.png",alt:"Codex",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Codex CLI"})]})]})]}),u.jsx(Li,{open:c,onOpenChange:d,children:u.jsx(Mi,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:I()})})]})}function Mz({className:e}){const{theme:t,setTheme:n}=Sv(),r=y.useRef(null),[a,o]=y.useState(!1);y.useEffect(()=>{o(!0)},[]);const i=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?u.jsx(LP,{className:"size-4"}):t==="light"?u.jsx(qie,{className:"size-5"}):u.jsx(Aie,{className:"size-4"}),d=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",f=async()=>{if(!r.current)return;const m=i();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{bd.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:E}=r.current.getBoundingClientRect(),x=h+E/2,w=g+v/2,S=window.innerWidth-g,_=window.innerHeight-h,T=Math.hypot(Math.max(g,S),Math.max(h,_));document.documentElement.animate({clipPath:[`circle(0px at ${w}px ${x}px)`,`circle(${T}px at ${w}px ${x}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return a?u.jsx("button",{ref:r,onClick:f,className:Oe(e),"aria-label":d(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):u.jsx("button",{ref:r,className:Oe(e),"aria-label":"Toggle theme",children:u.jsx(LP,{className:"size-4"})})}function jz({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[r,a]=y.useState(!1),o=.2,i=.7,c=.6,d=4,f=o+i+c,m=0,h=o/f,g=(o+i)/f,v=1;return u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Oe("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx("div",{className:"relative",children:u.jsxs(Ca.svg,{viewBox:"0 0 303 303",initial:"rest",animate:r?"hover":"rest",className:Oe("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[u.jsxs(Ca.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:f,times:[m,h,g,v],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:d,strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z"}),u.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),u.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),u.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:d,strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx(kxe,{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z",times:{T0:m,T1:h,T2:g,T3:v},total:f}),u.jsx(Pz,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f}),u.jsx(Pz,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f})]})]})}),t==="expanded"&&u.jsxs("div",{className:"font-ubuntu flex-col items-start -space-y-1 mr-3 hidden xl:flex",children:[u.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),u.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function kxe({d:e,times:t,total:n}){const{T0:r,T1:a,T2:o,T3:i}=t;return u.jsx(Ca.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,a,o,i],ease:"easeInOut"}}}})}function Pz({cx:e,cy:t,r:n,times:r,total:a}){const{T0:o,T1:i,T2:c,T3:d}=r;return u.jsx(Ca.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:a,times:[o,i,c,d],ease:"easeInOut"}}}})}function Qg({open:e,onOpenChange:t,serverUrl:n,serverName:r,serverId:a,headers:o,language:i}){const{prismStyle:c}=GA(),[d,f]=y.useState(!1),m=i==="typescript"?wbe(n,r,a,o):xbe(n,r,a,o),h=async()=>{await navigator.clipboard.writeText(m),f(!0),setTimeout(()=>f(!1),2e3)},g=i==="typescript"?"TypeScript":"Python",v=i==="typescript"?"npm install mcp-use":"pip install mcp-use";return u.jsx(Li,{open:e,onOpenChange:t,children:u.jsxs(Mi,{className:"max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsxs(Ws,{children:[u.jsxs(Ks,{children:["Add to ",g," SDK"]}),u.jsxs(ep,{children:["Copy the following code to integrate this server into your"," ",g," application using the mcp-use SDK."]})]}),u.jsxs("div",{className:"space-y-4 overflow-y-auto flex-1 min-h-0",children:[u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),u.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"1."}),u.jsxs("span",{children:["Install the mcp-use package:"," ",u.jsx("code",{className:"text-foreground",children:v})]})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"2."}),u.jsxs("span",{children:["Copy the following code into your ",g," project:"]})]})]})]}),u.jsxs("div",{className:"relative w-full overflow-x-auto overflow-y-auto max-h-[60vh]",children:[u.jsx("div",{className:"absolute top-2 right-2 z-10",children:u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:h,children:d?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})}),u.jsx(Ip,{language:i,style:c,customStyle:{margin:0,padding:"1rem",paddingRight:"3rem",borderRadius:"0.5rem",fontSize:"0.75rem",background:"var(--muted)",width:"100%",maxWidth:"100%",overflow:"auto"},wrapLines:!0,wrapLongLines:!0,PreTag:"div",children:m})]})]})]})})}function m9({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:r="3s",borderRadius:a="100px",background:o,className:i,children:c,...d}){const{resolvedTheme:f}=Sv(),m=f==="dark"?"#000000":"#ffffff",h=f==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=o||h;return u.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":a,"--speed":r,"--cut":n,"--bg":v},className:Oe("group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]","transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px",f==="dark"?"border-black/10 text-black":"border-white/10 text-white",i),ref:e,...d,children:[u.jsx("div",{className:Oe("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:u.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:u.jsx("div",{className:"animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]"})})}),c,u.jsx("div",{className:Oe("absolute inset-0 size-full","rounded-2xl px-4 py-1.5 text-sm font-medium","transform-gpu transition-all duration-300 ease-in-out",f==="dark"?"shadow-[inset_0_-8px_10px_#0000001f] group-hover:shadow-[inset_0_-6px_10px_#0000003f] group-active:shadow-[inset_0_-10px_10px_#0000003f]":"shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]")}),u.jsx("div",{className:Oe("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}m9.displayName="ShimmerButton";function $z({status:e}){const t=o=>{switch(o){case"ready":return{color:"bg-emerald-500",ringColor:"ring-emerald-500",tooltip:"Connected"};case"failed":return{color:"bg-red-500",ringColor:"ring-red-500",tooltip:"Failed"};default:return{color:"bg-yellow-500",ringColor:"ring-yellow-500",tooltip:o}}},{color:n,ringColor:r,tooltip:a}=t(e);return u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsxs("div",{className:"relative",children:[u.jsx("div",{className:`absolute w-2 h-2 rounded-full ${r} animate-ping`}),u.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),u.jsx(Ot,{children:u.jsx("p",{children:a})})]})}function Uz({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:r,mobileMode:a=!1}){const o=Nd(),[i,c]=y.useState(!1),[d,f]=y.useState(null),m=h=>{const g=e.find(v=>v.id===h);if(!g||g.state!=="ready"){pt.error("Server is not connected and cannot be inspected");return}n(h)};return a?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"relative",children:u.jsxs(Xb,{children:[u.jsx(Jb,{asChild:!0,children:u.jsxs(Ae,{variant:"ghost",className:"h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5",children:[t?u.jsx(uu,{server:t,size:"md"}):u.jsx(MB,{className:"h-5 w-5"}),u.jsx(Qs,{className:"h-4 w-4"})]})}),u.jsxs(wp,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[u.jsx(JE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>o("/"),children:"MCP Servers"}),u.jsx(ru,{}),e.length===0?u.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(h=>u.jsxs(Vr,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[u.jsx(uu,{server:h,size:"sm"}),u.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[u.jsx("div",{className:"font-medium",children:h.name}),u.jsx($z,{status:h.state})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),f(h),c(!0)},children:u.jsx(Qf,{className:"h-3 w-3"})}),u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),r(h.id)},children:u.jsx(yu,{className:"h-3 w-3"})})]})]},h.id)),u.jsx(ru,{}),u.jsx(Vr,{onClick:()=>o("/"),children:u.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})}),u.jsx(wS,{open:i,onOpenChange:c,connection:d})]}):u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("div",{className:"relative",children:[u.jsxs(Xb,{children:[u.jsx(Jb,{asChild:!0,children:u.jsxs(m9,{className:Oe("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-20"),children:[t&&u.jsx(uu,{server:t,size:"md",className:"mr-2"}),u.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[u.jsx("span",{className:"truncate lg:max-w-[120px] xl:max-w-none",children:t?t.serverInfo?.title||t.serverInfo?.name||t.name:"Select server to inspect"}),t&&u.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx("button",{onClick:h=>{h.stopPropagation()},className:"w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors",title:"Click to copy error message","aria-label":"Copy error message to clipboard"})}),u.jsx(Ot,{children:u.jsx("p",{className:"max-w-xs",children:t.error})})]}):u.jsx("div",{className:`w-2 h-2 rounded-full ${t.state==="ready"?"bg-emerald-600 animate-status-pulse":t.state==="failed"?"bg-rose-600 animate-status-pulse-red":"bg-yellow-500 animate-status-pulse-yellow"}`})})]})]})}),t&&u.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx("button",{type:"button",onClick:()=>{f(t),c(!0)},className:"p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"View server info",children:u.jsx(Qf,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:u.jsx("p",{children:"View server info"})})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx("button",{type:"button",onClick:()=>{r(t.id)},className:"p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"Edit connection settings",children:u.jsx(yu,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:u.jsx("p",{children:"Edit connection settings"})})]})]}),u.jsxs(wp,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[u.jsx(JE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>o("/"),children:"MCP Servers"}),u.jsx(ru,{}),e.length===0?u.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(h=>u.jsxs(Vr,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[u.jsx(uu,{server:h,size:"sm"}),u.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[u.jsx("div",{className:"font-medium",children:h.serverInfo?.title||h.serverInfo?.name||h.name}),u.jsx($z,{status:h.state})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),f(h),c(!0)},children:u.jsx(Qf,{className:"h-3 w-3"})}),u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),r(h.id)},children:u.jsx(yu,{className:"h-3 w-3"})})]})]},h.id)),u.jsx(ru,{}),u.jsx(Vr,{onClick:()=>o("/"),children:u.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]}),u.jsx(wS,{open:i,onOpenChange:c,connection:d})]})})}const zz=[{id:"tools",label:"Tools",icon:Ul},{id:"prompts",label:"Prompts",icon:Tp},{id:"resources",label:"Resources",icon:fie},{id:"sampling",label:"Sampling",icon:IB},{id:"elicitation",label:"Elicitation",icon:jB},{id:"notifications",label:"Notifications",icon:NT},{id:"chat",label:"Chat",icon:Tie}];function Fz(e,t){return e==="tools"?t.tools.length:e==="prompts"?t.prompts.length:e==="resources"?t.resources.length:e==="sampling"?t.pendingSamplingRequests?.length||0:e==="elicitation"?t.pendingElicitationRequests?.length||0:e==="notifications"?t.unreadNotificationCount:0}function Bz(e,t,n){const r=["sampling","elicitation","notifications"];return n&&t>0&&r.includes(e)}function Cxe({collapsed:e,onToggle:t}){return u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx("button",{onClick:t,className:Oe("shrink-0 p-1.5 rounded-md transition-all duration-500 ease-in-out cursor-pointer","text-muted-foreground hover:text-foreground","hover:bg-zinc-100 dark:hover:bg-zinc-800","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),"aria-label":e?"Expand tabs":"Collapse tabs",type:"button",children:e?u.jsx(RB,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):u.jsx(ov,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),u.jsx(Ot,{children:u.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function Rxe({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:a,onCommandPaletteOpen:o,onOpenConnectionOptions:i,embedded:c=!1}){const{tunnelUrl:d}=Ql(),f=t&&d,[m,h]=y.useState(!1),[g,v]=y.useState(!1),[E,x]=y.useState(!1),[w,S]=y.useState(!0),_=async()=>{if(d)try{await navigator.clipboard.writeText(`${d}/mcp`),h(!0),pt.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{pt.error("Failed to copy URL")}};return u.jsxs("header",{className:"w-full mx-auto",children:[u.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center justify-between w-full",children:[!c&&u.jsx("div",{className:"flex-1 flex justify-start",children:u.jsx(Uz,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:i,mobileMode:!0})}),!c&&u.jsx("div",{className:"flex-shrink-0 flex justify-center",children:u.jsx("div",{className:"scale-150",children:u.jsx(jz,{state:"collapsed"})})}),!c&&u.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[t&&(()=>{const T=t.serverInfo?.title||t.serverInfo?.name||t.name;return u.jsxs(u.Fragment,{children:[u.jsx(Lz,{serverConfig:{url:d?`${d}/mcp`:t.url,name:T,headers:t.customHeaders,serverId:t.id},onSuccess:R=>pt.success(`Opening in ${R}...`),onError:R=>pt.error(`Failed: ${R.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:u.jsx("img",{src:"https://cdn.simpleicons.org/typescript",alt:"TypeScript",className:"h-4 w-4"}),onClick:()=>v(!0)},{id:"py-sdk",label:"Python SDK",icon:u.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:u.jsxs(Ae,{variant:"ghost",className:"bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center p-2","aria-label":"Add to Client",children:[u.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[u.jsx(Np,{className:"size-3"}),"Client"]}),u.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",u.jsx(Qs,{className:"size-3"})]})]})}),u.jsx(Qg,{open:g,onOpenChange:v,serverUrl:d?`${d}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"typescript"}),u.jsx(Qg,{open:E,onOpenChange:x,serverUrl:d?`${d}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",asChild:!0,children:u.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:u.jsx(Dz,{className:"h-4 w-4"})})})}),u.jsx(Ot,{children:u.jsx("p",{children:"Give us a star ⭐"})})]}),u.jsx(Mz,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&u.jsx("div",{className:"w-full",children:u.jsx(m_,{value:n,onValueChange:T=>a(T),collapsed:w,onCollapsedChange:S,children:u.jsx(h_,{className:"w-full justify-center",children:zz.map(T=>{const R=Fz(T.id,t),C=Bz(T.id,R,w);return u.jsxs(g_,{value:T.id,icon:T.icon,showDot:C,className:Oe("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",w&&"pl-2"),children:[R>0&&!w&&u.jsx("span",{className:Oe(n===T.id?"dark:bg-black":"dark:bg-zinc-700","bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 rounded-full font-medium"),children:R}),u.jsx("span",{className:"sr-only",children:T.label})]},T.id)})})})})]}),u.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[!c&&u.jsx(Uz,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:i}),t&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(m_,{value:n,onValueChange:T=>a(T),collapsed:w,onCollapsedChange:S,children:u.jsx(h_,{className:"overflow-x-auto",collapsible:!0,children:zz.map(T=>{const R=Fz(T.id,t),C=R>0?`${T.label} (${R})`:T.label,A=Bz(T.id,R,w);return u.jsx(g_,{value:T.id,icon:T.icon,showDot:A,className:Oe("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",w&&"pl-4"),title:C,children:u.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[T.label,R>0&&u.jsx("span",{className:Oe(n===T.id?" dark:bg-black ":"dark:bg-zinc-700","bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-xs px-2 py-0.5 rounded-full font-medium"),children:R})]})})})})}),u.jsx(Cxe,{collapsed:w,onToggle:()=>S(!w)})]}),f&&u.jsxs(C6,{children:[u.jsx(R6,{asChild:!0,children:u.jsxs("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-500/10 to-pink-500/10 dark:from-purple-500/20 dark:to-pink-500/20 border border-purple-500/30 dark:border-purple-500/40 rounded-full hover:from-purple-500/20 hover:to-pink-500/20 dark:hover:from-purple-500/30 dark:hover:to-pink-500/30 transition-colors cursor-pointer",children:[u.jsx(kp,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),u.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),u.jsx(k1,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[u.jsx(kp,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),u.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[u.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[d,"/mcp"]}),u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:_,children:m?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})]})]}),u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),u.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"1."}),u.jsxs("span",{children:["Enable"," ",u.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"2."}),u.jsxs("span",{children:["In"," ",u.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",u.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"3."}),u.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),!c&&u.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[t&&(()=>{const T=t.serverInfo?.title||t.serverInfo?.name||t.name;return u.jsxs(u.Fragment,{children:[u.jsx(Lz,{serverConfig:{url:d?`${d}/mcp`:t.url,name:T,headers:t.customHeaders,serverId:t.id},onSuccess:R=>pt.success(`Opening in ${R}...`),onError:R=>pt.error(`Failed: ${R.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:u.jsx("img",{src:"https://cdn.simpleicons.org/typescript",alt:"TypeScript",className:"h-4 w-4"}),onClick:()=>v(!0)},{id:"py-sdk",label:"Python SDK",icon:u.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:u.jsxs(Ae,{variant:"ghost",className:"bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center","aria-label":"Add to Client",children:[u.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[u.jsx(Np,{className:"size-3"}),"Client"]}),u.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",u.jsx(Qs,{className:"size-3"})]})]})}),u.jsx(Qg,{open:g,onOpenChange:v,serverUrl:d?`${d}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"typescript"}),u.jsx(Qg,{open:E,onOpenChange:x,serverUrl:d?`${d}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),u.jsxs(At,{children:[u.jsx(It,{children:u.jsx(Mz,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),u.jsx(Ot,{children:u.jsx("p",{children:"Toggle theme"})})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsxs(Ae,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:o,children:[u.jsx(Zoe,{className:"size-4"}),u.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),u.jsx(Ot,{children:u.jsx("p",{children:"Command Palette"})})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",asChild:!0,children:u.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[u.jsx(Dz,{className:"h-4 w-4"}),u.jsx("span",{className:"hidden xl:inline",children:"Github"})]})})}),u.jsx(Ot,{children:u.jsx("p",{children:"Give us a star ⭐"})})]}),u.jsx(jz,{state:"expanded"})]})]})]})}function Axe({children:e}){const t=Nd(),n=Go(),{servers:r,addServer:a,removeServer:o,updateServer:i,storageLoaded:c}=tm(),d=y.useCallback((D,j,V,W)=>{a(D,{url:D,name:j,proxyConfig:V,transportType:W})},[a]),f=y.useCallback(async(D,j)=>{try{await i(D,j)}catch(V){console.error(`[Layout] Failed to update connection ${D}:`,V)}},[i]),{selectedServerId:m,setSelectedServerId:h,activeTab:g,setActiveTab:v,navigateToItem:E,setTunnelUrl:x,tunnelUrl:w,isEmbedded:S,embeddedConfig:_,setEmbeddedMode:T}=Ql(),[R,C]=y.useState(!1),[A,I]=y.useState(null),O=Kge();y.useEffect(()=>{const D=new URLSearchParams(n.search),j=D.get("embedded")==="true",V=D.get("embeddedConfig");if(j){let W={};if(V)try{W=JSON.parse(V)}catch(te){console.error("Failed to parse embeddedConfig:",te)}T(!0,W)}},[]),y.useEffect(()=>{const j=new URLSearchParams(n.search).get("tunnelUrl");x(j)},[n.search,x]),y.useEffect(()=>{const j=new URLSearchParams(n.search).get("tab");j&&["tools","prompts","resources","chat","sampling","elicitation","notifications"].includes(j)&&v(j)},[n.search,v]),y.useEffect(()=>{const D=W=>{const de=W.detail.requestId;m&&E(m,"sampling",de)},j=W=>{const de=W.detail.requestId;m&&E(m,"elicitation",de)},V=W=>{const de=W.detail.toolName;m&&de?E(m,"tools",de):m&&v("tools")};return window.addEventListener("navigate-to-sampling",D),window.addEventListener("navigate-to-elicitation",j),window.addEventListener("navigate-to-tool-result",V),()=>{window.removeEventListener("navigate-to-sampling",D),window.removeEventListener("navigate-to-elicitation",j),window.removeEventListener("navigate-to-tool-result",V)}},[m,v,E]);const U=y.useRef(null),L=y.useRef(null),$=y.useRef(null),{isAutoConnecting:H}=Wge({connections:r,addConnection:d,removeConnection:o,configLoaded:c,embedded:S}),Y=y.useCallback(D=>{Zr.getInstance().capture(new hoe({trigger:D})).catch(()=>{}),C(!0)},[]),q=D=>{const j=r.find(fe=>fe.id===D);if(!j||j.state!=="ready"){pt.error("Server is not connected and cannot be inspected");return}h(D);const V=new URLSearchParams(n.search),W=V.get("tunnelUrl"),te=V.get("tab"),de=new URLSearchParams;de.set("server",D),W&&de.set("tunnelUrl",W),te&&de.set("tab",te),t(`/?${de.toString()}`)},ne=y.useCallback(D=>{I(D)},[]),G=y.useCallback(D=>{A&&(D.url!==A?(o(A),d(D.url,D.name,D.proxyConfig,D.transportType)):f(A,{name:D.name,proxyConfig:D.proxyConfig,transportType:D.transportType}),I(null),pt.success("Connection settings updated"))},[A,o,d,f]),K=(D,j,V)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:D,itemName:j,serverId:V}),V){const W=r.find(se=>se.id===V);if(console.warn("[Layout] Server lookup:",{serverId:V,serverFound:!!W,serverState:W?.state}),!W||W.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),pt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:V,tab:D,itemName:j}),E(V,D,j);const te=new URLSearchParams(n.search),de=te.get("tunnelUrl"),fe=te.get("tab"),J=new URLSearchParams;J.set("server",V),de&&J.set("tunnelUrl",de),D?J.set("tab",D):fe&&J.set("tab",fe);const Q=`/?${J.toString()}`;console.warn("[Layout] Navigating to:",Q),t(Q)}else console.warn("[Layout] No serverId, just updating tab to:",D),v(D)},F=r.find(D=>D.id===m),re=F?F.tools.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.tools.map(j=>({...j,_serverId:D.id,_serverName:D.name})):[]),ee=F?F.prompts.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.prompts.map(j=>({...j,_serverId:D.id,_serverName:D.name})):[]),M=F?F.resources.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.resources.map(j=>({...j,_serverId:D.id,_serverName:D.name})):[]);if(y.useEffect(()=>{const j=new URLSearchParams(n.search).get("server"),V=j?decodeURIComponent(j):null;V!==m&&h(V)},[n.search,m,h]),y.useEffect(()=>{const j=new URLSearchParams(n.search).get("server");if(!j)return;const V=decodeURIComponent(j),W=r.find(te=>te.id===V);if(!W){const te=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(te)}if(W.state==="failed"){const te=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(te)}},[n.search,t,r]),ZV({onCommandPalette:()=>Y("keyboard"),onToolsTab:()=>{F&&v("tools")},onPromptsTab:()=>{F&&v("prompts")},onResourcesTab:()=>{F&&v("resources")},onChatTab:()=>{F&&v("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{g==="tools"&&U.current?U.current.focusSearch():g==="prompts"&&L.current?L.current.focusSearch():g==="resources"&&$.current&&$.current.focusSearch()},onBlurSearch:()=>{g==="tools"&&U.current?U.current.blurSearch():g==="prompts"&&L.current?L.current.blurSearch():g==="resources"&&$.current&&$.current.blurSearch()}}),H)return u.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:u.jsxs("div",{className:"flex flex-col items-center gap-4",children:[u.jsx(eo,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),u.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})});const B=S?{backgroundColor:_.backgroundColor||"#f3f3f3",padding:_.padding||"0.5rem"}:{},P=S?"h-screen flex flex-col gap-2 sm:gap-4":"h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-2 py-2 sm:px-4 sm:py-4 gap-2 sm:gap-4";return u.jsx(TT,{children:u.jsxs("div",{className:P,style:B,children:[u.jsx(Rxe,{connections:r,selectedServer:F,activeTab:g,onServerSelect:q,onTabChange:v,onCommandPaletteOpen:()=>Y("button"),onOpenConnectionOptions:ne,embedded:S}),u.jsx("main",{className:"flex-1 w-full mx-auto bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 p-0 overflow-auto",children:u.jsx(_xe,{selectedServer:F,activeTab:g,toolsSearchRef:U,promptsSearchRef:L,resourcesSearchRef:$,children:e})}),u.jsx(Sbe,{isOpen:R,onOpenChange:C,tools:re,prompts:ee,resources:M,savedRequests:O,connections:r,selectedServer:F,tunnelUrl:w,onNavigate:K,onServerSelect:q}),u.jsx(pH,{connection:A&&r.find(D=>D.id===A)||null,open:A!==null,onOpenChange:D=>{D||I(null)},onConnect:G})]})})}function Ixe(){const[e,t]=y.useState("processing"),[n,r]=y.useState("");return y.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),J_().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(a=>{console.error("[OAuthCallback] Authorization failed:",a),t("error"),r(a instanceof Error?a.message:String(a))})},[]),e==="processing"?u.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:u.jsxs("div",{className:"flex flex-col items-center gap-4",children:[u.jsx(Bi,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),u.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?u.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:u.jsxs("div",{className:"max-w-md p-6",children:[u.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),u.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),u.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):u.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:u.jsxs("div",{className:"max-w-md p-6",children:[u.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),u.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var Oxe=(e,t,n,r,a,o,i,c)=>{let d=document.documentElement,f=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(E=>{let x=E==="class",w=x&&o?a.map(S=>o[S]||S):a;x?(d.classList.remove(...w),d.classList.add(o&&o[v]?o[v]:v)):d.setAttribute(E,v)}),h(v)}function h(v){c&&f.includes(v)&&(d.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)m(r);else try{let v=localStorage.getItem(t)||n,E=i&&v==="system"?g():v;m(E)}catch{}},Dxe=y.createContext(void 0),Lxe={setTheme:e=>{},themes:[]},Mxe=()=>{var e;return(e=y.useContext(Dxe))!=null?e:Lxe};y.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:a,defaultTheme:o,value:i,themes:c,nonce:d,scriptProps:f})=>{let m=JSON.stringify([n,t,o,e,c,i,r,a]).slice(1,-1);return y.createElement("script",{...f,suppressHydrationWarning:!0,nonce:typeof window>"u"?d:"",dangerouslySetInnerHTML:{__html:`(${Oxe.toString()})(${m})`}})});function jxe({...e}){const{theme:t="system"}=Mxe();return u.jsx(eue,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Pxe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true",n=y.useMemo(()=>t?void 0:new Eee("mcp-inspector-connections"),[t]);return u.jsx(afe,{children:u.jsx(f4,{storageProvider:n,enableRpcLogging:!0,onServerAdded:(r,a)=>{console.log("[Inspector] Server added:",r,a.state)},onServerRemoved:r=>{console.log("[Inspector] Server removed:",r)},onServerStateChange:(r,a)=>{console.log("[Inspector] Server state changed:",r,a)},onSamplingRequest:(r,a,o,i,c)=>{const d=pt(u.jsx(bxe,{requestId:r.id,serverName:o,onViewDetails:()=>{const f=new CustomEvent("navigate-to-sampling",{detail:{requestId:r.id}});window.dispatchEvent(f),pt.dismiss(d)},onApprove:f=>{i(r.id,f),pt.success("Sampling request approved"),pt.dismiss(d)},onDeny:()=>{c(r.id,"User denied from toast"),pt.dismiss(d)}}),{duration:1/0})},onElicitationRequest:(r,a,o,i,c)=>{const d=r.request.mode||"form",f=r.request.message,m=d==="url"&&"url"in r.request?r.request.url:void 0,h=pt(u.jsx(vxe,{requestId:r.id,serverName:o,mode:d,message:f,url:m,onViewDetails:()=>{const g=new CustomEvent("navigate-to-elicitation",{detail:{requestId:r.id}});window.dispatchEvent(g),pt.dismiss(h)},onOpenUrl:d==="url"&&m?()=>{window.open(m,"_blank"),pt.dismiss(h)}:void 0,onCancel:()=>{c(r.id,"User cancelled from toast"),pt.dismiss(h)}}),{duration:1/0})},children:u.jsxs(Gge,{children:[u.jsx(yce,{basename:"/inspector",children:u.jsxs(Zle,{children:[u.jsx(aS,{path:"/oauth/callback",element:u.jsx(Ixe,{})}),u.jsx(aS,{path:"/",element:u.jsx(Axe,{children:u.jsx(Vge,{})})})]})}),u.jsx(jxe,{position:"top-center"})]})})})}const Hz=new URLSearchParams(window.location.search);if(Hz.has("code")||Hz.has("error"))try{J_()}catch(e){console.error("[inspector] OAuth callback error:",e)}const Vz=document.getElementById("root");Vz?Aee.createRoot(Vz).render(u.jsx(Pxe,{})):console.error("[inspector] Root element not found");const $xe=Object.freeze(Object.defineProperty({__proto__:null,clearRpcLogs:Bb,getAllRpcLogs:tT,getRpcLogs:p4,subscribeToRpcLogs:nT,wrapTransportForLogging:m4},Symbol.toStringTag,{value:"Module"}));export{LK as $,$f as A,oJ as B,Aj as C,Gxe as D,Wi as E,LY as F,GK as G,uee as H,eW as I,nb as J,rW as K,DY as L,oee as M,DK as N,Bxe as O,Z7 as P,$i as Q,ie as R,tq as S,Bs as T,Q2 as U,Vn as V,eY as W,r2 as X,B7 as Y,Nq as Z,De as _,pa as a,ob as a0,R7 as a1,dee as a2,A7 as a3,J_ as a4,H7 as a5,pd as b,Yp as c,iee as d,Ny as e,Fxe as f,zxe as g,lee as h,Ke as i,Bn as j,Sq as k,Le as l,dt as m,En as n,qe as o,Hxe as p,nF as q,y as r,le as s,Kxe as t,tr as u,Va as v,Gn as w,Wxe as x,Vxe as y,nr as z};
|
|
1753
|
+
`),ce.document.close())}},[E]),vt=y.useCallback(()=>{W?(he.current&&he.current.expand(),Ne.current&&Ne.current.expand(),te(!1)):(he.current&&he.current.collapse(),Ne.current&&Ne.current.collapse(),te(!0))},[W]),Ge=y.useCallback(()=>{i&&(ne(""),Y(!0))},[i]),wn=y.useCallback(()=>{if(!i)return;const Fe={id:`${Date.now()}-${Math.random()}`,name:q.trim()||`${i.name} - ${new Date().toLocaleString()}`,toolName:i.name,args:g,savedAt:Date.now(),serverId:i._serverId,serverName:i._serverName};ot([...L,Fe]),Zr.getInstance().capture(new goe({toolName:i.name,serverId:a})).catch(()=>{}),Y(!1),ne("")},[i,q,g,L,ot,a]),pn=y.useCallback(Fe=>{ot(L.filter(Ue=>Ue.id!==Fe)),d?.id===Fe&&f(null)},[L,ot,d]);return P?u.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[j!=="list"&&u.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[u.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{j==="response"?V("detail"):(c(null),V("list"))},className:"p-0 h-8 w-8",children:u.jsx(ov,{className:"h-4 w-4"})}),u.jsxs("div",{className:"flex items-center text-sm font-medium",children:[u.jsx("button",{onClick:()=>{c(null),V("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),j==="detail"&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),u.jsx("button",{onClick:()=>{V("response")},className:j==="detail"?"text-foreground hover:underline":j==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),j==="response"&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),u.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),u.jsx("div",{className:"flex-1 relative overflow-hidden",children:u.jsxs(Tv,{initial:!1,mode:"popLayout",children:[j==="list"&&u.jsxs(Ca.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:[u.jsx(Iz,{activeTab:O,isSearchExpanded:F,searchQuery:A,filteredToolsCount:Me.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:I,onSearchBlur:we,onTabSwitch:()=>U(O==="tools"?"saved":"tools"),searchInputRef:B}),O==="tools"?u.jsx(Az,{tools:Me,selectedTool:i,onToolSelect:Je,focusedIndex:ee}):u.jsx(_z,{savedRequests:L,selectedRequest:d,onLoadRequest:We,onDeleteRequest:pn,focusedIndex:ee})]},"list"),j==="detail"&&u.jsx(Ca.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:u.jsx(kz,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:Ee,onExecute:oe,onSave:Ge})},"detail"),j==="response"&&u.jsx(Ca.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:u.jsx(Rz,{results:Ve,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:Se,onDelete:Re,onFullscreen:ct,onTogglePreview:()=>K(!G)})},"response")]})}),u.jsx(Tz,{isOpen:H,requestName:q,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:wn,onCancel:()=>Y(!1)})]}):u.jsxs(ha,{direction:"horizontal",className:"h-full",children:[u.jsx(Pn,{ref:he,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:u.jsxs(ha,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[u.jsx(Pn,{defaultSize:75,minSize:30,children:u.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[u.jsx(Iz,{activeTab:O,isSearchExpanded:F,searchQuery:A,filteredToolsCount:Me.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:I,onSearchBlur:we,onTabSwitch:()=>U(O==="tools"?"saved":"tools"),searchInputRef:B}),O==="tools"?u.jsx(Az,{tools:Me,selectedTool:i,onToolSelect:Je,focusedIndex:ee}):u.jsx(_z,{savedRequests:L,selectedRequest:d,onLoadRequest:We,onDeleteRequest:pn,focusedIndex:ee})]})}),u.jsx(_s,{withHandle:!0}),u.jsxs(Pn,{ref:$e,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,style:{minHeight:45},onCollapse:()=>{Q(!0)},onExpand:()=>{Q(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[u.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),J?($e.current?.resize(25),Q(!1)):($e.current?.resize(5),Q(!0))},children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),de>0&&u.jsx(kr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:de}),de>0&&!J&&u.jsx(Ae,{variant:"ghost",size:"sm",onClick:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),Pe.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:u.jsx(Uo,{className:"h-3.5 w-3.5"})})]}),u.jsx(Qs,{className:`h-4 w-4 text-muted-foreground transition-transform ${J?"":"rotate-180"}`})]}),u.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${J?"hidden":""}`,children:u.jsx(aI,{serverIds:[a],onCountChange:fe,onClearRef:Pe})})]})]})}),u.jsx(_s,{withHandle:!0}),u.jsx(Pn,{defaultSize:67,children:u.jsxs(ha,{direction:"vertical",children:[u.jsx(Pn,{ref:Ne,defaultSize:40,collapsible:!0,children:u.jsx(kz,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:Ee,onExecute:oe,onSave:Ge,onCancel:()=>{R&&R.abort()}})}),u.jsx(_s,{withHandle:!0}),u.jsx(Pn,{ref:He,defaultSize:60,children:u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(Rz,{results:Ve,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:Se,onDelete:Re,onFullscreen:ct,onTogglePreview:()=>K(!G),onMaximize:vt,isMaximized:W})})})]})}),u.jsx(Tz,{isOpen:H,requestName:q,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:wn,onCancel:()=>Y(!1)})]})}u9.displayName="ToolsTab";function fxe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onRejectAll:c,searchInputRef:d}){return u.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[u.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?u.jsx(In,{ref:d,placeholder:"Search requests...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):u.jsxs(u.Fragment,{children:[u.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),u.jsx(kr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(Ot,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx(Uo,{className:"h-4 w-4"})})}),u.jsx(Ot,{side:"bottom",children:"Reject all"})]})})]})}function pxe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx(Ed,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):u.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,c)=>{const d=i.request.params?.messages?.length||0,f=i.request.params?.maxTokens;return u.jsx(Qi,{id:`sampling-request-${i.id}`,isSelected:t?.id===i.id,isFocused:r===c,title:u.jsxs("span",{className:"flex items-center gap-3",children:[i.serverName,u.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=a(i.timestamp),h=[];d>0&&h.push(`${d} message${d>1?"s":""}`),f&&h.push(`max ${f} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(i)},i.id)})})}function mxe({llmConfig:e}){const t=y.useRef(null);return{generateResponse:y.useCallback(async({request:r})=>{if(!e)throw new Error("LLM config is not available");const a=r.params||{},o=a.maxTokens,i=a.temperature;a.modelPreferences;const c=a.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!a,messagesCount:c.length,messages:c,params:a}),c.length===0)throw new Error("No messages found in sampling request");const d=[],{HumanMessage:f,AIMessage:m}=await pa(async()=>{const{HumanMessage:E,AIMessage:x}=await import("./index-DdrkmeYH.js").then(w=>w.bI);return{HumanMessage:E,AIMessage:x}},[]);for(const E of c){if(!E||!E.role){console.warn("Skipping invalid message:",E);continue}const x=Array.isArray(E.content)?E.content[0]:E.content;if(!x){console.warn("Skipping message with no content:",E);continue}x.type==="text"&&x.text?E.role==="user"?d.push(new f(x.text)):E.role==="assistant"&&d.push(new m(x.text)):console.warn("Skipping message with unsupported content type:",x)}if(d.length===0)throw new 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 E;const x={model:e.model,apiKey:e.apiKey};if(o!==void 0&&(x.maxTokens=o),i!==void 0?x.temperature=i:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:w}=await pa(async()=>{const{ChatOpenAI:S}=await import("./index-BDlTOMS5.js");return{ChatOpenAI:S}},__vite__mapDeps([0,1,2,3,4,5]));E=new w(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:w}=await pa(async()=>{const{ChatAnthropic:S}=await import("./index-DdkxcTE2.js");return{ChatAnthropic:S}},__vite__mapDeps([6,2,1,5]));E=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await pa(async()=>{const{ChatGoogleGenerativeAI:S}=await import("./index-D7_719w8.js");return{ChatGoogleGenerativeAI:S}},__vite__mapDeps([7,2,1,4]));E=new w(x)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:E,provider:e.provider,model:e.model,apiKey:e.apiKey}}const h=await t.current.instance.invoke(d);return{role:"assistant",content:{type:"text",text:h.content||h.text||""},model:e.model,stopReason:"endTurn"}},[e]),isAvailable:e!==null}}function hxe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:o,isCopied:i,onCopy:c,onDownload:d,onFullscreen:f,llmConfig:m}){const[h,g]=y.useState("manual"),[v,E]=y.useState("stub-model"),[x,w]=y.useState("endTurn"),[S,_]=y.useState("assistant"),[T,R]=y.useState("text"),[C,A]=y.useState("positive"),[I,O]=y.useState(""),[U,L]=y.useState("image/png"),[$,H]=y.useState(!1),[Y,q]=y.useState(null),{generateResponse:ne,isAvailable:G}=mxe({llmConfig:m});y.useEffect(()=>{e&&(E("stub-model"),w("endTurn"),_("assistant"),R("text"),A("positive"),O(""),L("image/png"),q(null))},[e?.id]);const K=async()=>{if(!(!e||!G)){H(!0),q(null);try{const M=await ne({request:e.request});E(M.model||m?.model||"stub-model"),w(M.stopReason||"endTurn"),_(M.role||"assistant");const B=Array.isArray(M.content)?M.content[0]:M.content;B.type==="text"?(R("text"),A(B.text||"")):B.type==="image"&&(R("image"),O(B.data||""),L(B.mimeType||"image/png"))}catch(M){const B=M instanceof Error?M.message:"Failed to generate response";q(B),pt.error("LLM Generation Failed",{description:B})}finally{H(!1)}}},F=y.useMemo(()=>{const M={model:v,stopReason:x,role:S,content:{type:T}};return T==="text"?M.content.text=C:T==="image"&&(M.content.data=I,M.content.mimeType=U),M},[v,x,S,T,C,I,U]),re=()=>{if(!e)return;const M=H_.safeParse(F);if(!M.success){pt.error("Invalid response",{description:`Validation failed: ${M.error.message}`});return}t(e.id,M.data),r(),pa(()=>Promise.resolve().then(()=>pd),void 0).then(B=>{const P=pt(B.createElement("div",{className:"space-y-3"},B.createElement("div",null,B.createElement("strong",null,"Sampling Response Sent"),B.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),B.createElement("div",{className:"flex gap-2"},B.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const D=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(D),pt.dismiss(P)}},"View Tool Result"))),{duration:5e3})})},ee=()=>{e&&(n(e.id,"User rejected sampling request"),r())};return e?u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),u.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:i?u.jsx(Er,{className:"h-4 w-4 text-green-600"}):u.jsx(dr,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Copy request"})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:u.jsx(um,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Download request"})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:u.jsx(RT,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Fullscreen"})]}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:u.jsx(ro,{className:"h-4 w-4"})})]})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),u.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:u.jsx(cr,{data:e.request})})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(on,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),u.jsxs(Oo,{value:h,onValueChange:M=>g(M),children:[u.jsx(Lo,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:u.jsx(Do,{})}),u.jsxs(Mo,{children:[u.jsx(ra,{value:"manual",children:"Manual"}),u.jsx(ra,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&u.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[G?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Ae,{onClick:K,disabled:$,size:"sm",className:"flex items-center gap-2",children:$?u.jsxs(u.Fragment,{children:[u.jsx(Bi,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):u.jsxs(u.Fragment,{children:[u.jsx(Gie,{className:"h-4 w-4"}),"Generate with LLM"]})}),u.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):u.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),Y&&u.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:Y})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`model-${e.id}`,children:"Model"}),u.jsx(In,{id:`model-${e.id}`,value:v,onChange:M=>E(M.target.value),placeholder:"stub-model",disabled:h==="llm"&&$})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),u.jsx(In,{id:`stopReason-${e.id}`,value:x,onChange:M=>w(M.target.value),placeholder:"endTurn",disabled:h==="llm"&&$})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`role-${e.id}`,children:"Role"}),u.jsxs(Oo,{value:S,onValueChange:M=>_(M),disabled:h==="llm"&&$,children:[u.jsx(Lo,{id:`role-${e.id}`,children:u.jsx(Do,{})}),u.jsxs(Mo,{children:[u.jsx(ra,{value:"assistant",children:"assistant"}),u.jsx(ra,{value:"user",children:"user"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),u.jsxs(Oo,{value:T,onValueChange:M=>R(M),disabled:h==="llm"&&$,children:[u.jsx(Lo,{id:`contentType-${e.id}`,children:u.jsx(Do,{})}),u.jsxs(Mo,{children:[u.jsx(ra,{value:"text",children:"text"}),u.jsx(ra,{value:"image",children:"image"})]})]})]}),T==="text"&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`text-${e.id}`,children:"Text Content"}),u.jsx(Vl,{id:`text-${e.id}`,value:C,onChange:M=>A(M.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&$})]}),T==="image"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),u.jsx(Vl,{id:`imageData-${e.id}`,value:I,onChange:M=>O(M.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&$})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(on,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),u.jsx(In,{id:`mimeType-${e.id}`,value:U,onChange:M=>L(M.target.value),placeholder:"image/png",disabled:h==="llm"&&$})]})]})]})]}),u.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[u.jsx(Ae,{onClick:re,className:"flex-1",disabled:h==="llm"&&$,children:"Approve"}),u.jsx(Ae,{onClick:ee,variant:"outline",className:"flex-1",disabled:h==="llm"&&$,children:"Reject"})]})]}):u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}const gxe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function bxe({requestId:e,serverName:t,onViewDetails:n,onApprove:r,onDeny:a}){return u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx("strong",{children:"Sampling Request Received"}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),n()},children:"View Details"}),u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),r(gxe)},children:"Approve"}),u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:o=>{o.stopPropagation(),a()},children:"Deny"})]})]})}function yxe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:a,mcpServerUrl:o}){const{selectedSamplingRequestId:i,setSelectedSamplingRequestId:c}=Ql(),{llmConfig:d}=P8({mcpServerUrl:o}),[f,m]=y.useState(null),[h,g]=y.useState(""),[v,E]=y.useState(-1),[x,w]=y.useState(!0),[S,_]=y.useState(!1),[T,R]=y.useState(!0),[C,A]=y.useState(!1),I=y.useRef(null),O=y.useRef(null),U=y.useRef(null),L=y.useRef(!1);y.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:i,pendingRequestsCount:e.length,currentSelectedId:f?.id}),i&&e.length>0){const F=e.find(re=>re.id===i);console.log("[SamplingTab] Found request for auto-selection:",!!F,F?.id),F&&(console.log("[SamplingTab] Auto-selecting request:",F.id),c(null),m(F),setTimeout(()=>{const re=document.getElementById(`sampling-request-${F.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,c]),y.useEffect(()=>{const F=re=>{const M=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",M);const B=e.find(P=>P.id===M);B&&(console.log("[SamplingTab] Selecting request from event:",M),m(B),setTimeout(()=>{const P=document.getElementById(`sampling-request-${M}`);P&&P.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",F),()=>window.removeEventListener("navigate-to-sampling",F)},[e]),y.useEffect(()=>{x&&e.length>0&&I.current&&!L.current&&(I.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const F=I.current;if(!F)return;const re=()=>{F.scrollTop>0&&(L.current=!0,w(!1))};return F.addEventListener("scroll",re),()=>F.removeEventListener("scroll",re)},[]),y.useEffect(()=>{e.length===0&&(L.current=!1,w(!0))},[e.length]),y.useEffect(()=>{S&&U.current&&U.current.focus()},[S]);const $=y.useCallback(()=>{h.trim()||_(!1)},[h]),H=y.useMemo(()=>{if(!h.trim())return e;const F=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(F)||JSON.stringify(re.request||{}).toLowerCase().includes(F))},[e,h]);y.useEffect(()=>{E(-1)},[h]),y.useEffect(()=>{const F=re=>{const ee=re.target;if(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const B=H;if(re.key==="ArrowDown")re.preventDefault(),E(P=>{const D=P+1;return D>=B.length?0:D});else if(re.key==="ArrowUp")re.preventDefault(),E(P=>{const D=P-1;return D<0?B.length-1:D});else if(re.key==="Enter"&&v>=0){re.preventDefault();const P=H[v];P&&Y(P)}};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[v,H]),y.useEffect(()=>{if(v>=0){const F=`sampling-request-${H[v]?.id}`,re=document.getElementById(F);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,H]);const Y=y.useCallback(F=>{m(F)},[]),q=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(F=>{n(F.id,"User rejected all requests")}),m(null))},[e,n]),ne=y.useCallback(async()=>{if(f)try{await navigator.clipboard.writeText(JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(F){console.error("[SamplingTab] Failed to copy request:",F)}},[f]),G=y.useCallback(()=>{if(f)try{const F=new globalThis.Blob([JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)],{type:"application/json"}),re=URL.createObjectURL(F),ee=document.createElement("a");ee.href=re,ee.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(re)}catch(F){console.error("[SamplingTab] Failed to download request:",F)}},[f]),K=y.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(F){console.error("[SamplingTab] Failed to toggle fullscreen:",F)}},[]);return a?u.jsxs(ha,{direction:"horizontal",className:"h-full",children:[u.jsx(Pn,{defaultSize:40,minSize:30,children:u.jsx(ha,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(Pn,{defaultSize:75,minSize:30,children:[u.jsx(fxe,{isSearchExpanded:S,searchQuery:h,filteredRequestsCount:H.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:$,onRejectAll:q,searchInputRef:U}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(pxe,{requests:H,selectedRequest:f,onRequestSelect:Y,focusedIndex:v,formatRelativeTime:Ty,listRef:I})})]})})}),u.jsx(_s,{}),u.jsx(Pn,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(hxe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:T,onTogglePreview:()=>R(!T),isCopied:C,onCopy:ne,onDownload:G,onFullscreen:K,llmConfig:d})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(IB,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function vxe({requestId:e,serverName:t,mode:n,message:r,url:a,onViewDetails:o,onOpenUrl:i,onCancel:c}){return u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx("strong",{children:"Elicitation Request Received"}),u.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",r]}),n==="url"&&a&&u.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:a})]}),u.jsxs("div",{className:"flex gap-2 flex-wrap",children:[u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:d=>{d.stopPropagation(),o()},children:"View Details"}),n==="url"&&i&&u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:d=>{d.stopPropagation(),i()},children:"Open URL"}),u.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:d=>{d.stopPropagation(),c()},children:"Cancel"})]})]})}function wxe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:r,onSearchExpand:a,onSearchChange:o,onSearchBlur:i,onCancelAll:c,searchInputRef:d}){return u.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[u.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?u.jsx(In,{ref:d,placeholder:"Search requests...",value:t,onChange:f=>o(f.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):u.jsxs(u.Fragment,{children:[u.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),u.jsx(kr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(Ot,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})}),u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx(ro,{className:"h-4 w-4"})})}),u.jsx(Ot,{side:"bottom",children:"Cancel all"})]})})]})}function xxe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:r,formatRelativeTime:a,listRef:o}){return e.length===0?u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx(Ed,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):u.jsx("div",{ref:o,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((i,c)=>{const d=i.request.mode||"form",f=d==="form"&&"requestedSchema"in i.request&&i.request.requestedSchema;return u.jsx(Qi,{id:`elicitation-request-${i.id}`,isSelected:t?.id===i.id,isFocused:r===c,title:u.jsxs("span",{className:"flex items-center gap-3",children:[i.serverName,u.jsx(kr,{variant:"outline",className:d==="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:d})]}),description:(()=>{const m=a(i.timestamp),h=[];f&&h.push("with schema"),d==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(i)},i.id)})})}function Exe({request:e,onApprove:t,onReject:n,onClose:r,previewMode:a,onTogglePreview:o,isCopied:i,onCopy:c,onDownload:d,onFullscreen:f}){const[m,h]=y.useState({}),[g,v]=y.useState(!1),E=e?.request.mode||"form",x=E==="form",w=E==="url";y.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const I=e.request.requestedSchema,O={};if(I?.type==="object"&&I.properties)for(const[U,L]of Object.entries(I.properties)){const $=L;$.default!==void 0?O[U]=$.default:$.type==="boolean"?O[U]=!1:$.type==="number"||$.type==="integer"?O[U]=0:O[U]=""}h(O)}v(!1)},[e?.id,x]);const S=(I,O)=>{h(U=>({...U,[I]:O}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const I=e.request.requestedSchema;if(I?.required){const O=I.required.filter(U=>m[U]===void 0||m[U]===""||m[U]===null);if(O.length>0){pt.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else w&&t(e.id,{action:"accept"});r(),pa(()=>Promise.resolve().then(()=>pd),void 0).then(I=>{const O=pt(I.createElement("div",{className:"space-y-3"},I.createElement("div",null,I.createElement("strong",null,"Elicitation Response Sent"),I.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),I.createElement("div",{className:"flex gap-2"},I.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const U=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent(U),pt.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},T=()=>{e&&(t(e.id,{action:"decline"}),r())},R=()=>{e&&(n(e.id,"User cancelled elicitation request"),r())},C=()=>{e&&w&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},A=y.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const I=e.request.requestedSchema;if(!I||I.type!=="object"||!I.properties)return u.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=I.properties,U=I.required||[];return u.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([L,$])=>{const H=$,Y=U.includes(L),q=H.type||"string",ne=H.title||L,G=H.description;return u.jsxs("div",{className:"space-y-2",children:[u.jsxs(on,{htmlFor:`field-${L}`,children:[ne,Y&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),G&&u.jsx("p",{className:"text-xs text-muted-foreground",children:G}),q==="boolean"?u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Vp,{id:`field-${L}`,checked:m[L]||!1,onCheckedChange:K=>S(L,K)}),u.jsx(on,{htmlFor:`field-${L}`,className:"text-sm font-normal cursor-pointer",children:H.title||L})]}):q==="number"||q==="integer"?u.jsx(In,{id:`field-${L}`,type:"number",value:m[L]||"",onChange:K=>S(L,q==="integer"?parseInt(K.target.value,10):parseFloat(K.target.value)),placeholder:H.default?.toString()||""}):H.enum?u.jsxs("select",{id:`field-${L}`,value:m[L]||"",onChange:K=>S(L,K.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:[u.jsx("option",{value:"",children:"Select..."}),H.enum.map(K=>u.jsx("option",{value:K,children:K},K))]}):q==="string"&&(H.format==="textarea"||H.maxLength>100)?u.jsx(Vl,{id:`field-${L}`,value:m[L]||"",onChange:K=>S(L,K.target.value),placeholder:H.default||"",rows:4}):u.jsx(In,{id:`field-${L}`,type:"text",value:m[L]||"",onChange:K=>S(L,K.target.value),placeholder:H.default||""})]},L)})})},[e,m,x]);return e?u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),u.jsx(kr,{variant:"outline",className:w?"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:E}),u.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:i?u.jsx(Er,{className:"h-4 w-4 text-green-600"}):u.jsx(dr,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Copy request"})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:u.jsx(um,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Download request"})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:u.jsx(RT,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:"Fullscreen"})]}),u.jsx(Ae,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:u.jsx(ro,{className:"h-4 w-4"})})]})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),u.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),w&&"url"in e.request&&u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),u.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[u.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),u.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[u.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),u.jsxs(Ae,{size:"sm",variant:"outline",onClick:C,className:"flex items-center gap-2",children:[u.jsx(tS,{className:"h-4 w-4"}),"Open URL"]})]}),u.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[u.jsx(Vp,{id:"url-completed",checked:g,onCheckedChange:I=>v(!!I)}),u.jsx(on,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),x&&u.jsxs("div",{className:"space-y-2",children:[u.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),A]}),x&&"requestedSchema"in e.request&&e.request.requestedSchema&&u.jsxs("details",{className:"space-y-2",children:[u.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),u.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:u.jsx(cr,{data:e.request.requestedSchema})})]})]}),u.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[u.jsx(Ae,{onClick:_,className:"flex-1",children:"Accept"}),u.jsx(Ae,{onClick:T,variant:"outline",className:"flex-1",children:"Decline"}),u.jsx(Ae,{onClick:R,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):u.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function Sxe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:a}){const{selectedElicitationRequestId:o,setSelectedElicitationRequestId:i}=Ql(),[c,d]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,E]=y.useState(!0),[x,w]=y.useState(!1),[S,_]=y.useState(!0),[T,R]=y.useState(!1),C=y.useRef(null),A=y.useRef(null),I=y.useRef(null),O=y.useRef(!1);y.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:o,pendingRequestsCount:e.length,currentSelectedId:c?.id}),o&&e.length>0){const G=e.find(K=>K.id===o);console.log("[ElicitationTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[ElicitationTab] Auto-selecting request:",G.id),i(null),d(G),setTimeout(()=>{const K=document.getElementById(`elicitation-request-${G.id}`);console.log("[ElicitationTab] Scrolling to element:",!!K),K&&K.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[o,e,i]),y.useEffect(()=>{const G=K=>{const re=K.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",re);const ee=e.find(M=>M.id===re);ee&&(console.log("[ElicitationTab] Selecting request from event:",re),d(ee),setTimeout(()=>{const M=document.getElementById(`elicitation-request-${re}`);M&&M.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",G),()=>window.removeEventListener("navigate-to-elicitation",G)},[e]),y.useEffect(()=>{v&&e.length>0&&C.current&&!O.current&&(C.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const G=C.current;if(!G)return;const K=()=>{G.scrollTop>0&&(O.current=!0,E(!1))};return G.addEventListener("scroll",K),()=>G.removeEventListener("scroll",K)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const U=y.useCallback(()=>{f.trim()||w(!1)},[f]),L=y.useMemo(()=>{if(!f.trim())return e;const G=f.toLowerCase();return e.filter(K=>K.serverName.toLowerCase().includes(G)||K.request.message.toLowerCase().includes(G)||JSON.stringify(K.request||{}).toLowerCase().includes(G))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const G=K=>{const F=K.target;if(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.contentEditable==="true"||K.metaKey||K.ctrlKey||K.altKey)return;const ee=L;if(K.key==="ArrowDown")K.preventDefault(),g(M=>{const B=M+1;return B>=ee.length?0:B});else if(K.key==="ArrowUp")K.preventDefault(),g(M=>{const B=M-1;return B<0?ee.length-1:B});else if(K.key==="Enter"&&h>=0){K.preventDefault();const M=L[h];M&&$(M)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[h,L]),y.useEffect(()=>{if(h>=0){const G=`elicitation-request-${L[h]?.id}`,K=document.getElementById(G);K&&K.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const $=y.useCallback(G=>{d(G)},[]),H=y.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(G=>{n(G.id,"User cancelled all requests")}),d(null))},[e,n]),Y=y.useCallback(async()=>{if(c)try{await navigator.clipboard.writeText(JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)),R(!0),setTimeout(()=>R(!1),2e3)}catch(G){console.error("[ElicitationTab] Failed to copy request:",G)}},[c]),q=y.useCallback(()=>{if(c)try{const G=new globalThis.Blob([JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)],{type:"application/json"}),K=URL.createObjectURL(G),F=document.createElement("a");F.href=K,F.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(F),F.click(),document.body.removeChild(F),URL.revokeObjectURL(K)}catch(G){console.error("[ElicitationTab] Failed to download request:",G)}},[c]),ne=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(G){console.error("[ElicitationTab] Failed to toggle fullscreen:",G)}},[]);return a?u.jsxs(ha,{direction:"horizontal",className:"h-full",children:[u.jsx(Pn,{defaultSize:40,minSize:30,children:u.jsx(ha,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(Pn,{defaultSize:75,minSize:30,children:[u.jsx(wxe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:L.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:U,onCancelAll:H,searchInputRef:I}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(xxe,{requests:L,selectedRequest:c,onRequestSelect:$,focusedIndex:h,formatRelativeTime:Ty,listRef:C})})]})})}),u.jsx(_s,{}),u.jsx(Pn,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(Exe,{request:c,onApprove:t,onReject:n,onClose:()=>d(null),previewMode:S,onTogglePreview:()=>_(!S),isCopied:T,onCopy:Y,onDownload:q,onFullscreen:ne})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(jB,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),u.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function _xe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:r,resourcesSearchRef:a,children:o}){return e?u.jsxs(u.Fragment,{children:[u.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:u.jsx(u9,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),u.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:u.jsx(o9,{ref:r,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),u.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:u.jsx(l9,{ref:a,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),u.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:u.jsx(ywe,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),u.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:u.jsx(yxe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),u.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:u.jsx(Sxe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),u.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:u.jsx(qwe,{notifications:e.notifications,unreadCount:e.unreadNotificationCount,markNotificationRead:e.markNotificationRead,markAllNotificationsRead:e.markAllNotificationsRead,clearNotifications:e.clearNotifications,serverId:e.id,isConnected:e.state==="ready"})}),t!=="tools"&&t!=="prompts"&&t!=="resources"&&t!=="chat"&&t!=="sampling"&&t!=="elicitation"&&t!=="notifications"&&u.jsx(u.Fragment,{children:o})]}):u.jsx(u.Fragment,{children:o})}function Dz({className:e}){return u.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentcolor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[u.jsx("path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"}),u.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const d9=y.createContext(void 0);function f9(){const e=y.use(d9);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const p9=y.createContext(void 0);function Txe(){return y.use(p9)}function m_({ref:e,children:t,defaultValue:n,value:r,onValueChange:a,className:o,collapsed:i,onCollapsedChange:c,...d}){const[f,m]=y.useState(n||""),h=r!==void 0,g=i!==void 0,[v,E]=y.useState(!1),x=y.useCallback(T=>{h||m(T),a?.(T)},[h,a]),w=h?r:f,S=g?i:v,_=y.useCallback(T=>{g||E(T),c?.(T)},[g,c]);return u.jsx(d9,{value:{activeValue:w,handleValueChange:x,collapsed:S,handleCollapsedChange:_},children:u.jsx("div",{ref:e,className:Oe("flex flex-col gap-2",o),...d,children:t})})}m_.displayName="Tabs";function h_({ref:e,children:t,className:n,variant:r="default",collapsible:a=!1,...o}){const{activeValue:i,collapsed:c,handleCollapsedChange:d}=f9(),[f,m]=y.useState({width:0,left:0}),h=y.useRef(null),g=y.useRef(null),v=y.useRef(null),E=y.useCallback(()=>{const S=h.current;if(!S)return;const _=S.querySelector("div:first-child");if(!_)return;const T=_.querySelector(`button[data-tab-value="${i}"]`);if(T&&i){const R=_.getBoundingClientRect(),C=T.getBoundingClientRect();m({width:C.width,left:C.left-R.left})}else m({width:0,left:0})},[i]),x=y.useCallback(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(E,16)},[E]);y.useEffect(()=>{const S=setTimeout(E,10);return()=>clearTimeout(S)},[E,c]),y.useEffect(()=>{const S=h.current;if(!S)return;g.current=new ResizeObserver(()=>{x()}),g.current.observe(S);const _=S.querySelector("div:first-child");return _&&_.querySelectorAll("button[data-tab-value]").forEach(R=>{g.current&&g.current.observe(R)}),()=>{g.current&&g.current.disconnect(),v.current&&clearTimeout(v.current)}},[x]),y.useEffect(()=>{const S=()=>{x()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[x]);const w=y.useRef(null);return y.useEffect(()=>{w.current&&(w.current.style.width=`${f.width}px`,w.current.style.left=`${f.left}px`)},[f]),u.jsx(p9,{value:{variant:r,collapsed:c,handleCollapsedChange:d},children:u.jsx("div",{ref:h,className:Oe("relative flex items-center bg-none gap-1",r==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",r==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...o,children:u.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,u.jsx("span",{ref:w,className:Oe("absolute transition-all duration-500 ease-in-out z-0",r==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",r==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}h_.displayName="TabsList";const Nxe=({children:e,title:t,collapsed:n})=>!t||!n?e:u.jsx(TT,{children:u.jsxs(At,{children:[u.jsx(It,{children:e}),u.jsx(Ot,{children:t})]})}),g_=y.forwardRef(({children:e,value:t,className:n,disabled:r,icon:a,title:o,showDot:i=!1,...c},d)=>{const{activeValue:f,handleValueChange:m,collapsed:h}=f9(),v=Txe()?.variant||"default",E=f===t,x=h&&o?o:void 0;return u.jsx(Nxe,{title:o,collapsed:h,children:u.jsxs("button",{ref:d,disabled:r,onClick:()=>m(t),"data-tab-value":t,"data-tab-active":E,role:"tab","aria-selected":E?"true":"false",title:x,className:Oe("relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-all duration-500 ease-in-out focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer",v==="default"&&"py-2.5",v==="default"&&"rounded-md px-4",v==="underline"&&"px-6 py-3 border-b-2 border-transparent",E&&"text-foreground",!E&&"text-muted-foreground hover:text-foreground",n),...c,children:[a&&u.jsx(a,{className:Oe("h-4 w-4 transition-all duration-500 ease-in-out",!h&&"mr-2",h&&"mr-0!")}),i&&u.jsx("span",{className:"absolute top-1.5 right-1.5 w-2 h-2 bg-orange-500 dark:bg-orange-400 border-2 border-white dark:border-zinc-900 rounded-full transition-opacity duration-300 z-10 animate-status-pulse-orange"}),u.jsx("span",{className:Oe("transition-all duration-500 ease-in-out overflow-hidden",h?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});g_.displayName="TabsTrigger";function Lz({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:r="",onSuccess:a,onError:o,trigger:i}){const[c,d]=y.useState(!1),[f,m]=y.useState(null),[h,g]=y.useState(!1),{url:v,name:E,headers:x}=e,w=()=>{try{const L=s6(v,E,x);window.location.href=L,a?.("Cursor")}catch(L){console.error("Failed to generate Cursor deep link:",L),o?.(L)}},S=()=>{try{const L=o6(v,E,x);window.location.href=L,a?.("VS Code")}catch(L){console.error("Failed to generate VS Code deep link:",L),o?.(L)}},_=()=>{try{i6(v,E,x),a?.("Claude Desktop")}catch(L){console.error("Failed to download .mcpb file:",L),o?.(L)}},T=()=>{m("claude-code"),d(!0)},R=()=>{m("gemini-cli"),d(!0)},C=()=>{m("codex-cli"),d(!0)},A=async L=>{try{await navigator.clipboard.writeText(L),g(!0),setTimeout(()=>g(!1),2e3)}catch($){console.error("Failed to copy:",$),o?.($)}},I=()=>{if(f==="claude-code"){const{command:L,envVars:$}=l6(v,E,x),H=SU($);return u.jsxs(u.Fragment,{children:[u.jsxs(Ws,{children:[u.jsx(Ks,{children:"Add to Claude Code"}),u.jsx(ep,{children:"Execute the following command in your shell to add this server to Claude Code."})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),u.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"1."}),u.jsx("span",{children:"Ensure the Claude Code executable is available in your path"})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"2."}),u.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{className:"absolute top-2 right-2 z-10",children:u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})}),u.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:L})})]}),H&&u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),u.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"After installation, set these environment variables in your shell:"}),u.jsx("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:H})})]}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["The MCP configuration supports environment variable expansion using ",u.jsx("code",{className:"text-foreground",children:"${VAR}"})," ","syntax."]})]})]})}if(f==="gemini-cli"){const{command:L,envVars:$}=c6(v,E,x),H=SU($);return u.jsxs(u.Fragment,{children:[u.jsxs(Ws,{children:[u.jsx(Ks,{children:"Add to Gemini CLI"}),u.jsx(ep,{children:"Execute the following command in your shell to add this server to Gemini CLI."})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),u.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"1."}),u.jsx("span",{children:"Ensure the Gemini CLI executable is available in your path"})]}),H&&u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"2."}),u.jsx("span",{children:"Set these environment variables in your shell before running the command:"})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:H?"3.":"2."}),u.jsx("span",{children:"Execute the following snippet in your shell:"})]})]})]}),H&&u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Environment Variables"}),u.jsx("pre",{className:"bg-muted p-3 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:H})})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{className:"absolute top-2 right-2 z-10",children:u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})}),u.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:L})})]}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Gemini CLI to load the new configuration."})]})]})}if(f==="codex-cli"){const{config:L,envVars:$}=u6(v,E,x);return u.jsxs(u.Fragment,{children:[u.jsxs(Ws,{children:[u.jsx(Ks,{children:"Add to Codex CLI"}),u.jsxs(ep,{children:["Add this configuration to your"," ",u.jsx("code",{className:"text-foreground",children:"~/.codex/config.toml"})," ","file."]})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),u.jsxs("p",{className:"text-xs text-muted-foreground",children:["Add this configuration to your"," ",u.jsx("code",{className:"text-foreground",children:"~/.codex/config.toml"}),":"]})]}),u.jsxs("div",{className:"relative",children:[u.jsx("div",{className:"absolute top-2 right-2 z-10",children:u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})}),u.jsx("pre",{className:"bg-muted p-3 pr-14 rounded-md text-xs overflow-x-auto",children:u.jsx("code",{children:L})})]}),$.length>0&&u.jsx("div",{children:u.jsxs("p",{className:"text-xs text-muted-foreground",children:["(optional) If you would rather use variables from your system's environment, replace the"," ",u.jsx("code",{className:"text-foreground",children:"http_headers"})," key with the ",u.jsx("code",{className:"text-foreground",children:"env_http_headers"})," ","key as shown in the commented section above."]})}),u.jsx("p",{className:"text-xs text-muted-foreground",children:"Restart Codex CLI to load the new configuration."})]})]})}return null},O=u.jsxs(Ae,{variant:"ghost",className:`bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center ${r}`,children:[u.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[u.jsx(Np,{className:"size-3"}),"Client"]}),u.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",u.jsx(Qs,{className:"size-3"})]})]}),U=i?typeof i=="function"?i({isOpen:!1,onClick:()=>{}}):i:O;return u.jsxs(u.Fragment,{children:[u.jsxs(Xb,{children:[u.jsx(Jb,{asChild:!0,children:U}),u.jsxs(wp,{align:"end",className:"w-auto min-w-[300px]",children:[t.map(L=>u.jsxs(Vr,{onClick:async()=>{await L.onClick()},className:"flex items-center gap-2",children:[L.icon,u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:L.label})]},L.id)),t.length>0&&u.jsx(ru,{}),n.cursor&&u.jsxs(Vr,{onClick:w,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Cursor"})]}),n.claudeCode&&u.jsxs(Vr,{onClick:T,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Code"})]}),n.claudeDesktop&&u.jsxs(Vr,{onClick:_,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Claude Desktop"})]}),n.vsCode&&u.jsxs(Vr,{onClick:S,className:"flex items-center gap-2",children:[u.jsx(a6,{className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code"})]}),n.geminiCli&&u.jsxs(Vr,{onClick:R,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Gemini CLI"})]}),n.codexCli&&u.jsxs(Vr,{onClick:C,className:"flex items-center gap-2",children:[u.jsx("img",{src:"https://inspector-cdn.mcp-use.com/providers/openai.png",alt:"Codex",className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"Codex CLI"})]})]})]}),u.jsx(Li,{open:c,onOpenChange:d,children:u.jsx(Mi,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:I()})})]})}function Mz({className:e}){const{theme:t,setTheme:n}=Sv(),r=y.useRef(null),[a,o]=y.useState(!1);y.useEffect(()=>{o(!0)},[]);const i=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?u.jsx(LP,{className:"size-4"}):t==="light"?u.jsx(qie,{className:"size-5"}):u.jsx(Aie,{className:"size-4"}),d=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",f=async()=>{if(!r.current)return;const m=i();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{bd.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:E}=r.current.getBoundingClientRect(),x=h+E/2,w=g+v/2,S=window.innerWidth-g,_=window.innerHeight-h,T=Math.hypot(Math.max(g,S),Math.max(h,_));document.documentElement.animate({clipPath:[`circle(0px at ${w}px ${x}px)`,`circle(${T}px at ${w}px ${x}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return a?u.jsx("button",{ref:r,onClick:f,className:Oe(e),"aria-label":d(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):u.jsx("button",{ref:r,className:Oe(e),"aria-label":"Toggle theme",children:u.jsx(LP,{className:"size-4"})})}function jz({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[r,a]=y.useState(!1),o=.2,i=.7,c=.6,d=4,f=o+i+c,m=0,h=o/f,g=(o+i)/f,v=1;return u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Oe("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[u.jsx("div",{className:"relative",children:u.jsxs(Ca.svg,{viewBox:"0 0 303 303",initial:"rest",animate:r?"hover":"rest",className:Oe("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[u.jsxs(Ca.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:f,times:[m,h,g,v],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:d,strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z"}),u.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),u.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),u.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:d,strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx(kxe,{d:"m105.5 34.8.6.6c9.5 9.5 14.4 21.9 14.6 34.4a112.6 112.6 0 0 0 112.2 112.1h.6c12 .4 24 5.1 33.2 14.1l.6.6a50 50 0 0 1-70.1 71.3l-.6-.6A49.9 49.9 0 0 1 182 230 112.6 112.6 0 0 0 73.4 120.7h-.8a49.9 49.9 0 0 1-36.7-14l-.5-.6a50 50 0 0 1-.6-70.2l.6-.5a50 50 0 0 1 69.5-1.2l.6.6Z",times:{T0:m,T1:h,T2:g,T3:v},total:f}),u.jsx(Pz,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f}),u.jsx(Pz,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f})]})]})}),t==="expanded"&&u.jsxs("div",{className:"font-ubuntu flex-col items-start -space-y-1 mr-3 hidden xl:flex",children:[u.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),u.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function kxe({d:e,times:t,total:n}){const{T0:r,T1:a,T2:o,T3:i}=t;return u.jsx(Ca.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[r,a,o,i],ease:"easeInOut"}}}})}function Pz({cx:e,cy:t,r:n,times:r,total:a}){const{T0:o,T1:i,T2:c,T3:d}=r;return u.jsx(Ca.circle,{cx:e,cy:t,r:n,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:a,times:[o,i,c,d],ease:"easeInOut"}}}})}function Qg({open:e,onOpenChange:t,serverUrl:n,serverName:r,serverId:a,headers:o,language:i}){const{prismStyle:c}=GA(),[d,f]=y.useState(!1),m=i==="typescript"?wbe(n,r,a,o):xbe(n,r,a,o),h=async()=>{await navigator.clipboard.writeText(m),f(!0),setTimeout(()=>f(!1),2e3)},g=i==="typescript"?"TypeScript":"Python",v=i==="typescript"?"npm install mcp-use":"pip install mcp-use";return u.jsx(Li,{open:e,onOpenChange:t,children:u.jsxs(Mi,{className:"max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsxs(Ws,{children:[u.jsxs(Ks,{children:["Add to ",g," SDK"]}),u.jsxs(ep,{children:["Copy the following code to integrate this server into your"," ",g," application using the mcp-use SDK."]})]}),u.jsxs("div",{className:"space-y-4 overflow-y-auto flex-1 min-h-0",children:[u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),u.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"1."}),u.jsxs("span",{children:["Install the mcp-use package:"," ",u.jsx("code",{className:"text-foreground",children:v})]})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"2."}),u.jsxs("span",{children:["Copy the following code into your ",g," project:"]})]})]})]}),u.jsxs("div",{className:"relative w-full overflow-x-auto overflow-y-auto max-h-[60vh]",children:[u.jsx("div",{className:"absolute top-2 right-2 z-10",children:u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:h,children:d?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})}),u.jsx(Ip,{language:i,style:c,customStyle:{margin:0,padding:"1rem",paddingRight:"3rem",borderRadius:"0.5rem",fontSize:"0.75rem",background:"var(--muted)",width:"100%",maxWidth:"100%",overflow:"auto"},wrapLines:!0,wrapLongLines:!0,PreTag:"div",children:m})]})]})]})})}function m9({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:r="3s",borderRadius:a="100px",background:o,className:i,children:c,...d}){const{resolvedTheme:f}=Sv(),m=f==="dark"?"#000000":"#ffffff",h=f==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=o||h;return u.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":a,"--speed":r,"--cut":n,"--bg":v},className:Oe("group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]","transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px",f==="dark"?"border-black/10 text-black":"border-white/10 text-white",i),ref:e,...d,children:[u.jsx("div",{className:Oe("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:u.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:u.jsx("div",{className:"animate-spin-around absolute -inset-full w-auto [translate:0_0] rotate-0 [background:conic-gradient(from_calc(270deg-(var(--spread)*0.5)),transparent_0,var(--shimmer-color)_var(--spread),transparent_var(--spread))]"})})}),c,u.jsx("div",{className:Oe("absolute inset-0 size-full","rounded-2xl px-4 py-1.5 text-sm font-medium","transform-gpu transition-all duration-300 ease-in-out",f==="dark"?"shadow-[inset_0_-8px_10px_#0000001f] group-hover:shadow-[inset_0_-6px_10px_#0000003f] group-active:shadow-[inset_0_-10px_10px_#0000003f]":"shadow-[inset_0_-8px_10px_#ffffff1f] group-hover:shadow-[inset_0_-6px_10px_#ffffff3f] group-active:shadow-[inset_0_-10px_10px_#ffffff3f]")}),u.jsx("div",{className:Oe("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}m9.displayName="ShimmerButton";function $z({status:e}){const t=o=>{switch(o){case"ready":return{color:"bg-emerald-500",ringColor:"ring-emerald-500",tooltip:"Connected"};case"failed":return{color:"bg-red-500",ringColor:"ring-red-500",tooltip:"Failed"};default:return{color:"bg-yellow-500",ringColor:"ring-yellow-500",tooltip:o}}},{color:n,ringColor:r,tooltip:a}=t(e);return u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsxs("div",{className:"relative",children:[u.jsx("div",{className:`absolute w-2 h-2 rounded-full ${r} animate-ping`}),u.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),u.jsx(Ot,{children:u.jsx("p",{children:a})})]})}function Uz({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:r,mobileMode:a=!1}){const o=Nd(),[i,c]=y.useState(!1),[d,f]=y.useState(null),m=h=>{const g=e.find(v=>v.id===h);if(!g||g.state!=="ready"){pt.error("Server is not connected and cannot be inspected");return}n(h)};return a?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"relative",children:u.jsxs(Xb,{children:[u.jsx(Jb,{asChild:!0,children:u.jsxs(Ae,{variant:"ghost",className:"h-11 px-2 bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200 flex items-center gap-1.5",children:[t?u.jsx(uu,{server:t,size:"md"}):u.jsx(MB,{className:"h-5 w-5"}),u.jsx(Qs,{className:"h-4 w-4"})]})}),u.jsxs(wp,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[u.jsx(JE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>o("/"),children:"MCP Servers"}),u.jsx(ru,{}),e.length===0?u.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(h=>u.jsxs(Vr,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[u.jsx(uu,{server:h,size:"sm"}),u.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[u.jsx("div",{className:"font-medium",children:h.name}),u.jsx($z,{status:h.state})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),f(h),c(!0)},children:u.jsx(Qf,{className:"h-3 w-3"})}),u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),r(h.id)},children:u.jsx(yu,{className:"h-3 w-3"})})]})]},h.id)),u.jsx(ru,{}),u.jsx(Vr,{onClick:()=>o("/"),children:u.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})}),u.jsx(wS,{open:i,onOpenChange:c,connection:d})]}):u.jsx("div",{className:"flex items-center gap-2",children:u.jsxs("div",{className:"relative",children:[u.jsxs(Xb,{children:[u.jsx(Jb,{asChild:!0,children:u.jsxs(m9,{className:Oe("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-20"),children:[t&&u.jsx(uu,{server:t,size:"md",className:"mr-2"}),u.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[u.jsx("span",{className:"truncate lg:max-w-[120px] xl:max-w-none",children:t?t.serverInfo?.title||t.serverInfo?.name||t.name:"Select server to inspect"}),t&&u.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx("button",{onClick:h=>{h.stopPropagation()},className:"w-2 h-2 rounded-full bg-rose-500 animate-status-pulse-red hover:bg-rose-600 transition-colors",title:"Click to copy error message","aria-label":"Copy error message to clipboard"})}),u.jsx(Ot,{children:u.jsx("p",{className:"max-w-xs",children:t.error})})]}):u.jsx("div",{className:`w-2 h-2 rounded-full ${t.state==="ready"?"bg-emerald-600 animate-status-pulse":t.state==="failed"?"bg-rose-600 animate-status-pulse-red":"bg-yellow-500 animate-status-pulse-yellow"}`})})]})]})}),t&&u.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx("button",{type:"button",onClick:()=>{f(t),c(!0)},className:"p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"View server info",children:u.jsx(Qf,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:u.jsx("p",{children:"View server info"})})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx("button",{type:"button",onClick:()=>{r(t.id)},className:"p-1.5 hover:bg-white/10 dark:hover:bg-black/10 rounded-full transition-colors text-white dark:text-black","aria-label":"Edit connection settings",children:u.jsx(yu,{className:"h-4 w-4"})})}),u.jsx(Ot,{children:u.jsx("p",{children:"Edit connection settings"})})]})]}),u.jsxs(wp,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[u.jsx(JE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>o("/"),children:"MCP Servers"}),u.jsx(ru,{}),e.length===0?u.jsx("div",{className:"px-2 py-4 text-sm text-muted-foreground dark:text-zinc-400 text-center",children:"No servers connected. Go to the dashboard to add one."}):e.map(h=>u.jsxs(Vr,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[u.jsx(uu,{server:h,size:"sm"}),u.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[u.jsx("div",{className:"font-medium",children:h.serverInfo?.title||h.serverInfo?.name||h.name}),u.jsx($z,{status:h.state})]}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),f(h),c(!0)},children:u.jsx(Qf,{className:"h-3 w-3"})}),u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),r(h.id)},children:u.jsx(yu,{className:"h-3 w-3"})})]})]},h.id)),u.jsx(ru,{}),u.jsx(Vr,{onClick:()=>o("/"),children:u.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]}),u.jsx(wS,{open:i,onOpenChange:c,connection:d})]})})}const zz=[{id:"tools",label:"Tools",icon:Ul},{id:"prompts",label:"Prompts",icon:Tp},{id:"resources",label:"Resources",icon:fie},{id:"sampling",label:"Sampling",icon:IB},{id:"elicitation",label:"Elicitation",icon:jB},{id:"notifications",label:"Notifications",icon:NT},{id:"chat",label:"Chat",icon:Tie}];function Fz(e,t){return e==="tools"?t.tools.length:e==="prompts"?t.prompts.length:e==="resources"?t.resources.length:e==="sampling"?t.pendingSamplingRequests?.length||0:e==="elicitation"?t.pendingElicitationRequests?.length||0:e==="notifications"?t.unreadNotificationCount:0}function Bz(e,t,n){const r=["sampling","elicitation","notifications"];return n&&t>0&&r.includes(e)}function Cxe({collapsed:e,onToggle:t}){return u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx("button",{onClick:t,className:Oe("shrink-0 p-1.5 rounded-md transition-all duration-500 ease-in-out cursor-pointer","text-muted-foreground hover:text-foreground","hover:bg-zinc-100 dark:hover:bg-zinc-800","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),"aria-label":e?"Expand tabs":"Collapse tabs",type:"button",children:e?u.jsx(RB,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):u.jsx(ov,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),u.jsx(Ot,{children:u.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function Rxe({connections:e,selectedServer:t,activeTab:n,onServerSelect:r,onTabChange:a,onCommandPaletteOpen:o,onOpenConnectionOptions:i,embedded:c=!1}){const{tunnelUrl:d}=Ql(),f=t&&d,[m,h]=y.useState(!1),[g,v]=y.useState(!1),[E,x]=y.useState(!1),[w,S]=y.useState(!0),_=async()=>{if(d)try{await navigator.clipboard.writeText(`${d}/mcp`),h(!0),pt.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{pt.error("Failed to copy URL")}};return u.jsxs("header",{className:"w-full mx-auto",children:[u.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center justify-between w-full",children:[!c&&u.jsx("div",{className:"flex-1 flex justify-start",children:u.jsx(Uz,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:i,mobileMode:!0})}),!c&&u.jsx("div",{className:"flex-shrink-0 flex justify-center",children:u.jsx("div",{className:"scale-150",children:u.jsx(jz,{state:"collapsed"})})}),!c&&u.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[t&&(()=>{const T=t.serverInfo?.title||t.serverInfo?.name||t.name;return u.jsxs(u.Fragment,{children:[u.jsx(Lz,{serverConfig:{url:d?`${d}/mcp`:t.url,name:T,headers:t.customHeaders,serverId:t.id},onSuccess:R=>pt.success(`Opening in ${R}...`),onError:R=>pt.error(`Failed: ${R.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:u.jsx("img",{src:"https://cdn.simpleicons.org/typescript",alt:"TypeScript",className:"h-4 w-4"}),onClick:()=>v(!0)},{id:"py-sdk",label:"Python SDK",icon:u.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:u.jsxs(Ae,{variant:"ghost",className:"bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center p-2","aria-label":"Add to Client",children:[u.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[u.jsx(Np,{className:"size-3"}),"Client"]}),u.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",u.jsx(Qs,{className:"size-3"})]})]})}),u.jsx(Qg,{open:g,onOpenChange:v,serverUrl:d?`${d}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"typescript"}),u.jsx(Qg,{open:E,onOpenChange:x,serverUrl:d?`${d}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",asChild:!0,children:u.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:u.jsx(Dz,{className:"h-4 w-4"})})})}),u.jsx(Ot,{children:u.jsx("p",{children:"Give us a star ⭐"})})]}),u.jsx(Mz,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&u.jsx("div",{className:"w-full",children:u.jsx(m_,{value:n,onValueChange:T=>a(T),collapsed:w,onCollapsedChange:S,children:u.jsx(h_,{className:"w-full justify-center",children:zz.map(T=>{const R=Fz(T.id,t),C=Bz(T.id,R,w);return u.jsxs(g_,{value:T.id,icon:T.icon,showDot:C,className:Oe("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",w&&"pl-2"),children:[R>0&&!w&&u.jsx("span",{className:Oe(n===T.id?"dark:bg-black":"dark:bg-zinc-700","bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-[10px] px-1.5 py-0.5 rounded-full font-medium"),children:R}),u.jsx("span",{className:"sr-only",children:T.label})]},T.id)})})})})]}),u.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[!c&&u.jsx(Uz,{connections:e,selectedServer:t,onServerSelect:r,onOpenConnectionOptions:i}),t&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(m_,{value:n,onValueChange:T=>a(T),collapsed:w,onCollapsedChange:S,children:u.jsx(h_,{className:"overflow-x-auto",collapsible:!0,children:zz.map(T=>{const R=Fz(T.id,t),C=R>0?`${T.label} (${R})`:T.label,A=Bz(T.id,R,w);return u.jsx(g_,{value:T.id,icon:T.icon,showDot:A,className:Oe("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",w&&"pl-4"),title:C,children:u.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[T.label,R>0&&u.jsx("span",{className:Oe(n===T.id?" dark:bg-black ":"dark:bg-zinc-700","bg-zinc-200 text-zinc-700 dark:text-zinc-300 text-xs px-2 py-0.5 rounded-full font-medium"),children:R})]})})})})}),u.jsx(Cxe,{collapsed:w,onToggle:()=>S(!w)})]}),f&&u.jsxs(C6,{children:[u.jsx(R6,{asChild:!0,children:u.jsxs("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-gradient-to-r from-purple-500/10 to-pink-500/10 dark:from-purple-500/20 dark:to-pink-500/20 border border-purple-500/30 dark:border-purple-500/40 rounded-full hover:from-purple-500/20 hover:to-pink-500/20 dark:hover:from-purple-500/30 dark:hover:to-pink-500/30 transition-colors cursor-pointer",children:[u.jsx(kp,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),u.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),u.jsx(k1,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[u.jsx(kp,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),u.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[u.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[d,"/mcp"]}),u.jsx(Ae,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:_,children:m?u.jsx(Er,{className:"size-3.5 text-green-600"}):u.jsx(dr,{className:"size-3.5"})})]})]}),u.jsxs("div",{children:[u.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),u.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"1."}),u.jsxs("span",{children:["Enable"," ",u.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"2."}),u.jsxs("span",{children:["In"," ",u.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",u.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),u.jsxs("li",{className:"flex gap-2",children:[u.jsx("span",{className:"font-semibold text-foreground",children:"3."}),u.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),!c&&u.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[t&&(()=>{const T=t.serverInfo?.title||t.serverInfo?.name||t.name;return u.jsxs(u.Fragment,{children:[u.jsx(Lz,{serverConfig:{url:d?`${d}/mcp`:t.url,name:T,headers:t.customHeaders,serverId:t.id},onSuccess:R=>pt.success(`Opening in ${R}...`),onError:R=>pt.error(`Failed: ${R.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:u.jsx("img",{src:"https://cdn.simpleicons.org/typescript",alt:"TypeScript",className:"h-4 w-4"}),onClick:()=>v(!0)},{id:"py-sdk",label:"Python SDK",icon:u.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:u.jsxs(Ae,{variant:"ghost",className:"bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded-full transition-colors px-3 flex items-center justify-center","aria-label":"Add to Client",children:[u.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[u.jsx(Np,{className:"size-3"}),"Client"]}),u.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",u.jsx(Qs,{className:"size-3"})]})]})}),u.jsx(Qg,{open:g,onOpenChange:v,serverUrl:d?`${d}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"typescript"}),u.jsx(Qg,{open:E,onOpenChange:x,serverUrl:d?`${d}/mcp`:t.url,serverName:T,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),u.jsxs(At,{children:[u.jsx(It,{children:u.jsx(Mz,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),u.jsx(Ot,{children:u.jsx("p",{children:"Toggle theme"})})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsxs(Ae,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:o,children:[u.jsx(Zoe,{className:"size-4"}),u.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),u.jsx(Ot,{children:u.jsx("p",{children:"Command Palette"})})]}),u.jsxs(At,{children:[u.jsx(It,{asChild:!0,children:u.jsx(Ae,{variant:"ghost",size:"sm",asChild:!0,children:u.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[u.jsx(Dz,{className:"h-4 w-4"}),u.jsx("span",{className:"hidden xl:inline",children:"Github"})]})})}),u.jsx(Ot,{children:u.jsx("p",{children:"Give us a star ⭐"})})]}),u.jsx(jz,{state:"expanded"})]})]})]})}function Axe({children:e}){const t=Nd(),n=Go(),{servers:r,addServer:a,removeServer:o,updateServer:i,storageLoaded:c}=tm(),d=y.useCallback((D,j,V,W)=>{a(D,{url:D,name:j,proxyConfig:V,transportType:W})},[a]),f=y.useCallback(async(D,j)=>{try{await i(D,j)}catch(V){console.error(`[Layout] Failed to update connection ${D}:`,V)}},[i]),{selectedServerId:m,setSelectedServerId:h,activeTab:g,setActiveTab:v,navigateToItem:E,setTunnelUrl:x,tunnelUrl:w,isEmbedded:S,embeddedConfig:_,setEmbeddedMode:T}=Ql(),[R,C]=y.useState(!1),[A,I]=y.useState(null),O=Kge();y.useEffect(()=>{const D=new URLSearchParams(n.search),j=D.get("embedded")==="true",V=D.get("embeddedConfig");if(j){let W={};if(V)try{W=JSON.parse(V)}catch(te){console.error("Failed to parse embeddedConfig:",te)}T(!0,W)}},[]),y.useEffect(()=>{const j=new URLSearchParams(n.search).get("tunnelUrl");x(j)},[n.search,x]),y.useEffect(()=>{const j=new URLSearchParams(n.search).get("tab");j&&["tools","prompts","resources","chat","sampling","elicitation","notifications"].includes(j)&&v(j)},[n.search,v]),y.useEffect(()=>{const D=W=>{const de=W.detail.requestId;m&&E(m,"sampling",de)},j=W=>{const de=W.detail.requestId;m&&E(m,"elicitation",de)},V=W=>{const de=W.detail.toolName;m&&de?E(m,"tools",de):m&&v("tools")};return window.addEventListener("navigate-to-sampling",D),window.addEventListener("navigate-to-elicitation",j),window.addEventListener("navigate-to-tool-result",V),()=>{window.removeEventListener("navigate-to-sampling",D),window.removeEventListener("navigate-to-elicitation",j),window.removeEventListener("navigate-to-tool-result",V)}},[m,v,E]);const U=y.useRef(null),L=y.useRef(null),$=y.useRef(null),{isAutoConnecting:H}=Wge({connections:r,addConnection:d,removeConnection:o,configLoaded:c,embedded:S}),Y=y.useCallback(D=>{Zr.getInstance().capture(new hoe({trigger:D})).catch(()=>{}),C(!0)},[]),q=D=>{const j=r.find(fe=>fe.id===D);if(!j||j.state!=="ready"){pt.error("Server is not connected and cannot be inspected");return}h(D);const V=new URLSearchParams(n.search),W=V.get("tunnelUrl"),te=V.get("tab"),de=new URLSearchParams;de.set("server",D),W&&de.set("tunnelUrl",W),te&&de.set("tab",te),t(`/?${de.toString()}`)},ne=y.useCallback(D=>{I(D)},[]),G=y.useCallback(D=>{A&&(D.url!==A?(o(A),d(D.url,D.name,D.proxyConfig,D.transportType)):f(A,{name:D.name,proxyConfig:D.proxyConfig,transportType:D.transportType}),I(null),pt.success("Connection settings updated"))},[A,o,d,f]),K=(D,j,V)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:D,itemName:j,serverId:V}),V){const W=r.find(se=>se.id===V);if(console.warn("[Layout] Server lookup:",{serverId:V,serverFound:!!W,serverState:W?.state}),!W||W.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),pt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:V,tab:D,itemName:j}),E(V,D,j);const te=new URLSearchParams(n.search),de=te.get("tunnelUrl"),fe=te.get("tab"),J=new URLSearchParams;J.set("server",V),de&&J.set("tunnelUrl",de),D?J.set("tab",D):fe&&J.set("tab",fe);const Q=`/?${J.toString()}`;console.warn("[Layout] Navigating to:",Q),t(Q)}else console.warn("[Layout] No serverId, just updating tab to:",D),v(D)},F=r.find(D=>D.id===m),re=F?F.tools.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.tools.map(j=>({...j,_serverId:D.id,_serverName:D.name})):[]),ee=F?F.prompts.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.prompts.map(j=>({...j,_serverId:D.id,_serverName:D.name})):[]),M=F?F.resources.map(D=>({...D,_serverId:F.id})):r.flatMap(D=>D.state==="ready"?D.resources.map(j=>({...j,_serverId:D.id,_serverName:D.name})):[]);if(y.useEffect(()=>{const j=new URLSearchParams(n.search).get("server"),V=j?decodeURIComponent(j):null;V!==m&&h(V)},[n.search,m,h]),y.useEffect(()=>{const j=new URLSearchParams(n.search).get("server");if(!j)return;const V=decodeURIComponent(j),W=r.find(te=>te.id===V);if(!W){const te=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(te)}if(W.state==="failed"){const te=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(te)}},[n.search,t,r]),ZV({onCommandPalette:()=>Y("keyboard"),onToolsTab:()=>{F&&v("tools")},onPromptsTab:()=>{F&&v("prompts")},onResourcesTab:()=>{F&&v("resources")},onChatTab:()=>{F&&v("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{g==="tools"&&U.current?U.current.focusSearch():g==="prompts"&&L.current?L.current.focusSearch():g==="resources"&&$.current&&$.current.focusSearch()},onBlurSearch:()=>{g==="tools"&&U.current?U.current.blurSearch():g==="prompts"&&L.current?L.current.blurSearch():g==="resources"&&$.current&&$.current.blurSearch()}}),H)return u.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:u.jsxs("div",{className:"flex flex-col items-center gap-4",children:[u.jsx(eo,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),u.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})});const B=S?{backgroundColor:_.backgroundColor||"#f3f3f3",padding:_.padding||"0.5rem"}:{},P=S?"h-screen flex flex-col gap-2 sm:gap-4":"h-screen bg-[#f3f3f3] dark:bg-black flex flex-col px-2 py-2 sm:px-4 sm:py-4 gap-2 sm:gap-4";return u.jsx(TT,{children:u.jsxs("div",{className:P,style:B,children:[u.jsx(Rxe,{connections:r,selectedServer:F,activeTab:g,onServerSelect:q,onTabChange:v,onCommandPaletteOpen:()=>Y("button"),onOpenConnectionOptions:ne,embedded:S}),u.jsx("main",{className:"flex-1 w-full mx-auto bg-white dark:bg-black rounded-2xl border border-zinc-200 dark:border-zinc-700 p-0 overflow-auto",children:u.jsx(_xe,{selectedServer:F,activeTab:g,toolsSearchRef:U,promptsSearchRef:L,resourcesSearchRef:$,children:e})}),u.jsx(Sbe,{isOpen:R,onOpenChange:C,tools:re,prompts:ee,resources:M,savedRequests:O,connections:r,selectedServer:F,tunnelUrl:w,onNavigate:K,onServerSelect:q}),u.jsx(pH,{connection:A&&r.find(D=>D.id===A)||null,open:A!==null,onOpenChange:D=>{D||I(null)},onConnect:G})]})})}function Ixe(){const[e,t]=y.useState("processing"),[n,r]=y.useState("");return y.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),J_().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(a=>{console.error("[OAuthCallback] Authorization failed:",a),t("error"),r(a instanceof Error?a.message:String(a))})},[]),e==="processing"?u.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:u.jsxs("div",{className:"flex flex-col items-center gap-4",children:[u.jsx(Bi,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),u.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?u.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:u.jsxs("div",{className:"max-w-md p-6",children:[u.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),u.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),u.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):u.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:u.jsxs("div",{className:"max-w-md p-6",children:[u.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),u.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var Oxe=(e,t,n,r,a,o,i,c)=>{let d=document.documentElement,f=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(E=>{let x=E==="class",w=x&&o?a.map(S=>o[S]||S):a;x?(d.classList.remove(...w),d.classList.add(o&&o[v]?o[v]:v)):d.setAttribute(E,v)}),h(v)}function h(v){c&&f.includes(v)&&(d.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)m(r);else try{let v=localStorage.getItem(t)||n,E=i&&v==="system"?g():v;m(E)}catch{}},Dxe=y.createContext(void 0),Lxe={setTheme:e=>{},themes:[]},Mxe=()=>{var e;return(e=y.useContext(Dxe))!=null?e:Lxe};y.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:a,defaultTheme:o,value:i,themes:c,nonce:d,scriptProps:f})=>{let m=JSON.stringify([n,t,o,e,c,i,r,a]).slice(1,-1);return y.createElement("script",{...f,suppressHydrationWarning:!0,nonce:typeof window>"u"?d:"",dangerouslySetInnerHTML:{__html:`(${Oxe.toString()})(${m})`}})});function jxe({...e}){const{theme:t="system"}=Mxe();return u.jsx(eue,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Pxe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true",n=y.useMemo(()=>t?void 0:new Eee("mcp-inspector-connections"),[t]);return u.jsx(afe,{children:u.jsx(f4,{storageProvider:n,enableRpcLogging:!0,onServerAdded:(r,a)=>{console.log("[Inspector] Server added:",r,a.state)},onServerRemoved:r=>{console.log("[Inspector] Server removed:",r)},onServerStateChange:(r,a)=>{console.log("[Inspector] Server state changed:",r,a)},onSamplingRequest:(r,a,o,i,c)=>{const d=pt(u.jsx(bxe,{requestId:r.id,serverName:o,onViewDetails:()=>{const f=new CustomEvent("navigate-to-sampling",{detail:{requestId:r.id}});window.dispatchEvent(f),pt.dismiss(d)},onApprove:f=>{i(r.id,f),pt.success("Sampling request approved"),pt.dismiss(d)},onDeny:()=>{c(r.id,"User denied from toast"),pt.dismiss(d)}}),{duration:1/0})},onElicitationRequest:(r,a,o,i,c)=>{const d=r.request.mode||"form",f=r.request.message,m=d==="url"&&"url"in r.request?r.request.url:void 0,h=pt(u.jsx(vxe,{requestId:r.id,serverName:o,mode:d,message:f,url:m,onViewDetails:()=>{const g=new CustomEvent("navigate-to-elicitation",{detail:{requestId:r.id}});window.dispatchEvent(g),pt.dismiss(h)},onOpenUrl:d==="url"&&m?()=>{window.open(m,"_blank"),pt.dismiss(h)}:void 0,onCancel:()=>{c(r.id,"User cancelled from toast"),pt.dismiss(h)}}),{duration:1/0})},children:u.jsxs(Gge,{children:[u.jsx(yce,{basename:"/inspector",children:u.jsxs(Zle,{children:[u.jsx(aS,{path:"/oauth/callback",element:u.jsx(Ixe,{})}),u.jsx(aS,{path:"/",element:u.jsx(Axe,{children:u.jsx(Vge,{})})})]})}),u.jsx(jxe,{position:"top-center"})]})})})}const Hz=new URLSearchParams(window.location.search);if(Hz.has("code")||Hz.has("error"))try{J_()}catch(e){console.error("[inspector] OAuth callback error:",e)}const Vz=document.getElementById("root");Vz?Aee.createRoot(Vz).render(u.jsx(Pxe,{})):console.error("[inspector] Root element not found");const $xe=Object.freeze(Object.defineProperty({__proto__:null,clearRpcLogs:Bb,getAllRpcLogs:tT,getRpcLogs:p4,subscribeToRpcLogs:nT,wrapTransportForLogging:m4},Symbol.toStringTag,{value:"Module"}));export{LK as $,$f as A,oJ as B,Aj as C,Gxe as D,Wi as E,LY as F,GK as G,uee as H,eW as I,nb as J,rW as K,DY as L,oee as M,DK as N,Bxe as O,Z7 as P,$i as Q,ie as R,tq as S,Bs as T,Q2 as U,Vn as V,eY as W,r2 as X,B7 as Y,Nq as Z,De as _,pa as a,ob as a0,R7 as a1,dee as a2,A7 as a3,J_ as a4,H7 as a5,pd as b,Yp as c,iee as d,Ny as e,Fxe as f,zxe as g,lee as h,Ke as i,Bn as j,Sq as k,Le as l,dt as m,En as n,qe as o,Hxe as p,nF as q,y as r,le as s,Kxe as t,tr as u,Va as v,Gn as w,Wxe as x,Vxe as y,nr as z};
|