@mcp-use/inspector 0.14.0 → 0.14.1-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{browser-EyInsrZa.js → browser-szdNinNK.js} +3 -3
- package/dist/client/assets/{client-JeU2zpxn.js → client-bKYVMi0j.js} +1 -1
- package/dist/client/assets/{display-A5IEINAP-Btv2gL3n.js → display-A5IEINAP-DWNdR0On.js} +2 -2
- package/dist/client/assets/{embeddings-Dya_KnH0.js → embeddings-DY7LEcGM.js} +1 -1
- package/dist/client/assets/{index-DoHGzyNN.js → index-B-I4WCT7.js} +6 -6
- package/dist/client/assets/{index-CwGEcSpK.js → index-B1GRA_yE.js} +1 -1
- package/dist/client/assets/{index-dRu1bjMq.js → index-B7K7EglZ.js} +1 -1
- package/dist/client/assets/{index-3gQQW6s7.js → index-BKSSQ8ab.js} +1 -1
- package/dist/client/assets/{index-BZCfajuh.js → index-CQWqWZPb.js} +1 -1
- package/dist/client/assets/{index-D7646HFQ.js → index-D05JX2rN.js} +1 -1
- package/dist/client/assets/{index-01y2e9ko.js → index-D89ggwyw.js} +1 -1
- package/dist/client/assets/{index--IpKhg5F.js → index-DpOgK2Yr.js} +1 -1
- package/dist/client/assets/{index-BiUxRAkS.js → index-NmfTs9aq.js} +1 -1
- package/dist/client/assets/{llms-CQ_t8ic9.js → llms-D3SVvBDG.js} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index
|
|
2
|
-
var b7=Object.defineProperty;var y7=(e,t,n)=>t in e?b7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Bh=(e,t,n)=>y7(e,typeof t!="symbol"?t+"":t,n);function v7(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 Mxe(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 w7(){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 x7(){return BL||(BL=1,Yx.exports=w7()),Yx.exports}var u=x7();const E7="modulepreload",S7=function(e){return"/inspector/"+e},HL={},fa=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=S7(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":E7,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 _7=Object.defineProperty,Me=(e,t)=>_7(e,"name",{value:t,configurable:!0}),jxe=(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.")}Me(Gz,"isLocalServer");function Wz(e){const t=e.split(".");return t.length<=2?e:t.slice(t.length-2).join(".")}Me(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)})}Me(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}}Me(Yz,"detectFavicon");function b_(e,t){if(!t?.proxyAddress)return{url:e,headers:t?.customHeaders||{}};const n=new URL(t.proxyAddress),r=new URL(e),a=`${n.origin}${n.pathname}${r.pathname}${r.search}`,o={"X-Target-URL":e,...t.customHeaders};return{url:a,headers:o}}Me(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"}}Me(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(" ")}Me(qz,"formatArgs");var _u,T7=(_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}},Me(_u,"SimpleConsoleLogger"),_u),Ai,N7=(Ai=class{static get(t=Zz){if(!this.instances[t]){const n=typeof process<"u"&&Pf?.DEBUG||void 0;this.instances[t]=new T7(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})}},Me(Ai,"Logger"),Bh(Ai,"instances",{}),Bh(Ai,"currentFormat","minimal"),Ai),Le=N7.get(),k7="1.12.0";function Ny(){return k7}Me(Ny,"getPackageVersion");var Tu,Rs=(Tu=class{},Me(Tu,"BaseTelemetryEvent"),Tu),Nu,C7=(Nu=class extends Rs{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}}},Me(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}}Me(Xz,"createServerRunEventData");var ku,R7=(ku=class extends Rs{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}}},Me(ku,"ServerRunEvent"),ku),Cu,A7=(Cu=class extends Rs{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}}},Me(Cu,"ServerInitializeEvent"),Cu),Ru,I7=(Ru=class extends Rs{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}}},Me(Ru,"ServerToolCallEvent"),Ru),Au,O7=(Au=class extends Rs{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}}},Me(Au,"ServerResourceCallEvent"),Au),Iu,D7=(Iu=class extends Rs{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}}},Me(Iu,"ServerPromptCallEvent"),Iu),Ou,L7=(Ou=class extends Rs{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}}},Me(Ou,"ServerContextEvent"),Ou),Du,M7=(Du=class extends Rs{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}}},Me(Du,"MCPClientInitEvent"),Du),Lu,j7=(Lu=class extends Rs{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}}},Me(Lu,"ConnectorInitEvent"),Lu),Mu,P7=(Mu=class extends Rs{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}}},Me(Mu,"ClientAddServerEvent"),Mu),ju,$7=(ju=class extends Rs{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},Me(ju,"ClientRemoveServerEvent"),ju);function Jz(e){return e._llm_type||e.constructor.name.toLowerCase()}Me(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}Me(Qz,"getModelName");function U7(e){return[Jz(e),Qz(e)]}Me(U7,"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)}`}Me(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)}Me(tb,"secureRandomString");var VL="mcp_use_user_id";function e2(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}Me(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"}Me(t2,"getStorageCapability");var Zx=null;function n2(){return Zx===null&&(Zx=e2()),Zx}Me(n2,"getRuntimeEnvironment");var xs,r2=(xs=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 fa(()=>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:Me(()=>{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 xs.instance||(xs.instance=new xs),xs.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 C7(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const r=Xz(t,n),a=new R7(r);await this.capture(a)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new A7(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new I7(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new O7(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new D7(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new L7(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new M7(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new j7(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const r=new P7({serverName:t,serverConfig:n});await this.capture(r)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new $7({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){}},Me(xs,"Telemetry"),Bh(xs,"instance",null),xs),Fs=r2;function z7(e){Fs.getInstance().setSource(e)}Me(z7,"setTelemetrySource");const F7=Object.freeze({status:"aborted"});function _e(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 Pi(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 Pxe(e,t="|"){return e.map(n=>W7(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 B7(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 Cn(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 H7(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 V7=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 G7=new Set(["string","number","symbol"]);function Zu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function rt(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 W7(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function K7(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Y7={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 Z7(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 Gi(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 Gi(e,r)}function X7(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 Gi(e,a)}function J7(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 Gi(e,n)}function Q7(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 Gi(e,n)}function eW(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 Gi(t,r)}function tW(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 Gi(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 $i(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=_e("$ZodError",l2),Cy=_e("$ZodError",l2,{Parent:Error});function nW(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 rW(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 aW(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 $xe(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 ${aW(r.path)}`);return t.join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DpOgK2Yr.js","assets/index-NmfTs9aq.js","assets/index-D89ggwyw.js","assets/llms-D3SVvBDG.js","assets/embeddings-DY7LEcGM.js","assets/index-B1GRA_yE.js","assets/index-BKSSQ8ab.js","assets/index-CQWqWZPb.js","assets/browser-szdNinNK.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var b7=Object.defineProperty;var y7=(e,t,n)=>t in e?b7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Bh=(e,t,n)=>y7(e,typeof t!="symbol"?t+"":t,n);function v7(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 Mxe(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 w7(){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 x7(){return BL||(BL=1,Yx.exports=w7()),Yx.exports}var u=x7();const E7="modulepreload",S7=function(e){return"/inspector/"+e},HL={},fa=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=S7(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":E7,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 _7=Object.defineProperty,Me=(e,t)=>_7(e,"name",{value:t,configurable:!0}),jxe=(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.")}Me(Gz,"isLocalServer");function Wz(e){const t=e.split(".");return t.length<=2?e:t.slice(t.length-2).join(".")}Me(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)})}Me(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}}Me(Yz,"detectFavicon");function b_(e,t){if(!t?.proxyAddress)return{url:e,headers:t?.customHeaders||{}};const n=new URL(t.proxyAddress),r=new URL(e),a=`${n.origin}${n.pathname}${r.pathname}${r.search}`,o={"X-Target-URL":e,...t.customHeaders};return{url:a,headers:o}}Me(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"}}Me(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(" ")}Me(qz,"formatArgs");var _u,T7=(_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}},Me(_u,"SimpleConsoleLogger"),_u),Ai,N7=(Ai=class{static get(t=Zz){if(!this.instances[t]){const n=typeof process<"u"&&Pf?.DEBUG||void 0;this.instances[t]=new T7(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})}},Me(Ai,"Logger"),Bh(Ai,"instances",{}),Bh(Ai,"currentFormat","minimal"),Ai),Le=N7.get(),k7="1.12.1-canary.1";function Ny(){return k7}Me(Ny,"getPackageVersion");var Tu,Rs=(Tu=class{},Me(Tu,"BaseTelemetryEvent"),Tu),Nu,C7=(Nu=class extends Rs{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}}},Me(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}}Me(Xz,"createServerRunEventData");var ku,R7=(ku=class extends Rs{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}}},Me(ku,"ServerRunEvent"),ku),Cu,A7=(Cu=class extends Rs{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}}},Me(Cu,"ServerInitializeEvent"),Cu),Ru,I7=(Ru=class extends Rs{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}}},Me(Ru,"ServerToolCallEvent"),Ru),Au,O7=(Au=class extends Rs{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}}},Me(Au,"ServerResourceCallEvent"),Au),Iu,D7=(Iu=class extends Rs{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}}},Me(Iu,"ServerPromptCallEvent"),Iu),Ou,L7=(Ou=class extends Rs{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}}},Me(Ou,"ServerContextEvent"),Ou),Du,M7=(Du=class extends Rs{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}}},Me(Du,"MCPClientInitEvent"),Du),Lu,j7=(Lu=class extends Rs{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}}},Me(Lu,"ConnectorInitEvent"),Lu),Mu,P7=(Mu=class extends Rs{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}}},Me(Mu,"ClientAddServerEvent"),Mu),ju,$7=(ju=class extends Rs{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},Me(ju,"ClientRemoveServerEvent"),ju);function Jz(e){return e._llm_type||e.constructor.name.toLowerCase()}Me(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}Me(Qz,"getModelName");function U7(e){return[Jz(e),Qz(e)]}Me(U7,"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)}`}Me(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)}Me(tb,"secureRandomString");var VL="mcp_use_user_id";function e2(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}Me(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"}Me(t2,"getStorageCapability");var Zx=null;function n2(){return Zx===null&&(Zx=e2()),Zx}Me(n2,"getRuntimeEnvironment");var xs,r2=(xs=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 fa(()=>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:Me(()=>{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 xs.instance||(xs.instance=new xs),xs.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 C7(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const r=Xz(t,n),a=new R7(r);await this.capture(a)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new A7(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new I7(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new O7(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new D7(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new L7(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new M7(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new j7(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const r=new P7({serverName:t,serverConfig:n});await this.capture(r)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new $7({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){}},Me(xs,"Telemetry"),Bh(xs,"instance",null),xs),Fs=r2;function z7(e){Fs.getInstance().setSource(e)}Me(z7,"setTelemetrySource");const F7=Object.freeze({status:"aborted"});function _e(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 Pi(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 Pxe(e,t="|"){return e.map(n=>W7(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 B7(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 Cn(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 H7(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 V7=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 G7=new Set(["string","number","symbol"]);function Zu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function rt(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 W7(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function K7(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Y7={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 Z7(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 Gi(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 Gi(e,r)}function X7(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 Gi(e,a)}function J7(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 Gi(e,n)}function Q7(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 Gi(e,n)}function eW(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 Gi(t,r)}function tW(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 Gi(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 $i(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=_e("$ZodError",l2),Cy=_e("$ZodError",l2,{Parent:Error});function nW(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 rW(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 aW(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 $xe(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 ${aW(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=>$i(d,o,Pi())));throw o2(c,a?.callee),c}return i.value},Uxe=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=>$i(d,o,Pi())));throw o2(c,a?.callee),c}return i.value},zxe=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=>$i(i,a,Pi())))}:{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=>$i(i,a,Pi())))}:{success:!0,data:o.value}},sW=Oy(Cy),oW=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ry(e)(t,n,a)},iW=e=>(t,n,r)=>Ry(e)(t,n,r),lW=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ay(e)(t,n,a)},cW=e=>async(t,n,r)=>Ay(e)(t,n,r),uW=e=>(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Iy(e)(t,n,a)},dW=e=>(t,n,r)=>Iy(e)(t,n,r),fW=e=>async(t,n,r)=>{const a=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oy(e)(t,n,a)},pW=e=>async(t,n,r)=>Oy(e)(t,n,r),mW=/^[cC][^\s-]{8,}$/,hW=/^[0-9a-z]+$/,gW=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bW=/^[0-9a-vA-V]{20}$/,yW=/^[A-Za-z0-9]{27}$/,vW=/^[a-zA-Z0-9_-]{21}$/,wW=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,xW=/^([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)$/,EW=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,SW="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function _W(){return new RegExp(SW,"u")}const TW=/^(?:(?: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])$/,NW=/^(([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}|:))$/,kW=/^((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])$/,CW=/^(([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])$/,RW=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,d2=/^[A-Za-z0-9_-]*$/,AW=/^\+(?:[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])))",IW=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 OW(e){return new RegExp(`^${p2(e)}$`)}function DW(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 LW=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},MW=/^-?\d+$/,jW=/^-?\d+(?:\.\d+)?/,PW=/^(?:true|false)$/i,$W=/^null$/i,UW=/^[^A-Z]*$/,zW=/^[^a-z]*$/,Ra=_e("$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=_e("$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=_e("$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})}}),FW=_e("$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):B7(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})}}),BW=_e("$ZodCheckNumberFormat",(e,t)=>{Ra.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[a,o]=Y7[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=MW)}),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})}}),HW=_e("$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})}}),VW=_e("$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})}}),GW=_e("$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=_e("$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=()=>{})}),WW=_e("$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})}}),KW=_e("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=UW),Dy.init(e,t)}),YW=_e("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zW),Dy.init(e,t)}),ZW=_e("$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=_e("$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})}}),XW=_e("$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})}}),JW=_e("$ZodCheckOverwrite",(e,t)=>{Ra.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class QW{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 eK={major:4,minor:2,patch:0},Rn=_e("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=eK;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 sW(e,a).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),x_=_e("$ZodString",(e,t)=>{Rn.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??LW(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}}),Wn=_e("$ZodStringFormat",(e,t)=>{Dy.init(e,t),x_.init(e,t)}),tK=_e("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=xW),Wn.init(e,t)}),nK=_e("$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());Wn.init(e,t)}),rK=_e("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=EW),Wn.init(e,t)}),aK=_e("$ZodURL",(e,t)=>{Wn.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})}}}),sK=_e("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=_W()),Wn.init(e,t)}),oK=_e("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=vW),Wn.init(e,t)}),iK=_e("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=mW),Wn.init(e,t)}),lK=_e("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=hW),Wn.init(e,t)}),cK=_e("$ZodULID",(e,t)=>{t.pattern??(t.pattern=gW),Wn.init(e,t)}),uK=_e("$ZodXID",(e,t)=>{t.pattern??(t.pattern=bW),Wn.init(e,t)}),dK=_e("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=yW),Wn.init(e,t)}),fK=_e("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=DW(t)),Wn.init(e,t)}),pK=_e("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=IW),Wn.init(e,t)}),mK=_e("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=OW(t)),Wn.init(e,t)}),hK=_e("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=wW),Wn.init(e,t)}),gK=_e("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=TW),Wn.init(e,t),e._zod.bag.format="ipv4"}),bK=_e("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=NW),Wn.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})}}}),yK=_e("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=kW),Wn.init(e,t)}),vK=_e("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=CW),Wn.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 wK=_e("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=RW),Wn.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 xK(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 EK=_e("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=d2),Wn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{xK(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),SK=_e("$ZodE164",(e,t)=>{t.pattern??(t.pattern=AW),Wn.init(e,t)});function _K(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 TK=_e("$ZodJWT",(e,t)=>{Wn.init(e,t),e._zod.check=n=>{_K(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),y2=_e("$ZodNumber",(e,t)=>{Rn.init(e,t),e._zod.pattern=e._zod.bag.pattern??jW,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}}),NK=_e("$ZodNumberFormat",(e,t)=>{BW.init(e,t),y2.init(e,t)}),kK=_e("$ZodBoolean",(e,t)=>{Rn.init(e,t),e._zod.pattern=PW,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}}),CK=_e("$ZodNull",(e,t)=>{Rn.init(e,t),e._zod.pattern=$W,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}}),RK=_e("$ZodAny",(e,t)=>{Rn.init(e,t),e._zod.parse=n=>n}),AK=_e("$ZodUnknown",(e,t)=>{Rn.init(e,t),e._zod.parse=n=>n}),IK=_e("$ZodNever",(e,t)=>{Rn.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 OK=_e("$ZodArray",(e,t)=>{Rn.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=K7(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 DK=_e("$ZodObject",(e,t)=>{if(Rn.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));Cn(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}}),LK=_e("$ZodObjectJIT",(e,t)=>{DK.init(e,t);const n=e._zod.parse,r=ky(()=>v2(t)),a=g=>{const v=new QW(["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 ZQ(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 XQ={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class _l extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class JQ{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??XQ}async _authThenStart(){if(!this._authProvider)throw new ns("No auth provider");let t;try{t=await Ro(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 ns;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 _l(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 ns("No auth provider");if(await Ro(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ns("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 _l(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:v,scope:E}=hp(c);if(this._resourceMetadataUrl=v,this._scope=E,await Ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ns;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 _l(403,"Server returned 403 after trying upscoping");if(E&&(this._scope=E),v&&(this._resourceMetadataUrl=v),this._lastUpscopingHeader=w??void 0,await Ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new ns;return this.send(t)}}throw new _l(c.status,`Error POSTing to endpoint: ${g}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,c.status===202){await c.body?.cancel(),Fq(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 _l(-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 _l(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 QQ(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),Gt=(e,t,n)=>(X_(e,t,"read from private field"),n?n.call(e):t.get(e)),Er=(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),Hn=(e,t,n,r)=>(X_(e,t,"write to private field"),t.set(e,n),n),ko=(e,t,n)=>(X_(e,t,"access private method"),n),Na,Nl,Vc,ab,Fb,qf,tu,Xf,ki,Gc,hu,Wc,zf,bs,jE,PE,$E,Pj,UE,zE,Ff,FE,BE;class sb extends EventTarget{constructor(t,n){var r,a;super(),Er(this,bs),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Er(this,Na),Er(this,Nl),Er(this,Vc),Er(this,ab),Er(this,Fb),Er(this,qf),Er(this,tu),Er(this,Xf,null),Er(this,ki),Er(this,Gc),Er(this,hu,null),Er(this,Wc,null),Er(this,zf,null),Er(this,PE,async o=>{var i;Gt(this,Gc).reset();const{body:c,redirected:d,status:f,headers:m}=o;if(f===204){ko(this,bs,Ff).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(d?Hn(this,Vc,new URL(o.url)):Hn(this,Vc,void 0),f!==200){ko(this,bs,Ff).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){ko(this,bs,Ff).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(Gt(this,Na)===this.CLOSED)return;Hn(this,Na,this.OPEN);const h=new Event("open");if((i=Gt(this,zf))==null||i.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){ko(this,bs,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&&Gt(this,Gc).feed(g.decode(w,{stream:!x})),x&&(E=!1,Gt(this,Gc).reset(),ko(this,bs,FE).call(this))}while(E)}),Er(this,$E,o=>{Hn(this,ki,void 0),!(o.name==="AbortError"||o.type==="aborted")&&ko(this,bs,FE).call(this,ME(o))}),Er(this,UE,o=>{typeof o.id=="string"&&Hn(this,Xf,o.id);const i=new MessageEvent(o.event||"message",{data:o.data,origin:Gt(this,Vc)?Gt(this,Vc).origin:Gt(this,Nl).origin,lastEventId:o.id||""});Gt(this,Wc)&&(!o.event||o.event==="message")&&Gt(this,Wc).call(this,i),this.dispatchEvent(i)}),Er(this,zE,o=>{Hn(this,qf,o)}),Er(this,BE,()=>{Hn(this,tu,void 0),Gt(this,Na)===this.CONNECTING&&ko(this,bs,jE).call(this)});try{if(t instanceof URL)Hn(this,Nl,t);else if(typeof t=="string")Hn(this,Nl,new URL(t,eee()));else throw new Error("Invalid URL")}catch{throw QQ("An invalid or illegal string was specified")}Hn(this,Gc,n4({onEvent:Gt(this,UE),onRetry:Gt(this,zE)})),Hn(this,Na,this.CONNECTING),Hn(this,qf,3e3),Hn(this,Fb,(r=n?.fetch)!=null?r:globalThis.fetch),Hn(this,ab,(a=n?.withCredentials)!=null?a:!1),ko(this,bs,jE).call(this)}get readyState(){return Gt(this,Na)}get url(){return Gt(this,Nl).href}get withCredentials(){return Gt(this,ab)}get onerror(){return Gt(this,hu)}set onerror(t){Hn(this,hu,t)}get onmessage(){return Gt(this,Wc)}set onmessage(t){Hn(this,Wc,t)}get onopen(){return Gt(this,zf)}set onopen(t){Hn(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(){Gt(this,tu)&&clearTimeout(Gt(this,tu)),Gt(this,Na)!==this.CLOSED&&(Gt(this,ki)&&Gt(this,ki).abort(),Hn(this,Na,this.CLOSED),Hn(this,ki,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,ki=new WeakMap,Gc=new WeakMap,hu=new WeakMap,Wc=new WeakMap,zf=new WeakMap,bs=new WeakSet,jE=function(){Hn(this,Na,this.CONNECTING),Hn(this,ki,new AbortController),Gt(this,Fb)(Gt(this,Nl),ko(this,bs,Pj).call(this)).then(Gt(this,PE)).catch(Gt(this,$E))},PE=new WeakMap,$E=new WeakMap,Pj=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Gt(this,Xf)?{"Last-Event-ID":Gt(this,Xf)}:void 0},cache:"no-store",signal:(e=Gt(this,ki))==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;Gt(this,Na)!==this.CLOSED&&Hn(this,Na,this.CLOSED);const r=new Mj("error",{code:t,message:e});(n=Gt(this,hu))==null||n.call(this,r),this.dispatchEvent(r)},FE=function(e,t){var n;if(Gt(this,Na)===this.CLOSED)return;Hn(this,Na,this.CONNECTING);const r=new Mj("error",{code:t,message:e});(n=Gt(this,hu))==null||n.call(this,r),this.dispatchEvent(r),Hn(this,tu,setTimeout(Gt(this,BE),Gt(this,qf)))},BE=new WeakMap,sb.CONNECTING=0,sb.OPEN=1,sb.CLOSED=2;function eee(){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 tee extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class nee{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 ns("No auth provider");let t;try{t=await Ro(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 ns;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 tee(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 ns("No auth provider");if(await Ro(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ns("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 Ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ns;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,ree=($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)}},Me($u,"MCPSession"),$u),Uu,aee=(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,Fs.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Fs.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 ree(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")}},Me(Uu,"BaseMCPClient"),Uu),zu,see=(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=Me(()=>{r.removeEventListener("abort",a),t()},"onAbort");r.addEventListener("abort",a)})}},Me(zu,"ConnectionManager"),zu),Fu,oee=(Fu=class extends see{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 nee(this.url,this.opts),n=t.send.bind(t);return t.send=async r=>{const a=Me(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}}},Me(Fu,"SseConnectionManager"),Fu),Bu,iee=(Bu=class extends rJ{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;disableSseFallback;gatewayUrl;serverId;transportType=null;streamableTransport=null;constructor(t,n={}){super(n),this.baseUrl=t.replace(/\/$/,""),this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.gatewayUrl=n.gatewayUrl,this.serverId=n.serverId,this.gatewayUrl&&(this.headers["X-Target-URL"]=this.baseUrl,this.serverId&&(this.headers["X-Server-Id"]=this.serverId)),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.gatewayUrl?this.gatewayUrl.replace(/\/$/,""):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){let r="Unknown error",a=!1;if(n instanceof _l){const o=n;a=o.code===401,o.code===400&&o.message.includes("Missing session ID")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Le.warn(`⚠️ ${r}`)):o.code===404||o.code===405?(r=`Server returned ${o.code} - server likely doesn't support streamable HTTP`,Le.debug(r)):(r=`Server returned ${o.code}: ${o.message}`,Le.debug(r))}else if(n instanceof Error){const o=n.toString(),i=n.message||"";a=o.includes("401")||i.includes("Unauthorized"),o.includes("Missing session ID")||o.includes("Bad Request: Missing session ID")||i.includes("FastMCP session ID error")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Le.warn(`⚠️ ${r}`)):o.includes("405 Method Not Allowed")||o.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 o=new Error("Authentication required");throw o.code=401,o}if(this.disableSseFallback)throw Le.info("SSE fallback disabled - failing connection"),await this.cleanupResources(),new Error(`Streamable HTTP connection failed: ${r}`);Le.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(o){if(Le.error("Failed to connect with both transports:"),Le.error(` Streamable HTTP: ${r}`),Le.error(` SSE: ${o}`),await this.cleanupResources(),o?.message?.includes("401")||o?.message?.includes("Unauthorized")){const c=new Error("Authentication required");throw c.code=401,c}throw new Error("Could not connect to server with any available transport")}}}async connectWithStreamableHttp(t){try{const n=new JQ(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:Me(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 oee(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}},Me(Bu,"HttpConnector"),Bu),jl,lee=(jl=class extends aee{static getPackageVersion(){return Ny()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Fs.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,samplingCallback:d,elicitationCallback:f,disableSseFallback:m,preferSse:h,clientInfo:g}=t;if(!n)throw new Error("Server URL is required");const v={headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:c,samplingCallback:d,elicitationCallback:f,disableSseFallback:m,preferSse:h,clientInfo:g};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new iee(n,v)}},Me(jl,"BrowserMCPClient"),jl);function nu(e){const t=Me(()=>{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}Me(nu,"sanitizeUrl");function a4([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}Me(a4,"sanitizeParam");var Hu,ob=(Hu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;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.onPopupWindow=n.onPopupWindow}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}`}},Me(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 Ro(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")))}}Me(J_,"onMcpAuthorization");var h0={exports:{}},Nt={};var $j;function cee(){if($j)return Nt;$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,F,U){this.props=M,this.context=F,this.refs=w,this.updater=U||E}S.prototype.isReactComponent={},S.prototype.setState=function(M,F){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,F,"setState")},S.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function _(){}_.prototype=S.prototype;function T(M,F,U){this.props=M,this.context=F,this.refs=w,this.updater=U||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 j(M,F,U){var D=U.ref;return{$$typeof:e,type:M,key:F,ref:D!==void 0?D:null,props:U}}function L(M,F){return j(M.type,F,M.props)}function z(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function H(M){var F={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(U){return F[U]})}var Z=/\/+/g;function J(M,F){return typeof M=="object"&&M!==null&&M.key!=null?H(""+M.key):F.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(F){M.status==="pending"&&(M.status="fulfilled",M.value=F)},function(F){M.status==="pending"&&(M.status="rejected",M.reason=F)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function G(M,F,U,D,P){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),F,U,D,P)}}if(W)return P=P(M),W=D===""?"."+J(M,0):D,C(P)?(U="",W!=null&&(U=W.replace(Z,"$&/")+"/"),G(P,F,U,"",function(le){return le})):P!=null&&(z(P)&&(P=L(P,U+(P.key==null||M&&M.key===P.key?"":(""+P.key).replace(Z,"$&/")+"/")+W)),F.push(P)),1;W=0;var te=D===""?".":D+":";if(C(M))for(var fe=0;fe<M.length;fe++)D=M[fe],V=te+J(D,fe),W+=G(D,F,U,V,P);else if(fe=v(M),typeof fe=="function")for(M=fe.call(M),fe=0;!(D=M.next()).done;)D=D.value,V=te+J(D,fe++),W+=G(D,F,U,V,P);else if(V==="object"){if(typeof M.then=="function")return G(ne(M),F,U,D,P);throw F=String(M),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.")}return W}function Y(M,F,U){if(M==null)return M;var D=[],P=0;return G(M,D,"","",function(V){return F.call(U,V,P++)}),D}function B(M){if(M._status===-1){var F=M._result;F=F(),F.then(function(U){(M._status===0||M._status===-1)&&(M._status=1,M._result=U)},function(U){(M._status===0||M._status===-1)&&(M._status=2,M._result=U)}),M._status===-1&&(M._status=0,M._result=F)}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 F=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(F))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ee={map:Y,forEach:function(M,F,U){Y(M,function(){F.apply(this,arguments)},U)},count:function(M){var F=0;return Y(M,function(){F++}),F},toArray:function(M){return Y(M,function(F){return F})||[]},only:function(M){if(!z(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Nt.Activity=h,Nt.Children=ee,Nt.Component=S,Nt.Fragment=n,Nt.Profiler=a,Nt.PureComponent=T,Nt.StrictMode=r,Nt.Suspense=d,Nt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,Nt.__COMPILER_RUNTIME={__proto__:null,c:function(M){return I.H.useMemoCache(M)}},Nt.cache=function(M){return function(){return M.apply(null,arguments)}},Nt.cacheSignal=function(){return null},Nt.cloneElement=function(M,F,U){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var D=x({},M.props),P=M.key;if(F!=null)for(V in F.key!==void 0&&(P=""+F.key),F)!O.call(F,V)||V==="key"||V==="__self"||V==="__source"||V==="ref"&&F.ref===void 0||(D[V]=F[V]);var V=arguments.length-2;if(V===1)D.children=U;else if(1<V){for(var W=Array(V),te=0;te<V;te++)W[te]=arguments[te+2];D.children=W}return j(M.type,P,D)},Nt.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},Nt.createElement=function(M,F,U){var D,P={},V=null;if(F!=null)for(D in F.key!==void 0&&(V=""+F.key),F)O.call(F,D)&&D!=="key"&&D!=="__self"&&D!=="__source"&&(P[D]=F[D]);var W=arguments.length-2;if(W===1)P.children=U;else if(1<W){for(var te=Array(W),fe=0;fe<W;fe++)te[fe]=arguments[fe+2];P.children=te}if(M&&M.defaultProps)for(D in W=M.defaultProps,W)P[D]===void 0&&(P[D]=W[D]);return j(M,V,P)},Nt.createRef=function(){return{current:null}},Nt.forwardRef=function(M){return{$$typeof:c,render:M}},Nt.isValidElement=z,Nt.lazy=function(M){return{$$typeof:m,_payload:{_status:-1,_result:M},_init:B}},Nt.memo=function(M,F){return{$$typeof:f,type:M,compare:F===void 0?null:F}},Nt.startTransition=function(M){var F=I.T,U={};I.T=U;try{var D=M(),P=I.S;P!==null&&P(U,D),typeof D=="object"&&D!==null&&typeof D.then=="function"&&D.then(A,re)}catch(V){re(V)}finally{F!==null&&U.types!==null&&(F.types=U.types),I.T=F}},Nt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},Nt.use=function(M){return I.H.use(M)},Nt.useActionState=function(M,F,U){return I.H.useActionState(M,F,U)},Nt.useCallback=function(M,F){return I.H.useCallback(M,F)},Nt.useContext=function(M){return I.H.useContext(M)},Nt.useDebugValue=function(){},Nt.useDeferredValue=function(M,F){return I.H.useDeferredValue(M,F)},Nt.useEffect=function(M,F){return I.H.useEffect(M,F)},Nt.useEffectEvent=function(M){return I.H.useEffectEvent(M)},Nt.useId=function(){return I.H.useId()},Nt.useImperativeHandle=function(M,F,U){return I.H.useImperativeHandle(M,F,U)},Nt.useInsertionEffect=function(M,F){return I.H.useInsertionEffect(M,F)},Nt.useLayoutEffect=function(M,F){return I.H.useLayoutEffect(M,F)},Nt.useMemo=function(M,F){return I.H.useMemo(M,F)},Nt.useOptimistic=function(M,F){return I.H.useOptimistic(M,F)},Nt.useReducer=function(M,F,U){return I.H.useReducer(M,F,U)},Nt.useRef=function(M){return I.H.useRef(M)},Nt.useState=function(M){return I.H.useState(M)},Nt.useSyncExternalStore=function(M,F,U){return I.H.useSyncExternalStore(M,F,U)},Nt.useTransition=function(){return I.H.useTransition()},Nt.version="19.2.3",Nt}var Uj;function Q_(){return Uj||(Uj=1,h0.exports=cee()),h0.exports}var y=Q_();const ie=Yp(y),pd=v7({__proto__:null,default:ie},[y]);function HE(e,t){if(!e)throw new Error(t)}Me(HE,"assert");var zj=3e3,uee=5e3;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={},customHeaders:i={},proxyConfig:c,debug:d=!1,autoRetry:f=!1,autoReconnect:m=zj,transportType:h="auto",preventAutoAuth:g=!1,useRedirectFlow:v=!1,onPopupWindow:E,timeout:x=3e4,sseReadTimeout:w=3e5,wrapTransport:S,onNotification:_,samplingCallback:T,onElicitation:R}=e,{url:C,headers:A}=y.useMemo(()=>b_(t||"",c),[t,c]),I=y.useMemo(()=>({...A,...i}),[A,i]),[O,j]=y.useState("discovering"),[L,z]=y.useState([]),[H,Z]=y.useState([]),[J,ne]=y.useState([]),[G,Y]=y.useState([]),[B,re]=y.useState(),[ee,M]=y.useState(),[F,U]=y.useState(void 0),[D,P]=y.useState([]),[V,W]=y.useState(void 0),[te,fe]=y.useState(void 0),le=y.useRef(null),q=y.useRef(null),Q=y.useRef(null),ae=y.useRef(!1),de=y.useRef(!0),he=y.useRef(0),xe=y.useRef(null),He=y.useRef(!1),Ie=y.useRef(O),je=y.useRef(m),at=y.useRef(null),Ue=y.useRef(null),Ye=y.useRef(null);y.useEffect(()=>{Ie.current=O,je.current=m},[O,m]);const pe=y.useCallback((Pe,$e,...Oe)=>{const lt=Oe.length>0?`${$e} ${Oe.map(it=>JSON.stringify(it)).join(" ")}`:$e;console[Pe](`[useMcp] ${lt}`),de.current&&P(it=>[...it.slice(-100),{level:Pe,message:lt,timestamp:Date.now()}])},[]),Se=y.useCallback(async(Pe=!1)=>{if(Pe||pe("info","Disconnecting..."),ae.current=!1,xe.current&&clearTimeout(xe.current),xe.current=null,le.current)try{const $e="inspector-server",Oe=le.current.getSession($e);Oe&&Oe._healthCheckCleanup&&(Oe._healthCheckCleanup(),Oe._healthCheckCleanup=null),await le.current.closeSession($e)}catch($e){Pe||pe("warn","Error closing session:",$e)}le.current=null,de.current&&!Pe&&(j("discovering"),z([]),Z([]),ne([]),Y([]),U(void 0),W(void 0))},[pe]),Ne=y.useCallback((Pe,$e)=>{if(pe("error",Pe,$e??""),de.current){j("failed"),U(Pe);const Oe=q.current?.getLastAttemptedAuthUrl();Oe&&(W(Oe),pe("info","Manual authentication URL may be available.",Oe))}ae.current=!1,t&&Fs.getInstance().trackUseMcpConnection({url:t,transportType:h,success:!1,errorType:$e?.name||"UnknownError",hasOAuth:!!q.current,hasSampling:!!T,hasElicitation:!!R}).catch(()=>{})},[pe,t,h,T,R]),oe=y.useCallback(async()=>{if(!n||!t){pe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(ae.current){pe("debug","Connection attempt already in progress.");return}if(!de.current){pe("debug","Connect called after unmount, aborting.");return}ae.current=!0,he.current+=1,U(void 0),W(void 0),at.current=null,j("discovering"),pe("info",`Connecting attempt #${he.current} to ${t}...`),q.current||(q.current=new ob(t,{storageKeyPrefix:a,clientName:o.name,clientUri:o.uri,logoUri:o.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:g,useRedirectFlow:v,onPopupWindow:E}),pe("debug","BrowserOAuthClientProvider initialized in connect.")),le.current||(le.current=new lee,pe("debug","BrowserMCPClient initialized in connect."));const Pe=Me(async(Oe,lt=!1)=>{pe("info",`Attempting connection with transport: ${Oe}`);try{const it="inspector-server",Je={url:C,transport:Oe==="sse"?"http":Oe,disableSseFallback:Oe==="http",preferSse:Oe==="sse",clientInfo:{name:"mcp-use Inspector",version:Ny()}};if(I&&Object.keys(I).length>0&&(Je.headers=I),q.current){const wt=await q.current.tokens();wt?.access_token&&(Je.headers={...Je.headers,Authorization:`Bearer ${wt.access_token}`})}le.current.addServer(it,{...Je,authProvider:q.current,clientOptions:o,samplingCallback:T,elicitationCallback:R,wrapTransport:S?wt=>(console.log("[useMcp] Applying transport wrapper for server:",it,"url:",t),S(wt,t)):void 0});const Pt=await le.current.createSession(it,!1);Pt.on("notification",wt=>{_?.(wt),wt.method==="notifications/tools/list_changed"?(pe("info","Tools list changed, auto-refreshing..."),sn().catch(pt=>pe("warn","Auto-refresh tools failed:",pt))):wt.method==="notifications/resources/list_changed"?(pe("info","Resources list changed, auto-refreshing..."),Be().catch(pt=>pe("warn","Auto-refresh resources failed:",pt))):wt.method==="notifications/prompts/list_changed"&&(pe("info","Prompts list changed, auto-refreshing..."),ze().catch(pt=>pe("warn","Auto-refresh prompts failed:",pt)))}),await Pt.initialize(),pe("info","✅ Successfully connected to MCP server"),pe("info","Server info:",Pt.connector.serverInfo),pe("info","Server capabilities:",Pt.connector.serverCapabilities),console.log("[useMcp] Server info:",Pt.connector.serverInfo),console.log("[useMcp] Server capabilities:",Pt.connector.serverCapabilities),j("ready"),at.current=Oe;const Kt=Me(()=>{let wt=null,pt=Date.now();const Kn=1e4,vr=3e4;return wt=setInterval(Me(async()=>{if(!de.current||Ie.current!=="ready"){wt&&(clearInterval(wt),wt=null);return}try{await Pt.connector.listTools(),pt=Date.now()}catch{const fn=Date.now()-pt;fn>vr&&(pe("warn",`Connection appears to be broken (no response for ${Math.round(fn/1e3)}s), attempting to reconnect...`),wt&&(clearInterval(wt),wt=null),je.current&&de.current&&(j("discovering"),pe("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{de.current&&Ie.current==="discovering"&&oe()},typeof je.current=="number"?je.current:zj)))}},"checkConnectionHealth"),Kn),()=>{wt&&(clearInterval(wt),wt=null)}},"setupConnectionMonitoring");if(m){const wt=Kt();Pt._healthCheckCleanup=wt}Fs.getInstance().trackUseMcpConnection({url:t,transportType:Oe,success:!0,hasOAuth:!!q.current,hasSampling:!!T,hasElicitation:!!R}).catch(()=>{}),z(Pt.connector.tools||[]);const Ln=await Pt.connector.listAllResources();Z(Ln.resources||[]);const yn=await Pt.connector.listPrompts();Y(yn.prompts||[]);const on=Pt.connector.serverInfo,nn=Pt.connector.serverCapabilities;if(on){console.log("[useMcp] Server info:",on),re(on);const wt=(async()=>{try{const pt=on.icons;if(pt&&Array.isArray(pt)&&pt.length>0){const Kn=pt[0].src||pt[0].url;if(Kn){pe("info","Server provided icon:",Kn);const ir=await(await fetch(Kn)).blob(),bt=await new Promise((fn,Or)=>{const Jr=new FileReader;Jr.onloadend=()=>fn(Jr.result),Jr.onerror=Or,Jr.readAsDataURL(ir)});return de.current&&(re(fn=>fn?{...fn,icon:bt}:void 0),pe("debug","Server icon converted to base64")),bt}}if(t){const Kn=await Yz(t);if(Kn&&de.current)return re(vr=>vr?{...vr,icon:Kn}:void 0),pe("debug","Favicon detected and added to serverInfo"),Kn}return null}catch(pt){return pe("debug","Icon loading failed (non-critical):",pt),null}})();Q.current=wt}if(nn&&(console.log("[useMcp] Server capabilities:",nn),M(nn)),q.current){const wt=await q.current.tokens();if(wt?.access_token){const pt=wt.expires_in?Date.now()+wt.expires_in*1e3:void 0;fe({access_token:wt.access_token,token_type:wt.token_type||"Bearer",expires_at:pt,refresh_token:wt.refresh_token,scope:wt.scope})}}return"success"}catch(it){const Je=it,Pt=Je?.message||String(it);if(Je.code===401||Pt.includes("401")||Pt.includes("Unauthorized")){if(q.current){pe("info","Authentication required. OAuth provider available.");try{const{auth:Kt}=await fa(async()=>{const{auth:yn}=await Promise.resolve().then(()=>Dj);return{auth:yn}},void 0),Ln=new URL(t).origin;Kt(q.current,{serverUrl:Ln}).catch(()=>{}),setTimeout(()=>{if(de.current){const yn=q.current?.getLastAttemptedAuthUrl();yn?(W(yn),pe("info","Manual authentication URL available:",yn)):pe("warn","Could not generate authentication URL")}},100)}catch(Kt){pe("warn","Error generating auth URL:",Kt)}return de.current&&j("pending_auth"),ae.current=!1,"auth_redirect"}return i&&Object.keys(i).length>0?(Ne("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Ne("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Ne(Pt,Je instanceof Error?Je:new Error(String(Je))),"failed"}},"tryConnectWithTransport");let $e="failed";if(h==="sse")pe("debug","Using SSE-only transport mode"),$e=await Pe("sse");else if(h==="http")pe("debug","Using HTTP-only transport mode"),$e=await Pe("http");else{pe("debug","Using auto transport mode (HTTP with SSE fallback)");const Oe=await Pe("http");Oe==="fallback"&&de.current&&Ie.current!=="authenticating"?(pe("info","HTTP failed, attempting SSE fallback..."),$e=await Pe("sse")):$e=Oe}($e==="success"||$e==="failed"||$e==="auth_redirect")&&(ae.current=!1),pe("debug",`Connection sequence finished with status: ${$e}`)},[pe,Ne,Se,t,a,r,o.name,o.version,o.uri,o.logo_uri,i,h,g,v,E,n,x,w]);y.useEffect(()=>{Ue.current=oe,Ye.current=Ne},[oe,Ne]);const ke=y.useCallback(async(Pe,$e,Oe)=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot call tool "${Pe}".`);pe("info",`Calling tool: ${Pe}`,$e);const lt=Date.now();try{const Je=le.current.getSession("inspector-server");if(!Je)throw new Error("No active session found");const Pt=await Je.connector.callTool(Pe,$e||{},Oe);return pe("info",`Tool "${Pe}" call successful:`,Pt),Fs.getInstance().trackUseMcpToolCall({toolName:Pe,success:!0,executionTimeMs:Date.now()-lt}).catch(()=>{}),Pt}catch(it){throw pe("error",`Tool "${Pe}" call failed:`,it),Fs.getInstance().trackUseMcpToolCall({toolName:Pe,success:!1,errorType:it instanceof Error?it.name:"UnknownError",executionTimeMs:Date.now()-lt}).catch(()=>{}),it}},[O]),Ve=y.useCallback(()=>{Ie.current==="failed"?(pe("info","Retry requested..."),Ue.current?.()):pe("warn",`Retry called but state is not 'failed' (state: ${Ie.current}). Ignoring.`)},[pe]),Ge=y.useCallback(async()=>{pe("info","Manual authentication requested...");const Pe=Ie.current;if(Pe==="failed")pe("info","Attempting to reconnect and authenticate via retry..."),Ve();else if(Pe==="pending_auth"){pe("info","Proceeding with authentication from pending state...");try{HE(q.current,"Auth Provider not available for manual auth"),HE(t,"Server URL is required for authentication"),pe("info","Clearing all OAuth state and initiating fresh flow...");const $e=`${a}:${q.current.serverUrlHash}`;Object.keys(localStorage).forEach(Je=>{Je.startsWith($e)&&(pe("debug",`Removing stale OAuth key: ${Je}`),localStorage.removeItem(Je)),Je.startsWith(`${a}:state_`)&&(pe("debug",`Removing orphaned state: ${Je}`),localStorage.removeItem(Je))}),j("authenticating");const Oe=new ob(t,{storageKeyPrefix:a,clientName:o.name,clientUri:o.uri,logoUri:o.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:v,onPopupWindow:E});q.current=Oe,pe("info","Triggering fresh OAuth authorization...");const{auth:lt}=await fa(async()=>{const{auth:Je}=await Promise.resolve().then(()=>Dj);return{auth:Je}},void 0),it=new URL(t).origin;lt(Oe,{serverUrl:it}).catch(Je=>{pe("info","OAuth flow initiated:",Je instanceof Error?Je.message:"Redirecting...")})}catch($e){if(!de.current)return;j("pending_auth"),pe("error",`Manual authentication failed: ${$e instanceof Error?$e.message:String($e)}`)}}else if(Pe==="authenticating"){pe("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const $e=q.current?.getLastAttemptedAuthUrl();$e&&!V&&(W($e),pe("info","Manual authentication URL retrieved:",$e))}else pe("info",`Client not in a state requiring manual authentication trigger (state: ${Pe}). If needed, try disconnecting and reconnecting.`)},[pe,Ve,V,t,v,E,a,o.name,o.uri,o.logo_uri,r]),mt=y.useCallback(()=>{if(q.current){const Pe=q.current.clearStorage();pe("info",`Cleared ${Pe} item(s) from localStorage for ${t}.`),W(void 0),Se()}else pe("warn","Auth provider not initialized, cannot clear storage.")},[t,pe,Se]),_t=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot list resources.`);pe("info","Listing resources");try{const $e=le.current.getSession("inspector-server");if(!$e)throw new Error("No active session found");const Oe=await $e.connector.listAllResources();Z(Oe.resources||[]),pe("info","Resources listed successfully")}catch(Pe){throw pe("error","List resources failed:",Pe),Pe}},[O]),st=y.useCallback(async Pe=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot read resource.`);pe("info",`Reading resource: ${Pe}`);try{const Oe=le.current.getSession("inspector-server");if(!Oe)throw new Error("No active session found");const lt=await Oe.connector.readResource(Pe);return pe("info","Resource read successful:",lt),Fs.getInstance().trackUseMcpResourceRead({resourceUri:Pe,success:!0}).catch(()=>{}),lt}catch($e){throw pe("error","Resource read failed:",$e),Fs.getInstance().trackUseMcpResourceRead({resourceUri:Pe,success:!1,errorType:$e instanceof Error?$e.name:"UnknownError"}).catch(()=>{}),$e}},[O]),Qn=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot list prompts.`);pe("info","Listing prompts");try{const $e=le.current.getSession("inspector-server");if(!$e)throw new Error("No active session found");const Oe=await $e.connector.listPrompts();Y(Oe.prompts||[]),pe("info","Prompts listed successfully")}catch(Pe){throw pe("error","List prompts failed:",Pe),Pe}},[O]),sn=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current){pe("debug","Cannot refresh tools - client not ready");return}pe("debug","Refreshing tools list");try{const $e=le.current.getSession("inspector-server");if(!$e){pe("warn","No active session found for tools refresh");return}const Oe=await $e.connector.listTools();z(Oe||[]),pe("info","Tools list refreshed successfully")}catch(Pe){pe("warn","Failed to refresh tools:",Pe)}},[pe]),Be=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current){pe("debug","Cannot refresh resources - client not ready");return}pe("debug","Refreshing resources list");try{const $e=le.current.getSession("inspector-server");if(!$e){pe("warn","No active session found for resources refresh");return}const Oe=await $e.connector.listAllResources();Z(Oe.resources||[]),pe("info","Resources list refreshed successfully")}catch(Pe){pe("warn","Failed to refresh resources:",Pe)}},[pe]),ze=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current){pe("debug","Cannot refresh prompts - client not ready");return}pe("debug","Refreshing prompts list");try{const $e=le.current.getSession("inspector-server");if(!$e){pe("warn","No active session found for prompts refresh");return}const Oe=await $e.connector.listPrompts();Y(Oe.prompts||[]),pe("info","Prompts list refreshed successfully")}catch(Pe){pe("warn","Failed to refresh prompts:",Pe)}},[pe]),qe=y.useCallback(async()=>{pe("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([sn(),Be(),ze()])},[sn,Be,ze,pe]),Et=y.useCallback(async(Pe,$e)=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot get prompt.`);pe("info",`Getting prompt: ${Pe}`,$e);try{const lt=le.current.getSession("inspector-server");if(!lt)throw new Error("No active session found");const it=await lt.connector.getPrompt(Pe,$e||{});return pe("info",`Prompt "${Pe}" retrieved successfully:`,it),it}catch(Oe){throw pe("error",`Prompt "${Pe}" retrieval failed:`,Oe),Oe}},[O]);y.useEffect(()=>{const Pe=Me($e=>{$e.origin===window.location.origin&&$e.data?.type==="mcp_auth_callback"&&(pe("info","Received auth callback message.",$e.data),xe.current&&clearTimeout(xe.current),xe.current=null,$e.data.success?(pe("info","Authentication successful via popup. Reconnecting client..."),ae.current&&pe("debug","Connection attempt already in progress, resetting flag to allow reconnection."),ae.current=!1,setTimeout(()=>{de.current&&(pe("debug","Initiating reconnection after successful auth callback."),Ue.current?.())},100)):Ye.current?.(`Authentication failed in callback: ${$e.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Pe),pe("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Pe),pe("debug","Auth callback message listener removed."),xe.current&&clearTimeout(xe.current)}},[pe]),y.useEffect(()=>(de.current=!0,!n||!t?(pe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),j("discovering"),()=>{de.current=!1}):(pe("debug","useMcp mounted, initiating connection."),he.current=0,(!q.current||q.current.serverUrl!==t)&&(q.current=new ob(t,{storageKeyPrefix:a,clientName:o.name,clientUri:o.uri,logoUri:o.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:g,useRedirectFlow:v,onPopupWindow:E}),pe("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),oe(),()=>{de.current=!1,pe("debug","useMcp unmounting, disconnecting."),Se(!0)})),[t,n,a,r,o.name,o.version,o.uri,o.logo_uri,v]);const St=y.useRef(Ve),Mt=y.useRef(pe);y.useEffect(()=>{St.current=Ve,Mt.current=pe},[Ve,pe]),y.useEffect(()=>{let Pe=null;if(O==="failed"&&f&&he.current>0){if(!He.current){He.current=!0;const $e=typeof f=="number"?f:uee;Mt.current("info",`Connection failed, auto-retrying in ${$e}ms...`),Pe=setTimeout(()=>{He.current=!1,de.current&&Ie.current==="failed"&&St.current()},$e)}}else O!=="failed"&&(He.current=!1);return()=>{Pe&&(clearTimeout(Pe),He.current=!1)}},[O,f]);const Tt=y.useCallback(async()=>Ie.current!=="ready"?(pe("warn","Cannot ensure icon loaded - not connected"),null):B?.icon?B.icon:Q.current?(pe("debug","Waiting for icon to finish loading..."),await Q.current):(pe("debug","No icon available and no loading in progress"),null),[B,pe]);return{state:O,name:B?.name||t||"",tools:L,resources:H,resourceTemplates:J,prompts:G,serverInfo:B,capabilities:ee,error:F,log:D,authUrl:V,authTokens:te,client:le.current,callTool:ke,readResource:st,listResources:_t,listPrompts:Qn,getPrompt:Et,refreshTools:sn,refreshResources:Be,refreshPrompts:ze,refreshAll:qe,retry:Ve,disconnect:Se,authenticate:Ge,clearStorage:mt,ensureIconLoaded:Tt}}Me(eT,"useMcp");var Vu,dee=(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}},Me(Vu,"ErrorBoundary"),Vu),Jf="openai:set_globals";function gs(e){return y.useSyncExternalStore(t=>{const n=Me(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)}Me(gs,"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),z=Me(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(Jf,z);const H=setTimeout(()=>{clearInterval(L),typeof window<"u"&&window.removeEventListener(Jf,z)},5e3);return()=>{clearInterval(L),clearTimeout(H),typeof window<"u"&&window.removeEventListener(Jf,z)}},[]);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"?gs("toolInput"):o.toolInput,c=r==="openai"?gs("toolOutput"):o.toolOutput,d=gs("toolResponseMetadata"),f=y.useMemo(()=>{if(d&&typeof d=="object"){const L=d["mcp-use/props"];if(L)return L}return e||{}},[d,e]),m=gs("widgetState"),h=gs("theme"),g=gs("displayMode"),v=gs("safeArea"),E=gs("maxHeight"),x=gs("userAgent"),w=gs("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,z)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(L,z)},[]),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,_]),j=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:j}}Me(md,"useWidget");function fee(e){const{props:t}=md(e);return t}Me(fee,"useWidgetProps");function pee(){const{theme:e}=md();return e}Me(pee,"useWidgetTheme");function mee(e){const{state:t,setState:n}=md();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Me(mee,"useWidgetState");var Fj=Me(({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=Me(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 s4({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),[j,L]=y.useState(!1),z=y.useRef(null),H=y.useRef(null),[Z,J]=y.useState([]),[ne,G]=y.useState(""),[Y,B]=y.useState("get-my-city"),[re,ee]=y.useState("{}"),[M,F]=y.useState("Test follow-up message"),[U,D]=y.useState("https://docs.mcp-use.com"),P=g==="fullscreen"&&S,V=g==="pip"&&S,W=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const Se=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const Ne=Object.keys(window.openai);J(Ne)}catch{J([])}else J([])},100);return()=>{clearTimeout(Se)}},[]);const te=h==="dark",fe=Me(()=>{const Se=["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[...Se,"top-4","left-4"];case"top-center":return[...Se,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...Se,"top-4","right-4"];case"center-left":return[...Se,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...Se,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...Se,"bottom-4","left-4"];case"bottom-center":return[...Se,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...Se,"bottom-4","right-4"];default:return[...Se,"top-4","right-4"]}},"getPositionClasses"),le=Me(()=>{const Ne=v?.insets?.top?Math.max(16,v.insets.top+8):16,oe=v?.insets?.right?Math.max(16,v.insets.right+8):16,ke=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Ve=v?.insets?.left?Math.max(16,v.insets.left+8):16,Ge={};switch(n){case"top-left":Ge.top=`${Ne}px`,Ge.left=`${Ve}px`;break;case"top-center":Ge.top=`${Ne}px`;break;case"top-right":Ge.top=`${Ne}px`,Ge.right=`${oe}px`;break;case"center-left":Ge.left=`${Ve}px`;break;case"center-right":Ge.right=`${oe}px`;break;case"bottom-left":Ge.bottom=`${ke}px`,Ge.left=`${Ve}px`;break;case"bottom-center":Ge.bottom=`${ke}px`;break;case"bottom-right":Ge.bottom=`${ke}px`,Ge.right=`${oe}px`;break;default:Ge.top=`${Ne}px`,Ge.right=`${oe}px`;break}return Ge},"getPositionOffsetStyles");y.useEffect(()=>{if(!r)return;const Se=Me(()=>O(!0),"handleMouseEnter"),Ne=Me(()=>O(!1),"handleMouseLeave");return r.addEventListener("mouseenter",Se),r.addEventListener("mouseleave",Ne),()=>{r.removeEventListener("mouseenter",Se),r.removeEventListener("mouseleave",Ne)}},[r]),y.useEffect(()=>{if(!j)return;const Se=Me(Ne=>{H.current&&!H.current.contains(Ne.target)&&L(!1)},"handleClickOutside");return document.addEventListener("mousedown",Se),()=>{document.removeEventListener("mousedown",Se)}},[j]),y.useEffect(()=>(j?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[j]);const q=Me(()=>{L(!j)},"handleToggleOverlay"),Q=Me(async()=>{try{G("Calling tool...");const Se=re.trim()?JSON.parse(re):{},Ne=await _(Y,Se);G(`Success: ${JSON.stringify(Ne,null,2)}`)}catch(Se){G(`Error: ${Se.message}`)}},"handleCallTool"),ae=Me(async()=>{try{G("Sending follow-up message..."),await T(M),G("Follow-up message sent successfully")}catch(Se){G(`Error: ${Se.message}`)}},"handleSendFollowUpMessage"),de=Me(()=>{try{R(U),G(`Opened external link: ${U}`)}catch(Se){G(`Error: ${Se.message}`)}},"handleOpenExternal"),he=Me(async Se=>{try{G(`Requesting display mode: ${Se}...`);const Ne=await C(Se);G(`Display mode granted: ${Ne.mode}`)}catch(Ne){G(`Error: ${Ne.message}`)}},"handleRequestDisplayMode"),xe=Me(async()=>{try{const Se=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};G("Setting state..."),await A(Se),G(`State updated: ${JSON.stringify(Se,null,2)}`)}catch(Se){G(`Error: ${Se.message}`)}},"handleSetState"),He=Me(async()=>{try{await C("fullscreen")}catch(Se){console.error("Failed to go fullscreen:",Se)}},"handleFullscreen"),Ie=Me(async()=>{try{await C("pip")}catch(Se){console.error("Failed to go pip:",Se)}},"handlePip"),je=Me(()=>{const Se=["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[...Se,"top-full","right-0","mt-2"];case"top-left":return[...Se,"top-full","left-0","mt-2"];case"top-center":return[...Se,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...Se,"bottom-full","right-0","mb-2"];case"bottom-left":return[...Se,"bottom-full","left-0","mb-2"];case"bottom-center":return[...Se,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...Se,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...Se,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...Se,"top-full","right-0","mt-2"]}},"getTooltipClasses"),at=Me(({onClick:Se,label:Ne,children:oe})=>{const[ke,Ve]=y.useState(!1),Ge=je();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:()=>Ve(!0),onMouseLeave:()=>Ve(!1),onClick:Se,"aria-label":Ne},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:`${Ge.join(" ")} ${ke?"opacity-100":"opacity-0"}`},Ne))},"IconButton"),Ue=Me(Se=>{if(Se===null)return"null";if(Se===void 0)return"undefined";if(typeof Se=="object")try{return JSON.stringify(Se,null,2)}catch{return String(Se)}return String(Se)},"formatValue"),Ye=Me(Se=>Se?`${Se.device?.type||"unknown"}`:"N/A","formatUserAgent"),pe=Me(Se=>{if(!Se?.insets)return"N/A";const{top:Ne,bottom:oe,left:ke,right:Ve}=Se.insets;return`T:${Ne} B:${oe} L:${ke} R:${Ve}`},"formatSafeArea");return ie.createElement(ie.Fragment,null,ie.createElement("div",{ref:z,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&O(!0),onMouseLeave:()=>!r&&O(!1)},ie.createElement("div",{className:fe().join(" "),style:le()},!W&&ie.createElement(ie.Fragment,null,!P&&!V&&ie.createElement(ie.Fragment,null,(i===!0||i==="fullscreen")&&ie.createElement(at,{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(at,{onClick:Ie,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(at,{onClick:q,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),j&&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:Se=>{Se.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"},Ue(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"},Ue(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"},Ue(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"},Ue(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"},Ye(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"},pe(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"},Z.length>0?Z.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:Y,onChange:Se=>B(Se.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:Se=>ee(Se.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:Se=>F(Se.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:ae,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:U,onChange:Se=>D(Se.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:de,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:xe,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"))))))}Me(s4,"WidgetControls");function o4(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Me(o4,"getBasename");var hee=150,gee=5;function bee({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!1}){const a=o4(),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 fa(()=>import("./index-dRu1bjMq.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 XQ={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class _l extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class JQ{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??XQ}async _authThenStart(){if(!this._authProvider)throw new ns("No auth provider");let t;try{t=await Ro(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 ns;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 _l(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 ns("No auth provider");if(await Ro(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ns("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 _l(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:v,scope:E}=hp(c);if(this._resourceMetadataUrl=v,this._scope=E,await Ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ns;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 _l(403,"Server returned 403 after trying upscoping");if(E&&(this._scope=E),v&&(this._resourceMetadataUrl=v),this._lastUpscopingHeader=w??void 0,await Ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new ns;return this.send(t)}}throw new _l(c.status,`Error POSTing to endpoint: ${g}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,c.status===202){await c.body?.cancel(),Fq(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 _l(-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 _l(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 QQ(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),Gt=(e,t,n)=>(X_(e,t,"read from private field"),n?n.call(e):t.get(e)),Er=(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),Hn=(e,t,n,r)=>(X_(e,t,"write to private field"),t.set(e,n),n),ko=(e,t,n)=>(X_(e,t,"access private method"),n),Na,Nl,Vc,ab,Fb,qf,tu,Xf,ki,Gc,hu,Wc,zf,bs,jE,PE,$E,Pj,UE,zE,Ff,FE,BE;class sb extends EventTarget{constructor(t,n){var r,a;super(),Er(this,bs),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Er(this,Na),Er(this,Nl),Er(this,Vc),Er(this,ab),Er(this,Fb),Er(this,qf),Er(this,tu),Er(this,Xf,null),Er(this,ki),Er(this,Gc),Er(this,hu,null),Er(this,Wc,null),Er(this,zf,null),Er(this,PE,async o=>{var i;Gt(this,Gc).reset();const{body:c,redirected:d,status:f,headers:m}=o;if(f===204){ko(this,bs,Ff).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(d?Hn(this,Vc,new URL(o.url)):Hn(this,Vc,void 0),f!==200){ko(this,bs,Ff).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){ko(this,bs,Ff).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(Gt(this,Na)===this.CLOSED)return;Hn(this,Na,this.OPEN);const h=new Event("open");if((i=Gt(this,zf))==null||i.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){ko(this,bs,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&&Gt(this,Gc).feed(g.decode(w,{stream:!x})),x&&(E=!1,Gt(this,Gc).reset(),ko(this,bs,FE).call(this))}while(E)}),Er(this,$E,o=>{Hn(this,ki,void 0),!(o.name==="AbortError"||o.type==="aborted")&&ko(this,bs,FE).call(this,ME(o))}),Er(this,UE,o=>{typeof o.id=="string"&&Hn(this,Xf,o.id);const i=new MessageEvent(o.event||"message",{data:o.data,origin:Gt(this,Vc)?Gt(this,Vc).origin:Gt(this,Nl).origin,lastEventId:o.id||""});Gt(this,Wc)&&(!o.event||o.event==="message")&&Gt(this,Wc).call(this,i),this.dispatchEvent(i)}),Er(this,zE,o=>{Hn(this,qf,o)}),Er(this,BE,()=>{Hn(this,tu,void 0),Gt(this,Na)===this.CONNECTING&&ko(this,bs,jE).call(this)});try{if(t instanceof URL)Hn(this,Nl,t);else if(typeof t=="string")Hn(this,Nl,new URL(t,eee()));else throw new Error("Invalid URL")}catch{throw QQ("An invalid or illegal string was specified")}Hn(this,Gc,n4({onEvent:Gt(this,UE),onRetry:Gt(this,zE)})),Hn(this,Na,this.CONNECTING),Hn(this,qf,3e3),Hn(this,Fb,(r=n?.fetch)!=null?r:globalThis.fetch),Hn(this,ab,(a=n?.withCredentials)!=null?a:!1),ko(this,bs,jE).call(this)}get readyState(){return Gt(this,Na)}get url(){return Gt(this,Nl).href}get withCredentials(){return Gt(this,ab)}get onerror(){return Gt(this,hu)}set onerror(t){Hn(this,hu,t)}get onmessage(){return Gt(this,Wc)}set onmessage(t){Hn(this,Wc,t)}get onopen(){return Gt(this,zf)}set onopen(t){Hn(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(){Gt(this,tu)&&clearTimeout(Gt(this,tu)),Gt(this,Na)!==this.CLOSED&&(Gt(this,ki)&&Gt(this,ki).abort(),Hn(this,Na,this.CLOSED),Hn(this,ki,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,ki=new WeakMap,Gc=new WeakMap,hu=new WeakMap,Wc=new WeakMap,zf=new WeakMap,bs=new WeakSet,jE=function(){Hn(this,Na,this.CONNECTING),Hn(this,ki,new AbortController),Gt(this,Fb)(Gt(this,Nl),ko(this,bs,Pj).call(this)).then(Gt(this,PE)).catch(Gt(this,$E))},PE=new WeakMap,$E=new WeakMap,Pj=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Gt(this,Xf)?{"Last-Event-ID":Gt(this,Xf)}:void 0},cache:"no-store",signal:(e=Gt(this,ki))==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;Gt(this,Na)!==this.CLOSED&&Hn(this,Na,this.CLOSED);const r=new Mj("error",{code:t,message:e});(n=Gt(this,hu))==null||n.call(this,r),this.dispatchEvent(r)},FE=function(e,t){var n;if(Gt(this,Na)===this.CLOSED)return;Hn(this,Na,this.CONNECTING);const r=new Mj("error",{code:t,message:e});(n=Gt(this,hu))==null||n.call(this,r),this.dispatchEvent(r),Hn(this,tu,setTimeout(Gt(this,BE),Gt(this,qf)))},BE=new WeakMap,sb.CONNECTING=0,sb.OPEN=1,sb.CLOSED=2;function eee(){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 tee extends Error{constructor(t,n,r){super(`SSE error: ${n}`),this.code=t,this.event=r}}class nee{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 ns("No auth provider");let t;try{t=await Ro(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 ns;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 tee(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 ns("No auth provider");if(await Ro(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ns("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 Ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new ns;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,ree=($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)}},Me($u,"MCPSession"),$u),Uu,aee=(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,Fs.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Fs.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 ree(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")}},Me(Uu,"BaseMCPClient"),Uu),zu,see=(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=Me(()=>{r.removeEventListener("abort",a),t()},"onAbort");r.addEventListener("abort",a)})}},Me(zu,"ConnectionManager"),zu),Fu,oee=(Fu=class extends see{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 nee(this.url,this.opts),n=t.send.bind(t);return t.send=async r=>{const a=Me(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}}},Me(Fu,"SseConnectionManager"),Fu),Bu,iee=(Bu=class extends rJ{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;disableSseFallback;gatewayUrl;serverId;transportType=null;streamableTransport=null;constructor(t,n={}){super(n),this.baseUrl=t.replace(/\/$/,""),this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`),this.gatewayUrl=n.gatewayUrl,this.serverId=n.serverId,this.gatewayUrl&&(this.headers["X-Target-URL"]=this.baseUrl,this.serverId&&(this.headers["X-Server-Id"]=this.serverId)),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.gatewayUrl?this.gatewayUrl.replace(/\/$/,""):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){let r="Unknown error",a=!1;if(n instanceof _l){const o=n;a=o.code===401,o.code===400&&o.message.includes("Missing session ID")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Le.warn(`⚠️ ${r}`)):o.code===404||o.code===405?(r=`Server returned ${o.code} - server likely doesn't support streamable HTTP`,Le.debug(r)):(r=`Server returned ${o.code}: ${o.message}`,Le.debug(r))}else if(n instanceof Error){const o=n.toString(),i=n.message||"";a=o.includes("401")||i.includes("Unauthorized"),o.includes("Missing session ID")||o.includes("Bad Request: Missing session ID")||i.includes("FastMCP session ID error")?(r="Server requires session ID (FastMCP compatibility) - using SSE transport",Le.warn(`⚠️ ${r}`)):o.includes("405 Method Not Allowed")||o.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 o=new Error("Authentication required");throw o.code=401,o}if(this.disableSseFallback)throw Le.info("SSE fallback disabled - failing connection"),await this.cleanupResources(),new Error(`Streamable HTTP connection failed: ${r}`);Le.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(o){if(Le.error("Failed to connect with both transports:"),Le.error(` Streamable HTTP: ${r}`),Le.error(` SSE: ${o}`),await this.cleanupResources(),o?.message?.includes("401")||o?.message?.includes("Unauthorized")){const c=new Error("Authentication required");throw c.code=401,c}throw new Error("Could not connect to server with any available transport")}}}async connectWithStreamableHttp(t){try{const n=new JQ(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:Me(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 oee(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}},Me(Bu,"HttpConnector"),Bu),jl,lee=(jl=class extends aee{static getPackageVersion(){return Ny()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Fs.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,samplingCallback:d,elicitationCallback:f,disableSseFallback:m,preferSse:h,clientInfo:g}=t;if(!n)throw new Error("Server URL is required");const v={headers:r,authToken:a,authProvider:o,wrapTransport:i,clientOptions:c,samplingCallback:d,elicitationCallback:f,disableSseFallback:m,preferSse:h,clientInfo:g};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new iee(n,v)}},Me(jl,"BrowserMCPClient"),jl);function nu(e){const t=Me(()=>{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}Me(nu,"sanitizeUrl");function a4([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}Me(a4,"sanitizeParam");var Hu,ob=(Hu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;logoUri;callbackUrl;preventAutoAuth;useRedirectFlow;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.onPopupWindow=n.onPopupWindow}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}`}},Me(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 Ro(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")))}}Me(J_,"onMcpAuthorization");var h0={exports:{}},Nt={};var $j;function cee(){if($j)return Nt;$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,F,U){this.props=M,this.context=F,this.refs=w,this.updater=U||E}S.prototype.isReactComponent={},S.prototype.setState=function(M,F){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,F,"setState")},S.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function _(){}_.prototype=S.prototype;function T(M,F,U){this.props=M,this.context=F,this.refs=w,this.updater=U||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 j(M,F,U){var D=U.ref;return{$$typeof:e,type:M,key:F,ref:D!==void 0?D:null,props:U}}function L(M,F){return j(M.type,F,M.props)}function z(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function H(M){var F={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(U){return F[U]})}var Z=/\/+/g;function J(M,F){return typeof M=="object"&&M!==null&&M.key!=null?H(""+M.key):F.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(F){M.status==="pending"&&(M.status="fulfilled",M.value=F)},function(F){M.status==="pending"&&(M.status="rejected",M.reason=F)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function G(M,F,U,D,P){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),F,U,D,P)}}if(W)return P=P(M),W=D===""?"."+J(M,0):D,C(P)?(U="",W!=null&&(U=W.replace(Z,"$&/")+"/"),G(P,F,U,"",function(le){return le})):P!=null&&(z(P)&&(P=L(P,U+(P.key==null||M&&M.key===P.key?"":(""+P.key).replace(Z,"$&/")+"/")+W)),F.push(P)),1;W=0;var te=D===""?".":D+":";if(C(M))for(var fe=0;fe<M.length;fe++)D=M[fe],V=te+J(D,fe),W+=G(D,F,U,V,P);else if(fe=v(M),typeof fe=="function")for(M=fe.call(M),fe=0;!(D=M.next()).done;)D=D.value,V=te+J(D,fe++),W+=G(D,F,U,V,P);else if(V==="object"){if(typeof M.then=="function")return G(ne(M),F,U,D,P);throw F=String(M),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.")}return W}function Y(M,F,U){if(M==null)return M;var D=[],P=0;return G(M,D,"","",function(V){return F.call(U,V,P++)}),D}function B(M){if(M._status===-1){var F=M._result;F=F(),F.then(function(U){(M._status===0||M._status===-1)&&(M._status=1,M._result=U)},function(U){(M._status===0||M._status===-1)&&(M._status=2,M._result=U)}),M._status===-1&&(M._status=0,M._result=F)}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 F=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(F))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ee={map:Y,forEach:function(M,F,U){Y(M,function(){F.apply(this,arguments)},U)},count:function(M){var F=0;return Y(M,function(){F++}),F},toArray:function(M){return Y(M,function(F){return F})||[]},only:function(M){if(!z(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Nt.Activity=h,Nt.Children=ee,Nt.Component=S,Nt.Fragment=n,Nt.Profiler=a,Nt.PureComponent=T,Nt.StrictMode=r,Nt.Suspense=d,Nt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,Nt.__COMPILER_RUNTIME={__proto__:null,c:function(M){return I.H.useMemoCache(M)}},Nt.cache=function(M){return function(){return M.apply(null,arguments)}},Nt.cacheSignal=function(){return null},Nt.cloneElement=function(M,F,U){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var D=x({},M.props),P=M.key;if(F!=null)for(V in F.key!==void 0&&(P=""+F.key),F)!O.call(F,V)||V==="key"||V==="__self"||V==="__source"||V==="ref"&&F.ref===void 0||(D[V]=F[V]);var V=arguments.length-2;if(V===1)D.children=U;else if(1<V){for(var W=Array(V),te=0;te<V;te++)W[te]=arguments[te+2];D.children=W}return j(M.type,P,D)},Nt.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},Nt.createElement=function(M,F,U){var D,P={},V=null;if(F!=null)for(D in F.key!==void 0&&(V=""+F.key),F)O.call(F,D)&&D!=="key"&&D!=="__self"&&D!=="__source"&&(P[D]=F[D]);var W=arguments.length-2;if(W===1)P.children=U;else if(1<W){for(var te=Array(W),fe=0;fe<W;fe++)te[fe]=arguments[fe+2];P.children=te}if(M&&M.defaultProps)for(D in W=M.defaultProps,W)P[D]===void 0&&(P[D]=W[D]);return j(M,V,P)},Nt.createRef=function(){return{current:null}},Nt.forwardRef=function(M){return{$$typeof:c,render:M}},Nt.isValidElement=z,Nt.lazy=function(M){return{$$typeof:m,_payload:{_status:-1,_result:M},_init:B}},Nt.memo=function(M,F){return{$$typeof:f,type:M,compare:F===void 0?null:F}},Nt.startTransition=function(M){var F=I.T,U={};I.T=U;try{var D=M(),P=I.S;P!==null&&P(U,D),typeof D=="object"&&D!==null&&typeof D.then=="function"&&D.then(A,re)}catch(V){re(V)}finally{F!==null&&U.types!==null&&(F.types=U.types),I.T=F}},Nt.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},Nt.use=function(M){return I.H.use(M)},Nt.useActionState=function(M,F,U){return I.H.useActionState(M,F,U)},Nt.useCallback=function(M,F){return I.H.useCallback(M,F)},Nt.useContext=function(M){return I.H.useContext(M)},Nt.useDebugValue=function(){},Nt.useDeferredValue=function(M,F){return I.H.useDeferredValue(M,F)},Nt.useEffect=function(M,F){return I.H.useEffect(M,F)},Nt.useEffectEvent=function(M){return I.H.useEffectEvent(M)},Nt.useId=function(){return I.H.useId()},Nt.useImperativeHandle=function(M,F,U){return I.H.useImperativeHandle(M,F,U)},Nt.useInsertionEffect=function(M,F){return I.H.useInsertionEffect(M,F)},Nt.useLayoutEffect=function(M,F){return I.H.useLayoutEffect(M,F)},Nt.useMemo=function(M,F){return I.H.useMemo(M,F)},Nt.useOptimistic=function(M,F){return I.H.useOptimistic(M,F)},Nt.useReducer=function(M,F,U){return I.H.useReducer(M,F,U)},Nt.useRef=function(M){return I.H.useRef(M)},Nt.useState=function(M){return I.H.useState(M)},Nt.useSyncExternalStore=function(M,F,U){return I.H.useSyncExternalStore(M,F,U)},Nt.useTransition=function(){return I.H.useTransition()},Nt.version="19.2.3",Nt}var Uj;function Q_(){return Uj||(Uj=1,h0.exports=cee()),h0.exports}var y=Q_();const ie=Yp(y),pd=v7({__proto__:null,default:ie},[y]);function HE(e,t){if(!e)throw new Error(t)}Me(HE,"assert");var zj=3e3,uee=5e3;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={},customHeaders:i={},proxyConfig:c,debug:d=!1,autoRetry:f=!1,autoReconnect:m=zj,transportType:h="auto",preventAutoAuth:g=!1,useRedirectFlow:v=!1,onPopupWindow:E,timeout:x=3e4,sseReadTimeout:w=3e5,wrapTransport:S,onNotification:_,samplingCallback:T,onElicitation:R}=e,{url:C,headers:A}=y.useMemo(()=>b_(t||"",c),[t,c]),I=y.useMemo(()=>({...A,...i}),[A,i]),[O,j]=y.useState("discovering"),[L,z]=y.useState([]),[H,Z]=y.useState([]),[J,ne]=y.useState([]),[G,Y]=y.useState([]),[B,re]=y.useState(),[ee,M]=y.useState(),[F,U]=y.useState(void 0),[D,P]=y.useState([]),[V,W]=y.useState(void 0),[te,fe]=y.useState(void 0),le=y.useRef(null),q=y.useRef(null),Q=y.useRef(null),ae=y.useRef(!1),de=y.useRef(!0),he=y.useRef(0),xe=y.useRef(null),He=y.useRef(!1),Ie=y.useRef(O),je=y.useRef(m),at=y.useRef(null),Ue=y.useRef(null),Ye=y.useRef(null);y.useEffect(()=>{Ie.current=O,je.current=m},[O,m]);const pe=y.useCallback((Pe,$e,...Oe)=>{const lt=Oe.length>0?`${$e} ${Oe.map(it=>JSON.stringify(it)).join(" ")}`:$e;console[Pe](`[useMcp] ${lt}`),de.current&&P(it=>[...it.slice(-100),{level:Pe,message:lt,timestamp:Date.now()}])},[]),Se=y.useCallback(async(Pe=!1)=>{if(Pe||pe("info","Disconnecting..."),ae.current=!1,xe.current&&clearTimeout(xe.current),xe.current=null,le.current)try{const $e="inspector-server",Oe=le.current.getSession($e);Oe&&Oe._healthCheckCleanup&&(Oe._healthCheckCleanup(),Oe._healthCheckCleanup=null),await le.current.closeSession($e)}catch($e){Pe||pe("warn","Error closing session:",$e)}le.current=null,de.current&&!Pe&&(j("discovering"),z([]),Z([]),ne([]),Y([]),U(void 0),W(void 0))},[pe]),Ne=y.useCallback((Pe,$e)=>{if(pe("error",Pe,$e??""),de.current){j("failed"),U(Pe);const Oe=q.current?.getLastAttemptedAuthUrl();Oe&&(W(Oe),pe("info","Manual authentication URL may be available.",Oe))}ae.current=!1,t&&Fs.getInstance().trackUseMcpConnection({url:t,transportType:h,success:!1,errorType:$e?.name||"UnknownError",hasOAuth:!!q.current,hasSampling:!!T,hasElicitation:!!R}).catch(()=>{})},[pe,t,h,T,R]),oe=y.useCallback(async()=>{if(!n||!t){pe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(ae.current){pe("debug","Connection attempt already in progress.");return}if(!de.current){pe("debug","Connect called after unmount, aborting.");return}ae.current=!0,he.current+=1,U(void 0),W(void 0),at.current=null,j("discovering"),pe("info",`Connecting attempt #${he.current} to ${t}...`),q.current||(q.current=new ob(t,{storageKeyPrefix:a,clientName:o.name,clientUri:o.uri,logoUri:o.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:g,useRedirectFlow:v,onPopupWindow:E}),pe("debug","BrowserOAuthClientProvider initialized in connect.")),le.current||(le.current=new lee,pe("debug","BrowserMCPClient initialized in connect."));const Pe=Me(async(Oe,lt=!1)=>{pe("info",`Attempting connection with transport: ${Oe}`);try{const it="inspector-server",Je={url:C,transport:Oe==="sse"?"http":Oe,disableSseFallback:Oe==="http",preferSse:Oe==="sse",clientInfo:{name:"mcp-use Inspector",version:Ny()}};if(I&&Object.keys(I).length>0&&(Je.headers=I),q.current){const wt=await q.current.tokens();wt?.access_token&&(Je.headers={...Je.headers,Authorization:`Bearer ${wt.access_token}`})}le.current.addServer(it,{...Je,authProvider:q.current,clientOptions:o,samplingCallback:T,elicitationCallback:R,wrapTransport:S?wt=>(console.log("[useMcp] Applying transport wrapper for server:",it,"url:",t),S(wt,t)):void 0});const Pt=await le.current.createSession(it,!1);Pt.on("notification",wt=>{_?.(wt),wt.method==="notifications/tools/list_changed"?(pe("info","Tools list changed, auto-refreshing..."),sn().catch(pt=>pe("warn","Auto-refresh tools failed:",pt))):wt.method==="notifications/resources/list_changed"?(pe("info","Resources list changed, auto-refreshing..."),Be().catch(pt=>pe("warn","Auto-refresh resources failed:",pt))):wt.method==="notifications/prompts/list_changed"&&(pe("info","Prompts list changed, auto-refreshing..."),ze().catch(pt=>pe("warn","Auto-refresh prompts failed:",pt)))}),await Pt.initialize(),pe("info","✅ Successfully connected to MCP server"),pe("info","Server info:",Pt.connector.serverInfo),pe("info","Server capabilities:",Pt.connector.serverCapabilities),console.log("[useMcp] Server info:",Pt.connector.serverInfo),console.log("[useMcp] Server capabilities:",Pt.connector.serverCapabilities),j("ready"),at.current=Oe;const Kt=Me(()=>{let wt=null,pt=Date.now();const Kn=1e4,vr=3e4;return wt=setInterval(Me(async()=>{if(!de.current||Ie.current!=="ready"){wt&&(clearInterval(wt),wt=null);return}try{await Pt.connector.listTools(),pt=Date.now()}catch{const fn=Date.now()-pt;fn>vr&&(pe("warn",`Connection appears to be broken (no response for ${Math.round(fn/1e3)}s), attempting to reconnect...`),wt&&(clearInterval(wt),wt=null),je.current&&de.current&&(j("discovering"),pe("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{de.current&&Ie.current==="discovering"&&oe()},typeof je.current=="number"?je.current:zj)))}},"checkConnectionHealth"),Kn),()=>{wt&&(clearInterval(wt),wt=null)}},"setupConnectionMonitoring");if(m){const wt=Kt();Pt._healthCheckCleanup=wt}Fs.getInstance().trackUseMcpConnection({url:t,transportType:Oe,success:!0,hasOAuth:!!q.current,hasSampling:!!T,hasElicitation:!!R}).catch(()=>{}),z(Pt.connector.tools||[]);const Ln=await Pt.connector.listAllResources();Z(Ln.resources||[]);const yn=await Pt.connector.listPrompts();Y(yn.prompts||[]);const on=Pt.connector.serverInfo,nn=Pt.connector.serverCapabilities;if(on){console.log("[useMcp] Server info:",on),re(on);const wt=(async()=>{try{const pt=on.icons;if(pt&&Array.isArray(pt)&&pt.length>0){const Kn=pt[0].src||pt[0].url;if(Kn){pe("info","Server provided icon:",Kn);const ir=await(await fetch(Kn)).blob(),bt=await new Promise((fn,Or)=>{const Jr=new FileReader;Jr.onloadend=()=>fn(Jr.result),Jr.onerror=Or,Jr.readAsDataURL(ir)});return de.current&&(re(fn=>fn?{...fn,icon:bt}:void 0),pe("debug","Server icon converted to base64")),bt}}if(t){const Kn=await Yz(t);if(Kn&&de.current)return re(vr=>vr?{...vr,icon:Kn}:void 0),pe("debug","Favicon detected and added to serverInfo"),Kn}return null}catch(pt){return pe("debug","Icon loading failed (non-critical):",pt),null}})();Q.current=wt}if(nn&&(console.log("[useMcp] Server capabilities:",nn),M(nn)),q.current){const wt=await q.current.tokens();if(wt?.access_token){const pt=wt.expires_in?Date.now()+wt.expires_in*1e3:void 0;fe({access_token:wt.access_token,token_type:wt.token_type||"Bearer",expires_at:pt,refresh_token:wt.refresh_token,scope:wt.scope})}}return"success"}catch(it){const Je=it,Pt=Je?.message||String(it);if(Je.code===401||Pt.includes("401")||Pt.includes("Unauthorized")){if(q.current){pe("info","Authentication required. OAuth provider available.");try{const{auth:Kt}=await fa(async()=>{const{auth:yn}=await Promise.resolve().then(()=>Dj);return{auth:yn}},void 0),Ln=new URL(t).origin;Kt(q.current,{serverUrl:Ln}).catch(()=>{}),setTimeout(()=>{if(de.current){const yn=q.current?.getLastAttemptedAuthUrl();yn?(W(yn),pe("info","Manual authentication URL available:",yn)):pe("warn","Could not generate authentication URL")}},100)}catch(Kt){pe("warn","Error generating auth URL:",Kt)}return de.current&&j("pending_auth"),ae.current=!1,"auth_redirect"}return i&&Object.keys(i).length>0?(Ne("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Ne("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Ne(Pt,Je instanceof Error?Je:new Error(String(Je))),"failed"}},"tryConnectWithTransport");let $e="failed";if(h==="sse")pe("debug","Using SSE-only transport mode"),$e=await Pe("sse");else if(h==="http")pe("debug","Using HTTP-only transport mode"),$e=await Pe("http");else{pe("debug","Using auto transport mode (HTTP with SSE fallback)");const Oe=await Pe("http");Oe==="fallback"&&de.current&&Ie.current!=="authenticating"?(pe("info","HTTP failed, attempting SSE fallback..."),$e=await Pe("sse")):$e=Oe}($e==="success"||$e==="failed"||$e==="auth_redirect")&&(ae.current=!1),pe("debug",`Connection sequence finished with status: ${$e}`)},[pe,Ne,Se,t,a,r,o.name,o.version,o.uri,o.logo_uri,i,h,g,v,E,n,x,w]);y.useEffect(()=>{Ue.current=oe,Ye.current=Ne},[oe,Ne]);const ke=y.useCallback(async(Pe,$e,Oe)=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot call tool "${Pe}".`);pe("info",`Calling tool: ${Pe}`,$e);const lt=Date.now();try{const Je=le.current.getSession("inspector-server");if(!Je)throw new Error("No active session found");const Pt=await Je.connector.callTool(Pe,$e||{},Oe);return pe("info",`Tool "${Pe}" call successful:`,Pt),Fs.getInstance().trackUseMcpToolCall({toolName:Pe,success:!0,executionTimeMs:Date.now()-lt}).catch(()=>{}),Pt}catch(it){throw pe("error",`Tool "${Pe}" call failed:`,it),Fs.getInstance().trackUseMcpToolCall({toolName:Pe,success:!1,errorType:it instanceof Error?it.name:"UnknownError",executionTimeMs:Date.now()-lt}).catch(()=>{}),it}},[O]),Ve=y.useCallback(()=>{Ie.current==="failed"?(pe("info","Retry requested..."),Ue.current?.()):pe("warn",`Retry called but state is not 'failed' (state: ${Ie.current}). Ignoring.`)},[pe]),Ge=y.useCallback(async()=>{pe("info","Manual authentication requested...");const Pe=Ie.current;if(Pe==="failed")pe("info","Attempting to reconnect and authenticate via retry..."),Ve();else if(Pe==="pending_auth"){pe("info","Proceeding with authentication from pending state...");try{HE(q.current,"Auth Provider not available for manual auth"),HE(t,"Server URL is required for authentication"),pe("info","Clearing all OAuth state and initiating fresh flow...");const $e=`${a}:${q.current.serverUrlHash}`;Object.keys(localStorage).forEach(Je=>{Je.startsWith($e)&&(pe("debug",`Removing stale OAuth key: ${Je}`),localStorage.removeItem(Je)),Je.startsWith(`${a}:state_`)&&(pe("debug",`Removing orphaned state: ${Je}`),localStorage.removeItem(Je))}),j("authenticating");const Oe=new ob(t,{storageKeyPrefix:a,clientName:o.name,clientUri:o.uri,logoUri:o.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:!1,useRedirectFlow:v,onPopupWindow:E});q.current=Oe,pe("info","Triggering fresh OAuth authorization...");const{auth:lt}=await fa(async()=>{const{auth:Je}=await Promise.resolve().then(()=>Dj);return{auth:Je}},void 0),it=new URL(t).origin;lt(Oe,{serverUrl:it}).catch(Je=>{pe("info","OAuth flow initiated:",Je instanceof Error?Je.message:"Redirecting...")})}catch($e){if(!de.current)return;j("pending_auth"),pe("error",`Manual authentication failed: ${$e instanceof Error?$e.message:String($e)}`)}}else if(Pe==="authenticating"){pe("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const $e=q.current?.getLastAttemptedAuthUrl();$e&&!V&&(W($e),pe("info","Manual authentication URL retrieved:",$e))}else pe("info",`Client not in a state requiring manual authentication trigger (state: ${Pe}). If needed, try disconnecting and reconnecting.`)},[pe,Ve,V,t,v,E,a,o.name,o.uri,o.logo_uri,r]),mt=y.useCallback(()=>{if(q.current){const Pe=q.current.clearStorage();pe("info",`Cleared ${Pe} item(s) from localStorage for ${t}.`),W(void 0),Se()}else pe("warn","Auth provider not initialized, cannot clear storage.")},[t,pe,Se]),_t=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot list resources.`);pe("info","Listing resources");try{const $e=le.current.getSession("inspector-server");if(!$e)throw new Error("No active session found");const Oe=await $e.connector.listAllResources();Z(Oe.resources||[]),pe("info","Resources listed successfully")}catch(Pe){throw pe("error","List resources failed:",Pe),Pe}},[O]),st=y.useCallback(async Pe=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot read resource.`);pe("info",`Reading resource: ${Pe}`);try{const Oe=le.current.getSession("inspector-server");if(!Oe)throw new Error("No active session found");const lt=await Oe.connector.readResource(Pe);return pe("info","Resource read successful:",lt),Fs.getInstance().trackUseMcpResourceRead({resourceUri:Pe,success:!0}).catch(()=>{}),lt}catch($e){throw pe("error","Resource read failed:",$e),Fs.getInstance().trackUseMcpResourceRead({resourceUri:Pe,success:!1,errorType:$e instanceof Error?$e.name:"UnknownError"}).catch(()=>{}),$e}},[O]),Qn=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot list prompts.`);pe("info","Listing prompts");try{const $e=le.current.getSession("inspector-server");if(!$e)throw new Error("No active session found");const Oe=await $e.connector.listPrompts();Y(Oe.prompts||[]),pe("info","Prompts listed successfully")}catch(Pe){throw pe("error","List prompts failed:",Pe),Pe}},[O]),sn=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current){pe("debug","Cannot refresh tools - client not ready");return}pe("debug","Refreshing tools list");try{const $e=le.current.getSession("inspector-server");if(!$e){pe("warn","No active session found for tools refresh");return}const Oe=await $e.connector.listTools();z(Oe||[]),pe("info","Tools list refreshed successfully")}catch(Pe){pe("warn","Failed to refresh tools:",Pe)}},[pe]),Be=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current){pe("debug","Cannot refresh resources - client not ready");return}pe("debug","Refreshing resources list");try{const $e=le.current.getSession("inspector-server");if(!$e){pe("warn","No active session found for resources refresh");return}const Oe=await $e.connector.listAllResources();Z(Oe.resources||[]),pe("info","Resources list refreshed successfully")}catch(Pe){pe("warn","Failed to refresh resources:",Pe)}},[pe]),ze=y.useCallback(async()=>{if(Ie.current!=="ready"||!le.current){pe("debug","Cannot refresh prompts - client not ready");return}pe("debug","Refreshing prompts list");try{const $e=le.current.getSession("inspector-server");if(!$e){pe("warn","No active session found for prompts refresh");return}const Oe=await $e.connector.listPrompts();Y(Oe.prompts||[]),pe("info","Prompts list refreshed successfully")}catch(Pe){pe("warn","Failed to refresh prompts:",Pe)}},[pe]),qe=y.useCallback(async()=>{pe("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([sn(),Be(),ze()])},[sn,Be,ze,pe]),Et=y.useCallback(async(Pe,$e)=>{if(Ie.current!=="ready"||!le.current)throw new Error(`MCP client is not ready (current state: ${O}). Cannot get prompt.`);pe("info",`Getting prompt: ${Pe}`,$e);try{const lt=le.current.getSession("inspector-server");if(!lt)throw new Error("No active session found");const it=await lt.connector.getPrompt(Pe,$e||{});return pe("info",`Prompt "${Pe}" retrieved successfully:`,it),it}catch(Oe){throw pe("error",`Prompt "${Pe}" retrieval failed:`,Oe),Oe}},[O]);y.useEffect(()=>{const Pe=Me($e=>{$e.origin===window.location.origin&&$e.data?.type==="mcp_auth_callback"&&(pe("info","Received auth callback message.",$e.data),xe.current&&clearTimeout(xe.current),xe.current=null,$e.data.success?(pe("info","Authentication successful via popup. Reconnecting client..."),ae.current&&pe("debug","Connection attempt already in progress, resetting flag to allow reconnection."),ae.current=!1,setTimeout(()=>{de.current&&(pe("debug","Initiating reconnection after successful auth callback."),Ue.current?.())},100)):Ye.current?.(`Authentication failed in callback: ${$e.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Pe),pe("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Pe),pe("debug","Auth callback message listener removed."),xe.current&&clearTimeout(xe.current)}},[pe]),y.useEffect(()=>(de.current=!0,!n||!t?(pe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),j("discovering"),()=>{de.current=!1}):(pe("debug","useMcp mounted, initiating connection."),he.current=0,(!q.current||q.current.serverUrl!==t)&&(q.current=new ob(t,{storageKeyPrefix:a,clientName:o.name,clientUri:o.uri,logoUri:o.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:r,preventAutoAuth:g,useRedirectFlow:v,onPopupWindow:E}),pe("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),oe(),()=>{de.current=!1,pe("debug","useMcp unmounting, disconnecting."),Se(!0)})),[t,n,a,r,o.name,o.version,o.uri,o.logo_uri,v]);const St=y.useRef(Ve),Mt=y.useRef(pe);y.useEffect(()=>{St.current=Ve,Mt.current=pe},[Ve,pe]),y.useEffect(()=>{let Pe=null;if(O==="failed"&&f&&he.current>0){if(!He.current){He.current=!0;const $e=typeof f=="number"?f:uee;Mt.current("info",`Connection failed, auto-retrying in ${$e}ms...`),Pe=setTimeout(()=>{He.current=!1,de.current&&Ie.current==="failed"&&St.current()},$e)}}else O!=="failed"&&(He.current=!1);return()=>{Pe&&(clearTimeout(Pe),He.current=!1)}},[O,f]);const Tt=y.useCallback(async()=>Ie.current!=="ready"?(pe("warn","Cannot ensure icon loaded - not connected"),null):B?.icon?B.icon:Q.current?(pe("debug","Waiting for icon to finish loading..."),await Q.current):(pe("debug","No icon available and no loading in progress"),null),[B,pe]);return{state:O,name:B?.name||t||"",tools:L,resources:H,resourceTemplates:J,prompts:G,serverInfo:B,capabilities:ee,error:F,log:D,authUrl:V,authTokens:te,client:le.current,callTool:ke,readResource:st,listResources:_t,listPrompts:Qn,getPrompt:Et,refreshTools:sn,refreshResources:Be,refreshPrompts:ze,refreshAll:qe,retry:Ve,disconnect:Se,authenticate:Ge,clearStorage:mt,ensureIconLoaded:Tt}}Me(eT,"useMcp");var Vu,dee=(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}},Me(Vu,"ErrorBoundary"),Vu),Jf="openai:set_globals";function gs(e){return y.useSyncExternalStore(t=>{const n=Me(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)}Me(gs,"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),z=Me(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(L))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(Jf,z);const H=setTimeout(()=>{clearInterval(L),typeof window<"u"&&window.removeEventListener(Jf,z)},5e3);return()=>{clearInterval(L),clearTimeout(H),typeof window<"u"&&window.removeEventListener(Jf,z)}},[]);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"?gs("toolInput"):o.toolInput,c=r==="openai"?gs("toolOutput"):o.toolOutput,d=gs("toolResponseMetadata"),f=y.useMemo(()=>{if(d&&typeof d=="object"){const L=d["mcp-use/props"];if(L)return L}return e||{}},[d,e]),m=gs("widgetState"),h=gs("theme"),g=gs("displayMode"),v=gs("safeArea"),E=gs("maxHeight"),x=gs("userAgent"),w=gs("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,z)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(L,z)},[]),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,_]),j=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:j}}Me(md,"useWidget");function fee(e){const{props:t}=md(e);return t}Me(fee,"useWidgetProps");function pee(){const{theme:e}=md();return e}Me(pee,"useWidgetTheme");function mee(e){const{state:t,setState:n}=md();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Me(mee,"useWidgetState");var Fj=Me(({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=Me(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 s4({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),[j,L]=y.useState(!1),z=y.useRef(null),H=y.useRef(null),[Z,J]=y.useState([]),[ne,G]=y.useState(""),[Y,B]=y.useState("get-my-city"),[re,ee]=y.useState("{}"),[M,F]=y.useState("Test follow-up message"),[U,D]=y.useState("https://docs.mcp-use.com"),P=g==="fullscreen"&&S,V=g==="pip"&&S,W=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const Se=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const Ne=Object.keys(window.openai);J(Ne)}catch{J([])}else J([])},100);return()=>{clearTimeout(Se)}},[]);const te=h==="dark",fe=Me(()=>{const Se=["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[...Se,"top-4","left-4"];case"top-center":return[...Se,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...Se,"top-4","right-4"];case"center-left":return[...Se,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...Se,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...Se,"bottom-4","left-4"];case"bottom-center":return[...Se,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...Se,"bottom-4","right-4"];default:return[...Se,"top-4","right-4"]}},"getPositionClasses"),le=Me(()=>{const Ne=v?.insets?.top?Math.max(16,v.insets.top+8):16,oe=v?.insets?.right?Math.max(16,v.insets.right+8):16,ke=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Ve=v?.insets?.left?Math.max(16,v.insets.left+8):16,Ge={};switch(n){case"top-left":Ge.top=`${Ne}px`,Ge.left=`${Ve}px`;break;case"top-center":Ge.top=`${Ne}px`;break;case"top-right":Ge.top=`${Ne}px`,Ge.right=`${oe}px`;break;case"center-left":Ge.left=`${Ve}px`;break;case"center-right":Ge.right=`${oe}px`;break;case"bottom-left":Ge.bottom=`${ke}px`,Ge.left=`${Ve}px`;break;case"bottom-center":Ge.bottom=`${ke}px`;break;case"bottom-right":Ge.bottom=`${ke}px`,Ge.right=`${oe}px`;break;default:Ge.top=`${Ne}px`,Ge.right=`${oe}px`;break}return Ge},"getPositionOffsetStyles");y.useEffect(()=>{if(!r)return;const Se=Me(()=>O(!0),"handleMouseEnter"),Ne=Me(()=>O(!1),"handleMouseLeave");return r.addEventListener("mouseenter",Se),r.addEventListener("mouseleave",Ne),()=>{r.removeEventListener("mouseenter",Se),r.removeEventListener("mouseleave",Ne)}},[r]),y.useEffect(()=>{if(!j)return;const Se=Me(Ne=>{H.current&&!H.current.contains(Ne.target)&&L(!1)},"handleClickOutside");return document.addEventListener("mousedown",Se),()=>{document.removeEventListener("mousedown",Se)}},[j]),y.useEffect(()=>(j?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[j]);const q=Me(()=>{L(!j)},"handleToggleOverlay"),Q=Me(async()=>{try{G("Calling tool...");const Se=re.trim()?JSON.parse(re):{},Ne=await _(Y,Se);G(`Success: ${JSON.stringify(Ne,null,2)}`)}catch(Se){G(`Error: ${Se.message}`)}},"handleCallTool"),ae=Me(async()=>{try{G("Sending follow-up message..."),await T(M),G("Follow-up message sent successfully")}catch(Se){G(`Error: ${Se.message}`)}},"handleSendFollowUpMessage"),de=Me(()=>{try{R(U),G(`Opened external link: ${U}`)}catch(Se){G(`Error: ${Se.message}`)}},"handleOpenExternal"),he=Me(async Se=>{try{G(`Requesting display mode: ${Se}...`);const Ne=await C(Se);G(`Display mode granted: ${Ne.mode}`)}catch(Ne){G(`Error: ${Ne.message}`)}},"handleRequestDisplayMode"),xe=Me(async()=>{try{const Se=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};G("Setting state..."),await A(Se),G(`State updated: ${JSON.stringify(Se,null,2)}`)}catch(Se){G(`Error: ${Se.message}`)}},"handleSetState"),He=Me(async()=>{try{await C("fullscreen")}catch(Se){console.error("Failed to go fullscreen:",Se)}},"handleFullscreen"),Ie=Me(async()=>{try{await C("pip")}catch(Se){console.error("Failed to go pip:",Se)}},"handlePip"),je=Me(()=>{const Se=["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[...Se,"top-full","right-0","mt-2"];case"top-left":return[...Se,"top-full","left-0","mt-2"];case"top-center":return[...Se,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...Se,"bottom-full","right-0","mb-2"];case"bottom-left":return[...Se,"bottom-full","left-0","mb-2"];case"bottom-center":return[...Se,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...Se,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...Se,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...Se,"top-full","right-0","mt-2"]}},"getTooltipClasses"),at=Me(({onClick:Se,label:Ne,children:oe})=>{const[ke,Ve]=y.useState(!1),Ge=je();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:()=>Ve(!0),onMouseLeave:()=>Ve(!1),onClick:Se,"aria-label":Ne},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:`${Ge.join(" ")} ${ke?"opacity-100":"opacity-0"}`},Ne))},"IconButton"),Ue=Me(Se=>{if(Se===null)return"null";if(Se===void 0)return"undefined";if(typeof Se=="object")try{return JSON.stringify(Se,null,2)}catch{return String(Se)}return String(Se)},"formatValue"),Ye=Me(Se=>Se?`${Se.device?.type||"unknown"}`:"N/A","formatUserAgent"),pe=Me(Se=>{if(!Se?.insets)return"N/A";const{top:Ne,bottom:oe,left:ke,right:Ve}=Se.insets;return`T:${Ne} B:${oe} L:${ke} R:${Ve}`},"formatSafeArea");return ie.createElement(ie.Fragment,null,ie.createElement("div",{ref:z,className:`${t} relative h-fit`,onMouseEnter:()=>!r&&O(!0),onMouseLeave:()=>!r&&O(!1)},ie.createElement("div",{className:fe().join(" "),style:le()},!W&&ie.createElement(ie.Fragment,null,!P&&!V&&ie.createElement(ie.Fragment,null,(i===!0||i==="fullscreen")&&ie.createElement(at,{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(at,{onClick:Ie,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(at,{onClick:q,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),j&&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:Se=>{Se.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"},Ue(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"},Ue(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"},Ue(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"},Ue(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"},Ye(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"},pe(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"},Z.length>0?Z.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:Y,onChange:Se=>B(Se.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:Se=>ee(Se.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:Se=>F(Se.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:ae,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:U,onChange:Se=>D(Se.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:de,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:xe,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"))))))}Me(s4,"WidgetControls");function o4(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Me(o4,"getBasename");var hee=150,gee=5;function bee({children:e,debugger:t=!1,viewControls:n=!1,autoSize:r=!1}){const a=o4(),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 fa(()=>import("./index-B7K7EglZ.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},aae=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())}},[])},sae=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,a=r===void 0?"margin":r;aae();var o=y.useMemo(function(){return tae(a)},[a]);return y.createElement(nae,{styles:rae(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,oae=function(e){return e.tagName==="TEXTAREA"},h3=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!oae(e)&&n[t]==="visible")},iae=function(e){return h3(e,"overflowY")},lae=function(e){return h3(e,"overflowX")},SP=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var a=g3(e,r);if(a){var o=b3(e,r),i=o[1],c=o[2];if(i>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},cae=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},uae=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},g3=function(e,t){return e==="v"?iae(t):lae(t)},b3=function(e,t){return e==="v"?cae(t):uae(t)},dae=function(e,t){return e==="h"&&t==="rtl"?-1:1},fae=function(e,t,n,r,a){var o=dae(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=b3(e,c),E=v[0],x=v[1],w=v[2],S=x-w-o*E;(E||S)&&g3(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},pae=function(e,t){return e[0]===t[0]&&e[1]===t[1]},mae=function(e){return`
|
|
89
89
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
90
90
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
91
|
-
`)},hae=0,Fc=[];function gae(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),a=y.useState(hae++)[0],o=y.useState(m3)[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=Pre([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(),j=O&&O.anchorNode,L=j?j===A||j.contains(A):!1;if(L)return!1;var z=SP(I,A);if(!z)return!0;if(z?C=I:(C=I==="v"?"h":"v",z=SP(I,A)),!z)return!1;if(!r.current&&"changedTouches"in x&&(T||R)&&(r.current=C),!C)return!0;var H=r.current||C;return fae(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)&&pae(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:bae(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:mae(a)}):null,v?y.createElement(sae,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bae(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const yae=Wre(p3,gae);var om=y.forwardRef(function(e,t){return y.createElement(Jy,Bs({},e,{ref:t,sideCar:yae}))});om.classNames=Jy.classNames;var XE=["Enter"," "],vae=["ArrowDown","PageUp","Home"],y3=["ArrowUp","PageDown","End"],wae=[...vae,...y3],xae={ltr:[...XE,"ArrowRight"],rtl:[...XE,"ArrowLeft"]},Eae={ltr:["ArrowLeft"],rtl:["ArrowRight"]},im="Menu",[yp,Sae,_ae]=aT(im),[Zl,v3]=Is(im,[_ae,Ki,s3]),Qy=Ki(),w3=s3(),[Tae,ql]=Zl(im),[Nae,lm]=Zl(im),x3=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=qs(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(Tae,{scope:t,open:n,onOpenChange:h,content:d,onContentChange:f,children:u.jsx(Nae,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:i,children:r})})})};x3.displayName=im;var kae="MenuAnchor",hT=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Qy(n);return u.jsx(am,{...a,...r,ref:t})});hT.displayName=kae;var gT="MenuPortal",[Cae,E3]=Zl(gT,{forceMount:void 0}),S3=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=ql(gT,t);return u.jsx(Cae,{scope:t,forceMount:n,children:u.jsx(Ga,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:r})})})};S3.displayName=gT;var ss="MenuContent",[Rae,bT]=Zl(ss),_3=y.forwardRef((e,t)=>{const n=E3(ss,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=ql(ss,e.__scopeMenu),i=lm(ss,e.__scopeMenu);return u.jsx(yp.Provider,{scope:e.__scopeMenu,children:u.jsx(Ga,{present:r||o.open,children:u.jsx(yp.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(Aae,{...a,ref:t}):u.jsx(Iae,{...a,ref:t})})})})}),Aae=y.forwardRef((e,t)=>{const n=ql(ss,e.__scopeMenu),r=y.useRef(null),a=tn(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:Ze(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Iae=y.forwardRef((e,t)=>{const n=ql(ss,e.__scopeMenu);return u.jsx(yT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Oae=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(ss,n),S=lm(ss,n),_=Qy(n),T=w3(n),R=Sae(n),[C,A]=y.useState(null),I=y.useRef(null),O=tn(t,I,w.onContentChange),j=y.useRef(0),L=y.useRef(""),z=y.useRef(0),H=y.useRef(null),Z=y.useRef("right"),J=y.useRef(0),ne=E?om:y.Fragment,G=E?{as:Oae,allowPinchZoom:!0}:void 0,Y=re=>{const ee=L.current+re,M=R().filter(W=>!W.disabled),F=document.activeElement,U=M.find(W=>W.ref.current===F)?.textValue,D=M.map(W=>W.textValue),P=Vae(D,ee,U),V=M.find(W=>W.textValue===P)?.ref.current;(function W(te){L.current=te,window.clearTimeout(j.current),te!==""&&(j.current=window.setTimeout(()=>W(""),1e3))})(ee),V&&setTimeout(()=>V.focus())};y.useEffect(()=>()=>window.clearTimeout(j.current),[]),Hy();const B=y.useCallback(re=>Z.current===H.current?.side&&Wae(re,H.current?.area),[]);return u.jsx(Rae,{scope:n,searchRef:L,onItemEnter:y.useCallback(re=>{B(re)&&re.preventDefault()},[B]),onItemLeave:y.useCallback(re=>{B(re)||(I.current?.focus(),A(null))},[B]),onTriggerLeave:y.useCallback(re=>{B(re)&&re.preventDefault()},[B]),pointerGraceTimerRef:z,onPointerGraceIntentChange:y.useCallback(re=>{H.current=re},[]),children:u.jsx(ne,{...G,children:u.jsx(nm,{asChild:!0,trapped:a,onMountAutoFocus:Ze(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(Ore,{asChild:!0,...T,dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:A,onEntryFocus:Ze(d,re=>{S.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(Zy,{role:"menu","aria-orientation":"vertical","data-state":z3(w.open),"data-radix-menu-content":"",dir:S.dir,..._,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:Ze(x.onKeyDown,re=>{const M=re.target.closest("[data-radix-menu-content]")===re.currentTarget,F=re.ctrlKey||re.altKey||re.metaKey,U=re.key.length===1;M&&(re.key==="Tab"&&re.preventDefault(),!F&&U&&Y(re.key));const D=I.current;if(re.target!==D||!wae.includes(re.key))return;re.preventDefault();const V=R().filter(W=>!W.disabled).map(W=>W.ref.current);y3.includes(re.key)&&V.reverse(),Bae(V)}),onBlur:Ze(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(j.current),L.current="")}),onPointerMove:Ze(e.onPointerMove,vp(re=>{const ee=re.target,M=J.current!==re.clientX;if(re.currentTarget.contains(ee)&&M){const F=re.clientX>J.current?"right":"left";Z.current=F,J.current=re.clientX}}))})})})})})})});_3.displayName=ss;var Dae="MenuGroup",vT=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ot.div,{role:"group",...r,ref:t})});vT.displayName=Dae;var Lae="MenuLabel",T3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ot.div,{...r,ref:t})});T3.displayName=Lae;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=tn(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}),D4(h,g),g.defaultPrevented?f.current=!1:i.onClose()}};return u.jsx(N3,{...a,ref:d,disabled:n,onClick:Ze(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:Ze(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:Ze(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 N3=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...o}=e,i=bT(Zb,n),c=w3(n),d=y.useRef(null),f=tn(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(Dre,{asChild:!0,...c,focusable:!r,children:u.jsx(Ot.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:f,onPointerMove:Ze(e.onPointerMove,vp(E=>{r?i.onItemLeave(E):(i.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ze(e.onPointerLeave,vp(E=>i.onItemLeave(E))),onFocus:Ze(e.onFocus,()=>h(!0)),onBlur:Ze(e.onBlur,()=>h(!1))})})})}),Mae="MenuCheckboxItem",k3=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return u.jsx(O3,{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:Ze(a.onSelect,()=>r?.(qb(n)?!0:!n),{checkForDefaultPrevented:!1})})})});k3.displayName=Mae;var C3="MenuRadioGroup",[jae,Pae]=Zl(C3,{value:void 0,onValueChange:()=>{}}),R3=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,o=qs(r);return u.jsx(jae,{scope:e.__scopeMenu,value:n,onValueChange:o,children:u.jsx(vT,{...a,ref:t})})});R3.displayName=C3;var A3="MenuRadioItem",I3=y.forwardRef((e,t)=>{const{value:n,...r}=e,a=Pae(A3,e.__scopeMenu),o=n===a.value;return u.jsx(O3,{scope:e.__scopeMenu,checked:o,children:u.jsx(ev,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":xT(o),onSelect:Ze(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});I3.displayName=A3;var wT="MenuItemIndicator",[O3,$ae]=Zl(wT,{checked:!1}),D3=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,o=$ae(wT,n);return u.jsx(Ga,{present:r||qb(o.checked)||o.checked===!0,children:u.jsx(Ot.span,{...a,ref:t,"data-state":xT(o.checked)})})});D3.displayName=wT;var Uae="MenuSeparator",L3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ot.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});L3.displayName=Uae;var zae="MenuArrow",M3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Qy(n);return u.jsx(qy,{...a,...r,ref:t})});M3.displayName=zae;var Fae="MenuSub",[Hxe,j3]=Zl(Fae),Bf="MenuSubTrigger",P3=y.forwardRef((e,t)=>{const n=ql(Bf,e.__scopeMenu),r=lm(Bf,e.__scopeMenu),a=j3(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(N3,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":z3(n.open),...e,ref:Zs(t,a.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ze(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:Ze(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:Ze(e.onKeyDown,h=>{const g=o.searchRef.current!=="";e.disabled||g&&h.key===" "||xae[r.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});P3.displayName=Bf;var $3="MenuSubContent",U3=y.forwardRef((e,t)=>{const n=E3(ss,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=ql(ss,e.__scopeMenu),i=lm(ss,e.__scopeMenu),c=j3($3,e.__scopeMenu),d=y.useRef(null),f=tn(t,d);return u.jsx(yp.Provider,{scope:e.__scopeMenu,children:u.jsx(Ga,{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:Ze(e.onFocusOutside,m=>{m.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Ze(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:Ze(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=Eae[i.dir].includes(m.key);h&&g&&(o.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});U3.displayName=$3;function z3(e){return e?"open":"closed"}function qb(e){return e==="indeterminate"}function xT(e){return qb(e)?"indeterminate":e?"checked":"unchecked"}function Bae(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Hae(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Vae(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=Hae(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 Gae(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 Wae(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Gae(n,t)}function vp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Kae=x3,Yae=hT,Zae=S3,qae=_3,Xae=vT,Jae=T3,Qae=ev,ese=k3,tse=R3,nse=I3,rse=D3,ase=L3,sse=M3,ose=P3,ise=U3,tv="DropdownMenu",[lse]=Is(tv,[v3]),ga=v3(),[cse,F3]=lse(tv),B3=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:o,onOpenChange:i,modal:c=!0}=e,d=ga(t),f=y.useRef(null),[m,h]=Mo({prop:a,defaultProp:o??!1,onChange:i,caller:tv});return u.jsx(cse,{scope:t,triggerId:Yr(),triggerRef:f,contentId:Yr(),open:m,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:c,children:u.jsx(Kae,{...d,open:m,onOpenChange:h,dir:r,modal:c,children:n})})};B3.displayName=tv;var H3="DropdownMenuTrigger",V3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,o=F3(H3,n),i=ga(n);return u.jsx(Yae,{asChild:!0,...i,children:u.jsx(Ot.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:Zs(t,o.triggerRef),onPointerDown:Ze(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(o.onOpenToggle(),o.open||c.preventDefault())}),onKeyDown:Ze(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&o.onOpenToggle(),c.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});V3.displayName=H3;var use="DropdownMenuPortal",G3=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ga(t);return u.jsx(Zae,{...r,...n})};G3.displayName=use;var W3="DropdownMenuContent",K3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=F3(W3,n),o=ga(n),i=y.useRef(!1);return u.jsx(qae,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...r,ref:t,onCloseAutoFocus:Ze(e.onCloseAutoFocus,c=>{i.current||a.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:Ze(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)"}})});K3.displayName=W3;var dse="DropdownMenuGroup",fse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(Xae,{...a,...r,ref:t})});fse.displayName=dse;var pse="DropdownMenuLabel",Y3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(Jae,{...a,...r,ref:t})});Y3.displayName=pse;var mse="DropdownMenuItem",Z3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(Qae,{...a,...r,ref:t})});Z3.displayName=mse;var hse="DropdownMenuCheckboxItem",q3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(ese,{...a,...r,ref:t})});q3.displayName=hse;var gse="DropdownMenuRadioGroup",bse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(tse,{...a,...r,ref:t})});bse.displayName=gse;var yse="DropdownMenuRadioItem",X3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(nse,{...a,...r,ref:t})});X3.displayName=yse;var vse="DropdownMenuItemIndicator",wse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(rse,{...a,...r,ref:t})});wse.displayName=vse;var xse="DropdownMenuSeparator",J3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(ase,{...a,...r,ref:t})});J3.displayName=xse;var Ese="DropdownMenuArrow",Sse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(sse,{...a,...r,ref:t})});Sse.displayName=Ese;var _se="DropdownMenuSubTrigger",Q3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(ose,{...a,...r,ref:t})});Q3.displayName=_se;var Tse="DropdownMenuSubContent",eB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(ise,{...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)"}})});eB.displayName=Tse;var Nse=B3,kse=V3,Cse=G3,tB=K3,nB=Y3,rB=Z3,Rse=q3,Ase=X3,aB=J3,Ise=Q3,Ose=eB;const Xb=Nse,Jb=kse;Ise.displayName;Ose.displayName;function wp({ref:e,className:t,sideOffset:n=4,...r}){return u.jsx(Cse,{children:u.jsx(tB,{ref:e,sideOffset:n,className:De("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=tB.displayName;function Fr({ref:e,className:t,inset:n,...r}){return u.jsx(rB,{ref:e,className:De("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})}Fr.displayName=rB.displayName;Rse.displayName;Ase.displayName;function JE({ref:e,className:t,inset:n,...r}){return u.jsx(nB,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...r})}JE.displayName=nB.displayName;function ru({ref:e,className:t,...n}){return u.jsx(aB,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}ru.displayName=aB.displayName;var Dse=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Bo=Dse.reduce((e,t)=>{const n=m4(`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}},{}),Lse="Label",sB=y.forwardRef((e,t)=>u.jsx(Bo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));sB.displayName=Lse;var Mse=sB;function en({className:e,...t}){return u.jsx(Mse,{"data-slot":"label",className:De("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:De(`mt-2 rounded-md p-6 ${t}`,!r&&"border"),children:u.jsxs("p",{className:De("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 oB({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:De("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",[jse]=Is(nv),[Pse,$se]=jse(nv),iB=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=tn(t,T=>v(T)),x=y.useRef(!1),w=g?m||!!g.closest("form"):!0,[S,_]=Mo({prop:a,defaultProp:o??!1,onChange:f,caller:nv});return u.jsxs(Pse,{scope:n,checked:S,disabled:c,children:[u.jsx(Ot.button,{type:"button",role:"switch","aria-checked":S,"aria-required":i,"data-state":dB(S),"data-disabled":c?"":void 0,disabled:c,value:d,...h,ref:E,onClick:Ze(e.onClick,T=>{_(R=>!R),w&&(x.current=T.isPropagationStopped(),x.current||T.stopPropagation())})}),w&&u.jsx(uB,{control:g,bubbles:!x.current,name:r,value:d,checked:S,required:i,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});iB.displayName=nv;var lB="SwitchThumb",cB=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=$se(lB,n);return u.jsx(Ot.span,{"data-state":dB(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});cB.displayName=lB;var Use="SwitchBubbleInput",uB=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},o)=>{const i=y.useRef(null),c=tn(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}})});uB.displayName=Use;function dB(e){return e?"checked":"unchecked"}var fB=iB,zse=cB;function rv({ref:e,className:t,...n}){return u.jsx(fB,{className:De("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(zse,{className:De("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=fB.displayName;var pB=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"}),Fse="VisuallyHidden",mB=y.forwardRef((e,t)=>u.jsx(Ot.span,{...e,ref:t,style:{...pB,...e.style}}));mB.displayName=Fse;var Bse=mB,[av]=Is("Tooltip",[Ki]),sv=Ki(),hB="TooltipProvider",Hse=700,QE="tooltip.open",[Vse,ST]=av(hB),gB=e=>{const{__scopeTooltip:t,delayDuration:n=Hse,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(Vse,{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})};gB.displayName=hB;var xp="Tooltip",[Gse,cm]=av(xp),bB=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=Yr(),v=y.useRef(0),E=i??d.disableHoverableContent,x=c??d.delayDuration,w=y.useRef(!1),[S,_]=Mo({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(Gse,{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})})};bB.displayName=xp;var eS="TooltipTrigger",yB=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=tn(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(Ot.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:d,onPointerMove:Ze(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ze(e.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:Ze(e.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ze(e.onFocus,()=>{f.current||a.onOpen()}),onBlur:Ze(e.onBlur,a.onClose),onClick:Ze(e.onClick,a.onClose)})})});yB.displayName=eS;var _T="TooltipPortal",[Wse,Kse]=av(_T,{forceMount:void 0}),vB=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:a}=e,o=cm(_T,t);return u.jsx(Wse,{scope:t,forceMount:n,children:u.jsx(Ga,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:r})})})};vB.displayName=_T;var ed="TooltipContent",wB=y.forwardRef((e,t)=>{const n=Kse(ed,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...o}=e,i=cm(ed,e.__scopeTooltip);return u.jsx(Ga,{present:r||i.open,children:i.disableHoverableContent?u.jsx(xB,{side:a,...o,ref:t}):u.jsx(Yse,{side:a,...o,ref:t})})}),Yse=y.forwardRef((e,t)=>{const n=cm(ed,e.__scopeTooltip),r=ST(ed,e.__scopeTooltip),a=y.useRef(null),o=tn(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},_=Jse(S,w.getBoundingClientRect()),T=Qse(S,_),R=eoe(x.getBoundingClientRect()),C=noe([...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=!toe(S,i);_?g():T&&(g(),f())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[d,m,i,f,g]),u.jsx(xB,{...e,ref:o})}),[Zse,qse]=av(xp,{isInside:!1}),Xse=Ite("TooltipContent"),xB=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(Xse,{children:r}),u.jsx(Zse,{scope:n,isInside:!0,children:u.jsx(Bse,{id:d.contentId,role:"tooltip",children:a||r})})]})})});wB.displayName=ed;var EB="TooltipArrow",SB=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=sv(n);return qse(EB,n).isInside?null:u.jsx(qy,{...a,...r,ref:t})});SB.displayName=EB;function Jse(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 Qse(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 eoe(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 toe(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 noe(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),roe(t)}function roe(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 aoe=gB,soe=bB,ooe=yB,ioe=vB,loe=wB,coe=SB;function TT({delayDuration:e=0,...t}){return u.jsx(aoe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Ct({...e}){return u.jsx(TT,{children:u.jsx(soe,{"data-slot":"tooltip",...e})})}function Rt({...e}){return u.jsx(ooe,{"data-slot":"tooltip-trigger",...e})}function At({className:e,sideOffset:t=0,children:n,...r}){return u.jsx(ioe,{children:u.jsxs(loe,{"data-slot":"tooltip-content",sideOffset:t,className:De("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(coe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class uoe{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 doe{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 foe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class poe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function O0(){try{return"0.14.0"}catch{return"0.0.0"}}var moe={};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 Wr{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"&&moe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(vi("source")):null}static getInstance(){return Wr.instance||(Wr.instance=new Wr),Wr.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 uoe(t);await this.capture(n)}}const hoe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),goe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),OP=e=>{const t=goe(e);return t.charAt(0).toUpperCase()+t.slice(1)},_B=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),boe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var yoe={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 voe=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,...yoe,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:_B("lucide",a),...!o&&!boe(c)&&{"aria-hidden":"true"},...c},[...i.map(([f,m])=>y.createElement(f,m)),...Array.isArray(o)?o:[o]]));const tt=(e,t)=>{const n=y.forwardRef(({className:r,...a},o)=>y.createElement(voe,{ref:o,iconNode:t,className:_B(`lucide-${hoe(OP(e))}`,`lucide-${e}`,r),...a}));return n.displayName=OP(e),n};const woe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],xoe=tt("arrow-down-to-line",woe);const Eoe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Soe=tt("arrow-up-from-line",Eoe);const _oe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Toe=tt("arrow-up",_oe);const Noe=[["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=tt("bell",Noe);const koe=[["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"}]],TB=tt("brush",koe);const Coe=[["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"}]],Roe=tt("bug",Coe);const Aoe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],yr=tt("check",Aoe);const Ioe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Js=tt("chevron-down",Ioe);const Ooe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ov=tt("chevron-left",Ooe);const Doe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],NB=tt("chevron-right",Doe);const Loe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Moe=tt("chevron-up",Loe);const joe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Poe=tt("chevrons-up-down",joe);const $oe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],DP=tt("circle-minus",$oe);const Uoe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ep=tt("clock",Uoe);const zoe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],kT=tt("code",zoe);const Foe=[["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"}]],Boe=tt("cog",Foe);const Hoe=[["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"}]],Voe=tt("command",Hoe);const Goe=[["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"}]],or=tt("copy",Goe);const Woe=[["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=tt("database",Woe);const Koe=[["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=tt("download",Koe);const Yoe=[["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"}]],Zoe=tt("ellipsis-vertical",Yoe);const qoe=[["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=tt("external-link",qoe);const Xoe=[["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"}]],kB=tt("eye-off",Xoe);const Joe=[["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=tt("eye",Joe);const Qoe=[["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"}]],eie=tt("file-code",Qoe);const tie=[["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"}]],nie=tt("file-image",tie);const rie=[["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=tt("file-text",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"}]],sie=tt("file",aie);const oie=[["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"}]],iie=tt("folder-open",oie);const lie=[["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"}]],cie=tt("globe",lie);const uie=[["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"}]],die=tt("grip-vertical",uie);const fie=[["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"}]],CB=tt("hash",fie);const pie=[["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=tt("history",pie);const mie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Qf=tt("info",mie);const hie=[["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"}]],RB=tt("key",hie);const gie=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Fi=tt("loader-circle",gie);const bie=[["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=tt("maximize-2",bie);const yie=[["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=tt("maximize",yie);const vie=[["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"}]],wie=tt("message-circle",vie);const xie=[["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=tt("message-square",xie);const Eie=[["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"}]],AB=tt("minimize",Eie);const Sie=[["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=tt("monitor",Sie);const _ie=[["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"}]],Tie=tt("moon",_ie);const Nie=[["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"}]],kie=tt("picture-in-picture",Nie);const Cie=[["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"}]],IB=tt("play",Cie);const Rie=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Np=tt("plus",Rie);const Aie=[["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=tt("rotate-ccw",Aie);const Iie=[["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=tt("save",Iie);const Oie=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Sd=tt("search",Oie);const Die=[["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"}]],Lie=tt("send",Die);const Mie=[["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"}]],OB=tt("server",Mie);const jie=[["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=tt("settings",jie);const Pie=[["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"}]],$ie=tt("shield",Pie);const Uie=[["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"}]],zie=tt("sparkles",Uie);const Fie=[["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"}]],DB=tt("square-check-big",Fie);const Bie=[["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"}]],Hie=tt("square-pen",Bie);const Vie=[["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"}]],Gie=tt("sun-dim",Vie);const Wie=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],L0=tt("terminal",Wie);const Kie=[["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"}]],$o=tt("trash-2",Kie);const Yie=[["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"}]],Zie=tt("trash",Yie);const qie=[["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=tt("wrench",qie);const Xie=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],no=tt("x",Xie);const Jie=[["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=tt("zap",Jie);var jP="popstate";function Qie(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 tle(t,n,null,e)}function Xn(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ns(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function ele(){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||ele()}}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 tle(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 nle(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 nle(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Xn(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 LB(e,t,n="/"){return rle(e,t,n,!1)}function rle(e,t,n,r){let a=typeof t=="string"?_d(t):t,o=Uo(a.pathname||"/",n);if(o==null)return null;let i=MB(e);ale(i);let c=null;for(let d=0;c==null&&d<i.length;++d){let f=hle(o);c=ple(i[d],f,r)}return c}function MB(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;Xn(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=Ao([r,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(Xn(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),MB(i.children,t,g,h,d)),!(i.path==null&&!i.index)&&t.push({path:h,score:dle(h,i.index),routesMeta:g})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))o(i,c);else for(let d of jB(i.path))o(i,c,!0,d)}),t}function jB(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=jB(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 ale(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:fle(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var sle=/^:[\w-]+$/,ole=3,ile=2,lle=1,cle=10,ule=-2,$P=e=>e==="*";function dle(e,t){let n=e.split("/"),r=n.length;return n.some($P)&&(r+=ule),t&&(r+=ile),n.filter(a=>!$P(a)).reduce((a,o)=>a+(sle.test(o)?ole:o===""?lle:cle),r)}function fle(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 ple(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:Ao([o,h.pathname]),pathnameBase:wle(Ao([o,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(o=Ao([o,h.pathnameBase]))}return i}function Qb(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=mle(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 mle(e,t=!1,n=!0){Ns(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 hle(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ns(!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 Uo(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 gle=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ble=e=>gle.test(e);function yle(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?_d(e):e,o;if(n)if(ble(n))o=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Ns(!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:xle(r),hash:Ele(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 vle(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function PB(e){let t=vle(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function $B(e,t,n,r=!1){let a;typeof e=="string"?a=_d(e):(a={...e},Xn(!a.pathname||!a.pathname.includes("?"),M0("?","pathname","search",a)),Xn(!a.pathname||!a.pathname.includes("#"),M0("#","pathname","hash",a)),Xn(!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=yle(a,c),f=i&&i!=="/"&&i.endsWith("/"),m=(o||i===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(f||m)&&(d.pathname+="/"),d}var Ao=e=>e.join("/").replace(/\/\/+/g,"/"),wle=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),xle=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ele=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Sle(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function _le(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var UB=["POST","PUT","PATCH","DELETE"];new Set(UB);var Tle=["GET",...UB];new Set(Tle);var Td=y.createContext(null);Td.displayName="DataRouter";var lv=y.createContext(null);lv.displayName="DataRouterState";y.createContext(!1);var zB=y.createContext({isTransitioning:!1});zB.displayName="ViewTransition";var Nle=y.createContext(new Map);Nle.displayName="Fetchers";var kle=y.createContext(null);kle.displayName="Await";var Os=y.createContext(null);Os.displayName="Navigation";var dm=y.createContext(null);dm.displayName="Location";var Ho=y.createContext({outlet:null,matches:[],isDataRoute:!1});Ho.displayName="Route";var IT=y.createContext(null);IT.displayName="RouteError";function Cle(e,{relative:t}={}){Xn(fm(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=y.useContext(Os),{hash:a,pathname:o,search:i}=pm(e,{relative:t}),c=o;return n!=="/"&&(c=o==="/"?n:Ao([n,o])),r.createHref({pathname:c,search:i,hash:a})}function fm(){return y.useContext(dm)!=null}function Vo(){return Xn(fm(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(dm).location}var FB="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function BB(e){y.useContext(Os).static||y.useLayoutEffect(e)}function Nd(){let{isDataRoute:e}=y.useContext(Ho);return e?Fle():Rle()}function Rle(){Xn(fm(),"useNavigate() may be used only in the context of a <Router> component.");let e=y.useContext(Td),{basename:t,navigator:n}=y.useContext(Os),{matches:r}=y.useContext(Ho),{pathname:a}=Vo(),o=JSON.stringify(PB(r)),i=y.useRef(!1);return BB(()=>{i.current=!0}),y.useCallback((d,f={})=>{if(Ns(i.current,FB),!i.current)return;if(typeof d=="number"){n.go(d);return}let m=$B(d,JSON.parse(o),a,f.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ao([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(Ho),{pathname:r}=Vo(),a=JSON.stringify(PB(n));return y.useMemo(()=>$B(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Ale(e,t){return HB(e,t)}function HB(e,t,n,r,a){Xn(fm(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=y.useContext(Os),{matches:i}=y.useContext(Ho),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||"";VB(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
|
+
`)},hae=0,Fc=[];function gae(e){var t=y.useRef([]),n=y.useRef([0,0]),r=y.useRef(),a=y.useState(hae++)[0],o=y.useState(m3)[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=Pre([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(),j=O&&O.anchorNode,L=j?j===A||j.contains(A):!1;if(L)return!1;var z=SP(I,A);if(!z)return!0;if(z?C=I:(C=I==="v"?"h":"v",z=SP(I,A)),!z)return!1;if(!r.current&&"changedTouches"in x&&(T||R)&&(r.current=C),!C)return!0;var H=r.current||C;return fae(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)&&pae(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:bae(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:mae(a)}):null,v?y.createElement(sae,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function bae(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const yae=Wre(p3,gae);var om=y.forwardRef(function(e,t){return y.createElement(Jy,Bs({},e,{ref:t,sideCar:yae}))});om.classNames=Jy.classNames;var XE=["Enter"," "],vae=["ArrowDown","PageUp","Home"],y3=["ArrowUp","PageDown","End"],wae=[...vae,...y3],xae={ltr:[...XE,"ArrowRight"],rtl:[...XE,"ArrowLeft"]},Eae={ltr:["ArrowLeft"],rtl:["ArrowRight"]},im="Menu",[yp,Sae,_ae]=aT(im),[Zl,v3]=Is(im,[_ae,Ki,s3]),Qy=Ki(),w3=s3(),[Tae,ql]=Zl(im),[Nae,lm]=Zl(im),x3=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=qs(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(Tae,{scope:t,open:n,onOpenChange:h,content:d,onContentChange:f,children:u.jsx(Nae,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:i,children:r})})})};x3.displayName=im;var kae="MenuAnchor",hT=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Qy(n);return u.jsx(am,{...a,...r,ref:t})});hT.displayName=kae;var gT="MenuPortal",[Cae,E3]=Zl(gT,{forceMount:void 0}),S3=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,o=ql(gT,t);return u.jsx(Cae,{scope:t,forceMount:n,children:u.jsx(Ga,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:r})})})};S3.displayName=gT;var ss="MenuContent",[Rae,bT]=Zl(ss),_3=y.forwardRef((e,t)=>{const n=E3(ss,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=ql(ss,e.__scopeMenu),i=lm(ss,e.__scopeMenu);return u.jsx(yp.Provider,{scope:e.__scopeMenu,children:u.jsx(Ga,{present:r||o.open,children:u.jsx(yp.Slot,{scope:e.__scopeMenu,children:i.modal?u.jsx(Aae,{...a,ref:t}):u.jsx(Iae,{...a,ref:t})})})})}),Aae=y.forwardRef((e,t)=>{const n=ql(ss,e.__scopeMenu),r=y.useRef(null),a=tn(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:Ze(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Iae=y.forwardRef((e,t)=>{const n=ql(ss,e.__scopeMenu);return u.jsx(yT,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Oae=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(ss,n),S=lm(ss,n),_=Qy(n),T=w3(n),R=Sae(n),[C,A]=y.useState(null),I=y.useRef(null),O=tn(t,I,w.onContentChange),j=y.useRef(0),L=y.useRef(""),z=y.useRef(0),H=y.useRef(null),Z=y.useRef("right"),J=y.useRef(0),ne=E?om:y.Fragment,G=E?{as:Oae,allowPinchZoom:!0}:void 0,Y=re=>{const ee=L.current+re,M=R().filter(W=>!W.disabled),F=document.activeElement,U=M.find(W=>W.ref.current===F)?.textValue,D=M.map(W=>W.textValue),P=Vae(D,ee,U),V=M.find(W=>W.textValue===P)?.ref.current;(function W(te){L.current=te,window.clearTimeout(j.current),te!==""&&(j.current=window.setTimeout(()=>W(""),1e3))})(ee),V&&setTimeout(()=>V.focus())};y.useEffect(()=>()=>window.clearTimeout(j.current),[]),Hy();const B=y.useCallback(re=>Z.current===H.current?.side&&Wae(re,H.current?.area),[]);return u.jsx(Rae,{scope:n,searchRef:L,onItemEnter:y.useCallback(re=>{B(re)&&re.preventDefault()},[B]),onItemLeave:y.useCallback(re=>{B(re)||(I.current?.focus(),A(null))},[B]),onTriggerLeave:y.useCallback(re=>{B(re)&&re.preventDefault()},[B]),pointerGraceTimerRef:z,onPointerGraceIntentChange:y.useCallback(re=>{H.current=re},[]),children:u.jsx(ne,{...G,children:u.jsx(nm,{asChild:!0,trapped:a,onMountAutoFocus:Ze(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(Ore,{asChild:!0,...T,dir:S.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:A,onEntryFocus:Ze(d,re=>{S.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:u.jsx(Zy,{role:"menu","aria-orientation":"vertical","data-state":z3(w.open),"data-radix-menu-content":"",dir:S.dir,..._,...x,ref:O,style:{outline:"none",...x.style},onKeyDown:Ze(x.onKeyDown,re=>{const M=re.target.closest("[data-radix-menu-content]")===re.currentTarget,F=re.ctrlKey||re.altKey||re.metaKey,U=re.key.length===1;M&&(re.key==="Tab"&&re.preventDefault(),!F&&U&&Y(re.key));const D=I.current;if(re.target!==D||!wae.includes(re.key))return;re.preventDefault();const V=R().filter(W=>!W.disabled).map(W=>W.ref.current);y3.includes(re.key)&&V.reverse(),Bae(V)}),onBlur:Ze(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(j.current),L.current="")}),onPointerMove:Ze(e.onPointerMove,vp(re=>{const ee=re.target,M=J.current!==re.clientX;if(re.currentTarget.contains(ee)&&M){const F=re.clientX>J.current?"right":"left";Z.current=F,J.current=re.clientX}}))})})})})})})});_3.displayName=ss;var Dae="MenuGroup",vT=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ot.div,{role:"group",...r,ref:t})});vT.displayName=Dae;var Lae="MenuLabel",T3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ot.div,{...r,ref:t})});T3.displayName=Lae;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=tn(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}),D4(h,g),g.defaultPrevented?f.current=!1:i.onClose()}};return u.jsx(N3,{...a,ref:d,disabled:n,onClick:Ze(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:Ze(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:Ze(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 N3=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...o}=e,i=bT(Zb,n),c=w3(n),d=y.useRef(null),f=tn(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(Dre,{asChild:!0,...c,focusable:!r,children:u.jsx(Ot.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:f,onPointerMove:Ze(e.onPointerMove,vp(E=>{r?i.onItemLeave(E):(i.onItemEnter(E),E.defaultPrevented||E.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ze(e.onPointerLeave,vp(E=>i.onItemLeave(E))),onFocus:Ze(e.onFocus,()=>h(!0)),onBlur:Ze(e.onBlur,()=>h(!1))})})})}),Mae="MenuCheckboxItem",k3=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return u.jsx(O3,{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:Ze(a.onSelect,()=>r?.(qb(n)?!0:!n),{checkForDefaultPrevented:!1})})})});k3.displayName=Mae;var C3="MenuRadioGroup",[jae,Pae]=Zl(C3,{value:void 0,onValueChange:()=>{}}),R3=y.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,o=qs(r);return u.jsx(jae,{scope:e.__scopeMenu,value:n,onValueChange:o,children:u.jsx(vT,{...a,ref:t})})});R3.displayName=C3;var A3="MenuRadioItem",I3=y.forwardRef((e,t)=>{const{value:n,...r}=e,a=Pae(A3,e.__scopeMenu),o=n===a.value;return u.jsx(O3,{scope:e.__scopeMenu,checked:o,children:u.jsx(ev,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":xT(o),onSelect:Ze(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});I3.displayName=A3;var wT="MenuItemIndicator",[O3,$ae]=Zl(wT,{checked:!1}),D3=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,o=$ae(wT,n);return u.jsx(Ga,{present:r||qb(o.checked)||o.checked===!0,children:u.jsx(Ot.span,{...a,ref:t,"data-state":xT(o.checked)})})});D3.displayName=wT;var Uae="MenuSeparator",L3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return u.jsx(Ot.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});L3.displayName=Uae;var zae="MenuArrow",M3=y.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=Qy(n);return u.jsx(qy,{...a,...r,ref:t})});M3.displayName=zae;var Fae="MenuSub",[Hxe,j3]=Zl(Fae),Bf="MenuSubTrigger",P3=y.forwardRef((e,t)=>{const n=ql(Bf,e.__scopeMenu),r=lm(Bf,e.__scopeMenu),a=j3(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(N3,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":z3(n.open),...e,ref:Zs(t,a.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ze(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:Ze(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:Ze(e.onKeyDown,h=>{const g=o.searchRef.current!=="";e.disabled||g&&h.key===" "||xae[r.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});P3.displayName=Bf;var $3="MenuSubContent",U3=y.forwardRef((e,t)=>{const n=E3(ss,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,o=ql(ss,e.__scopeMenu),i=lm(ss,e.__scopeMenu),c=j3($3,e.__scopeMenu),d=y.useRef(null),f=tn(t,d);return u.jsx(yp.Provider,{scope:e.__scopeMenu,children:u.jsx(Ga,{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:Ze(e.onFocusOutside,m=>{m.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Ze(e.onEscapeKeyDown,m=>{i.onClose(),m.preventDefault()}),onKeyDown:Ze(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=Eae[i.dir].includes(m.key);h&&g&&(o.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});U3.displayName=$3;function z3(e){return e?"open":"closed"}function qb(e){return e==="indeterminate"}function xT(e){return qb(e)?"indeterminate":e?"checked":"unchecked"}function Bae(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Hae(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Vae(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=Hae(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 Gae(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 Wae(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Gae(n,t)}function vp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Kae=x3,Yae=hT,Zae=S3,qae=_3,Xae=vT,Jae=T3,Qae=ev,ese=k3,tse=R3,nse=I3,rse=D3,ase=L3,sse=M3,ose=P3,ise=U3,tv="DropdownMenu",[lse]=Is(tv,[v3]),ga=v3(),[cse,F3]=lse(tv),B3=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:o,onOpenChange:i,modal:c=!0}=e,d=ga(t),f=y.useRef(null),[m,h]=Mo({prop:a,defaultProp:o??!1,onChange:i,caller:tv});return u.jsx(cse,{scope:t,triggerId:Yr(),triggerRef:f,contentId:Yr(),open:m,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:c,children:u.jsx(Kae,{...d,open:m,onOpenChange:h,dir:r,modal:c,children:n})})};B3.displayName=tv;var H3="DropdownMenuTrigger",V3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,o=F3(H3,n),i=ga(n);return u.jsx(Yae,{asChild:!0,...i,children:u.jsx(Ot.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:Zs(t,o.triggerRef),onPointerDown:Ze(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(o.onOpenToggle(),o.open||c.preventDefault())}),onKeyDown:Ze(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&o.onOpenToggle(),c.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});V3.displayName=H3;var use="DropdownMenuPortal",G3=e=>{const{__scopeDropdownMenu:t,...n}=e,r=ga(t);return u.jsx(Zae,{...r,...n})};G3.displayName=use;var W3="DropdownMenuContent",K3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=F3(W3,n),o=ga(n),i=y.useRef(!1);return u.jsx(qae,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...r,ref:t,onCloseAutoFocus:Ze(e.onCloseAutoFocus,c=>{i.current||a.triggerRef.current?.focus(),i.current=!1,c.preventDefault()}),onInteractOutside:Ze(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)"}})});K3.displayName=W3;var dse="DropdownMenuGroup",fse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(Xae,{...a,...r,ref:t})});fse.displayName=dse;var pse="DropdownMenuLabel",Y3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(Jae,{...a,...r,ref:t})});Y3.displayName=pse;var mse="DropdownMenuItem",Z3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(Qae,{...a,...r,ref:t})});Z3.displayName=mse;var hse="DropdownMenuCheckboxItem",q3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(ese,{...a,...r,ref:t})});q3.displayName=hse;var gse="DropdownMenuRadioGroup",bse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(tse,{...a,...r,ref:t})});bse.displayName=gse;var yse="DropdownMenuRadioItem",X3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(nse,{...a,...r,ref:t})});X3.displayName=yse;var vse="DropdownMenuItemIndicator",wse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(rse,{...a,...r,ref:t})});wse.displayName=vse;var xse="DropdownMenuSeparator",J3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(ase,{...a,...r,ref:t})});J3.displayName=xse;var Ese="DropdownMenuArrow",Sse=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(sse,{...a,...r,ref:t})});Sse.displayName=Ese;var _se="DropdownMenuSubTrigger",Q3=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(ose,{...a,...r,ref:t})});Q3.displayName=_se;var Tse="DropdownMenuSubContent",eB=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=ga(n);return u.jsx(ise,{...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)"}})});eB.displayName=Tse;var Nse=B3,kse=V3,Cse=G3,tB=K3,nB=Y3,rB=Z3,Rse=q3,Ase=X3,aB=J3,Ise=Q3,Ose=eB;const Xb=Nse,Jb=kse;Ise.displayName;Ose.displayName;function wp({ref:e,className:t,sideOffset:n=4,...r}){return u.jsx(Cse,{children:u.jsx(tB,{ref:e,sideOffset:n,className:De("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=tB.displayName;function Fr({ref:e,className:t,inset:n,...r}){return u.jsx(rB,{ref:e,className:De("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})}Fr.displayName=rB.displayName;Rse.displayName;Ase.displayName;function JE({ref:e,className:t,inset:n,...r}){return u.jsx(nB,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...r})}JE.displayName=nB.displayName;function ru({ref:e,className:t,...n}){return u.jsx(aB,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}ru.displayName=aB.displayName;var Dse=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Bo=Dse.reduce((e,t)=>{const n=m4(`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}},{}),Lse="Label",sB=y.forwardRef((e,t)=>u.jsx(Bo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));sB.displayName=Lse;var Mse=sB;function en({className:e,...t}){return u.jsx(Mse,{"data-slot":"label",className:De("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:De(`mt-2 rounded-md p-6 ${t}`,!r&&"border"),children:u.jsxs("p",{className:De("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 oB({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:De("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",[jse]=Is(nv),[Pse,$se]=jse(nv),iB=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=tn(t,T=>v(T)),x=y.useRef(!1),w=g?m||!!g.closest("form"):!0,[S,_]=Mo({prop:a,defaultProp:o??!1,onChange:f,caller:nv});return u.jsxs(Pse,{scope:n,checked:S,disabled:c,children:[u.jsx(Ot.button,{type:"button",role:"switch","aria-checked":S,"aria-required":i,"data-state":dB(S),"data-disabled":c?"":void 0,disabled:c,value:d,...h,ref:E,onClick:Ze(e.onClick,T=>{_(R=>!R),w&&(x.current=T.isPropagationStopped(),x.current||T.stopPropagation())})}),w&&u.jsx(uB,{control:g,bubbles:!x.current,name:r,value:d,checked:S,required:i,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});iB.displayName=nv;var lB="SwitchThumb",cB=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=$se(lB,n);return u.jsx(Ot.span,{"data-state":dB(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});cB.displayName=lB;var Use="SwitchBubbleInput",uB=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},o)=>{const i=y.useRef(null),c=tn(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}})});uB.displayName=Use;function dB(e){return e?"checked":"unchecked"}var fB=iB,zse=cB;function rv({ref:e,className:t,...n}){return u.jsx(fB,{className:De("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(zse,{className:De("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=fB.displayName;var pB=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"}),Fse="VisuallyHidden",mB=y.forwardRef((e,t)=>u.jsx(Ot.span,{...e,ref:t,style:{...pB,...e.style}}));mB.displayName=Fse;var Bse=mB,[av]=Is("Tooltip",[Ki]),sv=Ki(),hB="TooltipProvider",Hse=700,QE="tooltip.open",[Vse,ST]=av(hB),gB=e=>{const{__scopeTooltip:t,delayDuration:n=Hse,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(Vse,{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})};gB.displayName=hB;var xp="Tooltip",[Gse,cm]=av(xp),bB=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=Yr(),v=y.useRef(0),E=i??d.disableHoverableContent,x=c??d.delayDuration,w=y.useRef(!1),[S,_]=Mo({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(Gse,{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})})};bB.displayName=xp;var eS="TooltipTrigger",yB=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=tn(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(Ot.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...r,ref:d,onPointerMove:Ze(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ze(e.onPointerLeave,()=>{a.onTriggerLeave(),m.current=!1}),onPointerDown:Ze(e.onPointerDown,()=>{a.open&&a.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ze(e.onFocus,()=>{f.current||a.onOpen()}),onBlur:Ze(e.onBlur,a.onClose),onClick:Ze(e.onClick,a.onClose)})})});yB.displayName=eS;var _T="TooltipPortal",[Wse,Kse]=av(_T,{forceMount:void 0}),vB=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:a}=e,o=cm(_T,t);return u.jsx(Wse,{scope:t,forceMount:n,children:u.jsx(Ga,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:r})})})};vB.displayName=_T;var ed="TooltipContent",wB=y.forwardRef((e,t)=>{const n=Kse(ed,e.__scopeTooltip),{forceMount:r=n.forceMount,side:a="top",...o}=e,i=cm(ed,e.__scopeTooltip);return u.jsx(Ga,{present:r||i.open,children:i.disableHoverableContent?u.jsx(xB,{side:a,...o,ref:t}):u.jsx(Yse,{side:a,...o,ref:t})})}),Yse=y.forwardRef((e,t)=>{const n=cm(ed,e.__scopeTooltip),r=ST(ed,e.__scopeTooltip),a=y.useRef(null),o=tn(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},_=Jse(S,w.getBoundingClientRect()),T=Qse(S,_),R=eoe(x.getBoundingClientRect()),C=noe([...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=!toe(S,i);_?g():T&&(g(),f())};return document.addEventListener("pointermove",E),()=>document.removeEventListener("pointermove",E)}},[d,m,i,f,g]),u.jsx(xB,{...e,ref:o})}),[Zse,qse]=av(xp,{isInside:!1}),Xse=Ite("TooltipContent"),xB=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(Xse,{children:r}),u.jsx(Zse,{scope:n,isInside:!0,children:u.jsx(Bse,{id:d.contentId,role:"tooltip",children:a||r})})]})})});wB.displayName=ed;var EB="TooltipArrow",SB=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,a=sv(n);return qse(EB,n).isInside?null:u.jsx(qy,{...a,...r,ref:t})});SB.displayName=EB;function Jse(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 Qse(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 eoe(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 toe(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 noe(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),roe(t)}function roe(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 aoe=gB,soe=bB,ooe=yB,ioe=vB,loe=wB,coe=SB;function TT({delayDuration:e=0,...t}){return u.jsx(aoe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Ct({...e}){return u.jsx(TT,{children:u.jsx(soe,{"data-slot":"tooltip",...e})})}function Rt({...e}){return u.jsx(ooe,{"data-slot":"tooltip-trigger",...e})}function At({className:e,sideOffset:t=0,children:n,...r}){return u.jsx(ioe,{children:u.jsxs(loe,{"data-slot":"tooltip-content",sideOffset:t,className:De("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(coe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class uoe{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 doe{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 foe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class poe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function O0(){try{return"0.14.1-canary.1"}catch{return"0.0.0"}}var moe={};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 Wr{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"&&moe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(vi("source")):null}static getInstance(){return Wr.instance||(Wr.instance=new Wr),Wr.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 uoe(t);await this.capture(n)}}const hoe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),goe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),OP=e=>{const t=goe(e);return t.charAt(0).toUpperCase()+t.slice(1)},_B=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),boe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var yoe={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 voe=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,...yoe,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:_B("lucide",a),...!o&&!boe(c)&&{"aria-hidden":"true"},...c},[...i.map(([f,m])=>y.createElement(f,m)),...Array.isArray(o)?o:[o]]));const tt=(e,t)=>{const n=y.forwardRef(({className:r,...a},o)=>y.createElement(voe,{ref:o,iconNode:t,className:_B(`lucide-${hoe(OP(e))}`,`lucide-${e}`,r),...a}));return n.displayName=OP(e),n};const woe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],xoe=tt("arrow-down-to-line",woe);const Eoe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],Soe=tt("arrow-up-from-line",Eoe);const _oe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Toe=tt("arrow-up",_oe);const Noe=[["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=tt("bell",Noe);const koe=[["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"}]],TB=tt("brush",koe);const Coe=[["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"}]],Roe=tt("bug",Coe);const Aoe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],yr=tt("check",Aoe);const Ioe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Js=tt("chevron-down",Ioe);const Ooe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ov=tt("chevron-left",Ooe);const Doe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],NB=tt("chevron-right",Doe);const Loe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Moe=tt("chevron-up",Loe);const joe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Poe=tt("chevrons-up-down",joe);const $oe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],DP=tt("circle-minus",$oe);const Uoe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ep=tt("clock",Uoe);const zoe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],kT=tt("code",zoe);const Foe=[["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"}]],Boe=tt("cog",Foe);const Hoe=[["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"}]],Voe=tt("command",Hoe);const Goe=[["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"}]],or=tt("copy",Goe);const Woe=[["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=tt("database",Woe);const Koe=[["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=tt("download",Koe);const Yoe=[["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"}]],Zoe=tt("ellipsis-vertical",Yoe);const qoe=[["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=tt("external-link",qoe);const Xoe=[["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"}]],kB=tt("eye-off",Xoe);const Joe=[["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=tt("eye",Joe);const Qoe=[["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"}]],eie=tt("file-code",Qoe);const tie=[["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"}]],nie=tt("file-image",tie);const rie=[["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=tt("file-text",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"}]],sie=tt("file",aie);const oie=[["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"}]],iie=tt("folder-open",oie);const lie=[["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"}]],cie=tt("globe",lie);const uie=[["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"}]],die=tt("grip-vertical",uie);const fie=[["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"}]],CB=tt("hash",fie);const pie=[["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=tt("history",pie);const mie=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Qf=tt("info",mie);const hie=[["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"}]],RB=tt("key",hie);const gie=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Fi=tt("loader-circle",gie);const bie=[["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=tt("maximize-2",bie);const yie=[["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=tt("maximize",yie);const vie=[["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"}]],wie=tt("message-circle",vie);const xie=[["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=tt("message-square",xie);const Eie=[["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"}]],AB=tt("minimize",Eie);const Sie=[["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=tt("monitor",Sie);const _ie=[["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"}]],Tie=tt("moon",_ie);const Nie=[["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"}]],kie=tt("picture-in-picture",Nie);const Cie=[["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"}]],IB=tt("play",Cie);const Rie=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Np=tt("plus",Rie);const Aie=[["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=tt("rotate-ccw",Aie);const Iie=[["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=tt("save",Iie);const Oie=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Sd=tt("search",Oie);const Die=[["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"}]],Lie=tt("send",Die);const Mie=[["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"}]],OB=tt("server",Mie);const jie=[["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=tt("settings",jie);const Pie=[["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"}]],$ie=tt("shield",Pie);const Uie=[["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"}]],zie=tt("sparkles",Uie);const Fie=[["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"}]],DB=tt("square-check-big",Fie);const Bie=[["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"}]],Hie=tt("square-pen",Bie);const Vie=[["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"}]],Gie=tt("sun-dim",Vie);const Wie=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],L0=tt("terminal",Wie);const Kie=[["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"}]],$o=tt("trash-2",Kie);const Yie=[["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"}]],Zie=tt("trash",Yie);const qie=[["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=tt("wrench",qie);const Xie=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],no=tt("x",Xie);const Jie=[["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=tt("zap",Jie);var jP="popstate";function Qie(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 tle(t,n,null,e)}function Xn(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ns(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function ele(){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||ele()}}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 tle(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 nle(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 nle(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Xn(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 LB(e,t,n="/"){return rle(e,t,n,!1)}function rle(e,t,n,r){let a=typeof t=="string"?_d(t):t,o=Uo(a.pathname||"/",n);if(o==null)return null;let i=MB(e);ale(i);let c=null;for(let d=0;c==null&&d<i.length;++d){let f=hle(o);c=ple(i[d],f,r)}return c}function MB(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;Xn(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=Ao([r,m.relativePath]),g=n.concat(m);i.children&&i.children.length>0&&(Xn(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),MB(i.children,t,g,h,d)),!(i.path==null&&!i.index)&&t.push({path:h,score:dle(h,i.index),routesMeta:g})};return e.forEach((i,c)=>{if(i.path===""||!i.path?.includes("?"))o(i,c);else for(let d of jB(i.path))o(i,c,!0,d)}),t}function jB(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=jB(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 ale(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:fle(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var sle=/^:[\w-]+$/,ole=3,ile=2,lle=1,cle=10,ule=-2,$P=e=>e==="*";function dle(e,t){let n=e.split("/"),r=n.length;return n.some($P)&&(r+=ule),t&&(r+=ile),n.filter(a=>!$P(a)).reduce((a,o)=>a+(sle.test(o)?ole:o===""?lle:cle),r)}function fle(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 ple(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:Ao([o,h.pathname]),pathnameBase:wle(Ao([o,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(o=Ao([o,h.pathnameBase]))}return i}function Qb(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=mle(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 mle(e,t=!1,n=!0){Ns(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 hle(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ns(!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 Uo(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 gle=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ble=e=>gle.test(e);function yle(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?_d(e):e,o;if(n)if(ble(n))o=n;else{if(n.includes("//")){let i=n;n=n.replace(/\/\/+/g,"/"),Ns(!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:xle(r),hash:Ele(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 vle(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function PB(e){let t=vle(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function $B(e,t,n,r=!1){let a;typeof e=="string"?a=_d(e):(a={...e},Xn(!a.pathname||!a.pathname.includes("?"),M0("?","pathname","search",a)),Xn(!a.pathname||!a.pathname.includes("#"),M0("#","pathname","hash",a)),Xn(!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=yle(a,c),f=i&&i!=="/"&&i.endsWith("/"),m=(o||i===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(f||m)&&(d.pathname+="/"),d}var Ao=e=>e.join("/").replace(/\/\/+/g,"/"),wle=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),xle=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ele=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Sle(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function _le(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var UB=["POST","PUT","PATCH","DELETE"];new Set(UB);var Tle=["GET",...UB];new Set(Tle);var Td=y.createContext(null);Td.displayName="DataRouter";var lv=y.createContext(null);lv.displayName="DataRouterState";y.createContext(!1);var zB=y.createContext({isTransitioning:!1});zB.displayName="ViewTransition";var Nle=y.createContext(new Map);Nle.displayName="Fetchers";var kle=y.createContext(null);kle.displayName="Await";var Os=y.createContext(null);Os.displayName="Navigation";var dm=y.createContext(null);dm.displayName="Location";var Ho=y.createContext({outlet:null,matches:[],isDataRoute:!1});Ho.displayName="Route";var IT=y.createContext(null);IT.displayName="RouteError";function Cle(e,{relative:t}={}){Xn(fm(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=y.useContext(Os),{hash:a,pathname:o,search:i}=pm(e,{relative:t}),c=o;return n!=="/"&&(c=o==="/"?n:Ao([n,o])),r.createHref({pathname:c,search:i,hash:a})}function fm(){return y.useContext(dm)!=null}function Vo(){return Xn(fm(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(dm).location}var FB="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function BB(e){y.useContext(Os).static||y.useLayoutEffect(e)}function Nd(){let{isDataRoute:e}=y.useContext(Ho);return e?Fle():Rle()}function Rle(){Xn(fm(),"useNavigate() may be used only in the context of a <Router> component.");let e=y.useContext(Td),{basename:t,navigator:n}=y.useContext(Os),{matches:r}=y.useContext(Ho),{pathname:a}=Vo(),o=JSON.stringify(PB(r)),i=y.useRef(!1);return BB(()=>{i.current=!0}),y.useCallback((d,f={})=>{if(Ns(i.current,FB),!i.current)return;if(typeof d=="number"){n.go(d);return}let m=$B(d,JSON.parse(o),a,f.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ao([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(Ho),{pathname:r}=Vo(),a=JSON.stringify(PB(n));return y.useMemo(()=>$B(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Ale(e,t){return HB(e,t)}function HB(e,t,n,r,a){Xn(fm(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=y.useContext(Os),{matches:i}=y.useContext(Ho),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||"";VB(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=Vo(),v;if(t){let _=typeof t=="string"?_d(t):t;Xn(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=LB(e,{pathname:x});Ns(h||w!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Ns(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=Mle(w&&w.map(_=>Object.assign({},_,{params:Object.assign({},d,_.params),pathname:Ao([m,o.encodeLocation?o.encodeLocation(_.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathname]),pathnameBase:_.pathnameBase==="/"?m:Ao([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 Ile(){let e=zle(),t=Sle(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 Ole=y.createElement(Ile,null),Dle=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(Ho.Provider,{value:this.props.routeContext},y.createElement(IT.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Lle({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(Ho.Provider,{value:e},n)}function Mle(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);Xn(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:_le(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||Ole,c&&(d<0&&g===0?(VB("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(Lle,{match:h,routeContext:{outlet:m,matches:S,isDataRoute:n!=null},children:T})};return n&&(h.route.ErrorBoundary||h.route.errorElement||g===0)?y.createElement(Dle,{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 jle(e){let t=y.useContext(Td);return Xn(t,OT(e)),t}function Ple(e){let t=y.useContext(lv);return Xn(t,OT(e)),t}function $le(e){let t=y.useContext(Ho);return Xn(t,OT(e)),t}function DT(e){let t=$le(e),n=t.matches[t.matches.length-1];return Xn(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Ule(){return DT("useRouteId")}function zle(){let e=y.useContext(IT),t=Ple("useRouteError"),n=DT("useRouteError");return e!==void 0?e:t.errors?.[n]}function Fle(){let{router:e}=jle("useNavigate"),t=DT("useNavigate"),n=y.useRef(!1);return BB(()=>{n.current=!0}),y.useCallback(async(a,o={})=>{Ns(n.current,FB),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}var zP={};function VB(e,t,n){!t&&!zP[e]&&(zP[e]=!0,Ns(!1,n))}y.memo(Ble);function Ble({routes:e,future:t,state:n,unstable_onError:r}){return HB(e,void 0,n,r,t)}function aS(e){Xn(!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 Hle({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:o=!1,unstable_useTransitions:i}){Xn(!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=Uo(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 Ns(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(Os.Provider,{value:d},y.createElement(dm.Provider,{children:t,value:E}))}function Vle({children:e,location:t}){return Ale(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}Xn(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>`),Xn(!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 Gle(e){return cv(e)&&e.tagName.toLowerCase()==="button"}function Wle(e){return cv(e)&&e.tagName.toLowerCase()==="form"}function Kle(e){return cv(e)&&e.tagName.toLowerCase()==="input"}function Yle(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Zle(e,t){return e.button===0&&(!t||t==="_self")&&!Yle(e)}var zg=null;function qle(){if(zg===null)try{new FormData(document.createElement("form"),0),zg=!1}catch{zg=!0}return zg}var Xle=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function j0(e){return e!=null&&!Xle.has(e)?(Ns(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${db}"`),null):e}function Jle(e,t){let n,r,a,o,i;if(Wle(e)){let c=e.getAttribute("action");r=c?Uo(c,t):null,n=e.getAttribute("method")||ub,a=j0(e.getAttribute("enctype"))||db,o=new FormData(e)}else if(Gle(e)||Kle(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?Uo(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),!qle()){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 Qle(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&&Uo(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function ece(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 tce(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 nce(e,t,n){let r=await Promise.all(e.map(async a=>{let o=t.routes[a.route.id];if(o){let i=await ece(o,n);return i.links?i.links():[]}return[]}));return oce(r.flat(1).filter(tce).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 rce(e,t,{includeHydrateFallback:n}={}){return ace(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 ace(e){return[...new Set(e)]}function sce(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function oce(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let o=JSON.stringify(sce(a));return n.has(o)||(n.add(o),r.push({key:o,link:a})),r},[])}function GB(){let e=y.useContext(Td);return LT(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function ice(){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 WB(){let e=y.useContext(MT);return LT(e,"You must render this element inside a <HydratedRouter> element"),e}function lce(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 cce({page:e,...t}){let{router:n}=GB(),r=y.useMemo(()=>LB(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?y.createElement(dce,{page:e,matches:r,...t}):null}function uce(e){let{manifest:t,routeModules:n}=WB(),[r,a]=y.useState([]);return y.useEffect(()=>{let o=!1;return nce(e,t,n).then(i=>{o||a(i)}),()=>{o=!0}},[e,t,n]),r}function dce({page:e,matches:t,...n}){let r=Vo(),{manifest:a,routeModules:o}=WB(),{basename:i}=GB(),{loaderData:c,matches:d}=ice(),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=Qle(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(()=>rce(m,a),[m,a]),v=uce(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 fce(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var KB=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{KB&&(window.__reactRouterVersion="7.10.1")}catch{}function pce({basename:e,children:t,unstable_useTransitions:n,window:r}){let a=y.useRef();a.current==null&&(a.current=Qie({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(Hle,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:o,unstable_useTransitions:n===!0})}var YB=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,ZB=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(Os),w=typeof f=="string"&&YB.test(f),S,_=!1;if(typeof f=="string"&&w&&(S=f,KB))try{let L=new URL(window.location.href),z=f.startsWith("//")?new URL(L.protocol+f):new URL(f),H=Uo(z.pathname,E);z.origin===L.origin&&H!=null?f=H+z.search+z.hash:_=!0}catch{Ns(!1,`<Link to="${f}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let T=Cle(f,{relative:a}),[R,C,A]=lce(r,g),I=bce(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 j=y.createElement("a",{...g,...A,href:S||T,onClick:_||o?t:O,ref:fce(v,C),target:d,"data-discover":!w&&n==="render"?"true":void 0});return R&&!w?y.createElement(y.Fragment,null,j,y.createElement(cce,{page:T})):j});ZB.displayName="Link";var mce=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=Vo(),v=y.useContext(lv),{navigator:E,basename:x}=y.useContext(Os),w=v!=null&&Ece(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=Uo(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,j;typeof r=="function"?j=r(I):j=[r,C?"active":null,A?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let L=typeof o=="function"?o(I):o;return y.createElement(ZB,{...f,"aria-current":O,className:j,ref:m,style:L,to:i,viewTransition:c},typeof d=="function"?d(I):d)});mce.displayName="NavLink";var hce=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(Os),x=wce(),w=xce(c,{relative:f}),S=i.toLowerCase()==="get"?"get":"post",_=typeof c=="string"&&YB.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})});hce.displayName="Form";function gce(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 Xn(t,gce(e)),t}function bce(e,{target:t,replace:n,state:r,preventScrollReset:a,relative:o,viewTransition:i,unstable_useTransitions:c}={}){let d=Nd(),f=Vo(),m=pm(e,{relative:o});return y.useCallback(h=>{if(Zle(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 yce=0,vce=()=>`__${String(++yce)}__`;function wce(){let{router:e}=qB("useSubmit"),{basename:t}=y.useContext(Os),n=Ule(),r=e.fetch,a=e.navigate;return y.useCallback(async(o,i={})=>{let{action:c,method:d,encType:f,formData:m,body:h}=Jle(o,t);if(i.navigate===!1){let g=i.fetcherKey||vce();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 xce(e,{relative:t}={}){let{basename:n}=y.useContext(Os),r=y.useContext(Ho);Xn(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),o={...pm(e||".",{relative:t})},i=Vo();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:Ao([n,o.pathname])),Cp(o)}function Ece(e,{relative:t}={}){let n=y.useContext(zB);Xn(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=Uo(n.currentLocation.pathname,r)||n.currentLocation.pathname,i=Uo(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Qb(a.pathname,i)!=null||Qb(a.pathname,o)!=null}function Sce(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 _ce=e=>{switch(e){case"success":return kce;case"info":return Rce;case"warning":return Cce;case"error":return Ace;default:return null}},Tce=Array(12).fill(0),Nce=({visible:e,className:t})=>ie.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ie.createElement("div",{className:"sonner-spinner"},Tce.map((n,r)=>ie.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),kce=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"})),Cce=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"})),Rce=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"})),Ace=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"})),Ice=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"})),Oce=()=>{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 Dce{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(Mce(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 Dce,Lce=(e,t)=>{const n=t?.id||oS++;return Ta.addToast({title:e,...t,id:n}),n},Mce=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jce=Lce,Pce=()=>Ta.toasts,$ce=()=>Ta.getActiveToasts(),ut=Object.assign(jce,{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:Pce,getToasts:$ce});Sce("[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 Uce=3,zce="24px",Fce="16px",BP=4e3,Bce=356,Hce=14,Vce=45,Gce=200;function zs(...e){return e.filter(Boolean).join(" ")}function Wce(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const Kce=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:j,className:L="",descriptionClassName:z="",duration:H,position:Z,gap:J,expandByDefault:ne,classNames:G,icons:Y,closeButtonAriaLabel:B="Close toast"}=e,[re,ee]=ie.useState(null),[M,F]=ie.useState(null),[U,D]=ie.useState(!1),[P,V]=ie.useState(!1),[W,te]=ie.useState(!1),[fe,le]=ie.useState(!1),[q,Q]=ie.useState(!1),[ae,de]=ie.useState(0),[he,xe]=ie.useState(0),He=ie.useRef(h.duration||H||BP),Ie=ie.useRef(null),je=ie.useRef(null),at=S===0,Ue=S+1<=x,Ye=h.type,pe=h.dismissible!==!1,Se=h.className||"",Ne=h.descriptionClassName||"",oe=ie.useMemo(()=>w.findIndex(Oe=>Oe.toastId===h.id)||0,[w,h.id]),ke=ie.useMemo(()=>{var Oe;return(Oe=h.closeButton)!=null?Oe:A},[h.closeButton,A]),Ve=ie.useMemo(()=>h.duration||H||BP,[h.duration,H]),Ge=ie.useRef(0),mt=ie.useRef(0),_t=ie.useRef(0),st=ie.useRef(null),[Qn,sn]=Z.split("-"),Be=ie.useMemo(()=>w.reduce((Oe,lt,it)=>it>=oe?Oe:Oe+lt.height,0),[w,oe]),ze=Oce(),qe=h.invert||m,Et=Ye==="loading";mt.current=ie.useMemo(()=>oe*J+Be,[oe,Be]),ie.useEffect(()=>{He.current=Ve},[Ve]),ie.useEffect(()=>{D(!0)},[]),ie.useEffect(()=>{const Oe=je.current;if(Oe){const lt=Oe.getBoundingClientRect().height;return xe(lt),E(it=>[{toastId:h.id,height:lt,position:h.position},...it]),()=>E(it=>it.filter(Je=>Je.toastId!==h.id))}},[E,h.id]),ie.useLayoutEffect(()=>{if(!U)return;const Oe=je.current,lt=Oe.style.height;Oe.style.height="auto";const it=Oe.getBoundingClientRect().height;Oe.style.height=lt,xe(it),E(Je=>Je.find(Kt=>Kt.toastId===h.id)?Je.map(Kt=>Kt.toastId===h.id?{...Kt,height:it}:Kt):[{toastId:h.id,height:it,position:h.position},...Je])},[U,h.title,h.description,E,h.id,h.jsx,h.action,h.cancel]);const St=ie.useCallback(()=>{V(!0),de(mt.current),E(Oe=>Oe.filter(lt=>lt.toastId!==h.id)),setTimeout(()=>{R(h)},Gce)},[h,R,E,mt]);ie.useEffect(()=>{if(h.promise&&Ye==="loading"||h.duration===1/0||h.type==="loading")return;let Oe;return T||v||ze?(()=>{if(_t.current<Ge.current){const Je=new Date().getTime()-Ge.current;He.current=He.current-Je}_t.current=new Date().getTime()})():He.current!==1/0&&(Ge.current=new Date().getTime(),Oe=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),St()},He.current)),()=>clearTimeout(Oe)},[T,v,h,Ye,ze,St]),ie.useEffect(()=>{h.delete&&(St(),h.onDismiss==null||h.onDismiss.call(h,h))},[St,h.delete]);function Mt(){var Oe;if(Y?.loading){var lt;return ie.createElement("div",{className:zs(G?.loader,h==null||(lt=h.classNames)==null?void 0:lt.loader,"sonner-loader"),"data-visible":Ye==="loading"},Y.loading)}return ie.createElement(Nce,{className:zs(G?.loader,h==null||(Oe=h.classNames)==null?void 0:Oe.loader),visible:Ye==="loading"})}const Tt=h.icon||Y?.[Ye]||_ce(Ye);var Pe,$e;return ie.createElement("li",{tabIndex:0,ref:je,className:zs(L,Se,G?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,G?.default,G?.[Ye],h==null||(n=h.classNames)==null?void 0:n[Ye]),"data-sonner-toast":"","data-rich-colors":(Pe=h.richColors)!=null?Pe:C,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":U,"data-promise":!!h.promise,"data-swiped":q,"data-removed":P,"data-visible":Ue,"data-y-position":Qn,"data-x-position":sn,"data-index":S,"data-front":at,"data-swiping":W,"data-dismissible":pe,"data-type":Ye,"data-invert":qe,"data-swipe-out":fe,"data-swipe-direction":M,"data-expanded":!!(T||ne&&U),"data-testid":h.testId,style:{"--index":S,"--toasts-before":S,"--z-index":_.length-S,"--offset":`${P?ae:mt.current}px`,"--initial-height":ne?"auto":`${he}px`,...I,...h.style},onDragEnd:()=>{te(!1),ee(null),st.current=null},onPointerDown:Oe=>{Oe.button!==2&&(Et||!pe||(Ie.current=new Date,de(mt.current),Oe.target.setPointerCapture(Oe.pointerId),Oe.target.tagName!=="BUTTON"&&(te(!0),st.current={x:Oe.clientX,y:Oe.clientY})))},onPointerUp:()=>{var Oe,lt,it;if(fe||!pe)return;st.current=null;const Je=Number(((Oe=je.current)==null?void 0:Oe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Pt=Number(((lt=je.current)==null?void 0:lt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Kt=new Date().getTime()-((it=Ie.current)==null?void 0:it.getTime()),Ln=re==="x"?Je:Pt,yn=Math.abs(Ln)/Kt;if(Math.abs(Ln)>=Vce||yn>.11){de(mt.current),h.onDismiss==null||h.onDismiss.call(h,h),F(re==="x"?Je>0?"right":"left":Pt>0?"down":"up"),St(),le(!0);return}else{var on,nn;(on=je.current)==null||on.style.setProperty("--swipe-amount-x","0px"),(nn=je.current)==null||nn.style.setProperty("--swipe-amount-y","0px")}Q(!1),te(!1),ee(null)},onPointerMove:Oe=>{var lt,it,Je;if(!st.current||!pe||((lt=window.getSelection())==null?void 0:lt.toString().length)>0)return;const Kt=Oe.clientY-st.current.y,Ln=Oe.clientX-st.current.x;var yn;const on=(yn=e.swipeDirections)!=null?yn:Wce(Z);!re&&(Math.abs(Ln)>1||Math.abs(Kt)>1)&&ee(Math.abs(Ln)>Math.abs(Kt)?"x":"y");let nn={x:0,y:0};const wt=pt=>1/(1.5+Math.abs(pt)/20);if(re==="y"){if(on.includes("top")||on.includes("bottom"))if(on.includes("top")&&Kt<0||on.includes("bottom")&&Kt>0)nn.y=Kt;else{const pt=Kt*wt(Kt);nn.y=Math.abs(pt)<Math.abs(Kt)?pt:Kt}}else if(re==="x"&&(on.includes("left")||on.includes("right")))if(on.includes("left")&&Ln<0||on.includes("right")&&Ln>0)nn.x=Ln;else{const pt=Ln*wt(Ln);nn.x=Math.abs(pt)<Math.abs(Ln)?pt:Ln}(Math.abs(nn.x)>0||Math.abs(nn.y)>0)&&Q(!0),(it=je.current)==null||it.style.setProperty("--swipe-amount-x",`${nn.x}px`),(Je=je.current)==null||Je.style.setProperty("--swipe-amount-y",`${nn.y}px`)}},ke&&!h.jsx&&Ye!=="loading"?ie.createElement("button",{"aria-label":B,"data-disabled":Et,"data-close-button":!0,onClick:Et||!pe?()=>{}:()=>{St(),h.onDismiss==null||h.onDismiss.call(h,h)},className:zs(G?.closeButton,h==null||(r=h.classNames)==null?void 0:r.closeButton)},($e=Y?.close)!=null?$e:Ice):null,(Ye||h.icon||h.promise)&&h.icon!==null&&(Y?.[Ye]!==null||h.icon)?ie.createElement("div",{"data-icon":"",className:zs(G?.icon,h==null||(a=h.classNames)==null?void 0:a.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||Mt():null,h.type!=="loading"?Tt:null):null,ie.createElement("div",{"data-content":"",className:zs(G?.content,h==null||(o=h.classNames)==null?void 0:o.content)},ie.createElement("div",{"data-title":"",className:zs(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:zs(z,Ne,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:Oe=>{Fg(h.cancel)&&pe&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Oe),St())},className:zs(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||j,onClick:Oe=>{Fg(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Oe),!Oe.defaultPrevented&&St())},className:zs(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 Yce(e,t){const n={};return[e,t].forEach((r,a)=>{const o=a===1,i=o?"--mobile-offset":"--offset",c=o?Fce:zce;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 Zce=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=Uce,toastOptions:S,dir:_=HP(),gap:T=Hce,icons:R,containerAriaLabel:C="Notifications"}=t,[A,I]=ie.useState([]),O=ie.useMemo(()=>r?A.filter(U=>U.toasterId===r):A.filter(U=>!U.toasterId),[A,r]),j=ie.useMemo(()=>Array.from(new Set([o].concat(O.filter(U=>U.position).map(U=>U.position)))),[O,o]),[L,z]=ie.useState([]),[H,Z]=ie.useState(!1),[J,ne]=ie.useState(!1),[G,Y]=ie.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),B=ie.useRef(null),re=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),ee=ie.useRef(null),M=ie.useRef(!1),F=ie.useCallback(U=>{I(D=>{var P;return(P=D.find(V=>V.id===U.id))!=null&&P.delete||Ta.dismiss(U.id),D.filter(({id:V})=>V!==U.id)})},[]);return ie.useEffect(()=>Ta.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{I(D=>D.map(P=>P.id===U.id?{...P,delete:!0}:P))});return}setTimeout(()=>{I4.flushSync(()=>{I(D=>{const P=D.findIndex(V=>V.id===U.id);return P!==-1?[...D.slice(0,P),{...D[P],...U},...D.slice(P+1)]:[U,...D]})})})}),[A]),ie.useEffect(()=>{if(g!=="system"){Y(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Y("dark"):Y("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:D})=>{Y(D?"dark":"light")})}catch{U.addListener(({matches:P})=>{try{Y(P?"dark":"light")}catch(V){console.error(V)}})}},[g]),ie.useEffect(()=>{A.length<=1&&Z(!1)},[A]),ie.useEffect(()=>{const U=D=>{var P;if(i.every(te=>D[te]||D.code===te)){var W;Z(!0),(W=B.current)==null||W.focus()}D.code==="Escape"&&(document.activeElement===B.current||(P=B.current)!=null&&P.contains(document.activeElement))&&Z(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[i]),ie.useEffect(()=>{if(B.current)return()=>{ee.current&&(ee.current.focus({preventScroll:!0}),ee.current=null,M.current=!1)}},[B.current]),ie.createElement("section",{ref:n,"aria-label":`${C} ${re}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},j.map((U,D)=>{var P;const[V,W]=U.split("-");return O.length?ie.createElement("ol",{key:U,dir:_==="auto"?HP():_,tabIndex:-1,ref:B,className:f,"data-sonner-toaster":!0,"data-sonner-theme":G,"data-y-position":V,"data-x-position":W,style:{"--front-toast-height":`${((P=L[0])==null?void 0:P.height)||0}px`,"--width":`${Bce}px`,"--gap":`${T}px`,...x,...Yce(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:()=>Z(!0),onMouseMove:()=>Z(!0),onMouseLeave:()=>{J||Z(!1)},onDragEnd:()=>Z(!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===U).map((te,fe)=>{var le,q;return ie.createElement(Kce,{key:te.id,icons:R,index:fe,toast:te,defaultRichColors:v,duration:(le=S?.duration)!=null?le:E,className:S?.className,descriptionClassName:S?.descriptionClassName,invert:a,visibleToasts:w,closeButton:(q=S?.closeButton)!=null?q:d,interacting:J,position:U,style:S?.style,unstyled:S?.unstyled,classNames:S?.classNames,cancelButtonStyle:S?.cancelButtonStyle,actionButtonStyle:S?.actionButtonStyle,closeButtonAriaLabel:S?.closeButtonAriaLabel,removeToast:F,toasts:O.filter(Q=>Q.position==te.position),heights:L.filter(Q=>Q.position==te.position),setHeights:z,expandByDefault:c,gap:T,expanded:H,swipeDirections:t.swipeDirections})})):null}))});var uv="Dialog",[XB]=Is(uv),[qce,Ds]=XB(uv),JB=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]=Mo({prop:r,defaultProp:a??!1,onChange:o,caller:uv});return u.jsx(qce,{scope:t,triggerRef:c,contentRef:d,contentId:Yr(),titleId:Yr(),descriptionId:Yr(),open:f,onOpenChange:m,onOpenToggle:y.useCallback(()=>m(h=>!h),[m]),modal:i,children:n})};JB.displayName=uv;var QB="DialogTrigger",e5=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ds(QB,n),o=tn(t,a.triggerRef);return u.jsx(Ot.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":$T(a.open),...r,ref:o,onClick:Ze(e.onClick,a.onOpenToggle)})});e5.displayName=QB;var jT="DialogPortal",[Xce,t5]=XB(jT,{forceMount:void 0}),n5=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,o=Ds(jT,t);return u.jsx(Xce,{scope:t,forceMount:n,children:y.Children.map(r,i=>u.jsx(Ga,{present:n||o.open,children:u.jsx(xd,{asChild:!0,container:a,children:i})}))})};n5.displayName=jT;var ey="DialogOverlay",r5=y.forwardRef((e,t)=>{const n=t5(ey,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,o=Ds(ey,e.__scopeDialog);return o.modal?u.jsx(Ga,{present:r||o.open,children:u.jsx(Qce,{...a,ref:t})}):null});r5.displayName=ey;var Jce=Pl("DialogOverlay.RemoveScroll"),Qce=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ds(ey,n);return u.jsx(om,{as:Jce,allowPinchZoom:!0,shards:[a.contentRef],children:u.jsx(Ot.div,{"data-state":$T(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),zl="DialogContent",a5=y.forwardRef((e,t)=>{const n=t5(zl,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,o=Ds(zl,e.__scopeDialog);return u.jsx(Ga,{present:r||o.open,children:o.modal?u.jsx(eue,{...a,ref:t}):u.jsx(tue,{...a,ref:t})})});a5.displayName=zl;var eue=y.forwardRef((e,t)=>{const n=Ds(zl,e.__scopeDialog),r=y.useRef(null),a=tn(t,n.contentRef,r);return y.useEffect(()=>{const o=r.current;if(o)return Xy(o)},[]),u.jsx(s5,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ze(e.onCloseAutoFocus,o=>{o.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ze(e.onPointerDownOutside,o=>{const i=o.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&o.preventDefault()}),onFocusOutside:Ze(e.onFocusOutside,o=>o.preventDefault())})}),tue=y.forwardRef((e,t)=>{const n=Ds(zl,e.__scopeDialog),r=y.useRef(!1),a=y.useRef(!1);return u.jsx(s5,{...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()}})}),s5=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:o,...i}=e,c=Ds(zl,n),d=y.useRef(null),f=tn(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(nue,{titleId:c.titleId}),u.jsx(aue,{contentRef:d,descriptionId:c.descriptionId})]})]})}),PT="DialogTitle",o5=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ds(PT,n);return u.jsx(Ot.h2,{id:a.titleId,...r,ref:t})});o5.displayName=PT;var i5="DialogDescription",l5=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ds(i5,n);return u.jsx(Ot.p,{id:a.descriptionId,...r,ref:t})});l5.displayName=i5;var c5="DialogClose",u5=y.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=Ds(c5,n);return u.jsx(Ot.button,{type:"button",...r,ref:t,onClick:Ze(e.onClick,()=>a.onOpenChange(!1))})});u5.displayName=c5;function $T(e){return e?"open":"closed"}var d5="DialogTitleWarning",[Vxe,f5]=Tte(d5,{contentName:zl,titleName:PT,docsSlug:"dialog"}),nue=({titleId:e})=>{const t=f5(d5),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>`,E8=1,JU=2,S8=3,QU=4,_8=5,ez=Symbol.for("quilt.threads.serialize"),Hve=Symbol.for("quilt.threads.transferable");class Vve 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 Gve="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function T8(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let r=0;r<e;r++)t+=Gve[63&n[r]];return t}var Wf,qc,Kf,Sb,u_,N8;class Wve{constructor(){ws(this,u_),ws(this,Wf,new Map),ws(this,qc,new Map),ws(this,Kf,new Map),ws(this,Sb,new WeakMap)}get(t){return Vn(this,qc).get(t)}release(t){const n=Vn(this,qc).get(t);return n&&(Vn(this,qc).delete(t),Vn(this,Wf).delete(n)),!!n}serialize(t){let n=Vn(this,Wf).get(t);return n==null&&(n=T8(),Vn(this,Wf).set(t,n),Vn(this,qc).set(n,t)),n}deserialize(t,n){var r,a;let o=(r=Vn(this,Kf).get(t))==null?void 0:r.deref();return o||(o=(...i)=>{if(!Vn(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([S8,c,t,d],f)},i)},(a=Ur(this,u_,N8).call(this,n))==null||a.register(o,t),Vn(this,Kf).set(t,new WeakRef(o)),o)}}Wf=new WeakMap,qc=new WeakMap,Kf=new WeakMap,Sb=new WeakMap,u_=new WeakSet,N8=function(e){let t=Vn(this,Sb).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([_8,n])}),Vn(this,Sb).set(e,t)),t};function Kve(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,ts,_b,Si;class Yve{constructor(t){ws(this,ts),ws(this,up),ws(this,dp),l_(this,up,t?.serialize),l_(this,dp,t?.deserialize)}serialize(t,n,r){return Ur(this,ts,_b).call(this,t,n,r)}deserialize(t,n){return Ur(this,ts,Si).call(this,t,n)}}up=new WeakMap,dp=new WeakMap,ts=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(Vn(this,up)&&!a){const c=Vn(this,up).call(this,e,d=>Ur(this,ts,_b).call(this,d,t,n,r,!0),t,n);if(c!==void 0)return r.set(e,c),c}if(e[Hve])return n?.push(e),r.set(e,e),e;const o=c=>Ur(this,ts,_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=Kve(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(Vn(this,dp)&&!n){const a=Vn(this,dp).call(this,e,o=>Ur(this,ts,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=>Ur(this,ts,Si).call(this,a,t));if(e instanceof Map)return new Map([...e].map(([a,o])=>[Ur(this,ts,Si).call(this,a,t),Ur(this,ts,Si).call(this,o,t)]));if(e instanceof Set)return new Set([...e].map(a=>Ur(this,ts,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]=Ur(this,ts,Si).call(this,e[a],t);return r}return e};var Xc,Ol,_i,d_,k8,f_,C8;class Zve{constructor(t,{imports:n,exports:r,functions:a=new Wve,serialization:o=new Yve,signal:i}={}){ws(this,_i),ws(this,Xc),ws(this,Ol,new Map);var c,d,f,m;this.messages=t,l_(this,Xc,i?new Vve(i):new AbortController),this.exports=r??{},this.imports=qve(Ur(this,_i,k8).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 Vn(this,Ol).keys())Ur(this,_i,f_).call(this,h,void 0,new tz);Vn(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 E8:{const[,v,E,x]=g,w=this.exports[E]??(()=>{throw new Error(`No '${E}' method is exported from this thread`)});await Ur(this,_i,d_).call(this,w,x,(S,_,T)=>{this.messages.send([JU,v,S,_],T)});break}case S8:{const[,v,E,x]=g,w=this.functions.get(E,this)??Xve;await Ur(this,_i,d_).call(this,w,x,(S,_,T)=>{this.messages.send([QU,v,S,_],T)});break}case JU:case QU:{Ur(this,_i,f_).call(this,...g.slice(1));break}case _8:{const v=g[1];this.functions.release(v,this);break}}},{signal:this.signal})}get signal(){return Vn(this,Xc).signal}get closed(){return Vn(this,Xc).signal.aborted}close(){Vn(this,Xc).abort()}call(t,n){if(this.closed)return Promise.reject(new tz);const r=[],a=this.serialization.serialize(n,this,r),o=T8(),i=Ur(this,_i,C8).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))}},k8=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([E8,n,e,r],a)},t)}catch(n){return Promise.reject(n)}}},f_=function(...e){const t=e[0],n=Vn(this,Ol).get(t);n&&(n(...e),Vn(this,Ol).delete(t))},C8=function(e){const t=new Promise((n,r)=>{Vn(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 qve(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 Xve(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const Jve="quilt.threads.ping",az="quilt.threads.pong";function Qve(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(Jve)});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 ewe extends Zve{constructor(t,{targetOrigin:n="*",...r}={}){super(Qve(t.contentWindow,{targetOrigin:n}),r),this.iframe=t}}const R8=ie.forwardRef(({content:e,children:t,...n},r)=>u.jsx("span",{ref:r,...n,children:e||t}));R8.displayName="UIText";const A8=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}));A8.displayName="UIButton";const I8=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}));I8.displayName="UIStack";const O8=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}));O8.displayName="UIImage";const Q1={name:"basic",elements:[{tagName:"ui-text",component:R8,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:A8,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:I8,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:O8,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},twe=({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"})},nwe=({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 Dve,E=t||Q1,x=new Map;return E&&E.elements.forEach(w=>{const S=Uve(w.component);x.set(w.tagName,S)}),{receiver:v,components:x}}case"webcomponents":default:return{receiver:new Lve,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 ewe(v);o.current=E;const{code:x,error:w}=_ve(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:Bve,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},f),d==="react"&&h?u.jsx(Fve,{receiver:m,components:h}):u.jsx(twe,{receiver:m})]})};function rwe(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=rwe(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(g8,{resource:t,onUIAction:n,...a});case"remoteDom":return u.jsx(nwe,{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 awe={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},swe={tagName:"ui-text",remoteAttributes:["content"]},owe={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},iwe={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},lwe=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(Qs,{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(lwe,{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 cwe({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 uwe=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(cwe,{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(Hbe,{duration:2,spread:1,children:"Thinking..."})})})})})}),u.jsx("div",{ref:o})]})});function D8(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 dwe({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=D8(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 j=w[w.length-1];j&&j.type==="text"?j.text=x:w.push({type:"text",text:x}),console.log("[Parts after text]",w.length,"parts, text length:",x.length),o(L=>L.map(z=>z.id===E?{...z,parts:[...w]}:z))}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(j=>j.map(L=>L.id===E?{...L,parts:[...w]}:L));else if(O.type==="tool-result"){const j=w.find(L=>L.type==="tool-invocation"&&L.toolInvocation?.toolName===O.toolName&&!L.toolInvocation?.result);j&&j.toolInvocation?(j.toolInvocation.result=O.result,j.toolInvocation.state="result",console.log("[Parts after tool-result]",w.length,"parts, updated:",O.toolName),o(L=>L.map(z=>z.id===E?{...z,parts:[...w]}:z))):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(j=>j.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 fwe({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 fa(async()=>{const{ChatOpenAI:A}=await import("./index--IpKhg5F.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 fa(async()=>{const{ChatAnthropic:A}=await import("./index-3gQQW6s7.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 fa(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-BZCfajuh.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 fa(async()=>{const{MCPAgent:C}=await import("./browser-EyInsrZa.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 j=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 z={...A,content:[...A.content||[],...L],structuredContent:j};C.toolInvocation.result=z,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(j=>j.id===S?{...j,parts:[...T]}:j))}}}o(R=>R.map(C=>C.id===S?{...C,parts:[...T],content:""}:C)),t&&Wr.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&&Wr.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 L8({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 j=localStorage.getItem("mcp-inspector-api-keys");if(j)try{return JSON.parse(j)}catch(L){return console.error("Failed to load API keys:",L),{}}return{}},[]),E=y.useCallback(j=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(j))},[]),[x,w]=y.useState("none"),[S,_]=y.useState(""),[T,R]=y.useState(""),[C,A]=y.useState("");y.useEffect(()=>{const j=localStorage.getItem("mcp-inspector-llm-config"),L=v();if(j)try{const z=JSON.parse(j);n(z),d(z.provider),m(L[z.provider]||z.apiKey||""),g(z.model)}catch(z){console.error("Failed to load LLM config:",z)}},[v]),y.useEffect(()=>{const j=localStorage.getItem("mcp-inspector-auth-config");if(j)try{const L=JSON.parse(j);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",z=D8(e),H=`${L}_${z}_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 j=v();m(j[c]||"")},[c,v]);const I=y.useCallback(()=>{if(!f.trim())return;const j=v();j[c]=f,E(j);const L={provider:c,apiKey:f,model:h},z={type:x,...x==="basic"&&{username:S.trim(),password:T.trim()},...x==="bearer"&&{token:C.trim()}};n(L),a(z),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(L)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(z)),i(!1)},[c,f,h,x,S,T,C,v,E]),O=y.useCallback(()=>{n(null),a(null);const j=v();delete j[c],E(j),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 pwe({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:_}=L8({mcpServerUrl:e.url}),T={connection:e,llmConfig:c,isConnected:t,readResource:r},R=dwe({mcpServerUrl:e.url,llmConfig:c,authConfig:d,isConnected:t}),C=fwe(T),{messages:A,isLoading:I,sendMessage:O,clearMessages:j}=n?C:R;WV({onNewChat:j}),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]),z=y.useCallback(Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),L())},[L]),H=y.useCallback(()=>{_(),j()},[_,j]);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(Fbe,{mcpServerUrl:e.url,inputValue:a,isConnected:t,isLoading:I,textareaRef:i,llmConfig:c,onInputChange:o,onKeyDown:z,onSubmit:Z=>{Z.preventDefault(),L()},onConfigDialogOpenChange:m})]}):u.jsxs("div",{className:"flex flex-col h-full relative",children:[u.jsx($be,{llmConfig:c,hasMessages:A.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:j,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(uwe,{messages:A,isLoading:I,serverId:e.url,readResource:r,tools:e.tools}):u.jsx(Bbe,{onConfigureClick:()=>m(!0)})}),c&&u.jsx(Ube,{inputValue:a,isConnected:t,isLoading:I,textareaRef:i,onInputChange:o,onKeyDown:z,onSendMessage:L})]})}const jv=y.createContext(null);jv.displayName="PanelGroupContext";const rr={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,mwe=typeof iz=="function"?iz:()=>null;let hwe=0;function nI(e=null){const t=mwe(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+hwe++),e??n.current}function M8({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:j,unregisterPanel:L}=w,z=nI(i),H=y.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:a,maxSize:c,minSize:d},id:z,idIsFromProps:i!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),Ml(()=>{const{callbacks:J,constraints:ne}=H.current,G={...ne};H.current.id=z,H.current.idIsFromProps=i!==void 0,H.current.order=g,J.onCollapse=f,J.onExpand=m,J.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 J=H.current;return O(J),()=>{L(J)}},[g,z,O,L]),y.useImperativeHandle(o,()=>({collapse:()=>{S(H.current)},expand:J=>{_(H.current,J)},getId(){return z},getSize(){return T(H.current)},isCollapsed(){return A(H.current)},isExpanded(){return!A(H.current)},resize:J=>{j(H.current,J)}}),[S,_,T,A,z,j]);const Z=R(H.current,a);return y.createElement(E,{...x,children:e,className:t,id:z,style:{...Z,...v},[rr.groupId]:C,[rr.panel]:"",[rr.panelCollapsible]:r||void 0,[rr.panelId]:z,[rr.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const j8=y.forwardRef((e,t)=>y.createElement(M8,{...e,forwardedRef:t}));M8.displayName="Panel";j8.displayName="forwardRef(Panel)";let p_=null,Tb=-1,Ci=null;function gwe(e,t,n){const r=(t&F8)!==0,a=(t&B8)!==0,o=(t&H8)!==0,i=(t&V8)!==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 bwe(){Ci!==null&&(document.head.removeChild(Ci),p_=null,Ci=null,Tb=-1)}function dE(e,t,n){var r,a;const o=gwe(e,t);if(p_!==o){if(p_=o,Ci===null&&(Ci=document.createElement("style"),document.head.appendChild(Ci)),Tb>=0){var i;(i=Ci.sheet)===null||i===void 0||i.removeRule(Tb)}Tb=(r=(a=Ci.sheet)===null||a===void 0?void 0:a.insertRule(`*{cursor: ${o} !important;}`))!==null&&r!==void 0?r:-1}}function P8(e){return e.type==="keydown"}function $8(e){return e.type.startsWith("pointer")}function U8(e){return e.type.startsWith("mouse")}function Pv(e){if($8(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(U8(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function ywe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function vwe(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 wwe(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;jt(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 xwe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ewe(e){var t;const n=getComputedStyle((t=z8(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Swe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Ewe(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"||xwe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function lz(e){let t=e.length;for(;t--;){const n=e[t];if(jt(n,"Missing node"),Swe(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=z8(e);return t}function z8(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const F8=1,B8=2,H8=4,V8=8,_we=ywe()==="coarse";let Es=[],Eu=!1,Ri=new Map,$v=new Map;const Wp=new Set;function Twe(e,t,n,r,a){var o;const{ownerDocument:i}=t,c={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:a},d=(o=Ri.get(i))!==null&&o!==void 0?o:0;return Ri.set(i,d+1),Wp.add(c),Sy(),function(){var m;$v.delete(e),Wp.delete(c);const h=(m=Ri.get(i))!==null&&m!==void 0?m:1;if(Ri.set(i,h-1),Sy(),h===1&&Ri.delete(i),Es.includes(c)){const g=Es.indexOf(c);g>=0&&Es.splice(g,1),Uv(),a("up",!0,null)}}}function Nwe(e){const{target:t}=e,{x:n,y:r}=Pv(e);Eu=!0,rI({target:t,x:n,y:r}),Sy(),Es.length>0&&(_y("down",e),Uv(),e.preventDefault(),G8(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(),Es.length>0&&e.preventDefault()}function pE(e){const{target:t}=e,{x:n,y:r}=Pv(e);$v.clear(),Eu=!1,Es.length>0&&(e.preventDefault(),G8(t)||e.stopImmediatePropagation()),_y("up",e),rI({target:t,x:n,y:r}),Uv(),Sy()}function G8(e){let t=e;for(;t;){if(t.hasAttribute(rr.resizeHandle))return!0;t=t.parentElement}return!1}function rI({target:e,x:t,y:n}){Es.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=_we?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)&&wwe(r,o)>0){let E=r,x=!1;for(;E&&!E.contains(o);){if(vwe(E.getBoundingClientRect(),c)){x=!0;break}E=E.parentElement}if(x)return}Es.push(a)}})}function mE(e,t){$v.set(e,t)}function Uv(){let e=!1,t=!1;Es.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):bwe()}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?(Es.length>0&&Ri.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("contextmenu",pE,t),a.addEventListener("pointerleave",fE,t),a.addEventListener("pointermove",fE,t))}),Ri.forEach((n,r)=>{const{body:a}=r;a.addEventListener("pointerup",pE,t),a.addEventListener("pointercancel",pE,t)})):Ri.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("pointerdown",Nwe,t),a.addEventListener("pointermove",fE,t))}))}function _y(e,t){Wp.forEach(n=>{const{setResizeHandlerState:r}=n,a=Es.includes(n);r(e,a,t)})}function kwe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function jt(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 Co(e,t,n=tI){return Wl(e,t,n)===0}function za(e,t,n){return Wl(e,t,n)===0}function Cwe(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(!za(a,o,n))return!1}return!0}function pu({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];jt(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(za(e,0))return t;const i=[...t],[c,d]=r;jt(c!=null,"Invalid first pivot index"),jt(d!=null,"Invalid second pivot index");let f=0;if(o==="keyboard"){{const h=e<0?d:c,g=n[h];jt(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(jt(w!=null,`Previous layout not found for panel index ${h}`),za(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];jt(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(jt(w!=null,`Previous layout not found for panel index ${h}`),za(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];jt(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];jt(E!=null,`Previous layout not found for panel index ${g}`);const x=E-v,w=pu({panelConstraints:n,panelIndex:g,size:x});if(!za(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(Cwe(a,i))return a;{const h=e<0?d:c,g=t[h];jt(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,!za(E,v)){let x=v-E,S=e<0?d:c;for(;S>=0&&S<n.length;){const _=i[S];jt(_!=null,`Previous layout not found for panel index ${S}`);const T=_+x,R=pu({panelConstraints:n,panelIndex:S,size:T});if(za(_,R)||(x-=R-_,i[S]=R),za(x,0))break;e>0?S--:S++}}}const m=i.reduce((h,g)=>g+h,0);return za(m,100)?i:a}function Rwe({layout:e,panelsArray:t,pivotIndices:n}){let r=0,a=100,o=0,i=0;const c=n[0];jt(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(`[${rr.resizeHandleId}][data-panel-group-id="${e}"]`))}function W8(e,t,n=document){const a=Kp(e,n).findIndex(o=>o.getAttribute(rr.resizeHandleId)===t);return a??null}function K8(e,t,n){const r=W8(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Awe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Y8(e,t=document){if(Awe(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(`[${rr.resizeHandleId}="${e}"]`);return n||null}function Iwe(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 Owe({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}=Rwe({layout:r,panelsArray:a,pivotIndices:[d,d+1]}),g=c[d];if(g!=null){const v=a[d];jt(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;jt(c,"Eager values not found");const{panelDataArray:d}=c,f=Y8(n,o);jt(f!=null,`No group found for id "${n}"`);const m=Kp(n,o);jt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(rr.resizeHandleId);jt(v,"Resize handle element has no handle id attribute");const[E,x]=Iwe(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[_];jt(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:za(R,C)?I-C:C-R,initialLayout:r,panelConstraints:d.map(j=>j.constraints),pivotIndices:K8(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 Z8(e,t){const n=e==="horizontal",{x:r,y:a}=Pv(t);return n?r:a}function Dwe(e,t,n,r,a){const o=n==="horizontal",i=zv(t,a);jt(i,`No resize handle element found for id "${t}"`);const c=i.getAttribute(rr.groupId);jt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=r;const f=Z8(n,e),m=Y8(c,a);jt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=o?h.width:h.height;return(f-d)/g*100}function Lwe(e,t,n,r,a,o){if(P8(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:Dwe(e,t,n,r,o)}function Mwe({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];jt(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];jt(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];jt(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||Co(h,f))&&!Co(r,f)&&v(),g&&(h==null||!Co(h,f))&&Co(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 jwe({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 Pwe(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 X8(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 J8(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 $we(e,t,n){var r,a;const o=(r=J8(e,n))!==null&&r!==void 0?r:{},i=X8(t);return(a=o[i])!==null&&a!==void 0?a:null}function Uwe(e,t,n,r,a){var o;const i=q8(e),c=X8(t),d=(o=J8(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(!za(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const i=n[o];jt(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];jt(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(!za(a,0))for(let o=0;o<t.length;o++){const i=n[o];jt(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,za(a,0)))break}return n}const zwe=100,Zf={getItem:e=>(fz(Zf),Zf.getItem(e)),setItem:(e,t)=>{fz(Zf),Zf.setItem(e,t)}},mz={};function Q8({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([]),_=kwe(),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:U}=I.current;return U},setLayout:U=>{const{onLayout:D}=A.current,{layout:P,panelDataArray:V}=I.current,W=pz({layout:U,panelConstraints:V.map(te=>te.constraints)});dz(P,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}),Owe({committedValuesRef:A,eagerValuesRef:I,groupId:g,layout:w,panelDataArray:I.current.panelDataArray,setLayout:S,panelGroupElement:v.current}),y.useEffect(()=>{const{panelDataArray:U}=I.current;if(e){if(w.length===0||w.length!==U.length)return;let D=mz[e];D==null&&(D=Pwe(Uwe,zwe),mz[e]=D);const P=[...U],V=new Map(R.current);D(e,P,V,w,d)}},[e,w,d]),y.useEffect(()=>{});const O=y.useCallback(U=>{const{onLayout:D}=A.current,{layout:P,panelDataArray:V}=I.current;if(U.constraints.collapsible){const W=V.map(q=>q.constraints),{collapsedSize:te=0,panelSize:fe,pivotIndices:le}=El(V,U,P);if(jt(fe!=null,`Panel size not found for panel "${U.id}"`),!Co(fe,te)){R.current.set(U.id,fe);const Q=Jc(V,U)===V.length-1?fe-te:te-fe,ae=Yf({delta:Q,initialLayout:P,panelConstraints:W,pivotIndices:le,prevLayout:P,trigger:"imperative-api"});Jg(P,ae)||(S(ae),I.current.layout=ae,D&&D(ae),Hc(V,ae,T.current))}}},[]),j=y.useCallback((U,D)=>{const{onLayout:P}=A.current,{layout:V,panelDataArray:W}=I.current;if(U.constraints.collapsible){const te=W.map(de=>de.constraints),{collapsedSize:fe=0,panelSize:le=0,minSize:q=0,pivotIndices:Q}=El(W,U,V),ae=D??q;if(Co(le,fe)){const de=R.current.get(U.id),he=de!=null&&de>=ae?de:ae,He=Jc(W,U)===W.length-1?le-he:he-le,Ie=Yf({delta:He,initialLayout:V,panelConstraints:te,pivotIndices:Q,prevLayout:V,trigger:"imperative-api"});Jg(V,Ie)||(S(Ie),I.current.layout=Ie,P&&P(Ie),Hc(W,Ie,T.current))}}},[]),L=y.useCallback(U=>{const{layout:D,panelDataArray:P}=I.current,{panelSize:V}=El(P,U,D);return jt(V!=null,`Panel size not found for panel "${U.id}"`),V},[]),z=y.useCallback((U,D)=>{const{panelDataArray:P}=I.current,V=Jc(P,U);return jwe({defaultSize:D,dragState:E,layout:w,panelData:P,panelIndex:V})},[E,w]),H=y.useCallback(U=>{const{layout:D,panelDataArray:P}=I.current,{collapsedSize:V=0,collapsible:W,panelSize:te}=El(P,U,D);return jt(te!=null,`Panel size not found for panel "${U.id}"`),W===!0&&Co(te,V)},[]),Z=y.useCallback(U=>{const{layout:D,panelDataArray:P}=I.current,{collapsedSize:V=0,collapsible:W,panelSize:te}=El(P,U,D);return jt(te!=null,`Panel size not found for panel "${U.id}"`),!W||Wl(te,V)>0},[]),J=y.useCallback(U=>{const{panelDataArray:D}=I.current;D.push(U),D.sort((P,V)=>{const W=P.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:U,onLayout:D,storage:P}=A.current,{layout:V,panelDataArray:W}=I.current;let te=null;if(U){const le=$we(U,W,P);le&&(R.current=new Map(Object.entries(le.expandToSizes)),te=le.layout)}te==null&&(te=Mwe({panelDataArray:W}));const fe=pz({layout:te,panelConstraints:W.map(le=>le.constraints)});dz(V,fe)||(S(fe),I.current.layout=fe,D&&D(fe),Hc(W,fe,T.current))}}),Ml(()=>{const U=I.current;return()=>{U.layout=[]}},[]);const ne=y.useCallback(U=>{let D=!1;const P=v.current;return P&&window.getComputedStyle(P,null).getPropertyValue("direction")==="rtl"&&(D=!0),function(W){W.preventDefault();const te=v.current;if(!te)return()=>null;const{direction:fe,dragState:le,id:q,keyboardResizeBy:Q,onLayout:ae}=A.current,{layout:de,panelDataArray:he}=I.current,{initialLayout:xe}=le??{},He=K8(q,U,te);let Ie=Lwe(W,U,fe,le,Q,te);const je=fe==="horizontal";je&&D&&(Ie=-Ie);const at=he.map(pe=>pe.constraints),Ue=Yf({delta:Ie,initialLayout:xe??de,panelConstraints:at,pivotIndices:He,prevLayout:de,trigger:P8(W)?"keyboard":"mouse-or-touch"}),Ye=!Jg(de,Ue);($8(W)||U8(W))&&C.current!=Ie&&(C.current=Ie,!Ye&&Ie!==0?je?mE(U,Ie<0?F8:B8):mE(U,Ie<0?H8:V8):mE(U,0)),Ye&&(S(Ue),I.current.layout=Ue,ae&&ae(Ue),Hc(he,Ue,T.current))}},[]),G=y.useCallback((U,D)=>{const{onLayout:P}=A.current,{layout:V,panelDataArray:W}=I.current,te=W.map(de=>de.constraints),{panelSize:fe,pivotIndices:le}=El(W,U,V);jt(fe!=null,`Panel size not found for panel "${U.id}"`);const Q=Jc(W,U)===W.length-1?fe-D:D-fe,ae=Yf({delta:Q,initialLayout:V,panelConstraints:te,pivotIndices:le,prevLayout:V,trigger:"imperative-api"});Jg(V,ae)||(S(ae),I.current.layout=ae,P&&P(ae),Hc(W,ae,T.current))},[]),Y=y.useCallback((U,D)=>{const{layout:P,panelDataArray:V}=I.current,{collapsedSize:W=0,collapsible:te}=D,{collapsedSize:fe=0,collapsible:le,maxSize:q=100,minSize:Q=0}=U.constraints,{panelSize:ae}=El(V,U,P);ae!=null&&(te&&le&&Co(ae,W)?Co(W,fe)||G(U,fe):ae<Q?G(U,Q):ae>q&&G(U,q))},[G]),B=y.useCallback((U,D)=>{const{direction:P}=A.current,{layout:V}=I.current;if(!v.current)return;const W=zv(U,v.current);jt(W,`Drag handle element not found for id "${U}"`);const te=Z8(P,D);x({dragHandleId:U,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:te,initialLayout:V})},[]),re=y.useCallback(()=>{x(null)},[]),ee=y.useCallback(U=>{const{panelDataArray:D}=I.current,P=Jc(D,U);P>=0&&(D.splice(P,1),delete T.current[U.id],I.current.panelDataArrayChanged=!0,_())},[_]),M=y.useMemo(()=>({collapsePanel:O,direction:r,dragState:E,expandPanel:j,getPanelSize:L,getPanelStyle:z,groupId:g,isPanelCollapsed:H,isPanelExpanded:Z,reevaluatePanelConstraints:Y,registerPanel:J,registerResizeHandle:ne,resizePanel:G,startDragging:B,stopDragging:re,unregisterPanel:ee,panelGroupElement:v.current}),[O,E,r,j,L,z,g,H,Z,Y,J,ne,G,B,re,ee]),F={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:{...F,...f},[rr.group]:"",[rr.groupDirection]:r,[rr.groupId]:g}))}const e9=y.forwardRef((e,t)=>y.createElement(Q8,{...e,forwardedRef:t}));Q8.displayName="PanelGroup";e9.displayName="forwardRef(PanelGroup)";function Jc(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function El(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 Fwe({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(rr.groupId);jt(c,`No group element found for id "${c}"`);const d=Kp(c,r),f=W8(c,t,r);jt(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 t9({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:j}=T,L=nI(a),[z,H]=y.useState("inactive"),[Z,J]=y.useState(!1),[ne,G]=y.useState(null),Y=y.useRef({state:z});Ml(()=>{Y.current.state=z}),y.useEffect(()=>{if(n)G(null);else{const M=A(L);G(()=>M)}},[n,L,A]);const B=(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;jt(M,"Element ref not attached");let F=!1;return Twe(L,M,R,{coarse:B,fine:re},(D,P,V)=>{if(!P){H("inactive");return}switch(D){case"down":{H("drag"),F=!1,jt(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}=Y.current;F=!0,W!=="drag"&&H("hover"),jt(V,'Expected event to be defined for "move" action'),ne(V);break}case"up":{H("hover"),O();const{onClick:W,onDragging:te,onPointerUp:fe}=_.current;te?.(!1),fe?.(),F||W?.();break}}})},[B,R,n,re,A,L,ne,I,O]),Fwe({disabled:n,handleId:L,resizeHandler:ne,panelGroupElement:j});const ee={touchAction:"none",userSelect:"none"};return y.createElement(v,{...E,children:e,className:t,id:a,onBlur:()=>{J(!1),o?.()},onFocus:()=>{J(!0),d?.()},ref:S,role:"separator",style:{...ee,...h},tabIndex:g,[rr.groupDirection]:R,[rr.groupId]:C,[rr.resizeHandle]:"",[rr.resizeHandleActive]:z==="drag"?"pointer":Z?"keyboard":void 0,[rr.resizeHandleEnabled]:!n,[rr.resizeHandleId]:L,[rr.resizeHandleState]:z})}t9.displayName="PanelResizeHandle";function ma({className:e,...t}){return u.jsx(e9,{"data-slot":"resizable-panel-group",className:De("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function On({...e}){return u.jsx(j8,{"data-slot":"resizable-panel",...e})}function Ss({withHandle:e,className:t,...n}){return u.jsx(t9,{"data-slot":"resizable-handle",className:De("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(die,{className:"size-2.5"})})})}function Im({className:e,...t}){return u.jsx("kbd",{"data-slot":"kbd",className:De("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 Bwe({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(kn,{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(Tr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(At,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx($o,{className:"h-4 w-4"})})}),u.jsx(At,{side:"bottom",children:"Clear all"})]})})]})}function Ji({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:De("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:De("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:De("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 Hwe({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(Ji,{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 Vwe({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(Re,{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(TB,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:r,children:i?u.jsx(yr,{className:"h-4 w-4"}):u.jsx(or,{className:"h-4 w-4"})}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,children:u.jsx(um,{className:"h-4 w-4"})}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:o,children:u.jsx(_p,{className:"h-4 w-4"})}),c&&u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,children:u.jsx(no,{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(ar,{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 Gwe({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 Y=C.current;if(!Y)return;const B=()=>{Y.scrollTop>0&&(O.current=!0,E(!1))};return Y.addEventListener("scroll",B),()=>Y.removeEventListener("scroll",B)},[]),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 j=y.useCallback(()=>{f.trim()||w(!1)},[f]),L=y.useMemo(()=>{if(!f.trim())return e;const Y=f.toLowerCase();return e.filter(B=>B.method.toLowerCase().includes(Y)||JSON.stringify(B.params||{}).toLowerCase().includes(Y))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const Y=B=>{const re=B.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||B.metaKey||B.ctrlKey||B.altKey)return;const M=L;if(B.key==="ArrowDown")B.preventDefault(),g(F=>{const U=F+1;return U>=M.length?0:U});else if(B.key==="ArrowUp")B.preventDefault(),g(F=>{const U=F-1;return U<0?M.length-1:U});else if(B.key==="Enter"&&h>=0){B.preventDefault();const F=L[h];F&&z(F)}};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[h,L]),y.useEffect(()=>{if(h>=0){const Y=`notification-${L[h]?.id}`,B=document.getElementById(Y);B&&B.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const z=y.useCallback(Y=>{d(Y)},[]),H=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(a(),d(null))},[a]),Z=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(Y){console.error("[NotificationsTab] Failed to copy notification:",Y)}},[c]),J=y.useCallback(()=>{if(c)try{const Y=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),B=URL.createObjectURL(Y),re=document.createElement("a");re.href=B,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(B)}catch(Y){console.error("[NotificationsTab] Failed to download notification:",Y)}},[c]),ne=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(Y){console.error("[NotificationsTab] Failed to toggle fullscreen:",Y)}},[]),G=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:Ty}:null;return i?u.jsxs(ma,{direction:"horizontal",className:"h-full",children:[u.jsx(On,{defaultSize:40,minSize:30,children:u.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(On,{defaultSize:75,minSize:30,children:[u.jsx(Bwe,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:L.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:j,onClearAll:H,searchInputRef:I}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(Hwe,{notifications:L,selectedNotification:c,onNotificationSelect:z,focusedIndex:h,formatRelativeTime:Ty,listRef:C})})]})})}),u.jsx(Ss,{}),u.jsx(On,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(Vwe,{notification:G,previewMode:S,onTogglePreview:()=>_(!S),onCopy:Z,onDownload:J,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(Js,{className:"h-3 w-3 text-muted-foreground transition-transform"}):u.jsx(NB,{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(xoe,{className:"h-3 w-3"}):u.jsx(Soe,{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(ar,{data:v.payload})})})})]},v.id)})})})}function n9({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(kn,{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(Tr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:o}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(At,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})]})}),u.jsxs(Re,{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(Tr,{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(Ji,{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(Tr,{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(n9,{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(Ji,{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 Wwe({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(en,{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(en,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(kn,{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(en,{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(en,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(kn,{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(Re,{onClick:o,disabled:n||!r,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?u.jsxs(u.Fragment,{children:[u.jsx(Qs,{className:"mr-2"}),u.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):u.jsxs(u.Fragment,{children:[u.jsx(IB,{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(Re,{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(Wwe,{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 Kwe(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function Ywe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Zwe(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 qwe({message:e,index:t}){const[n,r]=y.useState(!1),a=async()=>{const i=Zwe(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(Tr,{variant:Kwe(e.role),children:Ywe(e.role)}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,className:"h-6 px-2",title:"Copy message content",children:n?u.jsx(yr,{className:"h-3.5 w-3.5"}):u.jsx(or,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"px-4 py-3",children:o()})]})}function Xwe(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 Jwe(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(Xwe(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||Jwe(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(Io,{value:f.toString(),onValueChange:C=>m(parseInt(C)),children:[u.jsx(Do,{className:"h-7 w-[120px] text-xs",children:u.jsx(Oo,{})}),u.jsx(Lo,{children:w.map((C,A)=>u.jsx(na,{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(Re,{variant:"ghost",size:"sm",onClick:()=>r(_,S.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?u.jsx(yr,{className:"h-4 w-4"}):u.jsx(or,{className:"h-4 w-4"})}),a&&u.jsx(Re,{variant:"ghost",size:"sm",onClick:()=>a(_),className:"h-7 w-7 p-0",title:"Delete result",children:u.jsx($o,{className:"h-4 w-4"})}),o&&u.jsx(Re,{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(Re,{variant:"ghost",size:"sm",onClick:c,className:"h-7 w-7 p-0 hidden sm:flex",title:d?"Restore":"Maximize",children:d?u.jsx(AB,{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(qwe,{message:C,index:A},A))}):u.jsx(ar,{data:S.result,filename:`prompt-result-${S.promptName}-${Date.now()}.json`})})]})})})}const wz="mcp-inspector-saved-prompts";function r9({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([]),[j,L]=y.useState(!1),[z,H]=y.useState(""),[Z,J]=y.useState(!1),[ne,G]=y.useState(-1),Y=y.useRef(null),[B,re]=y.useState(!1),[ee,M]=y.useState("list"),[F,U]=y.useState(0),[D,P]=y.useState(!0),[V,W]=y.useState(!1),te=y.useRef(null),fe=y.useRef(null),le=y.useRef(null),q=y.useRef(null);y.useEffect(()=>{const Ne=()=>{re(window.innerWidth<1024)};return Ne(),window.addEventListener("resize",Ne),()=>window.removeEventListener("resize",Ne)},[]),y.useEffect(()=>{M(o?"detail":"list")},[o]),y.useEffect(()=>{B&&v.length>0&&!x&&M("response")},[v,x,B]),y.useImperativeHandle(e,()=>({focusSearch:()=>{J(!0),setTimeout(()=>{Y.current&&Y.current.focus()},0)},blurSearch:()=>{R(""),J(!1),Y.current&&Y.current.blur()}})),y.useEffect(()=>{try{const Ne=localStorage.getItem(wz);if(Ne){const oe=JSON.parse(Ne);O(oe)}}catch(Ne){console.error("[PromptsTab] Failed to load saved prompts:",Ne)}},[]);const Q=y.useCallback(Ne=>{try{localStorage.setItem(wz,JSON.stringify(Ne))}catch(oe){console.error("[PromptsTab] Failed to save prompts:",oe)}},[]);y.useEffect(()=>{Z&&Y.current&&Y.current.focus()},[Z]);const ae=y.useCallback(()=>{T.trim()||J(!1)},[T]),de=y.useMemo(()=>{if(!T.trim())return t;const Ne=T.toLowerCase();return t.filter(oe=>oe.name.toLowerCase().includes(Ne)||oe.description?.toLowerCase().includes(Ne))},[t,T]),he=y.useCallback(Ne=>{i(Ne);const oe={};Ne.arguments&&Ne.arguments.forEach(ke=>{oe[ke.name]=""}),g(oe)},[]),xe=y.useCallback(Ne=>{const oe=t.find(ke=>ke.name===Ne.promptName);oe&&(i(oe),g(Ne.args),d(Ne))},[t]);y.useEffect(()=>{G(-1)},[T,C]),y.useEffect(()=>{const Ne=oe=>{const ke=oe.target;if(ke.tagName==="INPUT"||ke.tagName==="TEXTAREA"||ke.contentEditable==="true"||oe.metaKey||oe.ctrlKey||oe.altKey)return;const Ge=C==="prompts"?de:I;if(oe.key==="ArrowDown")oe.preventDefault(),G(mt=>{const _t=mt+1;return _t>=Ge.length?0:_t});else if(oe.key==="ArrowUp")oe.preventDefault(),G(mt=>{const _t=mt-1;return _t<0?Ge.length-1:_t});else if(oe.key==="Enter"&&ne>=0)if(oe.preventDefault(),C==="prompts"){const mt=de[ne];mt&&he(mt)}else{const mt=I[ne];mt&&xe(mt)}};return document.addEventListener("keydown",Ne),()=>document.removeEventListener("keydown",Ne)},[ne,de,I,C,he,xe]),y.useEffect(()=>{if(ne>=0){const Ne=C==="prompts"?`prompt-${de[ne]?.name}`:`saved-prompt-${I[ne]?.id}`,oe=document.getElementById(Ne);oe&&oe.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,de,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 Ne=t.find(oe=>oe.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!Ne,promptName:Ne?.name,shouldSelect:Ne&&o?.name!==Ne.name}),Ne&&o?.name!==Ne.name){console.warn("[PromptsTab] Selecting prompt:",Ne.name),m(null);const oe=setTimeout(()=>{he(Ne);const ke=document.getElementById(`prompt-${Ne.name}`);ke&&(console.warn("[PromptsTab] Scrolling to prompt element"),ke.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(oe)}}},[f,t,o,he,m]);const He=y.useCallback((Ne,oe)=>{g(ke=>({...ke,[Ne]:oe}))},[]),Ie=y.useCallback(async()=>{if(!o||x)return;w(!0);const Ne=Date.now();try{const oe=await n(o.name,h),ke=Date.now()-Ne;Wr.getInstance().capture(new RP({promptName:o.name,serverId:r,success:!0})).catch(()=>{}),E(Ge=>[{promptName:o.name,args:h,result:oe,timestamp:Ne,duration:ke},...Ge])}catch(oe){Wr.getInstance().capture(new RP({promptName:o.name,serverId:r,success:!1,error:oe instanceof Error?oe.message:"Unknown error"})).catch(()=>{});const Ve={promptName:o.name,args:h,result:null,error:oe instanceof Error?oe.message:String(oe),timestamp:Ne,duration:Date.now()-Ne};E(Ge=>[...Ge,{...Ve,result:{messages:[]}}])}finally{w(!1)}},[o,h,x,n,r]),je=y.useCallback(async(Ne,oe)=>{try{await navigator.clipboard.writeText(JSON.stringify(oe,null,2)),_(Ne),setTimeout(()=>_(null),2e3)}catch(ke){console.error("[PromptsTab] Failed to copy result:",ke)}},[]),at=y.useCallback(Ne=>{E(oe=>oe.filter((ke,Ve)=>Ve!==Ne))},[]),Ue=y.useCallback(Ne=>{if(B)M("response");else{const oe=v[Ne];if(oe){const ke=window.open("","_blank","width=800,height=600");if(ke){const Ve=oe.result;ke.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 j=w[w.length-1];j&&j.type==="text"?j.text=x:w.push({type:"text",text:x}),console.log("[Parts after text]",w.length,"parts, text length:",x.length),o(L=>L.map(z=>z.id===E?{...z,parts:[...w]}:z))}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(j=>j.map(L=>L.id===E?{...L,parts:[...w]}:L));else if(O.type==="tool-result"){const j=w.find(L=>L.type==="tool-invocation"&&L.toolInvocation?.toolName===O.toolName&&!L.toolInvocation?.result);j&&j.toolInvocation?(j.toolInvocation.result=O.result,j.toolInvocation.state="result",console.log("[Parts after tool-result]",w.length,"parts, updated:",O.toolName),o(L=>L.map(z=>z.id===E?{...z,parts:[...w]}:z))):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(j=>j.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 fwe({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 fa(async()=>{const{ChatOpenAI:A}=await import("./index-DpOgK2Yr.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 fa(async()=>{const{ChatAnthropic:A}=await import("./index-BKSSQ8ab.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 fa(async()=>{const{ChatGoogleGenerativeAI:A}=await import("./index-CQWqWZPb.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 fa(async()=>{const{MCPAgent:C}=await import("./browser-szdNinNK.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 j=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 z={...A,content:[...A.content||[],...L],structuredContent:j};C.toolInvocation.result=z,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(j=>j.id===S?{...j,parts:[...T]}:j))}}}o(R=>R.map(C=>C.id===S?{...C,parts:[...T],content:""}:C)),t&&Wr.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&&Wr.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 L8({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 j=localStorage.getItem("mcp-inspector-api-keys");if(j)try{return JSON.parse(j)}catch(L){return console.error("Failed to load API keys:",L),{}}return{}},[]),E=y.useCallback(j=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(j))},[]),[x,w]=y.useState("none"),[S,_]=y.useState(""),[T,R]=y.useState(""),[C,A]=y.useState("");y.useEffect(()=>{const j=localStorage.getItem("mcp-inspector-llm-config"),L=v();if(j)try{const z=JSON.parse(j);n(z),d(z.provider),m(L[z.provider]||z.apiKey||""),g(z.model)}catch(z){console.error("Failed to load LLM config:",z)}},[v]),y.useEffect(()=>{const j=localStorage.getItem("mcp-inspector-auth-config");if(j)try{const L=JSON.parse(j);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",z=D8(e),H=`${L}_${z}_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 j=v();m(j[c]||"")},[c,v]);const I=y.useCallback(()=>{if(!f.trim())return;const j=v();j[c]=f,E(j);const L={provider:c,apiKey:f,model:h},z={type:x,...x==="basic"&&{username:S.trim(),password:T.trim()},...x==="bearer"&&{token:C.trim()}};n(L),a(z),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(L)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(z)),i(!1)},[c,f,h,x,S,T,C,v,E]),O=y.useCallback(()=>{n(null),a(null);const j=v();delete j[c],E(j),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 pwe({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:_}=L8({mcpServerUrl:e.url}),T={connection:e,llmConfig:c,isConnected:t,readResource:r},R=dwe({mcpServerUrl:e.url,llmConfig:c,authConfig:d,isConnected:t}),C=fwe(T),{messages:A,isLoading:I,sendMessage:O,clearMessages:j}=n?C:R;WV({onNewChat:j}),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]),z=y.useCallback(Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),L())},[L]),H=y.useCallback(()=>{_(),j()},[_,j]);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(Fbe,{mcpServerUrl:e.url,inputValue:a,isConnected:t,isLoading:I,textareaRef:i,llmConfig:c,onInputChange:o,onKeyDown:z,onSubmit:Z=>{Z.preventDefault(),L()},onConfigDialogOpenChange:m})]}):u.jsxs("div",{className:"flex flex-col h-full relative",children:[u.jsx($be,{llmConfig:c,hasMessages:A.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:j,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(uwe,{messages:A,isLoading:I,serverId:e.url,readResource:r,tools:e.tools}):u.jsx(Bbe,{onConfigureClick:()=>m(!0)})}),c&&u.jsx(Ube,{inputValue:a,isConnected:t,isLoading:I,textareaRef:i,onInputChange:o,onKeyDown:z,onSendMessage:L})]})}const jv=y.createContext(null);jv.displayName="PanelGroupContext";const rr={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,mwe=typeof iz=="function"?iz:()=>null;let hwe=0;function nI(e=null){const t=mwe(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+hwe++),e??n.current}function M8({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:j,unregisterPanel:L}=w,z=nI(i),H=y.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:a,maxSize:c,minSize:d},id:z,idIsFromProps:i!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),Ml(()=>{const{callbacks:J,constraints:ne}=H.current,G={...ne};H.current.id=z,H.current.idIsFromProps=i!==void 0,H.current.order=g,J.onCollapse=f,J.onExpand=m,J.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 J=H.current;return O(J),()=>{L(J)}},[g,z,O,L]),y.useImperativeHandle(o,()=>({collapse:()=>{S(H.current)},expand:J=>{_(H.current,J)},getId(){return z},getSize(){return T(H.current)},isCollapsed(){return A(H.current)},isExpanded(){return!A(H.current)},resize:J=>{j(H.current,J)}}),[S,_,T,A,z,j]);const Z=R(H.current,a);return y.createElement(E,{...x,children:e,className:t,id:z,style:{...Z,...v},[rr.groupId]:C,[rr.panel]:"",[rr.panelCollapsible]:r||void 0,[rr.panelId]:z,[rr.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const j8=y.forwardRef((e,t)=>y.createElement(M8,{...e,forwardedRef:t}));M8.displayName="Panel";j8.displayName="forwardRef(Panel)";let p_=null,Tb=-1,Ci=null;function gwe(e,t,n){const r=(t&F8)!==0,a=(t&B8)!==0,o=(t&H8)!==0,i=(t&V8)!==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 bwe(){Ci!==null&&(document.head.removeChild(Ci),p_=null,Ci=null,Tb=-1)}function dE(e,t,n){var r,a;const o=gwe(e,t);if(p_!==o){if(p_=o,Ci===null&&(Ci=document.createElement("style"),document.head.appendChild(Ci)),Tb>=0){var i;(i=Ci.sheet)===null||i===void 0||i.removeRule(Tb)}Tb=(r=(a=Ci.sheet)===null||a===void 0?void 0:a.insertRule(`*{cursor: ${o} !important;}`))!==null&&r!==void 0?r:-1}}function P8(e){return e.type==="keydown"}function $8(e){return e.type.startsWith("pointer")}function U8(e){return e.type.startsWith("mouse")}function Pv(e){if($8(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(U8(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function ywe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function vwe(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 wwe(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;jt(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 xwe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ewe(e){var t;const n=getComputedStyle((t=z8(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function Swe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Ewe(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"||xwe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function lz(e){let t=e.length;for(;t--;){const n=e[t];if(jt(n,"Missing node"),Swe(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=z8(e);return t}function z8(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const F8=1,B8=2,H8=4,V8=8,_we=ywe()==="coarse";let Es=[],Eu=!1,Ri=new Map,$v=new Map;const Wp=new Set;function Twe(e,t,n,r,a){var o;const{ownerDocument:i}=t,c={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:a},d=(o=Ri.get(i))!==null&&o!==void 0?o:0;return Ri.set(i,d+1),Wp.add(c),Sy(),function(){var m;$v.delete(e),Wp.delete(c);const h=(m=Ri.get(i))!==null&&m!==void 0?m:1;if(Ri.set(i,h-1),Sy(),h===1&&Ri.delete(i),Es.includes(c)){const g=Es.indexOf(c);g>=0&&Es.splice(g,1),Uv(),a("up",!0,null)}}}function Nwe(e){const{target:t}=e,{x:n,y:r}=Pv(e);Eu=!0,rI({target:t,x:n,y:r}),Sy(),Es.length>0&&(_y("down",e),Uv(),e.preventDefault(),G8(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(),Es.length>0&&e.preventDefault()}function pE(e){const{target:t}=e,{x:n,y:r}=Pv(e);$v.clear(),Eu=!1,Es.length>0&&(e.preventDefault(),G8(t)||e.stopImmediatePropagation()),_y("up",e),rI({target:t,x:n,y:r}),Uv(),Sy()}function G8(e){let t=e;for(;t;){if(t.hasAttribute(rr.resizeHandle))return!0;t=t.parentElement}return!1}function rI({target:e,x:t,y:n}){Es.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=_we?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)&&wwe(r,o)>0){let E=r,x=!1;for(;E&&!E.contains(o);){if(vwe(E.getBoundingClientRect(),c)){x=!0;break}E=E.parentElement}if(x)return}Es.push(a)}})}function mE(e,t){$v.set(e,t)}function Uv(){let e=!1,t=!1;Es.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):bwe()}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?(Es.length>0&&Ri.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("contextmenu",pE,t),a.addEventListener("pointerleave",fE,t),a.addEventListener("pointermove",fE,t))}),Ri.forEach((n,r)=>{const{body:a}=r;a.addEventListener("pointerup",pE,t),a.addEventListener("pointercancel",pE,t)})):Ri.forEach((n,r)=>{const{body:a}=r;n>0&&(a.addEventListener("pointerdown",Nwe,t),a.addEventListener("pointermove",fE,t))}))}function _y(e,t){Wp.forEach(n=>{const{setResizeHandlerState:r}=n,a=Es.includes(n);r(e,a,t)})}function kwe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function jt(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 Co(e,t,n=tI){return Wl(e,t,n)===0}function za(e,t,n){return Wl(e,t,n)===0}function Cwe(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(!za(a,o,n))return!1}return!0}function pu({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];jt(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(za(e,0))return t;const i=[...t],[c,d]=r;jt(c!=null,"Invalid first pivot index"),jt(d!=null,"Invalid second pivot index");let f=0;if(o==="keyboard"){{const h=e<0?d:c,g=n[h];jt(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(jt(w!=null,`Previous layout not found for panel index ${h}`),za(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];jt(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(jt(w!=null,`Previous layout not found for panel index ${h}`),za(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];jt(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];jt(E!=null,`Previous layout not found for panel index ${g}`);const x=E-v,w=pu({panelConstraints:n,panelIndex:g,size:x});if(!za(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(Cwe(a,i))return a;{const h=e<0?d:c,g=t[h];jt(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,!za(E,v)){let x=v-E,S=e<0?d:c;for(;S>=0&&S<n.length;){const _=i[S];jt(_!=null,`Previous layout not found for panel index ${S}`);const T=_+x,R=pu({panelConstraints:n,panelIndex:S,size:T});if(za(_,R)||(x-=R-_,i[S]=R),za(x,0))break;e>0?S--:S++}}}const m=i.reduce((h,g)=>g+h,0);return za(m,100)?i:a}function Rwe({layout:e,panelsArray:t,pivotIndices:n}){let r=0,a=100,o=0,i=0;const c=n[0];jt(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(`[${rr.resizeHandleId}][data-panel-group-id="${e}"]`))}function W8(e,t,n=document){const a=Kp(e,n).findIndex(o=>o.getAttribute(rr.resizeHandleId)===t);return a??null}function K8(e,t,n){const r=W8(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function Awe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function Y8(e,t=document){if(Awe(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(`[${rr.resizeHandleId}="${e}"]`);return n||null}function Iwe(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 Owe({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}=Rwe({layout:r,panelsArray:a,pivotIndices:[d,d+1]}),g=c[d];if(g!=null){const v=a[d];jt(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;jt(c,"Eager values not found");const{panelDataArray:d}=c,f=Y8(n,o);jt(f!=null,`No group found for id "${n}"`);const m=Kp(n,o);jt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(rr.resizeHandleId);jt(v,"Resize handle element has no handle id attribute");const[E,x]=Iwe(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[_];jt(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:za(R,C)?I-C:C-R,initialLayout:r,panelConstraints:d.map(j=>j.constraints),pivotIndices:K8(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 Z8(e,t){const n=e==="horizontal",{x:r,y:a}=Pv(t);return n?r:a}function Dwe(e,t,n,r,a){const o=n==="horizontal",i=zv(t,a);jt(i,`No resize handle element found for id "${t}"`);const c=i.getAttribute(rr.groupId);jt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=r;const f=Z8(n,e),m=Y8(c,a);jt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=o?h.width:h.height;return(f-d)/g*100}function Lwe(e,t,n,r,a,o){if(P8(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:Dwe(e,t,n,r,o)}function Mwe({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];jt(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];jt(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];jt(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||Co(h,f))&&!Co(r,f)&&v(),g&&(h==null||!Co(h,f))&&Co(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 jwe({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 Pwe(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 X8(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 J8(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 $we(e,t,n){var r,a;const o=(r=J8(e,n))!==null&&r!==void 0?r:{},i=X8(t);return(a=o[i])!==null&&a!==void 0?a:null}function Uwe(e,t,n,r,a){var o;const i=q8(e),c=X8(t),d=(o=J8(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(!za(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const i=n[o];jt(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];jt(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(!za(a,0))for(let o=0;o<t.length;o++){const i=n[o];jt(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,za(a,0)))break}return n}const zwe=100,Zf={getItem:e=>(fz(Zf),Zf.getItem(e)),setItem:(e,t)=>{fz(Zf),Zf.setItem(e,t)}},mz={};function Q8({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([]),_=kwe(),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:U}=I.current;return U},setLayout:U=>{const{onLayout:D}=A.current,{layout:P,panelDataArray:V}=I.current,W=pz({layout:U,panelConstraints:V.map(te=>te.constraints)});dz(P,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}),Owe({committedValuesRef:A,eagerValuesRef:I,groupId:g,layout:w,panelDataArray:I.current.panelDataArray,setLayout:S,panelGroupElement:v.current}),y.useEffect(()=>{const{panelDataArray:U}=I.current;if(e){if(w.length===0||w.length!==U.length)return;let D=mz[e];D==null&&(D=Pwe(Uwe,zwe),mz[e]=D);const P=[...U],V=new Map(R.current);D(e,P,V,w,d)}},[e,w,d]),y.useEffect(()=>{});const O=y.useCallback(U=>{const{onLayout:D}=A.current,{layout:P,panelDataArray:V}=I.current;if(U.constraints.collapsible){const W=V.map(q=>q.constraints),{collapsedSize:te=0,panelSize:fe,pivotIndices:le}=El(V,U,P);if(jt(fe!=null,`Panel size not found for panel "${U.id}"`),!Co(fe,te)){R.current.set(U.id,fe);const Q=Jc(V,U)===V.length-1?fe-te:te-fe,ae=Yf({delta:Q,initialLayout:P,panelConstraints:W,pivotIndices:le,prevLayout:P,trigger:"imperative-api"});Jg(P,ae)||(S(ae),I.current.layout=ae,D&&D(ae),Hc(V,ae,T.current))}}},[]),j=y.useCallback((U,D)=>{const{onLayout:P}=A.current,{layout:V,panelDataArray:W}=I.current;if(U.constraints.collapsible){const te=W.map(de=>de.constraints),{collapsedSize:fe=0,panelSize:le=0,minSize:q=0,pivotIndices:Q}=El(W,U,V),ae=D??q;if(Co(le,fe)){const de=R.current.get(U.id),he=de!=null&&de>=ae?de:ae,He=Jc(W,U)===W.length-1?le-he:he-le,Ie=Yf({delta:He,initialLayout:V,panelConstraints:te,pivotIndices:Q,prevLayout:V,trigger:"imperative-api"});Jg(V,Ie)||(S(Ie),I.current.layout=Ie,P&&P(Ie),Hc(W,Ie,T.current))}}},[]),L=y.useCallback(U=>{const{layout:D,panelDataArray:P}=I.current,{panelSize:V}=El(P,U,D);return jt(V!=null,`Panel size not found for panel "${U.id}"`),V},[]),z=y.useCallback((U,D)=>{const{panelDataArray:P}=I.current,V=Jc(P,U);return jwe({defaultSize:D,dragState:E,layout:w,panelData:P,panelIndex:V})},[E,w]),H=y.useCallback(U=>{const{layout:D,panelDataArray:P}=I.current,{collapsedSize:V=0,collapsible:W,panelSize:te}=El(P,U,D);return jt(te!=null,`Panel size not found for panel "${U.id}"`),W===!0&&Co(te,V)},[]),Z=y.useCallback(U=>{const{layout:D,panelDataArray:P}=I.current,{collapsedSize:V=0,collapsible:W,panelSize:te}=El(P,U,D);return jt(te!=null,`Panel size not found for panel "${U.id}"`),!W||Wl(te,V)>0},[]),J=y.useCallback(U=>{const{panelDataArray:D}=I.current;D.push(U),D.sort((P,V)=>{const W=P.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:U,onLayout:D,storage:P}=A.current,{layout:V,panelDataArray:W}=I.current;let te=null;if(U){const le=$we(U,W,P);le&&(R.current=new Map(Object.entries(le.expandToSizes)),te=le.layout)}te==null&&(te=Mwe({panelDataArray:W}));const fe=pz({layout:te,panelConstraints:W.map(le=>le.constraints)});dz(V,fe)||(S(fe),I.current.layout=fe,D&&D(fe),Hc(W,fe,T.current))}}),Ml(()=>{const U=I.current;return()=>{U.layout=[]}},[]);const ne=y.useCallback(U=>{let D=!1;const P=v.current;return P&&window.getComputedStyle(P,null).getPropertyValue("direction")==="rtl"&&(D=!0),function(W){W.preventDefault();const te=v.current;if(!te)return()=>null;const{direction:fe,dragState:le,id:q,keyboardResizeBy:Q,onLayout:ae}=A.current,{layout:de,panelDataArray:he}=I.current,{initialLayout:xe}=le??{},He=K8(q,U,te);let Ie=Lwe(W,U,fe,le,Q,te);const je=fe==="horizontal";je&&D&&(Ie=-Ie);const at=he.map(pe=>pe.constraints),Ue=Yf({delta:Ie,initialLayout:xe??de,panelConstraints:at,pivotIndices:He,prevLayout:de,trigger:P8(W)?"keyboard":"mouse-or-touch"}),Ye=!Jg(de,Ue);($8(W)||U8(W))&&C.current!=Ie&&(C.current=Ie,!Ye&&Ie!==0?je?mE(U,Ie<0?F8:B8):mE(U,Ie<0?H8:V8):mE(U,0)),Ye&&(S(Ue),I.current.layout=Ue,ae&&ae(Ue),Hc(he,Ue,T.current))}},[]),G=y.useCallback((U,D)=>{const{onLayout:P}=A.current,{layout:V,panelDataArray:W}=I.current,te=W.map(de=>de.constraints),{panelSize:fe,pivotIndices:le}=El(W,U,V);jt(fe!=null,`Panel size not found for panel "${U.id}"`);const Q=Jc(W,U)===W.length-1?fe-D:D-fe,ae=Yf({delta:Q,initialLayout:V,panelConstraints:te,pivotIndices:le,prevLayout:V,trigger:"imperative-api"});Jg(V,ae)||(S(ae),I.current.layout=ae,P&&P(ae),Hc(W,ae,T.current))},[]),Y=y.useCallback((U,D)=>{const{layout:P,panelDataArray:V}=I.current,{collapsedSize:W=0,collapsible:te}=D,{collapsedSize:fe=0,collapsible:le,maxSize:q=100,minSize:Q=0}=U.constraints,{panelSize:ae}=El(V,U,P);ae!=null&&(te&&le&&Co(ae,W)?Co(W,fe)||G(U,fe):ae<Q?G(U,Q):ae>q&&G(U,q))},[G]),B=y.useCallback((U,D)=>{const{direction:P}=A.current,{layout:V}=I.current;if(!v.current)return;const W=zv(U,v.current);jt(W,`Drag handle element not found for id "${U}"`);const te=Z8(P,D);x({dragHandleId:U,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:te,initialLayout:V})},[]),re=y.useCallback(()=>{x(null)},[]),ee=y.useCallback(U=>{const{panelDataArray:D}=I.current,P=Jc(D,U);P>=0&&(D.splice(P,1),delete T.current[U.id],I.current.panelDataArrayChanged=!0,_())},[_]),M=y.useMemo(()=>({collapsePanel:O,direction:r,dragState:E,expandPanel:j,getPanelSize:L,getPanelStyle:z,groupId:g,isPanelCollapsed:H,isPanelExpanded:Z,reevaluatePanelConstraints:Y,registerPanel:J,registerResizeHandle:ne,resizePanel:G,startDragging:B,stopDragging:re,unregisterPanel:ee,panelGroupElement:v.current}),[O,E,r,j,L,z,g,H,Z,Y,J,ne,G,B,re,ee]),F={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:{...F,...f},[rr.group]:"",[rr.groupDirection]:r,[rr.groupId]:g}))}const e9=y.forwardRef((e,t)=>y.createElement(Q8,{...e,forwardedRef:t}));Q8.displayName="PanelGroup";e9.displayName="forwardRef(PanelGroup)";function Jc(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function El(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 Fwe({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(rr.groupId);jt(c,`No group element found for id "${c}"`);const d=Kp(c,r),f=W8(c,t,r);jt(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 t9({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:j}=T,L=nI(a),[z,H]=y.useState("inactive"),[Z,J]=y.useState(!1),[ne,G]=y.useState(null),Y=y.useRef({state:z});Ml(()=>{Y.current.state=z}),y.useEffect(()=>{if(n)G(null);else{const M=A(L);G(()=>M)}},[n,L,A]);const B=(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;jt(M,"Element ref not attached");let F=!1;return Twe(L,M,R,{coarse:B,fine:re},(D,P,V)=>{if(!P){H("inactive");return}switch(D){case"down":{H("drag"),F=!1,jt(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}=Y.current;F=!0,W!=="drag"&&H("hover"),jt(V,'Expected event to be defined for "move" action'),ne(V);break}case"up":{H("hover"),O();const{onClick:W,onDragging:te,onPointerUp:fe}=_.current;te?.(!1),fe?.(),F||W?.();break}}})},[B,R,n,re,A,L,ne,I,O]),Fwe({disabled:n,handleId:L,resizeHandler:ne,panelGroupElement:j});const ee={touchAction:"none",userSelect:"none"};return y.createElement(v,{...E,children:e,className:t,id:a,onBlur:()=>{J(!1),o?.()},onFocus:()=>{J(!0),d?.()},ref:S,role:"separator",style:{...ee,...h},tabIndex:g,[rr.groupDirection]:R,[rr.groupId]:C,[rr.resizeHandle]:"",[rr.resizeHandleActive]:z==="drag"?"pointer":Z?"keyboard":void 0,[rr.resizeHandleEnabled]:!n,[rr.resizeHandleId]:L,[rr.resizeHandleState]:z})}t9.displayName="PanelResizeHandle";function ma({className:e,...t}){return u.jsx(e9,{"data-slot":"resizable-panel-group",className:De("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function On({...e}){return u.jsx(j8,{"data-slot":"resizable-panel",...e})}function Ss({withHandle:e,className:t,...n}){return u.jsx(t9,{"data-slot":"resizable-handle",className:De("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(die,{className:"size-2.5"})})})}function Im({className:e,...t}){return u.jsx("kbd",{"data-slot":"kbd",className:De("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 Bwe({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(kn,{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(Tr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(At,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx($o,{className:"h-4 w-4"})})}),u.jsx(At,{side:"bottom",children:"Clear all"})]})})]})}function Ji({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:De("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:De("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:De("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 Hwe({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(Ji,{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 Vwe({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(Re,{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(TB,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:r,children:i?u.jsx(yr,{className:"h-4 w-4"}):u.jsx(or,{className:"h-4 w-4"})}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,children:u.jsx(um,{className:"h-4 w-4"})}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:o,children:u.jsx(_p,{className:"h-4 w-4"})}),c&&u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,children:u.jsx(no,{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(ar,{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 Gwe({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 Y=C.current;if(!Y)return;const B=()=>{Y.scrollTop>0&&(O.current=!0,E(!1))};return Y.addEventListener("scroll",B),()=>Y.removeEventListener("scroll",B)},[]),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 j=y.useCallback(()=>{f.trim()||w(!1)},[f]),L=y.useMemo(()=>{if(!f.trim())return e;const Y=f.toLowerCase();return e.filter(B=>B.method.toLowerCase().includes(Y)||JSON.stringify(B.params||{}).toLowerCase().includes(Y))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const Y=B=>{const re=B.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||B.metaKey||B.ctrlKey||B.altKey)return;const M=L;if(B.key==="ArrowDown")B.preventDefault(),g(F=>{const U=F+1;return U>=M.length?0:U});else if(B.key==="ArrowUp")B.preventDefault(),g(F=>{const U=F-1;return U<0?M.length-1:U});else if(B.key==="Enter"&&h>=0){B.preventDefault();const F=L[h];F&&z(F)}};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[h,L]),y.useEffect(()=>{if(h>=0){const Y=`notification-${L[h]?.id}`,B=document.getElementById(Y);B&&B.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const z=y.useCallback(Y=>{d(Y)},[]),H=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(a(),d(null))},[a]),Z=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(Y){console.error("[NotificationsTab] Failed to copy notification:",Y)}},[c]),J=y.useCallback(()=>{if(c)try{const Y=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),B=URL.createObjectURL(Y),re=document.createElement("a");re.href=B,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(B)}catch(Y){console.error("[NotificationsTab] Failed to download notification:",Y)}},[c]),ne=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(Y){console.error("[NotificationsTab] Failed to toggle fullscreen:",Y)}},[]),G=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:Ty}:null;return i?u.jsxs(ma,{direction:"horizontal",className:"h-full",children:[u.jsx(On,{defaultSize:40,minSize:30,children:u.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(On,{defaultSize:75,minSize:30,children:[u.jsx(Bwe,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:L.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:j,onClearAll:H,searchInputRef:I}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(Hwe,{notifications:L,selectedNotification:c,onNotificationSelect:z,focusedIndex:h,formatRelativeTime:Ty,listRef:C})})]})})}),u.jsx(Ss,{}),u.jsx(On,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(Vwe,{notification:G,previewMode:S,onTogglePreview:()=>_(!S),onCopy:Z,onDownload:J,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(Js,{className:"h-3 w-3 text-muted-foreground transition-transform"}):u.jsx(NB,{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(xoe,{className:"h-3 w-3"}):u.jsx(Soe,{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(ar,{data:v.payload})})})})]},v.id)})})})}function n9({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(kn,{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(Tr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:o}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(At,{side:"bottom",className:"flex gap-2",children:["Search",u.jsx(Im,{children:"F"})]})]})]})]})}),u.jsxs(Re,{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(Tr,{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(Ji,{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(Tr,{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(n9,{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(Ji,{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 Wwe({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(en,{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(en,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(kn,{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(en,{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(en,{htmlFor:c,className:"text-sm font-medium",children:[c,i.required&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),u.jsx(kn,{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(Re,{onClick:o,disabled:n||!r,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?u.jsxs(u.Fragment,{children:[u.jsx(Qs,{className:"mr-2"}),u.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):u.jsxs(u.Fragment,{children:[u.jsx(IB,{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(Re,{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(Wwe,{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 Kwe(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function Ywe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Zwe(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 qwe({message:e,index:t}){const[n,r]=y.useState(!1),a=async()=>{const i=Zwe(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(Tr,{variant:Kwe(e.role),children:Ywe(e.role)}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,className:"h-6 px-2",title:"Copy message content",children:n?u.jsx(yr,{className:"h-3.5 w-3.5"}):u.jsx(or,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"px-4 py-3",children:o()})]})}function Xwe(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 Jwe(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(Xwe(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||Jwe(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(Io,{value:f.toString(),onValueChange:C=>m(parseInt(C)),children:[u.jsx(Do,{className:"h-7 w-[120px] text-xs",children:u.jsx(Oo,{})}),u.jsx(Lo,{children:w.map((C,A)=>u.jsx(na,{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(Re,{variant:"ghost",size:"sm",onClick:()=>r(_,S.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?u.jsx(yr,{className:"h-4 w-4"}):u.jsx(or,{className:"h-4 w-4"})}),a&&u.jsx(Re,{variant:"ghost",size:"sm",onClick:()=>a(_),className:"h-7 w-7 p-0",title:"Delete result",children:u.jsx($o,{className:"h-4 w-4"})}),o&&u.jsx(Re,{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(Re,{variant:"ghost",size:"sm",onClick:c,className:"h-7 w-7 p-0 hidden sm:flex",title:d?"Restore":"Maximize",children:d?u.jsx(AB,{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(qwe,{message:C,index:A},A))}):u.jsx(ar,{data:S.result,filename:`prompt-result-${S.promptName}-${Date.now()}.json`})})]})})})}const wz="mcp-inspector-saved-prompts";function r9({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([]),[j,L]=y.useState(!1),[z,H]=y.useState(""),[Z,J]=y.useState(!1),[ne,G]=y.useState(-1),Y=y.useRef(null),[B,re]=y.useState(!1),[ee,M]=y.useState("list"),[F,U]=y.useState(0),[D,P]=y.useState(!0),[V,W]=y.useState(!1),te=y.useRef(null),fe=y.useRef(null),le=y.useRef(null),q=y.useRef(null);y.useEffect(()=>{const Ne=()=>{re(window.innerWidth<1024)};return Ne(),window.addEventListener("resize",Ne),()=>window.removeEventListener("resize",Ne)},[]),y.useEffect(()=>{M(o?"detail":"list")},[o]),y.useEffect(()=>{B&&v.length>0&&!x&&M("response")},[v,x,B]),y.useImperativeHandle(e,()=>({focusSearch:()=>{J(!0),setTimeout(()=>{Y.current&&Y.current.focus()},0)},blurSearch:()=>{R(""),J(!1),Y.current&&Y.current.blur()}})),y.useEffect(()=>{try{const Ne=localStorage.getItem(wz);if(Ne){const oe=JSON.parse(Ne);O(oe)}}catch(Ne){console.error("[PromptsTab] Failed to load saved prompts:",Ne)}},[]);const Q=y.useCallback(Ne=>{try{localStorage.setItem(wz,JSON.stringify(Ne))}catch(oe){console.error("[PromptsTab] Failed to save prompts:",oe)}},[]);y.useEffect(()=>{Z&&Y.current&&Y.current.focus()},[Z]);const ae=y.useCallback(()=>{T.trim()||J(!1)},[T]),de=y.useMemo(()=>{if(!T.trim())return t;const Ne=T.toLowerCase();return t.filter(oe=>oe.name.toLowerCase().includes(Ne)||oe.description?.toLowerCase().includes(Ne))},[t,T]),he=y.useCallback(Ne=>{i(Ne);const oe={};Ne.arguments&&Ne.arguments.forEach(ke=>{oe[ke.name]=""}),g(oe)},[]),xe=y.useCallback(Ne=>{const oe=t.find(ke=>ke.name===Ne.promptName);oe&&(i(oe),g(Ne.args),d(Ne))},[t]);y.useEffect(()=>{G(-1)},[T,C]),y.useEffect(()=>{const Ne=oe=>{const ke=oe.target;if(ke.tagName==="INPUT"||ke.tagName==="TEXTAREA"||ke.contentEditable==="true"||oe.metaKey||oe.ctrlKey||oe.altKey)return;const Ge=C==="prompts"?de:I;if(oe.key==="ArrowDown")oe.preventDefault(),G(mt=>{const _t=mt+1;return _t>=Ge.length?0:_t});else if(oe.key==="ArrowUp")oe.preventDefault(),G(mt=>{const _t=mt-1;return _t<0?Ge.length-1:_t});else if(oe.key==="Enter"&&ne>=0)if(oe.preventDefault(),C==="prompts"){const mt=de[ne];mt&&he(mt)}else{const mt=I[ne];mt&&xe(mt)}};return document.addEventListener("keydown",Ne),()=>document.removeEventListener("keydown",Ne)},[ne,de,I,C,he,xe]),y.useEffect(()=>{if(ne>=0){const Ne=C==="prompts"?`prompt-${de[ne]?.name}`:`saved-prompt-${I[ne]?.id}`,oe=document.getElementById(Ne);oe&&oe.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,de,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 Ne=t.find(oe=>oe.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!Ne,promptName:Ne?.name,shouldSelect:Ne&&o?.name!==Ne.name}),Ne&&o?.name!==Ne.name){console.warn("[PromptsTab] Selecting prompt:",Ne.name),m(null);const oe=setTimeout(()=>{he(Ne);const ke=document.getElementById(`prompt-${Ne.name}`);ke&&(console.warn("[PromptsTab] Scrolling to prompt element"),ke.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(oe)}}},[f,t,o,he,m]);const He=y.useCallback((Ne,oe)=>{g(ke=>({...ke,[Ne]:oe}))},[]),Ie=y.useCallback(async()=>{if(!o||x)return;w(!0);const Ne=Date.now();try{const oe=await n(o.name,h),ke=Date.now()-Ne;Wr.getInstance().capture(new RP({promptName:o.name,serverId:r,success:!0})).catch(()=>{}),E(Ge=>[{promptName:o.name,args:h,result:oe,timestamp:Ne,duration:ke},...Ge])}catch(oe){Wr.getInstance().capture(new RP({promptName:o.name,serverId:r,success:!1,error:oe instanceof Error?oe.message:"Unknown error"})).catch(()=>{});const Ve={promptName:o.name,args:h,result:null,error:oe instanceof Error?oe.message:String(oe),timestamp:Ne,duration:Date.now()-Ne};E(Ge=>[...Ge,{...Ve,result:{messages:[]}}])}finally{w(!1)}},[o,h,x,n,r]),je=y.useCallback(async(Ne,oe)=>{try{await navigator.clipboard.writeText(JSON.stringify(oe,null,2)),_(Ne),setTimeout(()=>_(null),2e3)}catch(ke){console.error("[PromptsTab] Failed to copy result:",ke)}},[]),at=y.useCallback(Ne=>{E(oe=>oe.filter((ke,Ve)=>Ve!==Ne))},[]),Ue=y.useCallback(Ne=>{if(B)M("response");else{const oe=v[Ne];if(oe){const ke=window.open("","_blank","width=800,height=600");if(ke){const Ve=oe.result;ke.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(ze.result,null,2)}</pre>
|
|
1751
1751
|
</body>
|
|
1752
1752
|
</html>
|
|
1753
|
-
`),qe.document.close())}},[E]),_t=y.useCallback(()=>{W?(he.current&&he.current.expand(),xe.current&&xe.current.expand(),te(!1)):(he.current&&he.current.collapse(),xe.current&&xe.current.collapse(),te(!0))},[W]),st=y.useCallback(()=>{i&&(ne(""),Z(!0))},[i]),Qn=y.useCallback(()=>{if(!i)return;const Be={id:`${Date.now()}-${Math.random()}`,name:J.trim()||`${i.name} - ${new Date().toLocaleString()}`,toolName:i.name,args:g,savedAt:Date.now(),serverId:i._serverId,serverName:i._serverName};at([...L,Be]),Wr.getInstance().capture(new poe({toolName:i.name,serverId:a})).catch(()=>{}),Z(!1),ne("")},[i,J,g,L,at,a]),sn=y.useCallback(Be=>{at(L.filter(ze=>ze.id!==Be)),d?.id===Be&&f(null)},[L,at,d]);return U?u.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[P!=="list"&&u.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[u.jsx(Re,{variant:"ghost",size:"sm",onClick:()=>{P==="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"}),P==="detail"&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),u.jsx("button",{onClick:()=>{V("response")},className:P==="detail"?"text-foreground hover:underline":P==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),P==="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:[P==="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:B,searchQuery:A,filteredToolsCount:Ue.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:I,onSearchBlur:Se,onTabSwitch:()=>j(O==="tools"?"saved":"tools"),searchInputRef:F}),O==="tools"?u.jsx(Az,{tools:Ue,selectedTool:i,onToolSelect:Ye,focusedIndex:ee}):u.jsx(_z,{savedRequests:L,selectedRequest:d,onLoadRequest:pe,onDeleteRequest:sn,focusedIndex:ee})]},"list"),P==="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:Ne,onExecute:oe,onSave:st})},"detail"),P==="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:Ge,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:ke,onDelete:Ve,onFullscreen:mt,onTogglePreview:()=>Y(!G)})},"response")]})}),u.jsx(Tz,{isOpen:H,requestName:J,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:Qn,onCancel:()=>Z(!1)})]}):u.jsxs(ma,{direction:"horizontal",className:"h-full",children:[u.jsx(On,{ref:he,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:u.jsxs(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[u.jsx(On,{defaultSize:75,minSize:30,children:u.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[u.jsx(Iz,{activeTab:O,isSearchExpanded:B,searchQuery:A,filteredToolsCount:Ue.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:I,onSearchBlur:Se,onTabSwitch:()=>j(O==="tools"?"saved":"tools"),searchInputRef:F}),O==="tools"?u.jsx(Az,{tools:Ue,selectedTool:i,onToolSelect:Ye,focusedIndex:ee}):u.jsx(_z,{savedRequests:L,selectedRequest:d,onLoadRequest:pe,onDeleteRequest:sn,focusedIndex:ee})]})}),u.jsx(Ss,{withHandle:!0}),u.jsxs(On,{ref:Ie,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:Be=>{Be.preventDefault(),Be.stopPropagation(),q?(Ie.current?.resize(25),Q(!1)):(Ie.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"}),fe>0&&u.jsx(Tr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:fe}),fe>0&&!q&&u.jsx(Re,{variant:"ghost",size:"sm",onClick:Be=>{Be.preventDefault(),Be.stopPropagation(),je.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:u.jsx($o,{className:"h-3.5 w-3.5"})})]}),u.jsx(Js,{className:`h-4 w-4 text-muted-foreground transition-transform ${q?"":"rotate-180"}`})]}),u.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${q?"hidden":""}`,children:u.jsx(aI,{serverIds:[a],onCountChange:le,onClearRef:je})})]})]})}),u.jsx(Ss,{withHandle:!0}),u.jsx(On,{defaultSize:67,children:u.jsxs(ma,{direction:"vertical",children:[u.jsx(On,{ref:xe,defaultSize:40,collapsible:!0,children:u.jsx(kz,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:Ne,onExecute:oe,onSave:st,onCancel:()=>{R&&R.abort()}})}),u.jsx(Ss,{withHandle:!0}),u.jsx(On,{ref:He,defaultSize:60,children:u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(Rz,{results:Ge,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:ke,onDelete:Ve,onFullscreen:mt,onTogglePreview:()=>Y(!G),onMaximize:_t,isMaximized:W})})})]})}),u.jsx(Tz,{isOpen:H,requestName:J,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:Qn,onCancel:()=>Z(!1)})]})}i9.displayName="ToolsTab";function ixe({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(kn,{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(Tr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(At,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx($o,{className:"h-4 w-4"})})}),u.jsx(At,{side:"bottom",children:"Reject all"})]})})]})}function lxe({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(Ji,{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 cxe({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 fa(async()=>{const{HumanMessage:E,AIMessage:x}=await import("./index-BiUxRAkS.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 fa(async()=>{const{ChatOpenAI:S}=await import("./index--IpKhg5F.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 fa(async()=>{const{ChatAnthropic:S}=await import("./index-3gQQW6s7.js");return{ChatAnthropic:S}},__vite__mapDeps([6,2,1,5]));E=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await fa(async()=>{const{ChatGoogleGenerativeAI:S}=await import("./index-BZCfajuh.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 uxe({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(""),[j,L]=y.useState("image/png"),[z,H]=y.useState(!1),[Z,J]=y.useState(null),{generateResponse:ne,isAvailable:G}=cxe({llmConfig:m});y.useEffect(()=>{e&&(E("stub-model"),w("endTurn"),_("assistant"),R("text"),A("positive"),O(""),L("image/png"),J(null))},[e?.id]);const Y=async()=>{if(!(!e||!G)){H(!0),J(null);try{const M=await ne({request:e.request});E(M.model||m?.model||"stub-model"),w(M.stopReason||"endTurn"),_(M.role||"assistant");const F=Array.isArray(M.content)?M.content[0]:M.content;F.type==="text"?(R("text"),A(F.text||"")):F.type==="image"&&(R("image"),O(F.data||""),L(F.mimeType||"image/png"))}catch(M){const F=M instanceof Error?M.message:"Failed to generate response";J(F),ut.error("LLM Generation Failed",{description:F})}finally{H(!1)}}},B=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=j),M},[v,x,S,T,C,I,j]),re=()=>{if(!e)return;const M=H_.safeParse(B);if(!M.success){ut.error("Invalid response",{description:`Validation failed: ${M.error.message}`});return}t(e.id,M.data),r(),fa(()=>Promise.resolve().then(()=>pd),void 0).then(F=>{const U=ut(F.createElement("div",{className:"space-y-3"},F.createElement("div",null,F.createElement("strong",null,"Sampling Response Sent"),F.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),F.createElement("div",{className:"flex gap-2"},F.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),ut.dismiss(U)}},"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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:i?u.jsx(yr,{className:"h-4 w-4 text-green-600"}):u.jsx(or,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Copy request"})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:u.jsx(um,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Download request"})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:u.jsx(RT,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Fullscreen"})]}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:u.jsx(no,{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(ar,{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(en,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),u.jsxs(Io,{value:h,onValueChange:M=>g(M),children:[u.jsx(Do,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:u.jsx(Oo,{})}),u.jsxs(Lo,{children:[u.jsx(na,{value:"manual",children:"Manual"}),u.jsx(na,{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(Re,{onClick:Y,disabled:z,size:"sm",className:"flex items-center gap-2",children:z?u.jsxs(u.Fragment,{children:[u.jsx(Fi,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):u.jsxs(u.Fragment,{children:[u.jsx(zie,{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."}),Z&&u.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:Z})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`model-${e.id}`,children:"Model"}),u.jsx(kn,{id:`model-${e.id}`,value:v,onChange:M=>E(M.target.value),placeholder:"stub-model",disabled:h==="llm"&&z})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),u.jsx(kn,{id:`stopReason-${e.id}`,value:x,onChange:M=>w(M.target.value),placeholder:"endTurn",disabled:h==="llm"&&z})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`role-${e.id}`,children:"Role"}),u.jsxs(Io,{value:S,onValueChange:M=>_(M),disabled:h==="llm"&&z,children:[u.jsx(Do,{id:`role-${e.id}`,children:u.jsx(Oo,{})}),u.jsxs(Lo,{children:[u.jsx(na,{value:"assistant",children:"assistant"}),u.jsx(na,{value:"user",children:"user"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),u.jsxs(Io,{value:T,onValueChange:M=>R(M),disabled:h==="llm"&&z,children:[u.jsx(Do,{id:`contentType-${e.id}`,children:u.jsx(Oo,{})}),u.jsxs(Lo,{children:[u.jsx(na,{value:"text",children:"text"}),u.jsx(na,{value:"image",children:"image"})]})]})]}),T==="text"&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{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"&&z})]}),T==="image"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{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"&&z})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),u.jsx(kn,{id:`mimeType-${e.id}`,value:j,onChange:M=>L(M.target.value),placeholder:"image/png",disabled:h==="llm"&&z})]})]})]})]}),u.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[u.jsx(Re,{onClick:re,className:"flex-1",disabled:h==="llm"&&z,children:"Approve"}),u.jsx(Re,{onClick:ee,variant:"outline",className:"flex-1",disabled:h==="llm"&&z,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 dxe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function fxe({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(dxe)},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 pxe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:a,mcpServerUrl:o}){const{selectedSamplingRequestId:i,setSelectedSamplingRequestId:c}=Ql(),{llmConfig:d}=L8({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),j=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 B=e.find(re=>re.id===i);console.log("[SamplingTab] Found request for auto-selection:",!!B,B?.id),B&&(console.log("[SamplingTab] Auto-selecting request:",B.id),c(null),m(B),setTimeout(()=>{const re=document.getElementById(`sampling-request-${B.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,c]),y.useEffect(()=>{const B=re=>{const M=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",M);const F=e.find(U=>U.id===M);F&&(console.log("[SamplingTab] Selecting request from event:",M),m(F),setTimeout(()=>{const U=document.getElementById(`sampling-request-${M}`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",B),()=>window.removeEventListener("navigate-to-sampling",B)},[e]),y.useEffect(()=>{x&&e.length>0&&I.current&&!L.current&&(I.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const B=I.current;if(!B)return;const re=()=>{B.scrollTop>0&&(L.current=!0,w(!1))};return B.addEventListener("scroll",re),()=>B.removeEventListener("scroll",re)},[]),y.useEffect(()=>{e.length===0&&(L.current=!1,w(!0))},[e.length]),y.useEffect(()=>{S&&j.current&&j.current.focus()},[S]);const z=y.useCallback(()=>{h.trim()||_(!1)},[h]),H=y.useMemo(()=>{if(!h.trim())return e;const B=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(B)||JSON.stringify(re.request||{}).toLowerCase().includes(B))},[e,h]);y.useEffect(()=>{E(-1)},[h]),y.useEffect(()=>{const B=re=>{const ee=re.target;if(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const F=H;if(re.key==="ArrowDown")re.preventDefault(),E(U=>{const D=U+1;return D>=F.length?0:D});else if(re.key==="ArrowUp")re.preventDefault(),E(U=>{const D=U-1;return D<0?F.length-1:D});else if(re.key==="Enter"&&v>=0){re.preventDefault();const U=H[v];U&&Z(U)}};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[v,H]),y.useEffect(()=>{if(v>=0){const B=`sampling-request-${H[v]?.id}`,re=document.getElementById(B);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,H]);const Z=y.useCallback(B=>{m(B)},[]),J=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(B=>{n(B.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(B){console.error("[SamplingTab] Failed to copy request:",B)}},[f]),G=y.useCallback(()=>{if(f)try{const B=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(B),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(B){console.error("[SamplingTab] Failed to download request:",B)}},[f]),Y=y.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(B){console.error("[SamplingTab] Failed to toggle fullscreen:",B)}},[]);return a?u.jsxs(ma,{direction:"horizontal",className:"h-full",children:[u.jsx(On,{defaultSize:40,minSize:30,children:u.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(On,{defaultSize:75,minSize:30,children:[u.jsx(ixe,{isSearchExpanded:S,searchQuery:h,filteredRequestsCount:H.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:z,onRejectAll:J,searchInputRef:j}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(lxe,{requests:H,selectedRequest:f,onRequestSelect:Z,focusedIndex:v,formatRelativeTime:Ty,listRef:I})})]})})}),u.jsx(Ss,{}),u.jsx(On,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(uxe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:T,onTogglePreview:()=>R(!T),isCopied:C,onCopy:ne,onDownload:G,onFullscreen:Y,llmConfig:d})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(CB,{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 mxe({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 hxe({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(kn,{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(Tr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(At,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx(no,{className:"h-4 w-4"})})}),u.jsx(At,{side:"bottom",children:"Cancel all"})]})})]})}function gxe({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(Ji,{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(Tr,{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 bxe({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[j,L]of Object.entries(I.properties)){const z=L;z.default!==void 0?O[j]=z.default:z.type==="boolean"?O[j]=!1:z.type==="number"||z.type==="integer"?O[j]=0:O[j]=""}h(O)}v(!1)},[e?.id,x]);const S=(I,O)=>{h(j=>({...j,[I]:O}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const I=e.request.requestedSchema;if(I?.required){const O=I.required.filter(j=>m[j]===void 0||m[j]===""||m[j]===null);if(O.length>0){ut.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(),fa(()=>Promise.resolve().then(()=>pd),void 0).then(I=>{const O=ut(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 j=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent(j),ut.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,j=I.required||[];return u.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([L,z])=>{const H=z,Z=j.includes(L),J=H.type||"string",ne=H.title||L,G=H.description;return u.jsxs("div",{className:"space-y-2",children:[u.jsxs(en,{htmlFor:`field-${L}`,children:[ne,Z&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),G&&u.jsx("p",{className:"text-xs text-muted-foreground",children:G}),J==="boolean"?u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Vp,{id:`field-${L}`,checked:m[L]||!1,onCheckedChange:Y=>S(L,Y)}),u.jsx(en,{htmlFor:`field-${L}`,className:"text-sm font-normal cursor-pointer",children:H.title||L})]}):J==="number"||J==="integer"?u.jsx(kn,{id:`field-${L}`,type:"number",value:m[L]||"",onChange:Y=>S(L,J==="integer"?parseInt(Y.target.value,10):parseFloat(Y.target.value)),placeholder:H.default?.toString()||""}):H.enum?u.jsxs("select",{id:`field-${L}`,value:m[L]||"",onChange:Y=>S(L,Y.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(Y=>u.jsx("option",{value:Y,children:Y},Y))]}):J==="string"&&(H.format==="textarea"||H.maxLength>100)?u.jsx(Vl,{id:`field-${L}`,value:m[L]||"",onChange:Y=>S(L,Y.target.value),placeholder:H.default||"",rows:4}):u.jsx(kn,{id:`field-${L}`,type:"text",value:m[L]||"",onChange:Y=>S(L,Y.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(Tr,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:i?u.jsx(yr,{className:"h-4 w-4 text-green-600"}):u.jsx(or,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Copy request"})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:u.jsx(um,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Download request"})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:u.jsx(RT,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Fullscreen"})]}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:u.jsx(no,{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(Re,{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(en,{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(ar,{data:e.request.requestedSchema})})]})]}),u.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[u.jsx(Re,{onClick:_,className:"flex-1",children:"Accept"}),u.jsx(Re,{onClick:T,variant:"outline",className:"flex-1",children:"Decline"}),u.jsx(Re,{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 yxe({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(Y=>Y.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 Y=document.getElementById(`elicitation-request-${G.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Y),Y&&Y.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[o,e,i]),y.useEffect(()=>{const G=Y=>{const re=Y.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 Y=()=>{G.scrollTop>0&&(O.current=!0,E(!1))};return G.addEventListener("scroll",Y),()=>G.removeEventListener("scroll",Y)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const j=y.useCallback(()=>{f.trim()||w(!1)},[f]),L=y.useMemo(()=>{if(!f.trim())return e;const G=f.toLowerCase();return e.filter(Y=>Y.serverName.toLowerCase().includes(G)||Y.request.message.toLowerCase().includes(G)||JSON.stringify(Y.request||{}).toLowerCase().includes(G))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const G=Y=>{const B=Y.target;if(B.tagName==="INPUT"||B.tagName==="TEXTAREA"||B.contentEditable==="true"||Y.metaKey||Y.ctrlKey||Y.altKey)return;const ee=L;if(Y.key==="ArrowDown")Y.preventDefault(),g(M=>{const F=M+1;return F>=ee.length?0:F});else if(Y.key==="ArrowUp")Y.preventDefault(),g(M=>{const F=M-1;return F<0?ee.length-1:F});else if(Y.key==="Enter"&&h>=0){Y.preventDefault();const M=L[h];M&&z(M)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[h,L]),y.useEffect(()=>{if(h>=0){const G=`elicitation-request-${L[h]?.id}`,Y=document.getElementById(G);Y&&Y.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const z=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]),Z=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]),J=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"}),Y=URL.createObjectURL(G),B=document.createElement("a");B.href=Y,B.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(B),B.click(),document.body.removeChild(B),URL.revokeObjectURL(Y)}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(ma,{direction:"horizontal",className:"h-full",children:[u.jsx(On,{defaultSize:40,minSize:30,children:u.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(On,{defaultSize:75,minSize:30,children:[u.jsx(hxe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:L.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:j,onCancelAll:H,searchInputRef:I}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(gxe,{requests:L,selectedRequest:c,onRequestSelect:z,focusedIndex:h,formatRelativeTime:Ty,listRef:C})})]})})}),u.jsx(Ss,{}),u.jsx(On,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(bxe,{request:c,onApprove:t,onReject:n,onClose:()=>d(null),previewMode:S,onTogglePreview:()=>_(!S),isCopied:T,onCopy:Z,onDownload:J,onFullscreen:ne})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(DB,{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({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(i9,{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(r9,{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(s9,{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(pwe,{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(pxe,{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(yxe,{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(Gwe,{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 l9=y.createContext(void 0);function c9(){const e=y.use(l9);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const u9=y.createContext(void 0);function wxe(){return y.use(u9)}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(l9,{value:{activeValue:w,handleValueChange:x,collapsed:S,handleCollapsedChange:_},children:u.jsx("div",{ref:e,className:De("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}=c9(),[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(u9,{value:{variant:r,collapsed:c,handleCollapsedChange:d},children:u.jsx("div",{ref:h,className:De("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:De("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 xxe=({children:e,title:t,collapsed:n})=>!t||!n?e:u.jsx(TT,{children:u.jsxs(Ct,{children:[u.jsx(Rt,{children:e}),u.jsx(At,{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}=c9(),v=wxe()?.variant||"default",E=f===t,x=h&&o?o:void 0;return u.jsx(xxe,{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:De("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:De("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:De("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=n6(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=r6(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{a6(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(z){console.error("Failed to copy:",z),o?.(z)}},I=()=>{if(f==="claude-code"){const{command:L,envVars:z}=s6(v,E,x),H=SU(z);return u.jsxs(u.Fragment,{children:[u.jsxs(Gs,{children:[u.jsx(Ws,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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:z}=o6(v,E,x),H=SU(z);return u.jsxs(u.Fragment,{children:[u.jsxs(Gs,{children:[u.jsx(Ws,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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:z}=i6(v,E,x);return u.jsxs(u.Fragment,{children:[u.jsxs(Gs,{children:[u.jsx(Ws,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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})})]}),z.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(Re,{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(Js,{className:"size-3"})]})]}),j=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:j}),u.jsxs(wp,{align:"end",className:"w-auto min-w-[300px]",children:[t.map(L=>u.jsxs(Fr,{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(Fr,{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(Fr,{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(Fr,{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(Fr,{onClick:S,className:"flex items-center gap-2",children:[u.jsx(t6,{className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code"})]}),n.geminiCli&&u.jsxs(Fr,{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(Fr,{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(Di,{open:c,onOpenChange:d,children:u.jsx(Li,{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(Gie,{className:"size-5"}):u.jsx(Tie,{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:De(e),"aria-label":d(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):u.jsx("button",{ref:r,className:De(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:De("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:De("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(Exe,{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 Exe({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"?hbe(n,r,a,o):gbe(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(Di,{open:e,onOpenChange:t,children:u.jsxs(Li,{className:"max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsxs(Gs,{children:[u.jsxs(Ws,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:h,children:d?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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 d9({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:De("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:De("-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:De("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:De("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}d9.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(Ct,{children:[u.jsx(Rt,{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(At,{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"){ut.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(Re,{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(OB,{className:"h-5 w-5"}),u.jsx(Js,{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(Fr,{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(Re,{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(Re,{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(Fr,{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(d9,{className:De("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(Ct,{children:[u.jsx(Rt,{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(At,{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(Ct,{children:[u.jsx(Rt,{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(At,{children:u.jsx("p",{children:"View server info"})})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{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(At,{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(Fr,{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(Re,{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(Re,{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(Fr,{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:iie},{id:"sampling",label:"Sampling",icon:CB},{id:"elicitation",label:"Elicitation",icon:DB},{id:"notifications",label:"Notifications",icon:NT},{id:"chat",label:"Chat",icon:wie}];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 Sxe({collapsed:e,onToggle:t}){return u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx("button",{onClick:t,className:De("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(NB,{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(At,{children:u.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function _xe({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),ut.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{ut.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=>ut.success(`Opening in ${R}...`),onError:R=>ut.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(Re,{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(Js,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{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(At,{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:De("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",w&&"pl-2"),children:[R>0&&!w&&u.jsx("span",{className:De(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:De("[&>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:De(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(Sxe,{collapsed:w,onToggle:()=>S(!w)})]}),f&&u.jsxs(T6,{children:[u.jsx(N6,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:_,children:m?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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=>ut.success(`Opening in ${R}...`),onError:R=>ut.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(Re,{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(Js,{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(Ct,{children:[u.jsx(Rt,{children:u.jsx(Mz,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),u.jsx(At,{children:u.jsx("p",{children:"Toggle theme"})})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsxs(Re,{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(Voe,{className:"size-4"}),u.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),u.jsx(At,{children:u.jsx("p",{children:"Command Palette"})})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{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(At,{children:u.jsx("p",{children:"Give us a star ⭐"})})]}),u.jsx(jz,{state:"expanded"})]})]})]})}function Txe({children:e}){const t=Nd(),n=Vo(),{servers:r,addServer:a,removeServer:o,updateServer:i,storageLoaded:c}=tm(),d=y.useCallback((D,P,V,W)=>{a(D,{url:D,name:P,proxyConfig:V,transportType:W})},[a]),f=y.useCallback(async(D,P)=>{try{await i(D,P)}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=Bge();y.useEffect(()=>{const D=new URLSearchParams(n.search),P=D.get("embedded")==="true",V=D.get("embeddedConfig");if(P){let W={};if(V)try{W=JSON.parse(V)}catch(te){console.error("Failed to parse embeddedConfig:",te)}T(!0,W)}},[]),y.useEffect(()=>{const P=new URLSearchParams(n.search).get("tunnelUrl");x(P)},[n.search,x]),y.useEffect(()=>{const P=new URLSearchParams(n.search).get("tab");P&&["tools","prompts","resources","chat","sampling","elicitation","notifications"].includes(P)&&v(P)},[n.search,v]),y.useEffect(()=>{const D=W=>{const fe=W.detail.requestId;m&&E(m,"sampling",fe)},P=W=>{const fe=W.detail.requestId;m&&E(m,"elicitation",fe)},V=W=>{const fe=W.detail.toolName;m&&fe?E(m,"tools",fe):m&&v("tools")};return window.addEventListener("navigate-to-sampling",D),window.addEventListener("navigate-to-elicitation",P),window.addEventListener("navigate-to-tool-result",V),()=>{window.removeEventListener("navigate-to-sampling",D),window.removeEventListener("navigate-to-elicitation",P),window.removeEventListener("navigate-to-tool-result",V)}},[m,v,E]);const j=y.useRef(null),L=y.useRef(null),z=y.useRef(null),{isAutoConnecting:H}=Fge({connections:r,addConnection:d,removeConnection:o,configLoaded:c,embedded:S}),Z=y.useCallback(D=>{Wr.getInstance().capture(new foe({trigger:D})).catch(()=>{}),C(!0)},[]),J=D=>{const P=r.find(le=>le.id===D);if(!P||P.state!=="ready"){ut.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"),fe=new URLSearchParams;fe.set("server",D),W&&fe.set("tunnelUrl",W),te&&fe.set("tab",te),t(`/?${fe.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),ut.success("Connection settings updated"))},[A,o,d,f]),Y=(D,P,V)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:D,itemName:P,serverId:V}),V){const W=r.find(ae=>ae.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"),ut.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:V,tab:D,itemName:P}),E(V,D,P);const te=new URLSearchParams(n.search),fe=te.get("tunnelUrl"),le=te.get("tab"),q=new URLSearchParams;q.set("server",V),fe&&q.set("tunnelUrl",fe),D?q.set("tab",D):le&&q.set("tab",le);const Q=`/?${q.toString()}`;console.warn("[Layout] Navigating to:",Q),t(Q)}else console.warn("[Layout] No serverId, just updating tab to:",D),v(D)},B=r.find(D=>D.id===m),re=B?B.tools.map(D=>({...D,_serverId:B.id})):r.flatMap(D=>D.state==="ready"?D.tools.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]),ee=B?B.prompts.map(D=>({...D,_serverId:B.id})):r.flatMap(D=>D.state==="ready"?D.prompts.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]),M=B?B.resources.map(D=>({...D,_serverId:B.id})):r.flatMap(D=>D.state==="ready"?D.resources.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]);if(y.useEffect(()=>{const P=new URLSearchParams(n.search).get("server"),V=P?decodeURIComponent(P):null;V!==m&&h(V)},[n.search,m,h]),y.useEffect(()=>{const P=new URLSearchParams(n.search).get("server");if(!P)return;const V=decodeURIComponent(P),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]),WV({onCommandPalette:()=>Z("keyboard"),onToolsTab:()=>{B&&v("tools")},onPromptsTab:()=>{B&&v("prompts")},onResourcesTab:()=>{B&&v("resources")},onChatTab:()=>{B&&v("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{g==="tools"&&j.current?j.current.focusSearch():g==="prompts"&&L.current?L.current.focusSearch():g==="resources"&&z.current&&z.current.focusSearch()},onBlurSearch:()=>{g==="tools"&&j.current?j.current.blurSearch():g==="prompts"&&L.current?L.current.blurSearch():g==="resources"&&z.current&&z.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(Qs,{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 F=S?{backgroundColor:_.backgroundColor||"#f3f3f3",padding:_.padding||"0.5rem"}:{},U=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:U,style:F,children:[u.jsx(_xe,{connections:r,selectedServer:B,activeTab:g,onServerSelect:J,onTabChange:v,onCommandPaletteOpen:()=>Z("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(vxe,{selectedServer:B,activeTab:g,toolsSearchRef:j,promptsSearchRef:L,resourcesSearchRef:z,children:e})}),u.jsx(ybe,{isOpen:R,onOpenChange:C,tools:re,prompts:ee,resources:M,savedRequests:O,connections:r,selectedServer:B,tunnelUrl:w,onNavigate:Y,onServerSelect:J}),u.jsx(uH,{connection:A&&r.find(D=>D.id===A)||null,open:A!==null,onOpenChange:D=>{D||I(null)},onConnect:G})]})})}function Nxe(){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(Fi,{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 kxe=(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{}},Cxe=y.createContext(void 0),Rxe={setTheme:e=>{},themes:[]},Axe=()=>{var e;return(e=y.useContext(Cxe))!=null?e:Rxe};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:`(${kxe.toString()})(${m})`}})});function Ixe({...e}){const{theme:t="system"}=Axe();return u.jsx(Zce,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Oxe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true",n=y.useMemo(()=>t?void 0:new vee("mcp-inspector-connections"),[t]);return u.jsx(Qde,{children:u.jsx(c4,{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=ut(u.jsx(fxe,{requestId:r.id,serverName:o,onViewDetails:()=>{const f=new CustomEvent("navigate-to-sampling",{detail:{requestId:r.id}});window.dispatchEvent(f),ut.dismiss(d)},onApprove:f=>{i(r.id,f),ut.success("Sampling request approved"),ut.dismiss(d)},onDeny:()=>{c(r.id,"User denied from toast"),ut.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=ut(u.jsx(mxe,{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),ut.dismiss(h)},onOpenUrl:d==="url"&&m?()=>{window.open(m,"_blank"),ut.dismiss(h)}:void 0,onCancel:()=>{c(r.id,"User cancelled from toast"),ut.dismiss(h)}}),{duration:1/0})},children:u.jsxs(zge,{children:[u.jsx(pce,{basename:"/inspector",children:u.jsxs(Vle,{children:[u.jsx(aS,{path:"/oauth/callback",element:u.jsx(Nxe,{})}),u.jsx(aS,{path:"/",element:u.jsx(Txe,{children:u.jsx(Uge,{})})})]})}),u.jsx(Ixe,{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?kee.createRoot(Vz).render(u.jsx(Oxe,{})):console.error("[inspector] Root element not found");const Dxe=Object.freeze(Object.defineProperty({__proto__:null,clearRpcLogs:Bb,getAllRpcLogs:tT,getRpcLogs:u4,subscribeToRpcLogs:nT,wrapTransportForLogging:d4},Symbol.toStringTag,{value:"Module"}));export{IK as $,$f as A,rJ as B,Aj as C,zxe as D,Gi as E,IY as F,BK as G,iee as H,X7 as I,nb as J,eW as K,AY as L,ree as M,AK as N,Pxe as O,W7 as P,Pi as Q,ie as R,JZ as S,Fs as T,Q2 as U,zn as V,XK as W,r2 as X,U7 as Y,Sq as Z,Me as _,fa as a,ob as a0,N7 as a1,lee as a2,k7 as a3,J_ as a4,z7 as a5,pd as b,Yp as c,aee as d,Ny as e,jxe as f,Mxe as g,see as h,We as i,$n as j,wq as k,Le as l,ct as m,bn as n,Ke as o,$xe as p,nF as q,y as r,ce as s,Bxe as t,Zn as u,Ha as v,Fn as w,Fxe as x,Uxe as y,qn as z};
|
|
1753
|
+
`),qe.document.close())}},[E]),_t=y.useCallback(()=>{W?(he.current&&he.current.expand(),xe.current&&xe.current.expand(),te(!1)):(he.current&&he.current.collapse(),xe.current&&xe.current.collapse(),te(!0))},[W]),st=y.useCallback(()=>{i&&(ne(""),Z(!0))},[i]),Qn=y.useCallback(()=>{if(!i)return;const Be={id:`${Date.now()}-${Math.random()}`,name:J.trim()||`${i.name} - ${new Date().toLocaleString()}`,toolName:i.name,args:g,savedAt:Date.now(),serverId:i._serverId,serverName:i._serverName};at([...L,Be]),Wr.getInstance().capture(new poe({toolName:i.name,serverId:a})).catch(()=>{}),Z(!1),ne("")},[i,J,g,L,at,a]),sn=y.useCallback(Be=>{at(L.filter(ze=>ze.id!==Be)),d?.id===Be&&f(null)},[L,at,d]);return U?u.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[P!=="list"&&u.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[u.jsx(Re,{variant:"ghost",size:"sm",onClick:()=>{P==="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"}),P==="detail"&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),u.jsx("button",{onClick:()=>{V("response")},className:P==="detail"?"text-foreground hover:underline":P==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),P==="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:[P==="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:B,searchQuery:A,filteredToolsCount:Ue.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:I,onSearchBlur:Se,onTabSwitch:()=>j(O==="tools"?"saved":"tools"),searchInputRef:F}),O==="tools"?u.jsx(Az,{tools:Ue,selectedTool:i,onToolSelect:Ye,focusedIndex:ee}):u.jsx(_z,{savedRequests:L,selectedRequest:d,onLoadRequest:pe,onDeleteRequest:sn,focusedIndex:ee})]},"list"),P==="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:Ne,onExecute:oe,onSave:st})},"detail"),P==="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:Ge,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:ke,onDelete:Ve,onFullscreen:mt,onTogglePreview:()=>Y(!G)})},"response")]})}),u.jsx(Tz,{isOpen:H,requestName:J,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:Qn,onCancel:()=>Z(!1)})]}):u.jsxs(ma,{direction:"horizontal",className:"h-full",children:[u.jsx(On,{ref:he,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:u.jsxs(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[u.jsx(On,{defaultSize:75,minSize:30,children:u.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[u.jsx(Iz,{activeTab:O,isSearchExpanded:B,searchQuery:A,filteredToolsCount:Ue.length,savedRequestsCount:L.length,onSearchExpand:()=>re(!0),onSearchChange:I,onSearchBlur:Se,onTabSwitch:()=>j(O==="tools"?"saved":"tools"),searchInputRef:F}),O==="tools"?u.jsx(Az,{tools:Ue,selectedTool:i,onToolSelect:Ye,focusedIndex:ee}):u.jsx(_z,{savedRequests:L,selectedRequest:d,onLoadRequest:pe,onDeleteRequest:sn,focusedIndex:ee})]})}),u.jsx(Ss,{withHandle:!0}),u.jsxs(On,{ref:Ie,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:Be=>{Be.preventDefault(),Be.stopPropagation(),q?(Ie.current?.resize(25),Q(!1)):(Ie.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"}),fe>0&&u.jsx(Tr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:fe}),fe>0&&!q&&u.jsx(Re,{variant:"ghost",size:"sm",onClick:Be=>{Be.preventDefault(),Be.stopPropagation(),je.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:u.jsx($o,{className:"h-3.5 w-3.5"})})]}),u.jsx(Js,{className:`h-4 w-4 text-muted-foreground transition-transform ${q?"":"rotate-180"}`})]}),u.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${q?"hidden":""}`,children:u.jsx(aI,{serverIds:[a],onCountChange:le,onClearRef:je})})]})]})}),u.jsx(Ss,{withHandle:!0}),u.jsx(On,{defaultSize:67,children:u.jsxs(ma,{direction:"vertical",children:[u.jsx(On,{ref:xe,defaultSize:40,collapsible:!0,children:u.jsx(kz,{selectedTool:i,toolArgs:g,isExecuting:w,isConnected:o,onArgChange:Ne,onExecute:oe,onSave:st,onCancel:()=>{R&&R.abort()}})}),u.jsx(Ss,{withHandle:!0}),u.jsx(On,{ref:He,defaultSize:60,children:u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(Rz,{results:Ge,copiedResult:_,previewMode:G,serverId:a,readResource:r,onCopy:ke,onDelete:Ve,onFullscreen:mt,onTogglePreview:()=>Y(!G),onMaximize:_t,isMaximized:W})})})]})}),u.jsx(Tz,{isOpen:H,requestName:J,defaultPlaceholder:`${i?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ne,onSave:Qn,onCancel:()=>Z(!1)})]})}i9.displayName="ToolsTab";function ixe({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(kn,{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(Tr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(At,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx($o,{className:"h-4 w-4"})})}),u.jsx(At,{side:"bottom",children:"Reject all"})]})})]})}function lxe({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(Ji,{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 cxe({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 fa(async()=>{const{HumanMessage:E,AIMessage:x}=await import("./index-NmfTs9aq.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 fa(async()=>{const{ChatOpenAI:S}=await import("./index-DpOgK2Yr.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 fa(async()=>{const{ChatAnthropic:S}=await import("./index-BKSSQ8ab.js");return{ChatAnthropic:S}},__vite__mapDeps([6,2,1,5]));E=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await fa(async()=>{const{ChatGoogleGenerativeAI:S}=await import("./index-CQWqWZPb.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 uxe({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(""),[j,L]=y.useState("image/png"),[z,H]=y.useState(!1),[Z,J]=y.useState(null),{generateResponse:ne,isAvailable:G}=cxe({llmConfig:m});y.useEffect(()=>{e&&(E("stub-model"),w("endTurn"),_("assistant"),R("text"),A("positive"),O(""),L("image/png"),J(null))},[e?.id]);const Y=async()=>{if(!(!e||!G)){H(!0),J(null);try{const M=await ne({request:e.request});E(M.model||m?.model||"stub-model"),w(M.stopReason||"endTurn"),_(M.role||"assistant");const F=Array.isArray(M.content)?M.content[0]:M.content;F.type==="text"?(R("text"),A(F.text||"")):F.type==="image"&&(R("image"),O(F.data||""),L(F.mimeType||"image/png"))}catch(M){const F=M instanceof Error?M.message:"Failed to generate response";J(F),ut.error("LLM Generation Failed",{description:F})}finally{H(!1)}}},B=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=j),M},[v,x,S,T,C,I,j]),re=()=>{if(!e)return;const M=H_.safeParse(B);if(!M.success){ut.error("Invalid response",{description:`Validation failed: ${M.error.message}`});return}t(e.id,M.data),r(),fa(()=>Promise.resolve().then(()=>pd),void 0).then(F=>{const U=ut(F.createElement("div",{className:"space-y-3"},F.createElement("div",null,F.createElement("strong",null,"Sampling Response Sent"),F.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),F.createElement("div",{className:"flex gap-2"},F.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),ut.dismiss(U)}},"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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:i?u.jsx(yr,{className:"h-4 w-4 text-green-600"}):u.jsx(or,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Copy request"})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:u.jsx(um,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Download request"})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:u.jsx(RT,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Fullscreen"})]}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:u.jsx(no,{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(ar,{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(en,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),u.jsxs(Io,{value:h,onValueChange:M=>g(M),children:[u.jsx(Do,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:u.jsx(Oo,{})}),u.jsxs(Lo,{children:[u.jsx(na,{value:"manual",children:"Manual"}),u.jsx(na,{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(Re,{onClick:Y,disabled:z,size:"sm",className:"flex items-center gap-2",children:z?u.jsxs(u.Fragment,{children:[u.jsx(Fi,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):u.jsxs(u.Fragment,{children:[u.jsx(zie,{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."}),Z&&u.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:Z})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`model-${e.id}`,children:"Model"}),u.jsx(kn,{id:`model-${e.id}`,value:v,onChange:M=>E(M.target.value),placeholder:"stub-model",disabled:h==="llm"&&z})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),u.jsx(kn,{id:`stopReason-${e.id}`,value:x,onChange:M=>w(M.target.value),placeholder:"endTurn",disabled:h==="llm"&&z})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`role-${e.id}`,children:"Role"}),u.jsxs(Io,{value:S,onValueChange:M=>_(M),disabled:h==="llm"&&z,children:[u.jsx(Do,{id:`role-${e.id}`,children:u.jsx(Oo,{})}),u.jsxs(Lo,{children:[u.jsx(na,{value:"assistant",children:"assistant"}),u.jsx(na,{value:"user",children:"user"})]})]})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),u.jsxs(Io,{value:T,onValueChange:M=>R(M),disabled:h==="llm"&&z,children:[u.jsx(Do,{id:`contentType-${e.id}`,children:u.jsx(Oo,{})}),u.jsxs(Lo,{children:[u.jsx(na,{value:"text",children:"text"}),u.jsx(na,{value:"image",children:"image"})]})]})]}),T==="text"&&u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{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"&&z})]}),T==="image"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{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"&&z})]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx(en,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),u.jsx(kn,{id:`mimeType-${e.id}`,value:j,onChange:M=>L(M.target.value),placeholder:"image/png",disabled:h==="llm"&&z})]})]})]})]}),u.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[u.jsx(Re,{onClick:re,className:"flex-1",disabled:h==="llm"&&z,children:"Approve"}),u.jsx(Re,{onClick:ee,variant:"outline",className:"flex-1",disabled:h==="llm"&&z,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 dxe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function fxe({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(dxe)},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 pxe({pendingRequests:e,onApprove:t,onReject:n,serverId:r,isConnected:a,mcpServerUrl:o}){const{selectedSamplingRequestId:i,setSelectedSamplingRequestId:c}=Ql(),{llmConfig:d}=L8({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),j=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 B=e.find(re=>re.id===i);console.log("[SamplingTab] Found request for auto-selection:",!!B,B?.id),B&&(console.log("[SamplingTab] Auto-selecting request:",B.id),c(null),m(B),setTimeout(()=>{const re=document.getElementById(`sampling-request-${B.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,c]),y.useEffect(()=>{const B=re=>{const M=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",M);const F=e.find(U=>U.id===M);F&&(console.log("[SamplingTab] Selecting request from event:",M),m(F),setTimeout(()=>{const U=document.getElementById(`sampling-request-${M}`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",B),()=>window.removeEventListener("navigate-to-sampling",B)},[e]),y.useEffect(()=>{x&&e.length>0&&I.current&&!L.current&&(I.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const B=I.current;if(!B)return;const re=()=>{B.scrollTop>0&&(L.current=!0,w(!1))};return B.addEventListener("scroll",re),()=>B.removeEventListener("scroll",re)},[]),y.useEffect(()=>{e.length===0&&(L.current=!1,w(!0))},[e.length]),y.useEffect(()=>{S&&j.current&&j.current.focus()},[S]);const z=y.useCallback(()=>{h.trim()||_(!1)},[h]),H=y.useMemo(()=>{if(!h.trim())return e;const B=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(B)||JSON.stringify(re.request||{}).toLowerCase().includes(B))},[e,h]);y.useEffect(()=>{E(-1)},[h]),y.useEffect(()=>{const B=re=>{const ee=re.target;if(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const F=H;if(re.key==="ArrowDown")re.preventDefault(),E(U=>{const D=U+1;return D>=F.length?0:D});else if(re.key==="ArrowUp")re.preventDefault(),E(U=>{const D=U-1;return D<0?F.length-1:D});else if(re.key==="Enter"&&v>=0){re.preventDefault();const U=H[v];U&&Z(U)}};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[v,H]),y.useEffect(()=>{if(v>=0){const B=`sampling-request-${H[v]?.id}`,re=document.getElementById(B);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,H]);const Z=y.useCallback(B=>{m(B)},[]),J=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(B=>{n(B.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(B){console.error("[SamplingTab] Failed to copy request:",B)}},[f]),G=y.useCallback(()=>{if(f)try{const B=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(B),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(B){console.error("[SamplingTab] Failed to download request:",B)}},[f]),Y=y.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(B){console.error("[SamplingTab] Failed to toggle fullscreen:",B)}},[]);return a?u.jsxs(ma,{direction:"horizontal",className:"h-full",children:[u.jsx(On,{defaultSize:40,minSize:30,children:u.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(On,{defaultSize:75,minSize:30,children:[u.jsx(ixe,{isSearchExpanded:S,searchQuery:h,filteredRequestsCount:H.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:z,onRejectAll:J,searchInputRef:j}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(lxe,{requests:H,selectedRequest:f,onRequestSelect:Z,focusedIndex:v,formatRelativeTime:Ty,listRef:I})})]})})}),u.jsx(Ss,{}),u.jsx(On,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(uxe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:T,onTogglePreview:()=>R(!T),isCopied:C,onCopy:ne,onDownload:G,onFullscreen:Y,llmConfig:d})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(CB,{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 mxe({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 hxe({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(kn,{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(Tr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:u.jsx(Sd,{className:"h-4 w-4"})})}),u.jsxs(At,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,disabled:r===0,className:"h-8 w-8 p-0",children:u.jsx(no,{className:"h-4 w-4"})})}),u.jsx(At,{side:"bottom",children:"Cancel all"})]})})]})}function gxe({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(Ji,{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(Tr,{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 bxe({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[j,L]of Object.entries(I.properties)){const z=L;z.default!==void 0?O[j]=z.default:z.type==="boolean"?O[j]=!1:z.type==="number"||z.type==="integer"?O[j]=0:O[j]=""}h(O)}v(!1)},[e?.id,x]);const S=(I,O)=>{h(j=>({...j,[I]:O}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const I=e.request.requestedSchema;if(I?.required){const O=I.required.filter(j=>m[j]===void 0||m[j]===""||m[j]===null);if(O.length>0){ut.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(),fa(()=>Promise.resolve().then(()=>pd),void 0).then(I=>{const O=ut(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 j=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent(j),ut.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,j=I.required||[];return u.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([L,z])=>{const H=z,Z=j.includes(L),J=H.type||"string",ne=H.title||L,G=H.description;return u.jsxs("div",{className:"space-y-2",children:[u.jsxs(en,{htmlFor:`field-${L}`,children:[ne,Z&&u.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),G&&u.jsx("p",{className:"text-xs text-muted-foreground",children:G}),J==="boolean"?u.jsxs("div",{className:"flex items-center space-x-2",children:[u.jsx(Vp,{id:`field-${L}`,checked:m[L]||!1,onCheckedChange:Y=>S(L,Y)}),u.jsx(en,{htmlFor:`field-${L}`,className:"text-sm font-normal cursor-pointer",children:H.title||L})]}):J==="number"||J==="integer"?u.jsx(kn,{id:`field-${L}`,type:"number",value:m[L]||"",onChange:Y=>S(L,J==="integer"?parseInt(Y.target.value,10):parseFloat(Y.target.value)),placeholder:H.default?.toString()||""}):H.enum?u.jsxs("select",{id:`field-${L}`,value:m[L]||"",onChange:Y=>S(L,Y.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(Y=>u.jsx("option",{value:Y,children:Y},Y))]}):J==="string"&&(H.format==="textarea"||H.maxLength>100)?u.jsx(Vl,{id:`field-${L}`,value:m[L]||"",onChange:Y=>S(L,Y.target.value),placeholder:H.default||"",rows:4}):u.jsx(kn,{id:`field-${L}`,type:"text",value:m[L]||"",onChange:Y=>S(L,Y.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(Tr,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:i?u.jsx(yr,{className:"h-4 w-4 text-green-600"}):u.jsx(or,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Copy request"})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:u.jsx(um,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Download request"})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:u.jsx(RT,{className:"h-4 w-4"})})}),u.jsx(At,{children:"Fullscreen"})]}),u.jsx(Re,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:u.jsx(no,{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(Re,{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(en,{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(ar,{data:e.request.requestedSchema})})]})]}),u.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[u.jsx(Re,{onClick:_,className:"flex-1",children:"Accept"}),u.jsx(Re,{onClick:T,variant:"outline",className:"flex-1",children:"Decline"}),u.jsx(Re,{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 yxe({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(Y=>Y.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 Y=document.getElementById(`elicitation-request-${G.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Y),Y&&Y.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[o,e,i]),y.useEffect(()=>{const G=Y=>{const re=Y.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 Y=()=>{G.scrollTop>0&&(O.current=!0,E(!1))};return G.addEventListener("scroll",Y),()=>G.removeEventListener("scroll",Y)},[]),y.useEffect(()=>{e.length===0&&(O.current=!1,E(!0))},[e.length]),y.useEffect(()=>{x&&I.current&&I.current.focus()},[x]);const j=y.useCallback(()=>{f.trim()||w(!1)},[f]),L=y.useMemo(()=>{if(!f.trim())return e;const G=f.toLowerCase();return e.filter(Y=>Y.serverName.toLowerCase().includes(G)||Y.request.message.toLowerCase().includes(G)||JSON.stringify(Y.request||{}).toLowerCase().includes(G))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const G=Y=>{const B=Y.target;if(B.tagName==="INPUT"||B.tagName==="TEXTAREA"||B.contentEditable==="true"||Y.metaKey||Y.ctrlKey||Y.altKey)return;const ee=L;if(Y.key==="ArrowDown")Y.preventDefault(),g(M=>{const F=M+1;return F>=ee.length?0:F});else if(Y.key==="ArrowUp")Y.preventDefault(),g(M=>{const F=M-1;return F<0?ee.length-1:F});else if(Y.key==="Enter"&&h>=0){Y.preventDefault();const M=L[h];M&&z(M)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[h,L]),y.useEffect(()=>{if(h>=0){const G=`elicitation-request-${L[h]?.id}`,Y=document.getElementById(G);Y&&Y.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,L]);const z=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]),Z=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]),J=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"}),Y=URL.createObjectURL(G),B=document.createElement("a");B.href=Y,B.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(B),B.click(),document.body.removeChild(B),URL.revokeObjectURL(Y)}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(ma,{direction:"horizontal",className:"h-full",children:[u.jsx(On,{defaultSize:40,minSize:30,children:u.jsx(ma,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:u.jsxs(On,{defaultSize:75,minSize:30,children:[u.jsx(hxe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:L.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:j,onCancelAll:H,searchInputRef:I}),u.jsx("div",{className:"flex flex-col h-full",children:u.jsx(gxe,{requests:L,selectedRequest:c,onRequestSelect:z,focusedIndex:h,formatRelativeTime:Ty,listRef:C})})]})})}),u.jsx(Ss,{}),u.jsx(On,{defaultSize:60,minSize:40,children:u.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:u.jsx(bxe,{request:c,onApprove:t,onReject:n,onClose:()=>d(null),previewMode:S,onTogglePreview:()=>_(!S),isCopied:T,onCopy:Z,onDownload:J,onFullscreen:ne})})})]}):u.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[u.jsx(DB,{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({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(i9,{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(r9,{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(s9,{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(pwe,{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(pxe,{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(yxe,{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(Gwe,{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 l9=y.createContext(void 0);function c9(){const e=y.use(l9);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const u9=y.createContext(void 0);function wxe(){return y.use(u9)}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(l9,{value:{activeValue:w,handleValueChange:x,collapsed:S,handleCollapsedChange:_},children:u.jsx("div",{ref:e,className:De("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}=c9(),[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(u9,{value:{variant:r,collapsed:c,handleCollapsedChange:d},children:u.jsx("div",{ref:h,className:De("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:De("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 xxe=({children:e,title:t,collapsed:n})=>!t||!n?e:u.jsx(TT,{children:u.jsxs(Ct,{children:[u.jsx(Rt,{children:e}),u.jsx(At,{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}=c9(),v=wxe()?.variant||"default",E=f===t,x=h&&o?o:void 0;return u.jsx(xxe,{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:De("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:De("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:De("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=n6(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=r6(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{a6(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(z){console.error("Failed to copy:",z),o?.(z)}},I=()=>{if(f==="claude-code"){const{command:L,envVars:z}=s6(v,E,x),H=SU(z);return u.jsxs(u.Fragment,{children:[u.jsxs(Gs,{children:[u.jsx(Ws,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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:z}=o6(v,E,x),H=SU(z);return u.jsxs(u.Fragment,{children:[u.jsxs(Gs,{children:[u.jsx(Ws,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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:z}=i6(v,E,x);return u.jsxs(u.Fragment,{children:[u.jsxs(Gs,{children:[u.jsx(Ws,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:()=>A(L),children:h?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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})})]}),z.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(Re,{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(Js,{className:"size-3"})]})]}),j=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:j}),u.jsxs(wp,{align:"end",className:"w-auto min-w-[300px]",children:[t.map(L=>u.jsxs(Fr,{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(Fr,{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(Fr,{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(Fr,{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(Fr,{onClick:S,className:"flex items-center gap-2",children:[u.jsx(t6,{className:"h-4 w-4"}),u.jsx("span",{className:"min-w-0 max-w-full whitespace-nowrap",children:"VS Code"})]}),n.geminiCli&&u.jsxs(Fr,{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(Fr,{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(Di,{open:c,onOpenChange:d,children:u.jsx(Li,{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(Gie,{className:"size-5"}):u.jsx(Tie,{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:De(e),"aria-label":d(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):u.jsx("button",{ref:r,className:De(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:De("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:De("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(Exe,{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 Exe({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"?hbe(n,r,a,o):gbe(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(Di,{open:e,onOpenChange:t,children:u.jsxs(Li,{className:"max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col",children:[u.jsxs(Gs,{children:[u.jsxs(Ws,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:h,children:d?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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 d9({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:De("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:De("-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:De("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:De("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}d9.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(Ct,{children:[u.jsx(Rt,{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(At,{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"){ut.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(Re,{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(OB,{className:"h-5 w-5"}),u.jsx(Js,{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(Fr,{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(Re,{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(Re,{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(Fr,{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(d9,{className:De("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(Ct,{children:[u.jsx(Rt,{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(At,{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(Ct,{children:[u.jsx(Rt,{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(At,{children:u.jsx("p",{children:"View server info"})})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{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(At,{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(Fr,{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(Re,{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(Re,{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(Fr,{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:iie},{id:"sampling",label:"Sampling",icon:CB},{id:"elicitation",label:"Elicitation",icon:DB},{id:"notifications",label:"Notifications",icon:NT},{id:"chat",label:"Chat",icon:wie}];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 Sxe({collapsed:e,onToggle:t}){return u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx("button",{onClick:t,className:De("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(NB,{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(At,{children:u.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function _xe({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),ut.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{ut.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=>ut.success(`Opening in ${R}...`),onError:R=>ut.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(Re,{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(Js,{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(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{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(At,{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:De("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",w&&"pl-2"),children:[R>0&&!w&&u.jsx("span",{className:De(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:De("[&>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:De(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(Sxe,{collapsed:w,onToggle:()=>S(!w)})]}),f&&u.jsxs(T6,{children:[u.jsx(N6,{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(Re,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:_,children:m?u.jsx(yr,{className:"size-3.5 text-green-600"}):u.jsx(or,{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=>ut.success(`Opening in ${R}...`),onError:R=>ut.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(Re,{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(Js,{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(Ct,{children:[u.jsx(Rt,{children:u.jsx(Mz,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),u.jsx(At,{children:u.jsx("p",{children:"Toggle theme"})})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsxs(Re,{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(Voe,{className:"size-4"}),u.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),u.jsx(At,{children:u.jsx("p",{children:"Command Palette"})})]}),u.jsxs(Ct,{children:[u.jsx(Rt,{asChild:!0,children:u.jsx(Re,{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(At,{children:u.jsx("p",{children:"Give us a star ⭐"})})]}),u.jsx(jz,{state:"expanded"})]})]})]})}function Txe({children:e}){const t=Nd(),n=Vo(),{servers:r,addServer:a,removeServer:o,updateServer:i,storageLoaded:c}=tm(),d=y.useCallback((D,P,V,W)=>{a(D,{url:D,name:P,proxyConfig:V,transportType:W})},[a]),f=y.useCallback(async(D,P)=>{try{await i(D,P)}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=Bge();y.useEffect(()=>{const D=new URLSearchParams(n.search),P=D.get("embedded")==="true",V=D.get("embeddedConfig");if(P){let W={};if(V)try{W=JSON.parse(V)}catch(te){console.error("Failed to parse embeddedConfig:",te)}T(!0,W)}},[]),y.useEffect(()=>{const P=new URLSearchParams(n.search).get("tunnelUrl");x(P)},[n.search,x]),y.useEffect(()=>{const P=new URLSearchParams(n.search).get("tab");P&&["tools","prompts","resources","chat","sampling","elicitation","notifications"].includes(P)&&v(P)},[n.search,v]),y.useEffect(()=>{const D=W=>{const fe=W.detail.requestId;m&&E(m,"sampling",fe)},P=W=>{const fe=W.detail.requestId;m&&E(m,"elicitation",fe)},V=W=>{const fe=W.detail.toolName;m&&fe?E(m,"tools",fe):m&&v("tools")};return window.addEventListener("navigate-to-sampling",D),window.addEventListener("navigate-to-elicitation",P),window.addEventListener("navigate-to-tool-result",V),()=>{window.removeEventListener("navigate-to-sampling",D),window.removeEventListener("navigate-to-elicitation",P),window.removeEventListener("navigate-to-tool-result",V)}},[m,v,E]);const j=y.useRef(null),L=y.useRef(null),z=y.useRef(null),{isAutoConnecting:H}=Fge({connections:r,addConnection:d,removeConnection:o,configLoaded:c,embedded:S}),Z=y.useCallback(D=>{Wr.getInstance().capture(new foe({trigger:D})).catch(()=>{}),C(!0)},[]),J=D=>{const P=r.find(le=>le.id===D);if(!P||P.state!=="ready"){ut.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"),fe=new URLSearchParams;fe.set("server",D),W&&fe.set("tunnelUrl",W),te&&fe.set("tab",te),t(`/?${fe.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),ut.success("Connection settings updated"))},[A,o,d,f]),Y=(D,P,V)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:D,itemName:P,serverId:V}),V){const W=r.find(ae=>ae.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"),ut.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:V,tab:D,itemName:P}),E(V,D,P);const te=new URLSearchParams(n.search),fe=te.get("tunnelUrl"),le=te.get("tab"),q=new URLSearchParams;q.set("server",V),fe&&q.set("tunnelUrl",fe),D?q.set("tab",D):le&&q.set("tab",le);const Q=`/?${q.toString()}`;console.warn("[Layout] Navigating to:",Q),t(Q)}else console.warn("[Layout] No serverId, just updating tab to:",D),v(D)},B=r.find(D=>D.id===m),re=B?B.tools.map(D=>({...D,_serverId:B.id})):r.flatMap(D=>D.state==="ready"?D.tools.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]),ee=B?B.prompts.map(D=>({...D,_serverId:B.id})):r.flatMap(D=>D.state==="ready"?D.prompts.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]),M=B?B.resources.map(D=>({...D,_serverId:B.id})):r.flatMap(D=>D.state==="ready"?D.resources.map(P=>({...P,_serverId:D.id,_serverName:D.name})):[]);if(y.useEffect(()=>{const P=new URLSearchParams(n.search).get("server"),V=P?decodeURIComponent(P):null;V!==m&&h(V)},[n.search,m,h]),y.useEffect(()=>{const P=new URLSearchParams(n.search).get("server");if(!P)return;const V=decodeURIComponent(P),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]),WV({onCommandPalette:()=>Z("keyboard"),onToolsTab:()=>{B&&v("tools")},onPromptsTab:()=>{B&&v("prompts")},onResourcesTab:()=>{B&&v("resources")},onChatTab:()=>{B&&v("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{g==="tools"&&j.current?j.current.focusSearch():g==="prompts"&&L.current?L.current.focusSearch():g==="resources"&&z.current&&z.current.focusSearch()},onBlurSearch:()=>{g==="tools"&&j.current?j.current.blurSearch():g==="prompts"&&L.current?L.current.blurSearch():g==="resources"&&z.current&&z.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(Qs,{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 F=S?{backgroundColor:_.backgroundColor||"#f3f3f3",padding:_.padding||"0.5rem"}:{},U=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:U,style:F,children:[u.jsx(_xe,{connections:r,selectedServer:B,activeTab:g,onServerSelect:J,onTabChange:v,onCommandPaletteOpen:()=>Z("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(vxe,{selectedServer:B,activeTab:g,toolsSearchRef:j,promptsSearchRef:L,resourcesSearchRef:z,children:e})}),u.jsx(ybe,{isOpen:R,onOpenChange:C,tools:re,prompts:ee,resources:M,savedRequests:O,connections:r,selectedServer:B,tunnelUrl:w,onNavigate:Y,onServerSelect:J}),u.jsx(uH,{connection:A&&r.find(D=>D.id===A)||null,open:A!==null,onOpenChange:D=>{D||I(null)},onConnect:G})]})})}function Nxe(){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(Fi,{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 kxe=(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{}},Cxe=y.createContext(void 0),Rxe={setTheme:e=>{},themes:[]},Axe=()=>{var e;return(e=y.useContext(Cxe))!=null?e:Rxe};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:`(${kxe.toString()})(${m})`}})});function Ixe({...e}){const{theme:t="system"}=Axe();return u.jsx(Zce,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Oxe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true",n=y.useMemo(()=>t?void 0:new vee("mcp-inspector-connections"),[t]);return u.jsx(Qde,{children:u.jsx(c4,{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=ut(u.jsx(fxe,{requestId:r.id,serverName:o,onViewDetails:()=>{const f=new CustomEvent("navigate-to-sampling",{detail:{requestId:r.id}});window.dispatchEvent(f),ut.dismiss(d)},onApprove:f=>{i(r.id,f),ut.success("Sampling request approved"),ut.dismiss(d)},onDeny:()=>{c(r.id,"User denied from toast"),ut.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=ut(u.jsx(mxe,{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),ut.dismiss(h)},onOpenUrl:d==="url"&&m?()=>{window.open(m,"_blank"),ut.dismiss(h)}:void 0,onCancel:()=>{c(r.id,"User cancelled from toast"),ut.dismiss(h)}}),{duration:1/0})},children:u.jsxs(zge,{children:[u.jsx(pce,{basename:"/inspector",children:u.jsxs(Vle,{children:[u.jsx(aS,{path:"/oauth/callback",element:u.jsx(Nxe,{})}),u.jsx(aS,{path:"/",element:u.jsx(Txe,{children:u.jsx(Uge,{})})})]})}),u.jsx(Ixe,{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?kee.createRoot(Vz).render(u.jsx(Oxe,{})):console.error("[inspector] Root element not found");const Dxe=Object.freeze(Object.defineProperty({__proto__:null,clearRpcLogs:Bb,getAllRpcLogs:tT,getRpcLogs:u4,subscribeToRpcLogs:nT,wrapTransportForLogging:d4},Symbol.toStringTag,{value:"Module"}));export{IK as $,$f as A,rJ as B,Aj as C,zxe as D,Gi as E,IY as F,BK as G,iee as H,X7 as I,nb as J,eW as K,AY as L,ree as M,AK as N,Pxe as O,W7 as P,Pi as Q,ie as R,JZ as S,Fs as T,Q2 as U,zn as V,XK as W,r2 as X,U7 as Y,Sq as Z,Me as _,fa as a,ob as a0,N7 as a1,lee as a2,k7 as a3,J_ as a4,z7 as a5,pd as b,Yp as c,aee as d,Ny as e,jxe as f,Mxe as g,see as h,We as i,$n as j,wq as k,Le as l,ct as m,bn as n,Ke as o,$xe as p,nF as q,y as r,ce as s,Bxe as t,Zn as u,Ha as v,Fn as w,Fxe as x,Uxe as y,qn as z};
|