@mcp-use/inspector 0.14.0-canary.8 → 0.14.0-canary.9

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.
Files changed (28) hide show
  1. package/dist/client/assets/{browser-C2Fn0YFm.js → browser-CAet5h5U.js} +3 -3
  2. package/dist/client/assets/{client-Bt6xNGvA.js → client-CAJCPqsR.js} +1 -1
  3. package/dist/client/assets/{display-A5IEINAP-CARbqwYz.js → display-A5IEINAP-CQoSnHLt.js} +2 -2
  4. package/dist/client/assets/{embeddings-CS1tQ9WC.js → embeddings-DtafgfMS.js} +1 -1
  5. package/dist/client/assets/{index-BGExFjwX.js → index-B8ArYgSz.js} +1 -1
  6. package/dist/client/assets/{index-CZ1ZJ4DA.js → index-BghX1ooe.js} +1 -1
  7. package/dist/client/assets/{index-w9z_NOXw.js → index-BwjhL_Ts.js} +1 -1
  8. package/dist/client/assets/{index-CWxR53gB.js → index-DXT6rsWo.js} +1 -1
  9. package/dist/client/assets/{index-BYhrMpLe.js → index-DfGhdcvP.js} +6 -6
  10. package/dist/client/assets/{index-B66nJ4Ui.js → index-DrmcYZGT.js} +1 -1
  11. package/dist/client/assets/{index-BHWuEnDp.js → index-Meiz2XrK.js} +1 -1
  12. package/dist/client/assets/{index-03ai9_N2.js → index-c1SU-y-r.js} +1 -1
  13. package/dist/client/assets/{index-CEc6a116.js → index-hiNxmj9U.js} +1 -1
  14. package/dist/client/assets/{llms-BT3kT7gN.js → llms-Bpg_7xxf.js} +1 -1
  15. package/dist/client/index.html +2 -2
  16. package/dist/server/{chunk-NOEIHEAG.js → chunk-4OEEUHLZ.js} +1 -1
  17. package/dist/server/{chunk-F7YWZTWJ.js → chunk-E4Y73JSU.js} +1 -1
  18. package/dist/server/{chunk-JCLAFMDT.js → chunk-PUX4EJWH.js} +11 -0
  19. package/dist/server/cli.js +2 -2
  20. package/dist/server/index.js +3 -3
  21. package/dist/server/middleware.js +3 -3
  22. package/dist/server/server.d.ts.map +1 -1
  23. package/dist/server/server.js +6 -24
  24. package/dist/server/shared-routes.js +2 -2
  25. package/dist/server/utils.d.ts +1 -0
  26. package/dist/server/utils.d.ts.map +1 -1
  27. package/dist/server/utils.js +5 -3
  28. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BHWuEnDp.js","assets/index-B66nJ4Ui.js","assets/index-w9z_NOXw.js","assets/llms-BT3kT7gN.js","assets/embeddings-CS1tQ9WC.js","assets/index-CWxR53gB.js","assets/index-CZ1ZJ4DA.js","assets/index-CEc6a116.js","assets/browser-C2Fn0YFm.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Meiz2XrK.js","assets/index-DrmcYZGT.js","assets/index-BwjhL_Ts.js","assets/llms-Bpg_7xxf.js","assets/embeddings-DtafgfMS.js","assets/index-DXT6rsWo.js","assets/index-BghX1ooe.js","assets/index-hiNxmj9U.js","assets/browser-CAet5h5U.js"])))=>i.map(i=>d[i]);
2
2
  var TJ=Object.defineProperty;var NJ=(e,t,n)=>t in e?TJ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var bg=(e,t,n)=>NJ(e,typeof t!="symbol"?t+"":t,n);function CJ(e,t){for(var n=0;n<t.length;n++){const a=t[n];if(typeof a!="string"&&!Array.isArray(a)){for(const r in a)if(r!=="default"&&!(r in e)){const i=Object.getOwnPropertyDescriptor(a,r);i&&Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>a[r]})}}}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 r of document.querySelectorAll('link[rel="modulepreload"]'))a(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&a(s)}).observe(document,{childList:!0,subtree:!0});function n(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(r){if(r.ep)return;r.ep=!0;const i=n(r);fetch(r.href,i)}})();function iy(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function bNe(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function a(){var r=!1;try{r=this instanceof a}catch{}return r?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(a){var r=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:function(){return e[a]}})}),n}var zx={exports:{}},Hf={};var SM;function RJ(){if(SM)return Hf;SM=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,r,i){var s=null;if(i!==void 0&&(s=""+i),r.key!==void 0&&(s=""+r.key),"key"in r){i={};for(var c in r)c!=="key"&&(i[c]=r[c])}else i=r;return r=i.ref,{$$typeof:e,type:a,key:s,ref:r!==void 0?r:null,props:i}}return Hf.Fragment=t,Hf.jsx=n,Hf.jsxs=n,Hf}var EM;function AJ(){return EM||(EM=1,zx.exports=RJ()),zx.exports}var d=AJ();const IJ="modulepreload",OJ=function(e){return"/inspector/"+e},_M={},ia=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){let u=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 s=document.querySelector("meta[property=csp-nonce]"),c=s?.nonce||s?.getAttribute("nonce");r=u(n.map(f=>{if(f=OJ(f),f in _M)return;_M[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":IJ,m||(g.as="script"),g.crossOrigin="",g.href=f,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,S)=>{g.addEventListener("load",v),g.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(s){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=s,window.dispatchEvent(c),!c.defaultPrevented)throw s}return r.then(s=>{for(const c of s||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};var DJ=Object.defineProperty,ke=(e,t)=>DJ(e,"name",{value:t,configurable:!0}),vNe=(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 xF(e){return e==="localhost"||e==="127.0.0.1"||e.startsWith("127.")||e.startsWith("192.168.")||e.startsWith("10.")||e.startsWith("172.")}ke(xF,"isLocalServer");function SF(e){const t=e.split(".");return t.length<=2?e:t.slice(t.length-2).join(".")}ke(SF,"getBaseDomain");function EF(e){return new Promise((t,n)=>{const a=new FileReader;a.onloadend=()=>{t(a.result)},a.onerror=n,a.readAsDataURL(e)})}ke(EF,"blobToBase64");async function _F(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],xF(t))return null;const n=SF(t),a=t!==n?[t,n]:[t];for(const r of a)try{const i=`https://favicon.tools.mcp-use.com/${r}`,s=new AbortController,c=setTimeout(()=>s.abort(),2e3);try{const u=await fetch(i,{signal:s.signal});if(clearTimeout(c),!u.ok)continue;const f=await u.blob();return await EF(f)}catch{clearTimeout(c);continue}}catch{continue}return null}catch(t){return console.warn("[favicon-detector] Error detecting favicon:",t),null}}ke(_F,"detectFavicon");function Xi(e){return e.replace(/[^a-zA-Z0-9-_]/g,"_").toLowerCase()}ke(Xi,"sanitizeServerName");function nc(e){return e.replace(/[^a-zA-Z0-9]/g,"_").toUpperCase().replace(/^_+|_+$/g,"")}ke(nc,"headerToEnvVar");function pk(e,t,n){const a={url:e};if(n&&Object.keys(n).length>0){const s={};for(const[c]of Object.entries(n)){const u=nc(c);s[c]=`{{${u}}}`}a.headers=s}const r=JSON.stringify(a);return`cursor://anysphere.cursor-deeplink/mcp/install?config=${btoa(r)}&name=${encodeURIComponent(Xi(t))}`}ke(pk,"generateCursorDeepLink");function mk(e,t,n){const a={url:e,name:Xi(t),type:"http"};if(n&&Object.keys(n).length>0){const s={};for(const[c]of Object.entries(n)){const u=nc(c);s[c]=`your-${u}-value`}a.headers=s}const r=JSON.stringify(a);return`vscode:mcp/install?${encodeURIComponent(r)}`}ke(mk,"generateVSCodeDeepLink");function kF(e,t,n){const a={url:e,name:Xi(t)};if(n&&Object.keys(n).length>0){const r={};for(const[i]of Object.entries(n)){const s=nc(i);r[i]=`your-${s}-value`}a.headers=r}return a}ke(kF,"generateMcpbConfig");function hk(e,t,n){try{const a=kF(e,t,n),r=JSON.stringify(a,null,2),i=globalThis.Blob,s=new i([r],{type:"application/json"}),c=URL.createObjectURL(s),u=document.createElement("a");u.href=c,u.download=`${Xi(t)}.mcpb`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(c)}catch(a){throw console.error("Failed to download .mcpb file:",a),a}}ke(hk,"downloadMcpbFile");function gk(e,t,n){let r=`claude mcp add --transport http "${Xi(t)}" \\
3
3
  "${e}"`;const i=[];if(n&&Object.keys(n).length>0)for(const[s]of Object.entries(n)){const c=nc(s);r+=` \\
4
4
  --header '${s}:\${${c}}'`,i.push({name:c,header:s})}return{command:r,envVars:i}}ke(gk,"generateClaudeCodeCommand");function bk(e,t,n){let r=`gemini mcp add --transport http "${Xi(t)}" "${e}"`;const i=[];if(n&&Object.keys(n).length>0)for(const[s]of Object.entries(n)){const c=nc(s);r+=` \\
@@ -62,7 +62,7 @@ print(f"Available resources: {[resource.name for resource in resources]}")
62
62
  # result = await session.call_tool("tool_name", {"param": "value"})
63
63
 
64
64
  # Read a resource (example)
65
- # resource_content = await session.read_resource("resource_uri")`}ke(NF,"generatePythonSDKCode");function yk(e,t){if(!t?.proxyAddress)return{url:e,headers:t?.customHeaders||{}};const n=new URL(t.proxyAddress),a=new URL(e),r=`${n.origin}${n.pathname}${a.pathname}${a.search}`,i={"X-Target-URL":e,...t.customHeaders};return{url:r,headers:i}}ke(yk,"applyProxyConfig");var Qf={},CF="mcp-use";function oE(e){switch((typeof process<"u"&&Qf?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}ke(oE,"resolveLevel");function RF(e){return e.length===0?"":e.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ")}ke(RF,"formatArgs");var Ou,jJ=(Ou=class{_level;name;format;constructor(t=CF,n="info",a="minimal"){this.name=t,this._level=n,this.format=a}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],a=n.indexOf(this._level);return n.indexOf(t)<=a}formatMessage(t,n,a){const r=new Date().toLocaleTimeString("en-US",{hour12:!1}),i=RF(a),s=i?`${n} ${i}`:n;switch(this.format){case"detailed":return`${r} [${this.name}] ${t.toUpperCase()}: ${s}`;case"emoji":{const c={error:"❌",warn:"⚠️",info:"ℹ️",http:"🌐",verbose:"📝",debug:"🔍",silly:"🤪"};return`${r} [${this.name}] ${c[t]||""} ${t.toUpperCase()}: ${s}`}case"minimal":default:return`${r} [${this.name}] ${t}: ${s}`}}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}},ke(Ou,"SimpleConsoleLogger"),Ou),Is,LJ=(Is=class{static get(t=CF){if(!this.instances[t]){const n=typeof process<"u"&&Qf?.DEBUG||void 0;this.instances[t]=new jJ(t,oE(n),this.currentFormat)}return this.instances[t]}static configure(t={}){const{level:n,format:a="minimal"}=t,r=typeof process<"u"&&Qf?.DEBUG||void 0,i=n??oE(r);this.currentFormat=a,Object.values(this.instances).forEach(s=>{s.level=i,s.setFormat(a)})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.instances).forEach(a=>{a.level=n}),typeof process<"u"&&Qf&&(Qf.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},ke(Is,"Logger"),bg(Is,"instances",{}),bg(Is,"currentFormat","minimal"),Is),$e=LJ.get(),$J="1.12.0-canary.8";function wk(){return $J}ke(wk,"getPackageVersion");var Du,Ti=(Du=class{},ke(Du,"BaseTelemetryEvent"),Du),ju,MJ=(ju=class extends Ti{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}}},ke(ju,"MCPAgentExecutionEvent"),ju);function AF(e,t){const n=Array.from(e.registrations.tools.values()),a=Array.from(e.registrations.prompts.values()),r=Array.from(e.registrations.resources.values()),i=Array.from(e.registrations.resourceTemplates.values()),s=r.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=s.filter(m=>m.mime_type==="text/html+skybridge"),u=s.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),f=s.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:s.length>0?s:null,prompts:a.length>0?a.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:i.length>0?i.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:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:f.length>0?f:null,mcpAppsResourcesNumber:f.length}}ke(AF,"createServerRunEventData");var Lu,PJ=(Lu=class extends Ti{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}}},ke(Lu,"ServerRunEvent"),Lu),$u,zJ=($u=class extends Ti{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}}},ke($u,"ServerInitializeEvent"),$u),Mu,UJ=(Mu=class extends Ti{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}}},ke(Mu,"ServerToolCallEvent"),Mu),Pu,FJ=(Pu=class extends Ti{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}}},ke(Pu,"ServerResourceCallEvent"),Pu),zu,BJ=(zu=class extends Ti{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}}},ke(zu,"ServerPromptCallEvent"),zu),Uu,HJ=(Uu=class extends Ti{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}}},ke(Uu,"ServerContextEvent"),Uu),Fu,VJ=(Fu=class extends Ti{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}}},ke(Fu,"MCPClientInitEvent"),Fu),Bu,GJ=(Bu=class extends Ti{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}}},ke(Bu,"ConnectorInitEvent"),Bu),Hu,WJ=(Hu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,a=n.url;return{server_name:t,server_url_domain:a?this._extractHostname(a):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},ke(Hu,"ClientAddServerEvent"),Hu),Vu,KJ=(Vu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},ke(Vu,"ClientRemoveServerEvent"),Vu);function IF(e){return e._llm_type||e.constructor.name.toLowerCase()}ke(IF,"getModelProvider");function OF(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}ke(OF,"getModelName");function ZJ(e){return[IF(e),OF(e)]}ke(ZJ,"extractModelInfo");function Rb(){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)}`}ke(Rb,"generateUUID");function Ab(){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)}ke(Ab,"secureRandomString");var kM="mcp_use_user_id";function DF(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}ke(DF,"detectRuntimeEnvironment");function jF(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"}ke(jF,"getStorageCapability");var Ux=null;function LF(){return Ux===null&&(Ux=DF()),Ux}ke(LF,"getRuntimeEnvironment");var hi,$F=(hi=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=LF(),this._storageCapability=jF(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";t?(this._posthogBrowserClient=null,$e.debug("Telemetry disabled via localStorage")):n?($e.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable."),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,$e.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 ia(()=>import("./module-D4IOASh4.js"),[]),a=n.default||n.posthog;if(!a||typeof a.init!="function")throw new Error("posthog-js module did not export expected interface");a.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:ke(()=>{$e.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=a}catch(t){$e.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return hi.instance||(hi.instance=new hi),hi.instance}setSource(t){this._source=t;try{typeof localStorage<"u"&&localStorage.setItem("MCP_USE_TELEMETRY_SOURCE",t)}catch{}$e.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-${Rb()}`}catch{this._currUserId=`session-${Date.now()}-${Ab()}`}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(kM);if(!t){try{t=Rb()}catch{t=`${Date.now()}-${Ab()}`}localStorage.setItem(kM,t)}return t}catch(t){$e.debug(`Failed to access localStorage for user ID: ${t}`);let n;try{n=`session-${Rb()}`}catch{n=`session-${Date.now()}-${Ab()}`}return n}}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;const n=this.userId,a={...t.properties};if(a.mcp_use_version=wk(),a.language="typescript",a.source=this._source,a.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(t.name,{...a,distinct_id:n})}catch(r){$e.debug(`Failed to track PostHog Browser event ${t.name}: ${r}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new MJ(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const a=AF(t,n),r=new PJ(a);await this.capture(r)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new zJ(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new UJ(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new FJ(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new BJ(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new HJ(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new VJ(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new GJ(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const a=new WJ({serverName:t,serverConfig:n});await this.capture(a)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new KJ({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(a){$e.debug(`Failed to identify user: ${a}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){$e.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(t){}},ke(hi,"Telemetry"),bg(hi,"instance",null),hi),Pi=$F;function YJ(e){Pi.getInstance().setSource(e)}ke(YJ,"setTelemetrySource");const MF=Object.freeze({status:"aborted"});function he(e,t,n){function a(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);const f=s.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 r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(c){var u;const f=n?.Parent?new i:this;a(f,c),(u=f._zod).deferred??(u.deferred=[]);for(const m of f._zod.deferred)m();return f}return Object.defineProperty(s,"init",{value:a}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}const PF=Symbol("zod_brand");class Dl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class oy extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const nv={};function qr(e){return e&&Object.assign(nv,e),nv}function qJ(e){return e}function XJ(e){return e}function JJ(e){}function QJ(e){throw new Error("Unexpected value in exhaustive check")}function eQ(e){}function xk(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function Ve(e,t="|"){return e.map(n=>bt(n)).join(t)}function rv(e,t){return typeof t=="bigint"?t.toString():t}function mm(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function rc(e){return e==null}function sy(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function zF(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let r=(a.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(a)){const u=a.match(/\d?e-(\d?)/);u?.[1]&&(r=Number.parseInt(u[1]))}const i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}const TM=Symbol("evaluating");function Kt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==TM)return a===void 0&&(a=TM,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function tQ(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Gs(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ho(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function nQ(e){return Ho(e._zod.def)}function rQ(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function aQ(e){const t=Object.keys(e),n=t.map(a=>e[a]);return Promise.all(n).then(a=>{const r={};for(let i=0;i<t.length;i++)r[t[i]]=a[i];return r})}function iQ(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let a=0;a<e;a++)n+=t[Math.floor(Math.random()*t.length)];return n}function sE(e){return JSON.stringify(e)}function UF(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Sk="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function nd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const FF=mm(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Hl(e){if(nd(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(nd(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ly(e){return Hl(e)?{...e}:Array.isArray(e)?[...e]:e}function oQ(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const sQ=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},av=new Set(["string","number","symbol"]),BF=new Set(["string","number","bigint","boolean","symbol","undefined"]);function jo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ni(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function Ae(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 lQ(e){let t;return new Proxy({},{get(n,a,r){return t??(t=e()),Reflect.get(t,a,r)},set(n,a,r,i){return t??(t=e()),Reflect.set(t,a,r,i)},has(n,a){return t??(t=e()),Reflect.has(t,a)},deleteProperty(n,a){return t??(t=e()),Reflect.deleteProperty(t,a)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,a){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(n,a,r){return t??(t=e()),Reflect.defineProperty(t,a,r)}})}function bt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function HF(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const VF={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]},GF={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function WF(e,t){const n=e._zod.def,a=Ho(e._zod.def,{get shape(){const r={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return Gs(this,"shape",r),r},checks:[]});return ni(e,a)}function KF(e,t){const n=e._zod.def,a=Ho(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return Gs(this,"shape",r),r},checks:[]});return ni(e,a)}function ZF(e,t){if(!Hl(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 r=Ho(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Gs(this,"shape",i),i},checks:[]});return ni(e,r)}function YF(e,t){if(!Hl(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const a={...e._zod.def.shape,...t};return Gs(this,"shape",a),a},checks:e._zod.def.checks};return ni(e,n)}function qF(e,t){const n=Ho(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Gs(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ni(e,n)}function XF(e,t,n){const a=Ho(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)i[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return Gs(this,"shape",i),i},checks:[]});return ni(t,a)}function JF(e,t,n){const a=Ho(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return Gs(this,"shape",i),i},checks:[]});return ni(t,a)}function Cl(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 gi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function ep(e){return typeof e=="string"?e:e?.message}function ti(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=ep(e.inst?._zod.def?.error?.(e))??ep(t?.error?.(e))??ep(n.customError?.(e))??ep(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function cy(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function uy(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function rd(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function cQ(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function QF(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function e3(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function uQ(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return QF(t+n)}function dQ(e){return e3(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function fQ(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let a=0;a<t.length;a+=2)n[a/2]=Number.parseInt(t.slice(a,a+2),16);return n}function pQ(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class mQ{constructor(...t){}}const t3=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:GF,Class:mQ,NUMBER_FORMAT_RANGES:VF,aborted:Cl,allowsEval:FF,assert:eQ,assertEqual:qJ,assertIs:JJ,assertNever:QJ,assertNotEqual:XJ,assignProp:Gs,base64ToUint8Array:QF,base64urlToUint8Array:uQ,cached:mm,captureStackTrace:Sk,cleanEnum:cQ,cleanRegex:sy,clone:ni,cloneDef:nQ,createTransparentProxy:lQ,defineLazy:Kt,esc:sE,escapeRegex:jo,extend:ZF,finalizeIssue:ti,floatSafeRemainder:zF,getElementAtPath:rQ,getEnumValues:xk,getLengthableOrigin:uy,getParsedType:sQ,getSizableOrigin:cy,hexToUint8Array:fQ,isObject:nd,isPlainObject:Hl,issue:rd,joinValues:Ve,jsonStringifyReplacer:rv,merge:qF,mergeDefs:Ho,normalizeParams:Ae,nullish:rc,numKeys:oQ,objectClone:tQ,omit:KF,optionalKeys:HF,partial:XF,pick:WF,prefixIssues:gi,primitiveTypes:BF,promiseAllObject:aQ,propertyKeyTypes:av,randomString:iQ,required:JF,safeExtend:YF,shallowClone:ly,slugify:UF,stringifyPrimitive:bt,uint8ArrayToBase64:e3,uint8ArrayToBase64url:dQ,uint8ArrayToHex:pQ,unwrapMessage:ep},Symbol.toStringTag,{value:"Module"})),n3=(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,rv,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ek=he("$ZodError",n3),Ma=he("$ZodError",n3,{Parent:Error});function _k(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function kk(e,t=n=>n.message){const n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>a({issues:s}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(t(i))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return a(e),n}function r3(e,t=n=>n.message){const n={errors:[]},a=(r,i=[])=>{var s,c;for(const u of r.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(f=>a({issues:f},u.path));else if(u.code==="invalid_key")a({issues:u.issues},u.path);else if(u.code==="invalid_element")a({issues:u.issues},u.path);else{const f=[...i,...u.path];if(f.length===0){n.errors.push(t(u));continue}let m=n,h=0;for(;h<f.length;){const g=f[h],v=h===f.length-1;typeof g=="string"?(m.properties??(m.properties={}),(s=m.properties)[g]??(s[g]={errors:[]}),m=m.properties[g]):(m.items??(m.items=[]),(c=m.items)[g]??(c[g]={errors:[]}),m=m.items[g]),v&&m.errors.push(t(u)),h++}}};return a(e),n}function a3(e){const t=[],n=e.map(a=>typeof a=="object"?a.key:a);for(const a of n)typeof a=="number"?t.push(`[${a}]`):typeof a=="symbol"?t.push(`[${JSON.stringify(String(a))}]`):/[^\w$]/.test(a)?t.push(`[${JSON.stringify(a)}]`):(t.length&&t.push("."),t.push(a));return t.join("")}function i3(e){const t=[],n=[...e.issues].sort((a,r)=>(a.path??[]).length-(r.path??[]).length);for(const a of n)t.push(`✖ ${a.message}`),a.path?.length&&t.push(` → at ${a3(a.path)}`);return t.join(`
65
+ # resource_content = await session.read_resource("resource_uri")`}ke(NF,"generatePythonSDKCode");function yk(e,t){if(!t?.proxyAddress)return{url:e,headers:t?.customHeaders||{}};const n=new URL(t.proxyAddress),a=new URL(e),r=`${n.origin}${n.pathname}${a.pathname}${a.search}`,i={"X-Target-URL":e,...t.customHeaders};return{url:r,headers:i}}ke(yk,"applyProxyConfig");var Qf={},CF="mcp-use";function oE(e){switch((typeof process<"u"&&Qf?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}ke(oE,"resolveLevel");function RF(e){return e.length===0?"":e.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ")}ke(RF,"formatArgs");var Ou,jJ=(Ou=class{_level;name;format;constructor(t=CF,n="info",a="minimal"){this.name=t,this._level=n,this.format=a}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],a=n.indexOf(this._level);return n.indexOf(t)<=a}formatMessage(t,n,a){const r=new Date().toLocaleTimeString("en-US",{hour12:!1}),i=RF(a),s=i?`${n} ${i}`:n;switch(this.format){case"detailed":return`${r} [${this.name}] ${t.toUpperCase()}: ${s}`;case"emoji":{const c={error:"❌",warn:"⚠️",info:"ℹ️",http:"🌐",verbose:"📝",debug:"🔍",silly:"🤪"};return`${r} [${this.name}] ${c[t]||""} ${t.toUpperCase()}: ${s}`}case"minimal":default:return`${r} [${this.name}] ${t}: ${s}`}}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}},ke(Ou,"SimpleConsoleLogger"),Ou),Is,LJ=(Is=class{static get(t=CF){if(!this.instances[t]){const n=typeof process<"u"&&Qf?.DEBUG||void 0;this.instances[t]=new jJ(t,oE(n),this.currentFormat)}return this.instances[t]}static configure(t={}){const{level:n,format:a="minimal"}=t,r=typeof process<"u"&&Qf?.DEBUG||void 0,i=n??oE(r);this.currentFormat=a,Object.values(this.instances).forEach(s=>{s.level=i,s.setFormat(a)})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.instances).forEach(a=>{a.level=n}),typeof process<"u"&&Qf&&(Qf.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},ke(Is,"Logger"),bg(Is,"instances",{}),bg(Is,"currentFormat","minimal"),Is),$e=LJ.get(),$J="1.12.0-canary.9";function wk(){return $J}ke(wk,"getPackageVersion");var Du,Ti=(Du=class{},ke(Du,"BaseTelemetryEvent"),Du),ju,MJ=(ju=class extends Ti{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}}},ke(ju,"MCPAgentExecutionEvent"),ju);function AF(e,t){const n=Array.from(e.registrations.tools.values()),a=Array.from(e.registrations.prompts.values()),r=Array.from(e.registrations.resources.values()),i=Array.from(e.registrations.resourceTemplates.values()),s=r.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=s.filter(m=>m.mime_type==="text/html+skybridge"),u=s.filter(m=>m.mime_type==="text/uri-list"||m.mime_type==="text/html"),f=s.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:s.length>0?s:null,prompts:a.length>0?a.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:i.length>0?i.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:u.length>0?u:null,mcpUiResourcesNumber:u.length,mcpAppsResources:f.length>0?f:null,mcpAppsResourcesNumber:f.length}}ke(AF,"createServerRunEventData");var Lu,PJ=(Lu=class extends Ti{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}}},ke(Lu,"ServerRunEvent"),Lu),$u,zJ=($u=class extends Ti{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}}},ke($u,"ServerInitializeEvent"),$u),Mu,UJ=(Mu=class extends Ti{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}}},ke(Mu,"ServerToolCallEvent"),Mu),Pu,FJ=(Pu=class extends Ti{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}}},ke(Pu,"ServerResourceCallEvent"),Pu),zu,BJ=(zu=class extends Ti{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}}},ke(zu,"ServerPromptCallEvent"),zu),Uu,HJ=(Uu=class extends Ti{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}}},ke(Uu,"ServerContextEvent"),Uu),Fu,VJ=(Fu=class extends Ti{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}}},ke(Fu,"MCPClientInitEvent"),Fu),Bu,GJ=(Bu=class extends Ti{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}}},ke(Bu,"ConnectorInitEvent"),Bu),Hu,WJ=(Hu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_add_server"}get properties(){const{serverName:t,serverConfig:n}=this.data,a=n.url;return{server_name:t,server_url_domain:a?this._extractHostname(a):null,transport:n.transport??null,has_auth:!!(n.authToken||n.authProvider)}}_extractHostname(t){try{return new URL(t).hostname}catch{return null}}},ke(Hu,"ClientAddServerEvent"),Hu),Vu,KJ=(Vu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},ke(Vu,"ClientRemoveServerEvent"),Vu);function IF(e){return e._llm_type||e.constructor.name.toLowerCase()}ke(IF,"getModelProvider");function OF(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}ke(OF,"getModelName");function ZJ(e){return[IF(e),OF(e)]}ke(ZJ,"extractModelInfo");function Rb(){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)}`}ke(Rb,"generateUUID");function Ab(){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)}ke(Ab,"secureRandomString");var kM="mcp_use_user_id";function DF(){try{return typeof window<"u"&&typeof document<"u"?"browser":"unknown"}catch{return"unknown"}}ke(DF,"detectRuntimeEnvironment");function jF(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"}ke(jF,"getStorageCapability");var Ux=null;function LF(){return Ux===null&&(Ux=DF()),Ux}ke(LF,"getRuntimeEnvironment");var hi,$F=(hi=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=LF(),this._storageCapability=jF(this._runtimeEnvironment),this._source=this._getSourceFromLocalStorage()||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";t?(this._posthogBrowserClient=null,$e.debug("Telemetry disabled via localStorage")):n?($e.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false in localStorage to disable."),this._posthogLoading=this._initPostHogBrowser()):(this._posthogBrowserClient=null,$e.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 ia(()=>import("./module-D4IOASh4.js"),[]),a=n.default||n.posthog;if(!a||typeof a.init!="function")throw new Error("posthog-js module did not export expected interface");a.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:ke(()=>{$e.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=a}catch(t){$e.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return hi.instance||(hi.instance=new hi),hi.instance}setSource(t){this._source=t;try{typeof localStorage<"u"&&localStorage.setItem("MCP_USE_TELEMETRY_SOURCE",t)}catch{}$e.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-${Rb()}`}catch{this._currUserId=`session-${Date.now()}-${Ab()}`}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(kM);if(!t){try{t=Rb()}catch{t=`${Date.now()}-${Ab()}`}localStorage.setItem(kM,t)}return t}catch(t){$e.debug(`Failed to access localStorage for user ID: ${t}`);let n;try{n=`session-${Rb()}`}catch{n=`session-${Date.now()}-${Ab()}`}return n}}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogBrowserClient)return;const n=this.userId,a={...t.properties};if(a.mcp_use_version=wk(),a.language="typescript",a.source=this._source,a.runtime=this._runtimeEnvironment,this._posthogBrowserClient)try{this._posthogBrowserClient.capture(t.name,{...a,distinct_id:n})}catch(r){$e.debug(`Failed to track PostHog Browser event ${t.name}: ${r}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new MJ(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const a=AF(t,n),r=new PJ(a);await this.capture(r)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new zJ(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new UJ(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new FJ(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new BJ(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new HJ(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new VJ(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new GJ(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const a=new WJ({serverName:t,serverConfig:n});await this.capture(a)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new KJ({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(a){$e.debug(`Failed to identify user: ${a}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){$e.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){}shutdown(){}async trackPackageDownload(t){}},ke(hi,"Telemetry"),bg(hi,"instance",null),hi),Pi=$F;function YJ(e){Pi.getInstance().setSource(e)}ke(YJ,"setTelemetrySource");const MF=Object.freeze({status:"aborted"});function he(e,t,n){function a(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:s,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);const f=s.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 r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(c){var u;const f=n?.Parent?new i:this;a(f,c),(u=f._zod).deferred??(u.deferred=[]);for(const m of f._zod.deferred)m();return f}return Object.defineProperty(s,"init",{value:a}),Object.defineProperty(s,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}const PF=Symbol("zod_brand");class Dl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class oy extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const nv={};function qr(e){return e&&Object.assign(nv,e),nv}function qJ(e){return e}function XJ(e){return e}function JJ(e){}function QJ(e){throw new Error("Unexpected value in exhaustive check")}function eQ(e){}function xk(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function Ve(e,t="|"){return e.map(n=>bt(n)).join(t)}function rv(e,t){return typeof t=="bigint"?t.toString():t}function mm(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function rc(e){return e==null}function sy(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function zF(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let r=(a.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(a)){const u=a.match(/\d?e-(\d?)/);u?.[1]&&(r=Number.parseInt(u[1]))}const i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}const TM=Symbol("evaluating");function Kt(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==TM)return a===void 0&&(a=TM,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function tQ(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Gs(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ho(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function nQ(e){return Ho(e._zod.def)}function rQ(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function aQ(e){const t=Object.keys(e),n=t.map(a=>e[a]);return Promise.all(n).then(a=>{const r={};for(let i=0;i<t.length;i++)r[t[i]]=a[i];return r})}function iQ(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let a=0;a<e;a++)n+=t[Math.floor(Math.random()*t.length)];return n}function sE(e){return JSON.stringify(e)}function UF(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Sk="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function nd(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const FF=mm(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function Hl(e){if(nd(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(nd(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ly(e){return Hl(e)?{...e}:Array.isArray(e)?[...e]:e}function oQ(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const sQ=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},av=new Set(["string","number","symbol"]),BF=new Set(["string","number","bigint","boolean","symbol","undefined"]);function jo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ni(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function Ae(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 lQ(e){let t;return new Proxy({},{get(n,a,r){return t??(t=e()),Reflect.get(t,a,r)},set(n,a,r,i){return t??(t=e()),Reflect.set(t,a,r,i)},has(n,a){return t??(t=e()),Reflect.has(t,a)},deleteProperty(n,a){return t??(t=e()),Reflect.deleteProperty(t,a)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,a){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,a)},defineProperty(n,a,r){return t??(t=e()),Reflect.defineProperty(t,a,r)}})}function bt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function HF(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const VF={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]},GF={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function WF(e,t){const n=e._zod.def,a=Ho(e._zod.def,{get shape(){const r={};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(r[i]=n.shape[i])}return Gs(this,"shape",r),r},checks:[]});return ni(e,a)}function KF(e,t){const n=e._zod.def,a=Ho(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const i in t){if(!(i in n.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete r[i]}return Gs(this,"shape",r),r},checks:[]});return ni(e,a)}function ZF(e,t){if(!Hl(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 r=Ho(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Gs(this,"shape",i),i},checks:[]});return ni(e,r)}function YF(e,t){if(!Hl(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const a={...e._zod.def.shape,...t};return Gs(this,"shape",a),a},checks:e._zod.def.checks};return ni(e,n)}function qF(e,t){const n=Ho(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Gs(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ni(e,n)}function XF(e,t,n){const a=Ho(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)i[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return Gs(this,"shape",i),i},checks:[]});return ni(t,a)}function JF(e,t,n){const a=Ho(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return Gs(this,"shape",i),i},checks:[]});return ni(t,a)}function Cl(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 gi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function ep(e){return typeof e=="string"?e:e?.message}function ti(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=ep(e.inst?._zod.def?.error?.(e))??ep(t?.error?.(e))??ep(n.customError?.(e))??ep(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function cy(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function uy(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function rd(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function cQ(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function QF(e){const t=atob(e),n=new Uint8Array(t.length);for(let a=0;a<t.length;a++)n[a]=t.charCodeAt(a);return n}function e3(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function uQ(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return QF(t+n)}function dQ(e){return e3(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function fQ(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let a=0;a<t.length;a+=2)n[a/2]=Number.parseInt(t.slice(a,a+2),16);return n}function pQ(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class mQ{constructor(...t){}}const t3=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:GF,Class:mQ,NUMBER_FORMAT_RANGES:VF,aborted:Cl,allowsEval:FF,assert:eQ,assertEqual:qJ,assertIs:JJ,assertNever:QJ,assertNotEqual:XJ,assignProp:Gs,base64ToUint8Array:QF,base64urlToUint8Array:uQ,cached:mm,captureStackTrace:Sk,cleanEnum:cQ,cleanRegex:sy,clone:ni,cloneDef:nQ,createTransparentProxy:lQ,defineLazy:Kt,esc:sE,escapeRegex:jo,extend:ZF,finalizeIssue:ti,floatSafeRemainder:zF,getElementAtPath:rQ,getEnumValues:xk,getLengthableOrigin:uy,getParsedType:sQ,getSizableOrigin:cy,hexToUint8Array:fQ,isObject:nd,isPlainObject:Hl,issue:rd,joinValues:Ve,jsonStringifyReplacer:rv,merge:qF,mergeDefs:Ho,normalizeParams:Ae,nullish:rc,numKeys:oQ,objectClone:tQ,omit:KF,optionalKeys:HF,partial:XF,pick:WF,prefixIssues:gi,primitiveTypes:BF,promiseAllObject:aQ,propertyKeyTypes:av,randomString:iQ,required:JF,safeExtend:YF,shallowClone:ly,slugify:UF,stringifyPrimitive:bt,uint8ArrayToBase64:e3,uint8ArrayToBase64url:dQ,uint8ArrayToHex:pQ,unwrapMessage:ep},Symbol.toStringTag,{value:"Module"})),n3=(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,rv,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ek=he("$ZodError",n3),Ma=he("$ZodError",n3,{Parent:Error});function _k(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function kk(e,t=n=>n.message){const n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>a({issues:s}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let s=n,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(t(i))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return a(e),n}function r3(e,t=n=>n.message){const n={errors:[]},a=(r,i=[])=>{var s,c;for(const u of r.issues)if(u.code==="invalid_union"&&u.errors.length)u.errors.map(f=>a({issues:f},u.path));else if(u.code==="invalid_key")a({issues:u.issues},u.path);else if(u.code==="invalid_element")a({issues:u.issues},u.path);else{const f=[...i,...u.path];if(f.length===0){n.errors.push(t(u));continue}let m=n,h=0;for(;h<f.length;){const g=f[h],v=h===f.length-1;typeof g=="string"?(m.properties??(m.properties={}),(s=m.properties)[g]??(s[g]={errors:[]}),m=m.properties[g]):(m.items??(m.items=[]),(c=m.items)[g]??(c[g]={errors:[]}),m=m.items[g]),v&&m.errors.push(t(u)),h++}}};return a(e),n}function a3(e){const t=[],n=e.map(a=>typeof a=="object"?a.key:a);for(const a of n)typeof a=="number"?t.push(`[${a}]`):typeof a=="symbol"?t.push(`[${JSON.stringify(String(a))}]`):/[^\w$]/.test(a)?t.push(`[${JSON.stringify(a)}]`):(t.length&&t.push("."),t.push(a));return t.join("")}function i3(e){const t=[],n=[...e.issues].sort((a,r)=>(a.path??[]).length-(r.path??[]).length);for(const a of n)t.push(`✖ ${a.message}`),a.path?.length&&t.push(` → at ${a3(a.path)}`);return t.join(`
66
66
  `)}const hm=e=>(t,n,a,r)=>{const i=a?Object.assign(a,{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Dl;if(s.issues.length){const c=new(r?.Err??e)(s.issues.map(u=>ti(u,i,qr())));throw Sk(c,r?.callee),c}return s.value},lE=hm(Ma),gm=e=>async(t,n,a,r)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const c=new(r?.Err??e)(s.issues.map(u=>ti(u,i,qr())));throw Sk(c,r?.callee),c}return s.value},cE=gm(Ma),bm=e=>(t,n,a)=>{const r=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new Dl;return i.issues.length?{success:!1,error:new(e??Ek)(i.issues.map(s=>ti(s,r,qr())))}:{success:!0,data:i.value}},Tk=bm(Ma),vm=e=>async(t,n,a)=>{const r=a?Object.assign(a,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>ti(s,r,qr())))}:{success:!0,data:i.value}},o3=vm(Ma),Nk=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return hm(e)(t,n,r)},hQ=Nk(Ma),Ck=e=>(t,n,a)=>hm(e)(t,n,a),gQ=Ck(Ma),Rk=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return gm(e)(t,n,r)},bQ=Rk(Ma),Ak=e=>async(t,n,a)=>gm(e)(t,n,a),vQ=Ak(Ma),Ik=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return bm(e)(t,n,r)},yQ=Ik(Ma),Ok=e=>(t,n,a)=>bm(e)(t,n,a),wQ=Ok(Ma),Dk=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return vm(e)(t,n,r)},xQ=Dk(Ma),jk=e=>async(t,n,a)=>vm(e)(t,n,a),SQ=jk(Ma),s3=/^[cC][^\s-]{8,}$/,l3=/^[0-9a-z]+$/,c3=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,u3=/^[0-9a-vA-V]{20}$/,d3=/^[A-Za-z0-9]{27}$/,f3=/^[a-zA-Z0-9_-]{21}$/,p3=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,EQ=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,m3=/^([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})$/,ad=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)$/,_Q=ad(4),kQ=ad(6),TQ=ad(7),h3=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,NQ=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,CQ=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,g3=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,RQ=g3,AQ=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,IQ="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function b3(){return new RegExp(IQ,"u")}const v3=/^(?:(?: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])$/,y3=/^(([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}|:))$/,w3=e=>{const t=jo(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},x3=/^((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])$/,S3=/^(([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])$/,E3=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Lk=/^[A-Za-z0-9_-]*$/,_3=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,k3=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,T3=/^\+(?:[0-9]){6,14}[0-9]$/,N3="(?:(?:\\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])))",C3=new RegExp(`^${N3}$`);function R3(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 A3(e){return new RegExp(`^${R3(e)}$`)}function I3(e){const t=R3({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${N3}T(?:${a})$`)}const O3=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},D3=/^-?\d+n?$/,j3=/^-?\d+$/,L3=/^-?\d+(?:\.\d+)?/,$3=/^(?:true|false)$/i,M3=/^null$/i,P3=/^undefined$/i,z3=/^[^A-Z]*$/,U3=/^[^a-z]*$/,F3=/^[0-9a-fA-F]*$/;function ym(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function wm(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const OQ=/^[0-9a-fA-F]{32}$/,DQ=ym(22,"=="),jQ=wm(22),LQ=/^[0-9a-fA-F]{40}$/,$Q=ym(27,"="),MQ=wm(27),PQ=/^[0-9a-fA-F]{64}$/,zQ=ym(43,"="),UQ=wm(43),FQ=/^[0-9a-fA-F]{96}$/,BQ=ym(64,""),HQ=wm(64),VQ=/^[0-9a-fA-F]{128}$/,GQ=ym(86,"=="),WQ=wm(86),$k=Object.freeze(Object.defineProperty({__proto__:null,base64:E3,base64url:Lk,bigint:D3,boolean:$3,browserEmail:AQ,cidrv4:x3,cidrv6:S3,cuid:s3,cuid2:l3,date:C3,datetime:I3,domain:k3,duration:p3,e164:T3,email:h3,emoji:b3,extendedDuration:EQ,guid:m3,hex:F3,hostname:_3,html5Email:NQ,idnEmail:RQ,integer:j3,ipv4:v3,ipv6:y3,ksuid:d3,lowercase:z3,mac:w3,md5_base64:DQ,md5_base64url:jQ,md5_hex:OQ,nanoid:f3,null:M3,number:L3,rfc5322Email:CQ,sha1_base64:$Q,sha1_base64url:MQ,sha1_hex:LQ,sha256_base64:zQ,sha256_base64url:UQ,sha256_hex:PQ,sha384_base64:BQ,sha384_base64url:HQ,sha384_hex:FQ,sha512_base64:GQ,sha512_base64url:WQ,sha512_hex:VQ,string:O3,time:A3,ulid:c3,undefined:P3,unicodeEmail:g3,uppercase:U3,uuid:ad,uuid4:_Q,uuid6:kQ,uuid7:TQ,xid:u3},Symbol.toStringTag,{value:"Module"})),Vn=he("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),B3={number:"number",bigint:"bigint",object:"date"},Mk=he("$ZodCheckLessThan",(e,t)=>{Vn.init(e,t);const n=B3[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pk=he("$ZodCheckGreaterThan",(e,t)=>{Vn.init(e,t);const n=B3[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),H3=he("$ZodCheckMultipleOf",(e,t)=>{Vn.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.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):zF(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})}}),V3=he("$ZodCheckNumberFormat",(e,t)=>{Vn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[r,i]=VF[t.format];e._zod.onattach.push(s=>{const c=s._zod.bag;c.format=t.format,c.minimum=r,c.maximum=i,n&&(c.pattern=j3)}),e._zod.check=s=>{const c=s.value;if(n){if(!Number.isInteger(c)){s.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,continue:!t.abort}):s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,continue:!t.abort});return}}c<r&&s.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>i&&s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inst:e})}}),G3=he("$ZodCheckBigIntFormat",(e,t)=>{Vn.init(e,t);const[n,a]=GF[t.format];e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,i.minimum=n,i.maximum=a}),e._zod.check=r=>{const i=r.value;i<n&&r.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>a&&r.issues.push({origin:"bigint",input:i,code:"too_big",maximum:a,inst:e})}}),W3=he("$ZodCheckMaxSize",(e,t)=>{var n;Vn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!rc(r)&&r.size!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;r.size<=t.maximum||a.issues.push({origin:cy(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),K3=he("$ZodCheckMinSize",(e,t)=>{var n;Vn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!rc(r)&&r.size!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;r.size>=t.minimum||a.issues.push({origin:cy(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Z3=he("$ZodCheckSizeEquals",(e,t)=>{var n;Vn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!rc(r)&&r.size!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=a=>{const r=a.value,i=r.size;if(i===t.size)return;const s=i>t.size;a.issues.push({origin:cy(r),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),Y3=he("$ZodCheckMaxLength",(e,t)=>{var n;Vn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!rc(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;if(r.length<=t.maximum)return;const s=uy(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),q3=he("$ZodCheckMinLength",(e,t)=>{var n;Vn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!rc(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;if(r.length>=t.minimum)return;const s=uy(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),X3=he("$ZodCheckLengthEquals",(e,t)=>{var n;Vn.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!rc(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=a=>{const r=a.value,i=r.length;if(i===t.length)return;const s=uy(r),c=i>t.length;a.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),xm=he("$ZodCheckStringFormat",(e,t)=>{var n,a;Vn.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),J3=he("$ZodCheckRegex",(e,t)=>{xm.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})}}),Q3=he("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=z3),xm.init(e,t)}),eB=he("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=U3),xm.init(e,t)}),tB=he("$ZodCheckIncludes",(e,t)=>{Vn.init(e,t);const n=jo(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),nB=he("$ZodCheckStartsWith",(e,t)=>{Vn.init(e,t);const n=new RegExp(`^${jo(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),rB=he("$ZodCheckEndsWith",(e,t)=>{Vn.init(e,t);const n=new RegExp(`.*${jo(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}});function NM(e,t,n){e.issues.length&&t.issues.push(...gi(n,e.issues))}const aB=he("$ZodCheckProperty",(e,t)=>{Vn.init(e,t),e._zod.check=n=>{const a=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(a instanceof Promise)return a.then(r=>NM(r,n,t.property));NM(a,n,t.property)}}),iB=he("$ZodCheckMimeType",(e,t)=>{Vn.init(e,t);const n=new Set(t.mime);e._zod.onattach.push(a=>{a._zod.bag.mime=t.mime}),e._zod.check=a=>{n.has(a.value.type)||a.issues.push({code:"invalid_value",values:t.mime,input:a.value.type,inst:e,continue:!t.abort})}}),oB=he("$ZodCheckOverwrite",(e,t)=>{Vn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class sB{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 a=t.split(`
67
67
  `).filter(s=>s),r=Math.min(...a.map(s=>s.length-s.trimStart().length)),i=a.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
68
68
  `))}}const lB={major:4,minor:2,patch:0},_t=he("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=lB;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const r of a)for(const i of r._zod.onattach)i(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(s,c,u)=>{let f=Cl(s),m;for(const h of c){if(h._zod.def.when){if(!h._zod.def.when(s))continue}else if(f)continue;const g=s.issues.length,v=h._zod.check(s);if(v instanceof Promise&&u?.async===!1)throw new Dl;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,s.issues.length!==g&&(f||(f=Cl(s,g)))});else{if(s.issues.length===g)continue;f||(f=Cl(s,g))}}return m?m.then(()=>s):s},i=(s,c,u)=>{if(Cl(s))return s.aborted=!0,s;const f=r(c,a,u);if(f instanceof Promise){if(u.async===!1)throw new Dl;return f.then(m=>e._zod.parse(m,u))}return e._zod.parse(f,u)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){const f=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return f instanceof Promise?f.then(m=>i(m,s,c)):i(f,s,c)}const u=e._zod.parse(s,c);if(u instanceof Promise){if(c.async===!1)throw new Dl;return u.then(f=>r(f,a,c))}return r(u,a,c)}}e["~standard"]={validate:r=>{try{const i=Tk(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return o3(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),Sm=he("$ZodString",(e,t)=>{_t.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??O3(e._zod.bag),e._zod.parse=(n,a)=>{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}}),Rn=he("$ZodStringFormat",(e,t)=>{xm.init(e,t),Sm.init(e,t)}),cB=he("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=m3),Rn.init(e,t)}),uB=he("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ad(a))}else t.pattern??(t.pattern=ad());Rn.init(e,t)}),dB=he("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=h3),Rn.init(e,t)}),fB=he("$ZodURL",(e,t)=>{Rn.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),r=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.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(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.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=r.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),pB=he("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=b3()),Rn.init(e,t)}),mB=he("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=f3),Rn.init(e,t)}),hB=he("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=s3),Rn.init(e,t)}),gB=he("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=l3),Rn.init(e,t)}),bB=he("$ZodULID",(e,t)=>{t.pattern??(t.pattern=c3),Rn.init(e,t)}),vB=he("$ZodXID",(e,t)=>{t.pattern??(t.pattern=u3),Rn.init(e,t)}),yB=he("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=d3),Rn.init(e,t)}),wB=he("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=I3(t)),Rn.init(e,t)}),xB=he("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=C3),Rn.init(e,t)}),SB=he("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=A3(t)),Rn.init(e,t)}),EB=he("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=p3),Rn.init(e,t)}),_B=he("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=v3),Rn.init(e,t),e._zod.bag.format="ipv4"}),kB=he("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=y3),Rn.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})}}}),TB=he("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=w3(t.delimiter)),Rn.init(e,t),e._zod.bag.format="mac"}),NB=he("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=x3),Rn.init(e,t)}),CB=he("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=S3),Rn.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[r,i]=a;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function zk(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const RB=he("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=E3),Rn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{zk(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function AB(e){if(!Lk.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return zk(n)}const IB=he("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Lk),Rn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{AB(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),OB=he("$ZodE164",(e,t)=>{t.pattern??(t.pattern=T3),Rn.init(e,t)});function DB(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const r=JSON.parse(atob(a));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const jB=he("$ZodJWT",(e,t)=>{Rn.init(e,t),e._zod.check=n=>{DB(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),LB=he("$ZodCustomStringFormat",(e,t)=>{Rn.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),Uk=he("$ZodNumber",(e,t)=>{_t.init(e,t),e._zod.pattern=e._zod.bag.pattern??L3,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),$B=he("$ZodNumberFormat",(e,t)=>{V3.init(e,t),Uk.init(e,t)}),Fk=he("$ZodBoolean",(e,t)=>{_t.init(e,t),e._zod.pattern=$3,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Bk=he("$ZodBigInt",(e,t)=>{_t.init(e,t),e._zod.pattern=D3,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),MB=he("$ZodBigIntFormat",(e,t)=>{G3.init(e,t),Bk.init(e,t)}),PB=he("$ZodSymbol",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),zB=he("$ZodUndefined",(e,t)=>{_t.init(e,t),e._zod.pattern=P3,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,a)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),UB=he("$ZodNull",(e,t)=>{_t.init(e,t),e._zod.pattern=M3,e._zod.values=new Set([null]),e._zod.parse=(n,a)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),FB=he("$ZodAny",(e,t)=>{_t.init(e,t),e._zod.parse=n=>n}),BB=he("$ZodUnknown",(e,t)=>{_t.init(e,t),e._zod.parse=n=>n}),HB=he("$ZodNever",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),VB=he("$ZodVoid",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),GB=he("$ZodDate",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const r=n.value,i=r instanceof Date;return i&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...i?{received:"Invalid Date"}:{},inst:e}),n}});function CM(e,t,n){e.issues.length&&t.issues.push(...gi(n,e.issues)),t.value[n]=e.value}const WB=he("$ZodArray",(e,t)=>{_t.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let s=0;s<r.length;s++){const c=r[s],u=t.element._zod.run({value:c,issues:[]},a);u instanceof Promise?i.push(u.then(f=>CM(f,n,s))):CM(u,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function iv(e,t,n,a){e.issues.length&&t.issues.push(...gi(n,e.issues)),e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function KB(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=HF(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ZB(e,t,n,a,r,i){const s=[],c=r.keySet,u=r.catchall._zod,f=u.def.type;for(const m in t){if(c.has(m))continue;if(f==="never"){s.push(m);continue}const h=u.run({value:t[m],issues:[]},a);h instanceof Promise?e.push(h.then(g=>iv(g,n,m,t))):iv(h,n,m,t)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const YB=he("$ZodObject",(e,t)=>{if(_t.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}const a=mm(()=>KB(t));Kt(e._zod,"propValues",()=>{const c=t.shape,u={};for(const f in c){const m=c[f]._zod;if(m.values){u[f]??(u[f]=new Set);for(const h of m.values)u[f].add(h)}}return u});const r=nd,i=t.catchall;let s;e._zod.parse=(c,u)=>{s??(s=a.value);const f=c.value;if(!r(f))return c.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),c;c.value={};const m=[],h=s.shape;for(const g of s.keys){const S=h[g]._zod.run({value:f[g],issues:[]},u);S instanceof Promise?m.push(S.then(x=>iv(x,c,g,f))):iv(S,c,g,f)}return i?ZB(m,f,c,u,a.value,e):m.length?Promise.all(m).then(()=>c):c}}),qB=he("$ZodObjectJIT",(e,t)=>{YB.init(e,t);const n=e._zod.parse,a=mm(()=>KB(t)),r=g=>{const v=new sB(["shape","payload","ctx"]),S=a.value,x=k=>{const R=sE(k);return`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`};v.write("const input = payload.value;");const w=Object.create(null);let E=0;for(const k of S.keys)w[k]=`key_${E++}`;v.write("const newResult = {};");for(const k of S.keys){const R=w[k],N=sE(k);v.write(`const ${R} = ${x(k)};`),v.write(`
@@ -95,7 +95,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
95
95
  `;break;case"id":c=w.includes("\0")?void 0:w;break;case"retry":/^\d+$/.test(w)?a(parseInt(w,10)):n(new pz(`Invalid \`retry\` value: "${w}"`,{type:"invalid-retry",value:w,line:E}));break;default:n(new pz(`Unknown field "${x.length>20?`${x.slice(0,20)}…`:x}"`,{type:"unknown-field",field:x,value:w,line:E}));break}}function v(){u.length>0&&t({id:c,event:f||void 0,data:u.endsWith(`
96
96
  `)?u.slice(0,-1):u}),c=void 0,u="",f=""}function S(x={}){i&&x.consume&&h(i),s=!0,c=void 0,u="",f="",i=""}return{feed:m,reset:S}}function Doe(e){const t=[];let n="",a=0;for(;a<e.length;){const r=e.indexOf("\r",a),i=e.indexOf(`
97
97
  `,a);let s=-1;if(r!==-1&&i!==-1?s=Math.min(r,i):r!==-1?r===e.length-1?s=-1:s=r:i!==-1&&(s=i),s===-1){n=e.slice(a);break}else{const c=e.slice(a,s);t.push(c),a=s+1,e[a-1]==="\r"&&e[a]===`
98
- `&&a++}}return[t,n]}class joe extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let r;super({start(i){r=b9({onEvent:s=>{i.enqueue(s)},onError(s){t==="terminate"?i.error(s):typeof t=="function"&&t(s)},onRetry:n,onComment:a})},transform(i){r.feed(i)}})}}const Loe={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 $oe{constructor(t,n){var a;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=r9(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(a=n?.reconnectionOptions)!==null&&a!==void 0?a:Loe}async _authThenStart(){var t;if(!this._authProvider)throw new qa("No auth provider");let n;try{n=await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new qa;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(n["mcp-session-id"]=this._sessionId),this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=gv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}async _startOrAuthSse(t){var n,a,r,i;const{resumptionToken:s}=t;try{const c=await this._commonHeaders();c.set("Accept","text/event-stream"),s&&c.set("last-event-id",s);const u=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,{method:"GET",headers:c,signal:(a=this._abortController)===null||a===void 0?void 0:a.signal});if(!u.ok){if(await((r=u.body)===null||r===void 0?void 0:r.cancel()),u.status===401&&this._authProvider)return await this._authThenStart();if(u.status===405)return;throw new _l(u.status,`Failed to open SSE stream: ${u.statusText}`)}this._handleSseStream(u.body,t,!0)}catch(c){throw(i=this.onerror)===null||i===void 0||i.call(this,c),c}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,a=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(a,t),r)}_scheduleReconnection(t,n=0){var a;const r=this._reconnectionOptions.maxRetries;if(n>=r){(a=this.onerror)===null||a===void 0||a.call(this,new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const i=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,n+1)})},i)}_handleSseStream(t,n,a){if(!t)return;const{onresumptiontoken:r,replayMessageId:i}=n;let s,c=!1,u=!1;(async()=>{var m,h,g,v;try{const S=t.pipeThrough(new TextDecoderStream).pipeThrough(new joe({onRetry:E=>{this._serverRetryMs=E}})).getReader();for(;;){const{value:E,done:_}=await S.read();if(_)break;if(E.id&&(s=E.id,c=!0,r?.(E.id)),!!E.data&&(!E.event||E.event==="message"))try{const k=Ob.parse(JSON.parse(E.data));rp(k)&&(u=!0,i!==void 0&&(k.id=i)),(m=this.onmessage)===null||m===void 0||m.call(this,k)}catch(k){(h=this.onerror)===null||h===void 0||h.call(this,k)}}(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(S){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${S}`)),(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(E){(v=this.onerror)===null||v===void 0||v.call(this,new Error(`Failed to reconnect: ${E instanceof Error?E.message:String(E)}`))}}})()}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 qa("No auth provider");if(await Co(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa("Failed to authorize")}async close(){var t,n;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)===null||t===void 0||t.abort(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(t,n){var a,r,i,s,c,u,f;try{const{resumptionToken:m,onresumptiontoken:h}=n||{};if(m){this._startOrAuthSse({resumptionToken:m,replayMessageId:hE(t)?t.id:void 0}).catch(k=>{var R;return(R=this.onerror)===null||R===void 0?void 0:R.call(this,k)});return}const g=await this._commonHeaders();g.set("content-type","application/json"),g.set("accept","application/json, text/event-stream");const v={...this._requestInit,method:"POST",headers:g,body:JSON.stringify(t),signal:(a=this._abortController)===null||a===void 0?void 0:a.signal},S=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,v),x=S.headers.get("mcp-session-id");if(x&&(this._sessionId=x),!S.ok){const k=await S.text().catch(()=>null);if(S.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new _l(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:R,scope:N}=Mp(S);if(this._resourceMetadataUrl=R,this._scope=N,await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa;return this._hasCompletedAuthFlow=!0,this.send(t)}if(S.status===403&&this._authProvider){const{resourceMetadataUrl:R,scope:N,error:I}=Mp(S);if(I==="insufficient_scope"){const O=S.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===O)throw new _l(403,"Server returned 403 after trying upscoping");if(N&&(this._scope=N),R&&(this._resourceMetadataUrl=R),this._lastUpscopingHeader=O??void 0,await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new qa;return this.send(t)}}throw new _l(S.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,S.status===202){await((i=S.body)===null||i===void 0?void 0:i.cancel()),Tre(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var R;return(R=this.onerror)===null||R===void 0?void 0:R.call(this,k)});return}const E=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,_=S.headers.get("content-type");if(E)if(_?.includes("text/event-stream"))this._handleSseStream(S.body,{onresumptiontoken:h},!1);else if(_?.includes("application/json")){const k=await S.json(),R=Array.isArray(k)?k.map(N=>Ob.parse(N)):[Ob.parse(k)];for(const N of R)(s=this.onmessage)===null||s===void 0||s.call(this,N)}else throw await((c=S.body)===null||c===void 0?void 0:c.cancel()),new _l(-1,`Unexpected content type: ${_}`);else await((u=S.body)===null||u===void 0?void 0:u.cancel())}catch(m){throw(f=this.onerror)===null||f===void 0||f.call(this,m),m}}get sessionId(){return this._sessionId}async terminateSession(){var t,n,a,r;if(this._sessionId)try{const i=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:i,signal:(t=this._abortController)===null||t===void 0?void 0:t.signal},c=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,s);if(await((a=c.body)===null||a===void 0?void 0:a.cancel()),!c.ok&&c.status!==405)throw new _l(c.status,`Failed to terminate session: ${c.statusText}`);this._sessionId=void 0}catch(i){throw(r=this.onerror)===null||r===void 0||r.call(this,i),i}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class mz extends Event{constructor(t,n){var a,r;super(t),this.code=(a=n?.code)!=null?a:void 0,this.message=(r=n?.message)!=null?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,a){return a(hz(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(hz(this),n)}}function Moe(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function CE(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(CE).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${CE(e.cause)}`:e.message:`${e}`}function hz(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var v9=e=>{throw TypeError(e)},ON=(e,t,n)=>t.has(e)||v9("Cannot "+n),Gt=(e,t,n)=>(ON(e,t,"read from private field"),n?n.call(e):t.get(e)),mr=(e,t,n)=>t.has(e)?v9("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Fn=(e,t,n,a)=>(ON(e,t,"write to private field"),t.set(e,n),n),_o=(e,t,n)=>(ON(e,t,"access private method"),n),ya,Tl,eu,jb,xv,hp,du,gp,Cs,tu,Eu,nu,ap,di,RE,AE,IE,gz,OE,DE,ip,jE,LE;class Lb extends EventTarget{constructor(t,n){var a,r;super(),mr(this,di),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,mr(this,ya),mr(this,Tl),mr(this,eu),mr(this,jb),mr(this,xv),mr(this,hp),mr(this,du),mr(this,gp,null),mr(this,Cs),mr(this,tu),mr(this,Eu,null),mr(this,nu,null),mr(this,ap,null),mr(this,AE,async i=>{var s;Gt(this,tu).reset();const{body:c,redirected:u,status:f,headers:m}=i;if(f===204){_o(this,di,ip).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?Fn(this,eu,new URL(i.url)):Fn(this,eu,void 0),f!==200){_o(this,di,ip).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){_o(this,di,ip).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(Gt(this,ya)===this.CLOSED)return;Fn(this,ya,this.OPEN);const h=new Event("open");if((s=Gt(this,ap))==null||s.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){_o(this,di,ip).call(this,"Invalid response body, expected a web ReadableStream",f),this.close();return}const g=new TextDecoder,v=c.getReader();let S=!0;do{const{done:x,value:w}=await v.read();w&&Gt(this,tu).feed(g.decode(w,{stream:!x})),x&&(S=!1,Gt(this,tu).reset(),_o(this,di,jE).call(this))}while(S)}),mr(this,IE,i=>{Fn(this,Cs,void 0),!(i.name==="AbortError"||i.type==="aborted")&&_o(this,di,jE).call(this,CE(i))}),mr(this,OE,i=>{typeof i.id=="string"&&Fn(this,gp,i.id);const s=new MessageEvent(i.event||"message",{data:i.data,origin:Gt(this,eu)?Gt(this,eu).origin:Gt(this,Tl).origin,lastEventId:i.id||""});Gt(this,nu)&&(!i.event||i.event==="message")&&Gt(this,nu).call(this,s),this.dispatchEvent(s)}),mr(this,DE,i=>{Fn(this,hp,i)}),mr(this,LE,()=>{Fn(this,du,void 0),Gt(this,ya)===this.CONNECTING&&_o(this,di,RE).call(this)});try{if(t instanceof URL)Fn(this,Tl,t);else if(typeof t=="string")Fn(this,Tl,new URL(t,Poe()));else throw new Error("Invalid URL")}catch{throw Moe("An invalid or illegal string was specified")}Fn(this,tu,b9({onEvent:Gt(this,OE),onRetry:Gt(this,DE)})),Fn(this,ya,this.CONNECTING),Fn(this,hp,3e3),Fn(this,xv,(a=n?.fetch)!=null?a:globalThis.fetch),Fn(this,jb,(r=n?.withCredentials)!=null?r:!1),_o(this,di,RE).call(this)}get readyState(){return Gt(this,ya)}get url(){return Gt(this,Tl).href}get withCredentials(){return Gt(this,jb)}get onerror(){return Gt(this,Eu)}set onerror(t){Fn(this,Eu,t)}get onmessage(){return Gt(this,nu)}set onmessage(t){Fn(this,nu,t)}get onopen(){return Gt(this,ap)}set onopen(t){Fn(this,ap,t)}addEventListener(t,n,a){const r=n;super.addEventListener(t,r,a)}removeEventListener(t,n,a){const r=n;super.removeEventListener(t,r,a)}close(){Gt(this,du)&&clearTimeout(Gt(this,du)),Gt(this,ya)!==this.CLOSED&&(Gt(this,Cs)&&Gt(this,Cs).abort(),Fn(this,ya,this.CLOSED),Fn(this,Cs,void 0))}}ya=new WeakMap,Tl=new WeakMap,eu=new WeakMap,jb=new WeakMap,xv=new WeakMap,hp=new WeakMap,du=new WeakMap,gp=new WeakMap,Cs=new WeakMap,tu=new WeakMap,Eu=new WeakMap,nu=new WeakMap,ap=new WeakMap,di=new WeakSet,RE=function(){Fn(this,ya,this.CONNECTING),Fn(this,Cs,new AbortController),Gt(this,xv)(Gt(this,Tl),_o(this,di,gz).call(this)).then(Gt(this,AE)).catch(Gt(this,IE))},AE=new WeakMap,IE=new WeakMap,gz=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Gt(this,gp)?{"Last-Event-ID":Gt(this,gp)}:void 0},cache:"no-store",signal:(e=Gt(this,Cs))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},OE=new WeakMap,DE=new WeakMap,ip=function(e,t){var n;Gt(this,ya)!==this.CLOSED&&Fn(this,ya,this.CLOSED);const a=new mz("error",{code:t,message:e});(n=Gt(this,Eu))==null||n.call(this,a),this.dispatchEvent(a)},jE=function(e,t){var n;if(Gt(this,ya)===this.CLOSED)return;Fn(this,ya,this.CONNECTING);const a=new mz("error",{code:t,message:e});(n=Gt(this,Eu))==null||n.call(this,a),this.dispatchEvent(a),Fn(this,du,setTimeout(Gt(this,LE),Gt(this,hp)))},LE=new WeakMap,Lb.CONNECTING=0,Lb.OPEN=1,Lb.CLOSED=2;function Poe(){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 zoe extends Error{constructor(t,n,a){super(`SSE error: ${n}`),this.code=t,this.event=a}}class Uoe{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=r9(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new qa("No auth provider");let n;try{n=await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new qa;return await this._startOrAuth()}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=gv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}_startOrAuth(){var t,n,a;const r=(a=(n=(t=this===null||this===void 0?void 0:this._eventSourceInit)===null||t===void 0?void 0:t.fetch)!==null&&n!==void 0?n:this._fetch)!==null&&a!==void 0?a:fetch;return new Promise((i,s)=>{this._eventSource=new Lb(this._url.href,{...this._eventSourceInit,fetch:async(c,u)=>{const f=await this._commonHeaders();f.set("Accept","text/event-stream");const m=await r(c,{...u,headers:f});if(m.status===401&&m.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=Mp(m);this._resourceMetadataUrl=h,this._scope=g}return m}}),this._abortController=new AbortController,this._eventSource.onerror=c=>{var u;if(c.code===401&&this._authProvider){this._authThenStart().then(i,s);return}const f=new zoe(c.code,c.message,c);s(f),(u=this.onerror)===null||u===void 0||u.call(this,f)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",c=>{var u;const f=c;try{if(this._endpoint=new URL(f.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(m){s(m),(u=this.onerror)===null||u===void 0||u.call(this,m),this.close();return}i()}),this._eventSource.onmessage=c=>{var u,f;const m=c;let h;try{h=Ob.parse(JSON.parse(m.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(f=this.onmessage)===null||f===void 0||f.call(this,h)}})}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 qa("No auth provider");if(await Co(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa("Failed to authorize")}async close(){var t,n,a;(t=this._abortController)===null||t===void 0||t.abort(),(n=this._eventSource)===null||n===void 0||n.close(),(a=this.onclose)===null||a===void 0||a.call(this)}async send(t){var n,a,r,i;if(!this._endpoint)throw new Error("Not connected");try{const s=await this._commonHeaders();s.set("content-type","application/json");const c={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},u=await((a=this._fetch)!==null&&a!==void 0?a:fetch)(this._endpoint,c);if(!u.ok){const f=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:m,scope:h}=Mp(u);if(this._resourceMetadataUrl=m,this._scope=h,await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${f}`)}await((r=u.body)===null||r===void 0?void 0:r.cancel())}catch(s){throw(i=this.onerror)===null||i===void 0||i.call(this,s),s}}setProtocolVersion(t){this._protocolVersion=t}}var Wu,Foe=(Wu=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={},a){return this.connector.callTool(t,n,a)}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,a){return this.connector.request(t,n,a)}},ke(Wu,"MCPSession"),Wu),Ku,Boe=(Ku=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,Pi.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Pi.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 a=this.config.mcpServers??{};if(Object.keys(a).length===0&&$e.warn("No MCP servers defined in config"),!a[t])throw new Error(`Server '${t}' not found in config`);const r=this.createConnectorFromConfig(a[t]),i=new Foe(r);return n&&await i.initialize(),this.sessions[t]=i,this.activeSessions.includes(t)||this.activeSessions.push(t),i}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&$e.warn("No MCP servers defined in config");for(const a of Object.keys(n))await this.createSession(a,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){$e.warn(`No session exists for server ${t}, nothing to close`);return}try{$e.debug(`Closing session for server ${t}`),await n.disconnect()}catch(a){$e.error(`Error closing session for server '${t}': ${a}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(a=>a!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const a of t)try{$e.debug(`Closing session for server ${a}`),await this.closeSession(a)}catch(r){const i=`Failed to close session for server '${a}': ${r}`;$e.error(i),n.push(i)}n.length?$e.error(`Encountered ${n.length} errors while closing sessions`):$e.debug("All sessions closed successfully")}},ke(Ku,"BaseMCPClient"),Ku),Zu,Hoe=(Zu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),$e.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){$e.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?$e.debug(`${this.constructor.name} task aborted successfully`):$e.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,$e.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(){$e.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),$e.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,$e.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){$e.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 a=this._abortController.signal;if(a.aborted){t();return}const r=ke(()=>{a.removeEventListener("abort",r),t()},"onAbort");a.addEventListener("abort",r)})}},ke(Zu,"ConnectionManager"),Zu),Yu,Voe=(Yu=class extends Hoe{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 Uoe(this.url,this.opts),n=t.send.bind(t);return t.send=async a=>{const r=ke(async i=>{if(Array.isArray(i))for(const s of i)await n(s);else await n(i)},"sendMessage");try{await r(a)}catch(i){if(i?.code===404&&t.sessionId&&!this.reinitializing){$e.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),$e.info("[SSE] Re-initialization successful, retrying request"),await r(a)}finally{this.reinitializing=!1}}else throw i}},this._transport=t,$e.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){$e.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){$e.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},ke(Yu,"SseConnectionManager"),Yu),qu,Goe=(qu=class extends Bae{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){$e.debug("Already connected to MCP implementation");return}const t=this.gatewayUrl?this.gatewayUrl.replace(/\/$/,""):this.baseUrl;if(this.preferSse){$e.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}$e.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{$e.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),$e.info("✅ Successfully connected via streamable HTTP")}catch(n){let a="Unknown error",r=!1;if(n instanceof _l){const i=n;r=i.code===401,i.code===400&&i.message.includes("Missing session ID")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",$e.warn(`⚠️ ${a}`)):i.code===404||i.code===405?(a=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,$e.debug(a)):(a=`Server returned ${i.code}: ${i.message}`,$e.debug(a))}else if(n instanceof Error){const i=n.toString(),s=n.message||"";r=i.includes("401")||s.includes("Unauthorized"),i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||s.includes("FastMCP session ID error")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",$e.warn(`⚠️ ${a}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(a="Server doesn't support streamable HTTP (405/404)",$e.debug(a)):(a=`Streamable HTTP failed: ${n.message}`,$e.debug(a))}if(r){$e.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}if(this.disableSseFallback)throw $e.info("SSE fallback disabled - failing connection"),await this.cleanupResources(),new Error(`Streamable HTTP connection failed: ${a}`);$e.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if($e.error("Failed to connect with both transports:"),$e.error(` Streamable HTTP: ${a}`),$e.error(` SSE: ${i}`),await this.cleanupResources(),i?.message?.includes("401")||i?.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 $oe(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let a=n;if(this.opts.wrapTransport){const i=this.baseUrl;a=this.opts.wrapTransport(a,i)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};$e.debug("Creating Client with capabilities:",JSON.stringify(r.capabilities,null,2)),this.client=new cz(this.clientInfo,r),this.setupRootsHandler(),$e.debug("Roots handler registered before connect");try{await this.client.connect(a,{timeout:this.timeout});const i=n.sessionId;i?$e.debug(`Session ID obtained: ${i}`):$e.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(i){if(i instanceof Error){const s=i.message||i.toString();if(s.includes("Missing session ID")||s.includes("Bad Request: Missing session ID")||s.includes("Mcp-Session-Id header is required")){const c=new Error(`Session ID error: ${s}. The SDK should automatically extract session ID from initialize response.`);throw c.cause=i,c}}throw i}this.streamableTransport=n,this.connectionManager={stop:ke(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){$e.warn(`Error closing Streamable HTTP transport: ${i}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$e.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 Voe(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const r=this.baseUrl;n=this.opts.wrapTransport(n,r)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};$e.debug("Creating Client with capabilities (SSE):",JSON.stringify(a.capabilities,null,2)),this.client=new cz(this.clientInfo,a),this.setupRootsHandler(),$e.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$e.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}},ke(qu,"HttpConnector"),qu),Bl,Woe=(Bl=class extends Boe{static getPackageVersion(){return wk()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Pi.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>$e.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new Bl(t)}createConnectorFromConfig(t){const{url:n,headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:f,disableSseFallback:m,preferSse:h}=t;if(!n)throw new Error("Server URL is required");const g={headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:f,disableSseFallback:m,preferSse:h};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new Goe(n,g)}},ke(Bl,"BrowserMCPClient"),Bl);function fu(e){const t=ke(()=>{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(y9).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}ke(fu,"sanitizeUrl");function y9([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}ke(y9,"sanitizeParam");var Xu,$b=(Xu=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=fu(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 fu(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(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,a),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(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,a),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(),a=`${this.storageKeyPrefix}:state_${n}`,r={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(a,JSON.stringify(r)),t.searchParams.set("state",n);const i=t.toString(),s=fu(i);return localStorage.setItem(this.getKey("last_auth_url"),s),s}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 a="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const r=window.open(n,`mcp_auth_${this.serverUrlHash}`,a);this.onPopupWindow&&this.onPopupWindow(n,a,r),!r||r.closed||typeof r.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(r.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(r){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,r)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?fu(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,a=[];let r=0;for(let s=0;s<localStorage.length;s++){const c=localStorage.key(s);if(c){if(c.startsWith(t))a.push(c);else if(c.startsWith(n))try{const u=localStorage.getItem(c);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&a.push(c)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${c} during clearStorage:`,u)}}}return[...new Set(a)].forEach(s=>{localStorage.removeItem(s),r++}),r}hashString(t){let n=0;for(let a=0;a<t.length;a++){const r=t.charCodeAt(a);n=(n<<5)-n+r,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},ke(Xu,"BrowserOAuthClientProvider"),Xu);async function DN(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),a=e.get("error"),r=e.get("error_description"),i="[mcp-callback]";console.log(`${i} Handling callback...`,{code:t,state:n,error:a,errorDescription:r});let s=null,c=null;const u=n?`mcp:auth:state_${n}`:null;try{if(a)throw new Error(`OAuth error: ${a} - ${r||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!u)throw new Error("State parameter not found or invalid in callback query parameters.");const f=localStorage.getItem(u);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(u),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(`${i} Re-instantiating provider for server: ${m}`),s=new $b(m,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await Co(s,{serverUrl:g,authorizationCode:t});if(v==="AUTHORIZED")if(console.log(`${i} Authorization successful via SDK auth().`),c.flowType==="redirect"&&c.returnUrl)console.log(`${i} Redirect flow complete. Returning to: ${c.returnUrl}`),localStorage.removeItem(u),window.location.href=c.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${i} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(u),window.close();else{console.warn(`${i} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(u);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(`${i} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(f){console.error(`${i} 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 S=document.createElement("p");S.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),S.appendChild(x),S.appendChild(document.createTextNode(".")),h.appendChild(S),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(`${i} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),s&&(localStorage.removeItem(s.getKey("code_verifier")),localStorage.removeItem(s.getKey("last_auth_url")))}}ke(DN,"onMcpAuthorization");var aS={exports:{}},Et={};var bz;function Koe(){if(bz)return Et;bz=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(L){return L===null||typeof L!="object"?null:(L=g&&L[g]||L["@@iterator"],typeof L=="function"?L:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function E(L,B,P){this.props=L,this.context=B,this.refs=w,this.updater=P||S}E.prototype.isReactComponent={},E.prototype.setState=function(L,B){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,B,"setState")},E.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function _(){}_.prototype=E.prototype;function k(L,B,P){this.props=L,this.context=B,this.refs=w,this.updater=P||S}var R=k.prototype=new _;R.constructor=k,x(R,E.prototype),R.isPureReactComponent=!0;var N=Array.isArray;function I(){}var O={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function M(L,B,P){var $=P.ref;return{$$typeof:e,type:L,key:B,ref:$!==void 0?$:null,props:P}}function j(L,B){return M(L.type,B,L.props)}function F(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function V(L){var B={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(P){return B[P]})}var J=/\/+/g;function ee(L,B){return typeof L=="object"&&L!==null&&L.key!=null?V(""+L.key):B.toString(36)}function ie(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(I,I):(L.status="pending",L.then(function(B){L.status==="pending"&&(L.status="fulfilled",L.value=B)},function(B){L.status==="pending"&&(L.status="rejected",L.reason=B)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function W(L,B,P,$,z){var G=typeof L;(G==="undefined"||G==="boolean")&&(L=null);var K=!1;if(L===null)K=!0;else switch(G){case"bigint":case"string":case"number":K=!0;break;case"object":switch(L.$$typeof){case e:case t:K=!0;break;case m:return K=L._init,W(K(L._payload),B,P,$,z)}}if(K)return z=z(L),K=$===""?"."+ee(L,0):$,N(z)?(P="",K!=null&&(P=K.replace(J,"$&/")+"/"),W(z,B,P,"",function(ce){return ce})):z!=null&&(F(z)&&(z=j(z,P+(z.key==null||L&&L.key===z.key?"":(""+z.key).replace(J,"$&/")+"/")+K)),B.push(z)),1;K=0;var re=$===""?".":$+":";if(N(L))for(var fe=0;fe<L.length;fe++)$=L[fe],G=re+ee($,fe),K+=W($,B,P,G,z);else if(fe=v(L),typeof fe=="function")for(L=fe.call(L),fe=0;!($=L.next()).done;)$=$.value,G=re+ee($,fe++),K+=W($,B,P,G,z);else if(G==="object"){if(typeof L.then=="function")return W(ie(L),B,P,$,z);throw B=String(L),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return K}function Z(L,B,P){if(L==null)return L;var $=[],z=0;return W(L,$,"","",function(G){return B.call(P,G,z++)}),$}function H(L){if(L._status===-1){var B=L._result;B=B(),B.then(function(P){(L._status===0||L._status===-1)&&(L._status=1,L._result=P)},function(P){(L._status===0||L._status===-1)&&(L._status=2,L._result=P)}),L._status===-1&&(L._status=0,L._result=B)}if(L._status===1)return L._result.default;throw L._result}var ae=typeof reportError=="function"?reportError:function(L){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var B=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof L=="object"&&L!==null&&typeof L.message=="string"?String(L.message):String(L),error:L});if(!window.dispatchEvent(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",L);return}console.error(L)},ne={map:Z,forEach:function(L,B,P){Z(L,function(){B.apply(this,arguments)},P)},count:function(L){var B=0;return Z(L,function(){B++}),B},toArray:function(L){return Z(L,function(B){return B})||[]},only:function(L){if(!F(L))throw Error("React.Children.only expected to receive a single React element child.");return L}};return Et.Activity=h,Et.Children=ne,Et.Component=E,Et.Fragment=n,Et.Profiler=r,Et.PureComponent=k,Et.StrictMode=a,Et.Suspense=u,Et.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Et.__COMPILER_RUNTIME={__proto__:null,c:function(L){return O.H.useMemoCache(L)}},Et.cache=function(L){return function(){return L.apply(null,arguments)}},Et.cacheSignal=function(){return null},Et.cloneElement=function(L,B,P){if(L==null)throw Error("The argument must be a React element, but you passed "+L+".");var $=x({},L.props),z=L.key;if(B!=null)for(G in B.key!==void 0&&(z=""+B.key),B)!A.call(B,G)||G==="key"||G==="__self"||G==="__source"||G==="ref"&&B.ref===void 0||($[G]=B[G]);var G=arguments.length-2;if(G===1)$.children=P;else if(1<G){for(var K=Array(G),re=0;re<G;re++)K[re]=arguments[re+2];$.children=K}return M(L.type,z,$)},Et.createContext=function(L){return L={$$typeof:s,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null},L.Provider=L,L.Consumer={$$typeof:i,_context:L},L},Et.createElement=function(L,B,P){var $,z={},G=null;if(B!=null)for($ in B.key!==void 0&&(G=""+B.key),B)A.call(B,$)&&$!=="key"&&$!=="__self"&&$!=="__source"&&(z[$]=B[$]);var K=arguments.length-2;if(K===1)z.children=P;else if(1<K){for(var re=Array(K),fe=0;fe<K;fe++)re[fe]=arguments[fe+2];z.children=re}if(L&&L.defaultProps)for($ in K=L.defaultProps,K)z[$]===void 0&&(z[$]=K[$]);return M(L,G,z)},Et.createRef=function(){return{current:null}},Et.forwardRef=function(L){return{$$typeof:c,render:L}},Et.isValidElement=F,Et.lazy=function(L){return{$$typeof:m,_payload:{_status:-1,_result:L},_init:H}},Et.memo=function(L,B){return{$$typeof:f,type:L,compare:B===void 0?null:B}},Et.startTransition=function(L){var B=O.T,P={};O.T=P;try{var $=L(),z=O.S;z!==null&&z(P,$),typeof $=="object"&&$!==null&&typeof $.then=="function"&&$.then(I,ae)}catch(G){ae(G)}finally{B!==null&&P.types!==null&&(B.types=P.types),O.T=B}},Et.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Et.use=function(L){return O.H.use(L)},Et.useActionState=function(L,B,P){return O.H.useActionState(L,B,P)},Et.useCallback=function(L,B){return O.H.useCallback(L,B)},Et.useContext=function(L){return O.H.useContext(L)},Et.useDebugValue=function(){},Et.useDeferredValue=function(L,B){return O.H.useDeferredValue(L,B)},Et.useEffect=function(L,B){return O.H.useEffect(L,B)},Et.useEffectEvent=function(L){return O.H.useEffectEvent(L)},Et.useId=function(){return O.H.useId()},Et.useImperativeHandle=function(L,B,P){return O.H.useImperativeHandle(L,B,P)},Et.useInsertionEffect=function(L,B){return O.H.useInsertionEffect(L,B)},Et.useLayoutEffect=function(L,B){return O.H.useLayoutEffect(L,B)},Et.useMemo=function(L,B){return O.H.useMemo(L,B)},Et.useOptimistic=function(L,B){return O.H.useOptimistic(L,B)},Et.useReducer=function(L,B,P){return O.H.useReducer(L,B,P)},Et.useRef=function(L){return O.H.useRef(L)},Et.useState=function(L){return O.H.useState(L)},Et.useSyncExternalStore=function(L,B,P){return O.H.useSyncExternalStore(L,B,P)},Et.useTransition=function(){return O.H.useTransition()},Et.version="19.2.3",Et}var vz;function jN(){return vz||(vz=1,aS.exports=Koe()),aS.exports}var y=jN();const X=iy(y),Rd=CJ({__proto__:null,default:X},[y]);function $E(e,t){if(!e)throw new Error(t)}ke($E,"assert");var yz=3e3,Zoe=5e3;function LN(e){const{url:t,enabled:n=!0,callbackUrl:a=typeof window<"u"?fu(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:r="mcp:auth",clientConfig:i={},customHeaders:s={},proxyConfig:c,debug:u=!1,autoRetry:f=!1,autoReconnect:m=yz,transportType:h="auto",preventAutoAuth:g=!1,useRedirectFlow:v=!1,onPopupWindow:S,timeout:x=3e4,sseReadTimeout:w=3e5,wrapTransport:E,onNotification:_,samplingCallback:k,onElicitation:R}=e,{url:N,headers:I}=y.useMemo(()=>yk(t||"",c),[t,c]),O=y.useMemo(()=>({...I,...s}),[I,s]),[A,M]=y.useState("discovering"),[j,F]=y.useState([]),[V,J]=y.useState([]),[ee,ie]=y.useState([]),[W,Z]=y.useState([]),[H,ae]=y.useState(),[ne,L]=y.useState(),[B,P]=y.useState(void 0),[$,z]=y.useState([]),[G,K]=y.useState(void 0),[re,fe]=y.useState(void 0),ce=y.useRef(null),q=y.useRef(null),te=y.useRef(null),se=y.useRef(!1),de=y.useRef(!0),ye=y.useRef(0),Te=y.useRef(null),Ge=y.useRef(!1),Ie=y.useRef(A),Me=y.useRef(m),nt=y.useRef(null),Ue=y.useRef(null),pe=y.useRef(null);y.useEffect(()=>{Ie.current=A,Me.current=m},[A,m]);const oe=y.useCallback((Pe,ze,...De)=>{const it=De.length>0?`${ze} ${De.map(at=>JSON.stringify(at)).join(" ")}`:ze;console[Pe](`[useMcp] ${it}`),de.current&&z(at=>[...at.slice(-100),{level:Pe,message:it,timestamp:Date.now()}])},[]),xe=y.useCallback(async(Pe=!1)=>{if(Pe||oe("info","Disconnecting..."),se.current=!1,Te.current&&clearTimeout(Te.current),Te.current=null,ce.current)try{const ze="inspector-server",De=ce.current.getSession(ze);De&&De._healthCheckCleanup&&(De._healthCheckCleanup(),De._healthCheckCleanup=null),await ce.current.closeSession(ze)}catch(ze){Pe||oe("warn","Error closing session:",ze)}ce.current=null,de.current&&!Pe&&(M("discovering"),F([]),J([]),ie([]),Z([]),P(void 0),K(void 0))},[oe]),Ee=y.useCallback((Pe,ze)=>{if(oe("error",Pe,ze??""),de.current){M("failed"),P(Pe);const De=q.current?.getLastAttemptedAuthUrl();De&&(K(De),oe("info","Manual authentication URL may be available.",De))}se.current=!1,t&&Pi.getInstance().trackUseMcpConnection({url:t,transportType:h,success:!1,errorType:ze?.name||"UnknownError",hasOAuth:!!q.current,hasSampling:!!k,hasElicitation:!!R}).catch(()=>{})},[oe,t,h,k,R]),je=y.useCallback(async()=>{if(!n||!t){oe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(se.current){oe("debug","Connection attempt already in progress.");return}if(!de.current){oe("debug","Connect called after unmount, aborting.");return}se.current=!0,ye.current+=1,P(void 0),K(void 0),nt.current=null,M("discovering"),oe("info",`Connecting attempt #${ye.current} to ${t}...`),q.current||(q.current=new $b(t,{storageKeyPrefix:r,clientName:i.name,clientUri:i.uri,logoUri:i.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:a,preventAutoAuth:g,useRedirectFlow:v,onPopupWindow:S}),oe("debug","BrowserOAuthClientProvider initialized in connect.")),ce.current||(ce.current=new Woe,oe("debug","BrowserMCPClient initialized in connect."));const Pe=ke(async(De,it=!1)=>{oe("info",`Attempting connection with transport: ${De}`);try{const at="inspector-server",Xe={url:N,transport:De==="sse"?"http":De,disableSseFallback:De==="http",preferSse:De==="sse"};if(O&&Object.keys(O).length>0&&(Xe.headers=O),q.current){const vt=await q.current.tokens();vt?.access_token&&(Xe.headers={...Xe.headers,Authorization:`Bearer ${vt.access_token}`})}ce.current.addServer(at,{...Xe,authProvider:q.current,clientOptions:i,samplingCallback:k,elicitationCallback:R,wrapTransport:E?vt=>(console.log("[useMcp] Applying transport wrapper for server:",at,"url:",t),E(vt,t)):void 0});const Mt=await ce.current.createSession(at,!1);Mt.on("notification",vt=>{_?.(vt),vt.method==="notifications/tools/list_changed"?(oe("info","Tools list changed, auto-refreshing..."),sn().catch(ut=>oe("warn","Auto-refresh tools failed:",ut))):vt.method==="notifications/resources/list_changed"?(oe("info","Resources list changed, auto-refreshing..."),He().catch(ut=>oe("warn","Auto-refresh resources failed:",ut))):vt.method==="notifications/prompts/list_changed"&&(oe("info","Prompts list changed, auto-refreshing..."),Fe().catch(ut=>oe("warn","Auto-refresh prompts failed:",ut)))}),await Mt.initialize(),oe("info","✅ Successfully connected to MCP server"),oe("info","Server info:",Mt.connector.serverInfo),oe("info","Server capabilities:",Mt.connector.serverCapabilities),console.log("[useMcp] Server info:",Mt.connector.serverInfo),console.log("[useMcp] Server capabilities:",Mt.connector.serverCapabilities),M("ready"),nt.current=De;const Zt=ke(()=>{let vt=null,ut=Date.now();const Gn=1e4,dr=3e4;return vt=setInterval(ke(async()=>{if(!de.current||Ie.current!=="ready"){vt&&(clearInterval(vt),vt=null);return}try{await Mt.connector.listTools(),ut=Date.now()}catch{const pn=Date.now()-ut;pn>dr&&(oe("warn",`Connection appears to be broken (no response for ${Math.round(pn/1e3)}s), attempting to reconnect...`),vt&&(clearInterval(vt),vt=null),Me.current&&de.current&&(M("discovering"),oe("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{de.current&&Ie.current==="discovering"&&je()},typeof Me.current=="number"?Me.current:yz)))}},"checkConnectionHealth"),Gn),()=>{vt&&(clearInterval(vt),vt=null)}},"setupConnectionMonitoring");if(m){const vt=Zt();Mt._healthCheckCleanup=vt}Pi.getInstance().trackUseMcpConnection({url:t,transportType:De,success:!0,hasOAuth:!!q.current,hasSampling:!!k,hasElicitation:!!R}).catch(()=>{}),F(Mt.connector.tools||[]);const $n=await Mt.connector.listAllResources();J($n.resources||[]);const vn=await Mt.connector.listPrompts();Z(vn.prompts||[]);const ln=Mt.connector.serverInfo,rn=Mt.connector.serverCapabilities;if(ln){console.log("[useMcp] Server info:",ln),ae(ln);const vt=(async()=>{try{const ut=ln.icons;if(ut&&Array.isArray(ut)&&ut.length>0){const Gn=ut[0].src||ut[0].url;if(Gn){oe("info","Server provided icon:",Gn);const er=await(await fetch(Gn)).blob(),mt=await new Promise((pn,kr)=>{const Br=new FileReader;Br.onloadend=()=>pn(Br.result),Br.onerror=kr,Br.readAsDataURL(er)});return de.current&&(ae(pn=>pn?{...pn,icon:mt}:void 0),oe("debug","Server icon converted to base64")),mt}}if(t){const Gn=await _F(t);if(Gn&&de.current)return ae(dr=>dr?{...dr,icon:Gn}:void 0),oe("debug","Favicon detected and added to serverInfo"),Gn}return null}catch(ut){return oe("debug","Icon loading failed (non-critical):",ut),null}})();te.current=vt}if(rn&&(console.log("[useMcp] Server capabilities:",rn),L(rn)),q.current){const vt=await q.current.tokens();if(vt?.access_token){const ut=vt.expires_in?Date.now()+vt.expires_in*1e3:void 0;fe({access_token:vt.access_token,token_type:vt.token_type||"Bearer",expires_at:ut,refresh_token:vt.refresh_token,scope:vt.scope})}}return"success"}catch(at){const Xe=at,Mt=Xe?.message||String(at);if(Xe.code===401||Mt.includes("401")||Mt.includes("Unauthorized")){if(q.current){oe("info","Authentication required. OAuth provider available.");try{const{auth:Zt}=await ia(async()=>{const{auth:vn}=await Promise.resolve().then(()=>fz);return{auth:vn}},void 0),$n=new URL(t).origin;Zt(q.current,{serverUrl:$n}).catch(()=>{}),setTimeout(()=>{if(de.current){const vn=q.current?.getLastAttemptedAuthUrl();vn?(K(vn),oe("info","Manual authentication URL available:",vn)):oe("warn","Could not generate authentication URL")}},100)}catch(Zt){oe("warn","Error generating auth URL:",Zt)}return de.current&&M("pending_auth"),se.current=!1,"auth_redirect"}return s&&Object.keys(s).length>0?(Ee("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Ee("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Ee(Mt,Xe instanceof Error?Xe:new Error(String(Xe))),"failed"}},"tryConnectWithTransport");let ze="failed";if(h==="sse")oe("debug","Using SSE-only transport mode"),ze=await Pe("sse");else if(h==="http")oe("debug","Using HTTP-only transport mode"),ze=await Pe("http");else{oe("debug","Using auto transport mode (HTTP with SSE fallback)");const De=await Pe("http");De==="fallback"&&de.current&&Ie.current!=="authenticating"?(oe("info","HTTP failed, attempting SSE fallback..."),ze=await Pe("sse")):ze=De}(ze==="success"||ze==="failed"||ze==="auth_redirect")&&(se.current=!1),oe("debug",`Connection sequence finished with status: ${ze}`)},[oe,Ee,xe,t,r,a,i.name,i.version,i.uri,i.logo_uri,s,h,g,v,S,n,x,w]);y.useEffect(()=>{Ue.current=je,pe.current=Ee},[je,Ee]);const We=y.useCallback(async(Pe,ze,De)=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot call tool "${Pe}".`);oe("info",`Calling tool: ${Pe}`,ze);const it=Date.now();try{const Xe=ce.current.getSession("inspector-server");if(!Xe)throw new Error("No active session found");const Mt=await Xe.connector.callTool(Pe,ze||{},De);return oe("info",`Tool "${Pe}" call successful:`,Mt),Pi.getInstance().trackUseMcpToolCall({toolName:Pe,success:!0,executionTimeMs:Date.now()-it}).catch(()=>{}),Mt}catch(at){throw oe("error",`Tool "${Pe}" call failed:`,at),Pi.getInstance().trackUseMcpToolCall({toolName:Pe,success:!1,errorType:at instanceof Error?at.name:"UnknownError",executionTimeMs:Date.now()-it}).catch(()=>{}),at}},[A]),Ye=y.useCallback(()=>{Ie.current==="failed"?(oe("info","Retry requested..."),Ue.current?.()):oe("warn",`Retry called but state is not 'failed' (state: ${Ie.current}). Ignoring.`)},[oe]),ot=y.useCallback(async()=>{oe("info","Manual authentication requested...");const Pe=Ie.current;if(Pe==="failed")oe("info","Attempting to reconnect and authenticate via retry..."),Ye();else if(Pe==="pending_auth"){oe("info","Proceeding with authentication from pending state...");try{$E(q.current,"Auth Provider not available for manual auth"),$E(t,"Server URL is required for authentication"),oe("info","Clearing all OAuth state and initiating fresh flow...");const ze=`${r}:${q.current.serverUrlHash}`;Object.keys(localStorage).forEach(Xe=>{Xe.startsWith(ze)&&(oe("debug",`Removing stale OAuth key: ${Xe}`),localStorage.removeItem(Xe)),Xe.startsWith(`${r}:state_`)&&(oe("debug",`Removing orphaned state: ${Xe}`),localStorage.removeItem(Xe))}),M("authenticating");const De=new $b(t,{storageKeyPrefix:r,clientName:i.name,clientUri:i.uri,logoUri:i.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:a,preventAutoAuth:!1,useRedirectFlow:v,onPopupWindow:S});q.current=De,oe("info","Triggering fresh OAuth authorization...");const{auth:it}=await ia(async()=>{const{auth:Xe}=await Promise.resolve().then(()=>fz);return{auth:Xe}},void 0),at=new URL(t).origin;it(De,{serverUrl:at}).catch(Xe=>{oe("info","OAuth flow initiated:",Xe instanceof Error?Xe.message:"Redirecting...")})}catch(ze){if(!de.current)return;M("pending_auth"),oe("error",`Manual authentication failed: ${ze instanceof Error?ze.message:String(ze)}`)}}else if(Pe==="authenticating"){oe("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const ze=q.current?.getLastAttemptedAuthUrl();ze&&!G&&(K(ze),oe("info","Manual authentication URL retrieved:",ze))}else oe("info",`Client not in a state requiring manual authentication trigger (state: ${Pe}). If needed, try disconnecting and reconnecting.`)},[oe,Ye,G,t,v,S,r,i.name,i.uri,i.logo_uri,a]),kt=y.useCallback(()=>{if(q.current){const Pe=q.current.clearStorage();oe("info",`Cleared ${Pe} item(s) from localStorage for ${t}.`),K(void 0),xe()}else oe("warn","Auth provider not initialized, cannot clear storage.")},[t,oe,xe]),Ln=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list resources.`);oe("info","Listing resources");try{const ze=ce.current.getSession("inspector-server");if(!ze)throw new Error("No active session found");const De=await ze.connector.listAllResources();J(De.resources||[]),oe("info","Resources listed successfully")}catch(Pe){throw oe("error","List resources failed:",Pe),Pe}},[A]),pt=y.useCallback(async Pe=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot read resource.`);oe("info",`Reading resource: ${Pe}`);try{const De=ce.current.getSession("inspector-server");if(!De)throw new Error("No active session found");const it=await De.connector.readResource(Pe);return oe("info","Resource read successful:",it),Pi.getInstance().trackUseMcpResourceRead({resourceUri:Pe,success:!0}).catch(()=>{}),it}catch(ze){throw oe("error","Resource read failed:",ze),Pi.getInstance().trackUseMcpResourceRead({resourceUri:Pe,success:!1,errorType:ze instanceof Error?ze.name:"UnknownError"}).catch(()=>{}),ze}},[A]),Zn=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list prompts.`);oe("info","Listing prompts");try{const ze=ce.current.getSession("inspector-server");if(!ze)throw new Error("No active session found");const De=await ze.connector.listPrompts();Z(De.prompts||[]),oe("info","Prompts listed successfully")}catch(Pe){throw oe("error","List prompts failed:",Pe),Pe}},[A]),sn=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current){oe("debug","Cannot refresh tools - client not ready");return}oe("debug","Refreshing tools list");try{const ze=ce.current.getSession("inspector-server");if(!ze){oe("warn","No active session found for tools refresh");return}const De=await ze.connector.listTools();F(De||[]),oe("info","Tools list refreshed successfully")}catch(Pe){oe("warn","Failed to refresh tools:",Pe)}},[oe]),He=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current){oe("debug","Cannot refresh resources - client not ready");return}oe("debug","Refreshing resources list");try{const ze=ce.current.getSession("inspector-server");if(!ze){oe("warn","No active session found for resources refresh");return}const De=await ze.connector.listAllResources();J(De.resources||[]),oe("info","Resources list refreshed successfully")}catch(Pe){oe("warn","Failed to refresh resources:",Pe)}},[oe]),Fe=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current){oe("debug","Cannot refresh prompts - client not ready");return}oe("debug","Refreshing prompts list");try{const ze=ce.current.getSession("inspector-server");if(!ze){oe("warn","No active session found for prompts refresh");return}const De=await ze.connector.listPrompts();Z(De.prompts||[]),oe("info","Prompts list refreshed successfully")}catch(Pe){oe("warn","Failed to refresh prompts:",Pe)}},[oe]),Ze=y.useCallback(async()=>{oe("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([sn(),He(),Fe()])},[sn,He,Fe,oe]),wt=y.useCallback(async(Pe,ze)=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot get prompt.`);oe("info",`Getting prompt: ${Pe}`,ze);try{const it=ce.current.getSession("inspector-server");if(!it)throw new Error("No active session found");const at=await it.connector.getPrompt(Pe,ze||{});return oe("info",`Prompt "${Pe}" retrieved successfully:`,at),at}catch(De){throw oe("error",`Prompt "${Pe}" retrieval failed:`,De),De}},[A]);y.useEffect(()=>{const Pe=ke(ze=>{ze.origin===window.location.origin&&ze.data?.type==="mcp_auth_callback"&&(oe("info","Received auth callback message.",ze.data),Te.current&&clearTimeout(Te.current),Te.current=null,ze.data.success?(oe("info","Authentication successful via popup. Reconnecting client..."),se.current&&oe("debug","Connection attempt already in progress, resetting flag to allow reconnection."),se.current=!1,setTimeout(()=>{de.current&&(oe("debug","Initiating reconnection after successful auth callback."),Ue.current?.())},100)):pe.current?.(`Authentication failed in callback: ${ze.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Pe),oe("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Pe),oe("debug","Auth callback message listener removed."),Te.current&&clearTimeout(Te.current)}},[oe]),y.useEffect(()=>(de.current=!0,!n||!t?(oe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),M("discovering"),()=>{de.current=!1}):(oe("debug","useMcp mounted, initiating connection."),ye.current=0,(!q.current||q.current.serverUrl!==t)&&(q.current=new $b(t,{storageKeyPrefix:r,clientName:i.name,clientUri:i.uri,logoUri:i.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:a,preventAutoAuth:g,useRedirectFlow:v,onPopupWindow:S}),oe("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),je(),()=>{de.current=!1,oe("debug","useMcp unmounting, disconnecting."),xe(!0)})),[t,n,r,a,i.name,i.version,i.uri,i.logo_uri,v]);const xt=y.useRef(Ye),jt=y.useRef(oe);y.useEffect(()=>{xt.current=Ye,jt.current=oe},[Ye,oe]),y.useEffect(()=>{let Pe=null;if(A==="failed"&&f&&ye.current>0){if(!Ge.current){Ge.current=!0;const ze=typeof f=="number"?f:Zoe;jt.current("info",`Connection failed, auto-retrying in ${ze}ms...`),Pe=setTimeout(()=>{Ge.current=!1,de.current&&Ie.current==="failed"&&xt.current()},ze)}}else A!=="failed"&&(Ge.current=!1);return()=>{Pe&&(clearTimeout(Pe),Ge.current=!1)}},[A,f]);const St=y.useCallback(async()=>Ie.current!=="ready"?(oe("warn","Cannot ensure icon loaded - not connected"),null):H?.icon?H.icon:te.current?(oe("debug","Waiting for icon to finish loading..."),await te.current):(oe("debug","No icon available and no loading in progress"),null),[H,oe]);return{state:A,name:H?.name||t||"",tools:j,resources:V,resourceTemplates:ee,prompts:W,serverInfo:H,capabilities:ne,error:B,log:$,authUrl:G,authTokens:re,client:ce.current,callTool:We,readResource:pt,listResources:Ln,listPrompts:Zn,getPrompt:wt,refreshTools:sn,refreshResources:He,refreshPrompts:Fe,refreshAll:Ze,retry:Ye,disconnect:xe,authenticate:ot,clearStorage:kt,ensureIconLoaded:St}}ke(LN,"useMcp");function ME({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:a="",onSuccess:r,onError:i,trigger:s}){const[c,u]=y.useState(!1),[f,m]=y.useState(null),[h,g]=y.useState(!1),[v,S]=y.useState(!1),{url:x,name:w,headers:E}=e,_=ke(()=>{try{const j=pk(x,w,E);window.location.href=j,r?.("Cursor")}catch(j){console.error("Failed to generate Cursor deep link:",j),i?.(j)}},"handleCursorClick"),k=ke(()=>{try{const j=mk(x,w,E);window.location.href=j,r?.("VS Code")}catch(j){console.error("Failed to generate VS Code deep link:",j),i?.(j)}},"handleVSCodeClick"),R=ke(()=>{try{hk(x,w,E),r?.("Claude Desktop")}catch(j){console.error("Failed to download .mcpb file:",j),i?.(j)}},"handleClaudeDesktopClick"),N=ke(()=>{m("claude-code"),u(!0)},"handleClaudeCodeClick"),I=ke(()=>{m("gemini-cli"),u(!0)},"handleGeminiCLIClick"),O=ke(()=>{m("codex-cli"),u(!0)},"handleCodexCLIClick"),A=ke(async j=>{try{await navigator.clipboard.writeText(j),g(!0),setTimeout(()=>g(!1),2e3)}catch(F){console.error("Failed to copy:",F),i?.(F)}},"handleCopy"),M=ke(()=>{if(f==="claude-code"){const{command:j,envVars:F}=gk(x,w,E),V=iE(F);return X.createElement("div",{className:"space-y-4"},X.createElement("div",null,X.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Claude Code"),X.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Execute the following command in your shell to add this server to Claude Code.")),X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),X.createElement("ol",{className:"space-y-2 text-xs text-gray-600 dark:text-gray-400"},X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"1."),X.createElement("span",null,"Ensure the Claude Code executable is available in your path")),X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"2."),X.createElement("span",null,"Execute the following snippet in your shell:")))),X.createElement("div",{className:"relative"},X.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>A(j)},h?"✓ Copied":"Copy"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-bash"},j))),V&&X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Environment Variables"),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2"},"After installation, set these environment variables in your shell:"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-bash"},V))),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"The MCP configuration supports environment variable expansion using"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"${VAR}")," ","syntax."))}if(f==="gemini-cli"){const{command:j,envVars:F}=bk(x,w,E),V=iE(F);return X.createElement("div",{className:"space-y-4"},X.createElement("div",null,X.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Gemini CLI"),X.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Execute the following command in your shell to add this server to Gemini CLI.")),X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),X.createElement("ol",{className:"space-y-2 text-xs text-gray-600 dark:text-gray-400"},X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"1."),X.createElement("span",null,"Ensure the Gemini CLI executable is available in your path")),V&&X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"2."),X.createElement("span",null,"Set these environment variables in your shell before running the command:")),X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},V?"3.":"2."),X.createElement("span",null,"Execute the following snippet in your shell:")))),V&&X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Environment Variables"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-bash"},V))),X.createElement("div",{className:"relative"},X.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>A(j)},h?"✓ Copied":"Copy"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-bash"},j))),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Restart Gemini CLI to load the new configuration."))}if(f==="codex-cli"){const{config:j,envVars:F}=vk(x,w,E);return X.createElement("div",{className:"space-y-4"},X.createElement("div",null,X.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Codex CLI"),X.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Add this configuration to your"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"~/.codex/config.toml")," ","file.")),X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Add this configuration to your"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"~/.codex/config.toml"),":")),X.createElement("div",{className:"relative"},X.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>A(j)},h?"✓ Copied":"Copy"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-toml"},j))),F.length>0&&X.createElement("div",null,X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"(optional) If you would rather use variables from your system's environment, replace the"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"http_headers")," ","key with the"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"env_http_headers")," ","key as shown in the commented section above.")),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Restart Codex CLI to load the new configuration."))}return null},"renderModalContent");return X.createElement(X.Fragment,null,X.createElement("div",{className:"relative inline-block"},s?X.createElement("div",{onClick:j=>{j.stopPropagation(),S(!v)},className:"cursor-pointer"},typeof s=="function"?s({isOpen:v,onClick:ke(()=>S(!v),"onClick")}):X.isValidElement(s)?X.cloneElement(s,{onClick:ke(j=>{j.preventDefault(),j.stopPropagation(),S(!v)},"onClick")}):s):X.createElement("button",{onClick:()=>S(!v),className:`inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${a}`},X.createElement("span",null,"Add to Client"),X.createElement("svg",{className:`w-4 h-4 transition-transform ${v?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},X.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),v&&X.createElement(X.Fragment,null,X.createElement("div",{className:"fixed inset-0 z-40",onClick:()=>S(!1)}),X.createElement("div",{className:"absolute right-0 mt-2 w-auto min-w-[300px] rounded-md shadow-lg bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 z-50"},X.createElement("div",{className:"py-1"},t.map(j=>X.createElement("button",{key:j.id,onClick:async()=>{S(!1),await j.onClick()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},j.icon,X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},j.label))),t.length>0&&X.createElement("div",{className:"border-t border-gray-200 dark:border-gray-700 my-1"}),n.cursor&&X.createElement("button",{onClick:()=>{S(!1),_()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Cursor")),n.claudeCode&&X.createElement("button",{onClick:()=>{S(!1),N()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Claude Code")),n.claudeDesktop&&X.createElement("button",{onClick:()=>{S(!1),R()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Claude Desktop")),n.vsCode&&X.createElement("button",{onClick:()=>{S(!1),k()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor"},X.createElement("path",{d:"M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z"})),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"VS Code")),n.geminiCli&&X.createElement("button",{onClick:()=>{S(!1),I()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Gemini CLI")),n.codexCli&&X.createElement("button",{onClick:()=>{S(!1),O()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://inspector-cdn.mcp-use.com/providers/openai.png",alt:"Codex",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Codex CLI")))))),c&&X.createElement(X.Fragment,null,X.createElement("div",{className:"fixed inset-0 bg-black/50 z-50",onClick:()=>{u(!1),m(null)}}),X.createElement("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:()=>{u(!1),m(null)}},X.createElement("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl max-w-3xl w-full max-h-[80vh] overflow-y-auto border border-gray-200 dark:border-gray-700 p-6 relative",onClick:j=>j.stopPropagation()},X.createElement("button",{onClick:()=>{u(!1),m(null)},className:"absolute top-4 right-4 p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors","aria-label":"Close"},X.createElement("svg",{className:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},X.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))),M()))))}ke(ME,"AddToClientDropdown");var Ju,Yoe=(Ju=class extends X.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?X.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"},X.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),X.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},ke(Ju,"ErrorBoundary"),Ju),bp="openai:set_globals";function ui(e){return y.useSyncExternalStore(t=>{const n=ke(a=>{a.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(bp,n),()=>{typeof window<"u"&&window.removeEventListener(bp,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}ke(ui,"useOpenAiGlobal");function Ad(e){const[t,n]=y.useState(()=>typeof window<"u"&&!!window.openai);y.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const j=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(j))},100),F=ke(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(j))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(bp,F);const V=setTimeout(()=>{clearInterval(j),typeof window<"u"&&window.removeEventListener(bp,F)},5e3);return()=>{clearInterval(j),clearTimeout(V),typeof window<"u"&&window.removeEventListener(bp,F)}},[]);const a=y.useMemo(()=>t?"openai":"mcp-ui",[t]),r=typeof window<"u"?window.location.search:"",i=y.useMemo(()=>{const j=new URLSearchParams(r);return j.has("mcpUseParams")?JSON.parse(j.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[r]),s=a==="openai"?ui("toolInput"):i.toolInput,c=a==="openai"?ui("toolOutput"):i.toolOutput,u=ui("toolResponseMetadata"),f=y.useMemo(()=>{if(u&&typeof u=="object"){const j=u["mcp-use/props"];if(j)return j}return e||{}},[u,e]),m=ui("widgetState"),h=ui("theme"),g=ui("displayMode"),v=ui("safeArea"),S=ui("maxHeight"),x=ui("userAgent"),w=ui("locale"),E=y.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,k]=y.useState(null);y.useEffect(()=>{m!==void 0&&k(m)},[m]);const R=y.useCallback(async(j,F)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(j,F)},[]),N=y.useCallback(async j=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:j})},[]),I=y.useCallback(j=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:j})},[]),O=y.useCallback(async j=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:j})},[]),A=y.useCallback(async j=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const V=typeof j=="function"?j(m!==void 0?m:_):j;return k(V),window.openai.setWidgetState(V)},[m,_]),M=y.useMemo(()=>a==="openai"&&u===null,[a,u]);return{props:f,toolInput:s||{},output:c??null,metadata:u??null,state:_,setState:A,theme:h||"light",displayMode:g||"inline",safeArea:v||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:S||600,userAgent:x||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:w||"en",mcp_url:E,callTool:R,sendFollowUpMessage:N,openExternal:I,requestDisplayMode:O,isAvailable:t,isPending:M}}ke(Ad,"useWidget");function qoe(e){const{props:t}=Ad(e);return t}ke(qoe,"useWidgetProps");function Xoe(){const{theme:e}=Ad();return e}ke(Xoe,"useWidgetTheme");function Joe(e){const{state:t,setState:n}=Ad();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}ke(Joe,"useWidgetState");var wz=ke(({children:e})=>{const{theme:t,isAvailable:n}=Ad();console.log("theme",t);const[a,r]=y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");y.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),c=ke(u=>{r(u.matches?"dark":"light")},"handleChange");return s.addEventListener("change",c),()=>s.removeEventListener("change",c)},[]);const i=n?t:a;return y.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),X.createElement(X.Fragment,null,e)},"ThemeProvider");function w9({children:e,className:t="",position:n="top-right",attachTo:a,showLabels:r=!0,debugger:i=!1,viewControls:s=!1}){const{props:c,output:u,metadata:f,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:S,userAgent:x,locale:w,isAvailable:E,callTool:_,sendFollowUpMessage:k,openExternal:R,requestDisplayMode:N,setState:I}=Ad(),[O,A]=y.useState(!1),[M,j]=y.useState(!1),F=y.useRef(null),V=y.useRef(null),[J,ee]=y.useState([]),[ie,W]=y.useState(""),[Z,H]=y.useState("get-my-city"),[ae,ne]=y.useState("{}"),[L,B]=y.useState("Test follow-up message"),[P,$]=y.useState("https://docs.mcp-use.com"),z=g==="fullscreen"&&E,G=g==="pip"&&E,K=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const xe=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const Ee=Object.keys(window.openai);ee(Ee)}catch{ee([])}else ee([])},100);return()=>{clearTimeout(xe)}},[]);const re=h==="dark",fe=ke(()=>{const xe=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",O?"opacity-100":"opacity-0",O?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...xe,"top-4","left-4"];case"top-center":return[...xe,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...xe,"top-4","right-4"];case"center-left":return[...xe,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...xe,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...xe,"bottom-4","left-4"];case"bottom-center":return[...xe,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...xe,"bottom-4","right-4"];default:return[...xe,"top-4","right-4"]}},"getPositionClasses"),ce=ke(()=>{const Ee=v?.insets?.top?Math.max(16,v.insets.top+8):16,je=v?.insets?.right?Math.max(16,v.insets.right+8):16,We=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Ye=v?.insets?.left?Math.max(16,v.insets.left+8):16,ot={};switch(n){case"top-left":ot.top=`${Ee}px`,ot.left=`${Ye}px`;break;case"top-center":ot.top=`${Ee}px`;break;case"top-right":ot.top=`${Ee}px`,ot.right=`${je}px`;break;case"center-left":ot.left=`${Ye}px`;break;case"center-right":ot.right=`${je}px`;break;case"bottom-left":ot.bottom=`${We}px`,ot.left=`${Ye}px`;break;case"bottom-center":ot.bottom=`${We}px`;break;case"bottom-right":ot.bottom=`${We}px`,ot.right=`${je}px`;break;default:ot.top=`${Ee}px`,ot.right=`${je}px`;break}return ot},"getPositionOffsetStyles");y.useEffect(()=>{if(!a)return;const xe=ke(()=>A(!0),"handleMouseEnter"),Ee=ke(()=>A(!1),"handleMouseLeave");return a.addEventListener("mouseenter",xe),a.addEventListener("mouseleave",Ee),()=>{a.removeEventListener("mouseenter",xe),a.removeEventListener("mouseleave",Ee)}},[a]),y.useEffect(()=>{if(!M)return;const xe=ke(Ee=>{V.current&&!V.current.contains(Ee.target)&&j(!1)},"handleClickOutside");return document.addEventListener("mousedown",xe),()=>{document.removeEventListener("mousedown",xe)}},[M]),y.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const q=ke(()=>{j(!M)},"handleToggleOverlay"),te=ke(async()=>{try{W("Calling tool...");const xe=ae.trim()?JSON.parse(ae):{},Ee=await _(Z,xe);W(`Success: ${JSON.stringify(Ee,null,2)}`)}catch(xe){W(`Error: ${xe.message}`)}},"handleCallTool"),se=ke(async()=>{try{W("Sending follow-up message..."),await k(L),W("Follow-up message sent successfully")}catch(xe){W(`Error: ${xe.message}`)}},"handleSendFollowUpMessage"),de=ke(()=>{try{R(P),W(`Opened external link: ${P}`)}catch(xe){W(`Error: ${xe.message}`)}},"handleOpenExternal"),ye=ke(async xe=>{try{W(`Requesting display mode: ${xe}...`);const Ee=await N(xe);W(`Display mode granted: ${Ee.mode}`)}catch(Ee){W(`Error: ${Ee.message}`)}},"handleRequestDisplayMode"),Te=ke(async()=>{try{const xe=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};W("Setting state..."),await I(xe),W(`State updated: ${JSON.stringify(xe,null,2)}`)}catch(xe){W(`Error: ${xe.message}`)}},"handleSetState"),Ge=ke(async()=>{try{await N("fullscreen")}catch(xe){console.error("Failed to go fullscreen:",xe)}},"handleFullscreen"),Ie=ke(async()=>{try{await N("pip")}catch(xe){console.error("Failed to go pip:",xe)}},"handlePip"),Me=ke(()=>{const xe=["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[...xe,"top-full","right-0","mt-2"];case"top-left":return[...xe,"top-full","left-0","mt-2"];case"top-center":return[...xe,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...xe,"bottom-full","right-0","mb-2"];case"bottom-left":return[...xe,"bottom-full","left-0","mb-2"];case"bottom-center":return[...xe,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...xe,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...xe,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...xe,"top-full","right-0","mt-2"]}},"getTooltipClasses"),nt=ke(({onClick:xe,label:Ee,children:je})=>{const[We,Ye]=y.useState(!1),ot=Me();return X.createElement("button",{className:`p-2 ${re?"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 ${re?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Ye(!0),onMouseLeave:()=>Ye(!1),onClick:xe,"aria-label":Ee},X.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"},je),r&&X.createElement("span",{className:`${ot.join(" ")} ${We?"opacity-100":"opacity-0"}`},Ee))},"IconButton"),Ue=ke(xe=>{if(xe===null)return"null";if(xe===void 0)return"undefined";if(typeof xe=="object")try{return JSON.stringify(xe,null,2)}catch{return String(xe)}return String(xe)},"formatValue"),pe=ke(xe=>xe?`${xe.device?.type||"unknown"}`:"N/A","formatUserAgent"),oe=ke(xe=>{if(!xe?.insets)return"N/A";const{top:Ee,bottom:je,left:We,right:Ye}=xe.insets;return`T:${Ee} B:${je} L:${We} R:${Ye}`},"formatSafeArea");return X.createElement(X.Fragment,null,X.createElement("div",{ref:F,className:`${t} relative h-fit`,onMouseEnter:()=>!a&&A(!0),onMouseLeave:()=>!a&&A(!1)},X.createElement("div",{className:fe().join(" "),style:ce()},!K&&X.createElement(X.Fragment,null,!z&&!G&&X.createElement(X.Fragment,null,(s===!0||s==="fullscreen")&&X.createElement(nt,{onClick:Ge,label:"Fullscreen"},X.createElement("path",{d:"M15 3h6v6"}),X.createElement("path",{d:"m21 3-7 7"}),X.createElement("path",{d:"m3 21 7-7"}),X.createElement("path",{d:"M9 21H3v-6"})),(s===!0||s==="pip")&&X.createElement(nt,{onClick:Ie,label:"Picture in Picture"},X.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),X.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&X.createElement(nt,{onClick:q,label:"Debug Info"},X.createElement("path",{d:"M12 20v-9"}),X.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),X.createElement("path",{d:"M14.12 3.88 16 2"}),X.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),X.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),X.createElement("path",{d:"M22 13h-4"}),X.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),X.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),X.createElement("path",{d:"M6 13H2"}),X.createElement("path",{d:"m8 2 1.88 1.88"}),X.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),M&&i&&X.createElement("div",{ref:V,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:xe=>{xe.target===V.current&&j(!1)}},X.createElement("button",{onClick:()=>j(!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"},"×"),X.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},X.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),X.createElement("table",{className:"w-full border-collapse border-spacing-0"},X.createElement("tbody",null,X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),X.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Ue(c))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),X.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Ue(u))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),X.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Ue(f))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),X.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Ue(m))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),X.createElement("td",{className:"p-2"},h)),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),X.createElement("td",{className:"p-2"},g)),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),X.createElement("td",{className:"p-2"},w)),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),X.createElement("td",{className:"p-2"},S,"px")),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),X.createElement("td",{className:"p-2"},pe(x))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),X.createElement("td",{className:"p-2"},oe(v))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),X.createElement("td",{className:"p-2"},E?"Yes":"No")),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),X.createElement("td",{className:"p-2"},J.length>0?J.join(", "):"N/A")))),X.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),X.createElement("div",{className:"flex flex-col gap-3"},X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("input",{type:"text",value:Z,onChange:xe=>H(xe.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]"}),X.createElement("input",{type:"text",value:ae,onChange:xe=>ne(xe.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"}),X.createElement("button",{onClick:te,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("input",{type:"text",value:L,onChange:xe=>B(xe.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"}),X.createElement("button",{onClick:se,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Send Follow-Up")),X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("input",{type:"text",value:P,onChange:xe=>$(xe.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"}),X.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")),X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),X.createElement("button",{onClick:()=>ye("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"),X.createElement("button",{onClick:()=>ye("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"),X.createElement("button",{onClick:()=>ye("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")),X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("button",{onClick:Te,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)")),ie&&X.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"},X.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ie,X.createElement("button",{onClick:()=>W(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}ke(w9,"WidgetControls");function x9(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}ke(x9,"getBasename");var Qoe=150,ese=5;function tse({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=x9(),i=y.useRef(null),s=y.useRef(0),c=y.useRef(null),u=y.useRef(!1),[f,m]=y.useState(null),[h,g]=y.useState(null),[v,S]=y.useState(!0);y.useEffect(()=>{let _=!0;return(async()=>{try{const k=await ia(()=>import("./index-BGExFjwX.js"),[]);_&&(m(()=>k.BrowserRouter),S(!1))}catch{_&&(g(new Error(`❌ react-router not installed!
98
+ `&&a++}}return[t,n]}class joe extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let r;super({start(i){r=b9({onEvent:s=>{i.enqueue(s)},onError(s){t==="terminate"?i.error(s):typeof t=="function"&&t(s)},onRetry:n,onComment:a})},transform(i){r.feed(i)}})}}const Loe={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 $oe{constructor(t,n){var a;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=r9(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(a=n?.reconnectionOptions)!==null&&a!==void 0?a:Loe}async _authThenStart(){var t;if(!this._authProvider)throw new qa("No auth provider");let n;try{n=await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new qa;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._sessionId&&(n["mcp-session-id"]=this._sessionId),this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=gv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}async _startOrAuthSse(t){var n,a,r,i;const{resumptionToken:s}=t;try{const c=await this._commonHeaders();c.set("Accept","text/event-stream"),s&&c.set("last-event-id",s);const u=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,{method:"GET",headers:c,signal:(a=this._abortController)===null||a===void 0?void 0:a.signal});if(!u.ok){if(await((r=u.body)===null||r===void 0?void 0:r.cancel()),u.status===401&&this._authProvider)return await this._authThenStart();if(u.status===405)return;throw new _l(u.status,`Failed to open SSE stream: ${u.statusText}`)}this._handleSseStream(u.body,t,!0)}catch(c){throw(i=this.onerror)===null||i===void 0||i.call(this,c),c}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const n=this._reconnectionOptions.initialReconnectionDelay,a=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(n*Math.pow(a,t),r)}_scheduleReconnection(t,n=0){var a;const r=this._reconnectionOptions.maxRetries;if(n>=r){(a=this.onerror)===null||a===void 0||a.call(this,new Error(`Maximum reconnection attempts (${r}) exceeded.`));return}const i=this._getNextReconnectionDelay(n);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{var c;(c=this.onerror)===null||c===void 0||c.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,n+1)})},i)}_handleSseStream(t,n,a){if(!t)return;const{onresumptiontoken:r,replayMessageId:i}=n;let s,c=!1,u=!1;(async()=>{var m,h,g,v;try{const S=t.pipeThrough(new TextDecoderStream).pipeThrough(new joe({onRetry:E=>{this._serverRetryMs=E}})).getReader();for(;;){const{value:E,done:_}=await S.read();if(_)break;if(E.id&&(s=E.id,c=!0,r?.(E.id)),!!E.data&&(!E.event||E.event==="message"))try{const k=Ob.parse(JSON.parse(E.data));rp(k)&&(u=!0,i!==void 0&&(k.id=i)),(m=this.onmessage)===null||m===void 0||m.call(this,k)}catch(k){(h=this.onerror)===null||h===void 0||h.call(this,k)}}(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(S){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${S}`)),(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(E){(v=this.onerror)===null||v===void 0||v.call(this,new Error(`Failed to reconnect: ${E instanceof Error?E.message:String(E)}`))}}})()}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 qa("No auth provider");if(await Co(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa("Failed to authorize")}async close(){var t,n;this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),(t=this._abortController)===null||t===void 0||t.abort(),(n=this.onclose)===null||n===void 0||n.call(this)}async send(t,n){var a,r,i,s,c,u,f;try{const{resumptionToken:m,onresumptiontoken:h}=n||{};if(m){this._startOrAuthSse({resumptionToken:m,replayMessageId:hE(t)?t.id:void 0}).catch(k=>{var R;return(R=this.onerror)===null||R===void 0?void 0:R.call(this,k)});return}const g=await this._commonHeaders();g.set("content-type","application/json"),g.set("accept","application/json, text/event-stream");const v={...this._requestInit,method:"POST",headers:g,body:JSON.stringify(t),signal:(a=this._abortController)===null||a===void 0?void 0:a.signal},S=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,v),x=S.headers.get("mcp-session-id");if(x&&(this._sessionId=x),!S.ok){const k=await S.text().catch(()=>null);if(S.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new _l(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:R,scope:N}=Mp(S);if(this._resourceMetadataUrl=R,this._scope=N,await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa;return this._hasCompletedAuthFlow=!0,this.send(t)}if(S.status===403&&this._authProvider){const{resourceMetadataUrl:R,scope:N,error:I}=Mp(S);if(I==="insufficient_scope"){const O=S.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===O)throw new _l(403,"Server returned 403 after trying upscoping");if(N&&(this._scope=N),R&&(this._resourceMetadataUrl=R),this._lastUpscopingHeader=O??void 0,await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new qa;return this.send(t)}}throw new _l(S.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,S.status===202){await((i=S.body)===null||i===void 0?void 0:i.cancel()),Tre(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var R;return(R=this.onerror)===null||R===void 0?void 0:R.call(this,k)});return}const E=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,_=S.headers.get("content-type");if(E)if(_?.includes("text/event-stream"))this._handleSseStream(S.body,{onresumptiontoken:h},!1);else if(_?.includes("application/json")){const k=await S.json(),R=Array.isArray(k)?k.map(N=>Ob.parse(N)):[Ob.parse(k)];for(const N of R)(s=this.onmessage)===null||s===void 0||s.call(this,N)}else throw await((c=S.body)===null||c===void 0?void 0:c.cancel()),new _l(-1,`Unexpected content type: ${_}`);else await((u=S.body)===null||u===void 0?void 0:u.cancel())}catch(m){throw(f=this.onerror)===null||f===void 0||f.call(this,m),m}}get sessionId(){return this._sessionId}async terminateSession(){var t,n,a,r;if(this._sessionId)try{const i=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:i,signal:(t=this._abortController)===null||t===void 0?void 0:t.signal},c=await((n=this._fetch)!==null&&n!==void 0?n:fetch)(this._url,s);if(await((a=c.body)===null||a===void 0?void 0:a.cancel()),!c.ok&&c.status!==405)throw new _l(c.status,`Failed to terminate session: ${c.statusText}`);this._sessionId=void 0}catch(i){throw(r=this.onerror)===null||r===void 0||r.call(this,i),i}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,n){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:n?.onresumptiontoken})}}class mz extends Event{constructor(t,n){var a,r;super(t),this.code=(a=n?.code)!=null?a:void 0,this.message=(r=n?.message)!=null?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,a){return a(hz(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(hz(this),n)}}function Moe(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function CE(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(CE).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${CE(e.cause)}`:e.message:`${e}`}function hz(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var v9=e=>{throw TypeError(e)},ON=(e,t,n)=>t.has(e)||v9("Cannot "+n),Gt=(e,t,n)=>(ON(e,t,"read from private field"),n?n.call(e):t.get(e)),mr=(e,t,n)=>t.has(e)?v9("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Fn=(e,t,n,a)=>(ON(e,t,"write to private field"),t.set(e,n),n),_o=(e,t,n)=>(ON(e,t,"access private method"),n),ya,Tl,eu,jb,xv,hp,du,gp,Cs,tu,Eu,nu,ap,di,RE,AE,IE,gz,OE,DE,ip,jE,LE;class Lb extends EventTarget{constructor(t,n){var a,r;super(),mr(this,di),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,mr(this,ya),mr(this,Tl),mr(this,eu),mr(this,jb),mr(this,xv),mr(this,hp),mr(this,du),mr(this,gp,null),mr(this,Cs),mr(this,tu),mr(this,Eu,null),mr(this,nu,null),mr(this,ap,null),mr(this,AE,async i=>{var s;Gt(this,tu).reset();const{body:c,redirected:u,status:f,headers:m}=i;if(f===204){_o(this,di,ip).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?Fn(this,eu,new URL(i.url)):Fn(this,eu,void 0),f!==200){_o(this,di,ip).call(this,`Non-200 status code (${f})`,f);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){_o(this,di,ip).call(this,'Invalid content type, expected "text/event-stream"',f);return}if(Gt(this,ya)===this.CLOSED)return;Fn(this,ya,this.OPEN);const h=new Event("open");if((s=Gt(this,ap))==null||s.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){_o(this,di,ip).call(this,"Invalid response body, expected a web ReadableStream",f),this.close();return}const g=new TextDecoder,v=c.getReader();let S=!0;do{const{done:x,value:w}=await v.read();w&&Gt(this,tu).feed(g.decode(w,{stream:!x})),x&&(S=!1,Gt(this,tu).reset(),_o(this,di,jE).call(this))}while(S)}),mr(this,IE,i=>{Fn(this,Cs,void 0),!(i.name==="AbortError"||i.type==="aborted")&&_o(this,di,jE).call(this,CE(i))}),mr(this,OE,i=>{typeof i.id=="string"&&Fn(this,gp,i.id);const s=new MessageEvent(i.event||"message",{data:i.data,origin:Gt(this,eu)?Gt(this,eu).origin:Gt(this,Tl).origin,lastEventId:i.id||""});Gt(this,nu)&&(!i.event||i.event==="message")&&Gt(this,nu).call(this,s),this.dispatchEvent(s)}),mr(this,DE,i=>{Fn(this,hp,i)}),mr(this,LE,()=>{Fn(this,du,void 0),Gt(this,ya)===this.CONNECTING&&_o(this,di,RE).call(this)});try{if(t instanceof URL)Fn(this,Tl,t);else if(typeof t=="string")Fn(this,Tl,new URL(t,Poe()));else throw new Error("Invalid URL")}catch{throw Moe("An invalid or illegal string was specified")}Fn(this,tu,b9({onEvent:Gt(this,OE),onRetry:Gt(this,DE)})),Fn(this,ya,this.CONNECTING),Fn(this,hp,3e3),Fn(this,xv,(a=n?.fetch)!=null?a:globalThis.fetch),Fn(this,jb,(r=n?.withCredentials)!=null?r:!1),_o(this,di,RE).call(this)}get readyState(){return Gt(this,ya)}get url(){return Gt(this,Tl).href}get withCredentials(){return Gt(this,jb)}get onerror(){return Gt(this,Eu)}set onerror(t){Fn(this,Eu,t)}get onmessage(){return Gt(this,nu)}set onmessage(t){Fn(this,nu,t)}get onopen(){return Gt(this,ap)}set onopen(t){Fn(this,ap,t)}addEventListener(t,n,a){const r=n;super.addEventListener(t,r,a)}removeEventListener(t,n,a){const r=n;super.removeEventListener(t,r,a)}close(){Gt(this,du)&&clearTimeout(Gt(this,du)),Gt(this,ya)!==this.CLOSED&&(Gt(this,Cs)&&Gt(this,Cs).abort(),Fn(this,ya,this.CLOSED),Fn(this,Cs,void 0))}}ya=new WeakMap,Tl=new WeakMap,eu=new WeakMap,jb=new WeakMap,xv=new WeakMap,hp=new WeakMap,du=new WeakMap,gp=new WeakMap,Cs=new WeakMap,tu=new WeakMap,Eu=new WeakMap,nu=new WeakMap,ap=new WeakMap,di=new WeakSet,RE=function(){Fn(this,ya,this.CONNECTING),Fn(this,Cs,new AbortController),Gt(this,xv)(Gt(this,Tl),_o(this,di,gz).call(this)).then(Gt(this,AE)).catch(Gt(this,IE))},AE=new WeakMap,IE=new WeakMap,gz=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Gt(this,gp)?{"Last-Event-ID":Gt(this,gp)}:void 0},cache:"no-store",signal:(e=Gt(this,Cs))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},OE=new WeakMap,DE=new WeakMap,ip=function(e,t){var n;Gt(this,ya)!==this.CLOSED&&Fn(this,ya,this.CLOSED);const a=new mz("error",{code:t,message:e});(n=Gt(this,Eu))==null||n.call(this,a),this.dispatchEvent(a)},jE=function(e,t){var n;if(Gt(this,ya)===this.CLOSED)return;Fn(this,ya,this.CONNECTING);const a=new mz("error",{code:t,message:e});(n=Gt(this,Eu))==null||n.call(this,a),this.dispatchEvent(a),Fn(this,du,setTimeout(Gt(this,LE),Gt(this,hp)))},LE=new WeakMap,Lb.CONNECTING=0,Lb.OPEN=1,Lb.CLOSED=2;function Poe(){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 zoe extends Error{constructor(t,n,a){super(`SSE error: ${n}`),this.code=t,this.event=a}}class Uoe{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=r9(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new qa("No auth provider");let n;try{n=await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(a){throw(t=this.onerror)===null||t===void 0||t.call(this,a),a}if(n!=="AUTHORIZED")throw new qa;return await this._startOrAuth()}async _commonHeaders(){var t;const n={};if(this._authProvider){const r=await this._authProvider.tokens();r&&(n.Authorization=`Bearer ${r.access_token}`)}this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion);const a=gv((t=this._requestInit)===null||t===void 0?void 0:t.headers);return new Headers({...n,...a})}_startOrAuth(){var t,n,a;const r=(a=(n=(t=this===null||this===void 0?void 0:this._eventSourceInit)===null||t===void 0?void 0:t.fetch)!==null&&n!==void 0?n:this._fetch)!==null&&a!==void 0?a:fetch;return new Promise((i,s)=>{this._eventSource=new Lb(this._url.href,{...this._eventSourceInit,fetch:async(c,u)=>{const f=await this._commonHeaders();f.set("Accept","text/event-stream");const m=await r(c,{...u,headers:f});if(m.status===401&&m.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=Mp(m);this._resourceMetadataUrl=h,this._scope=g}return m}}),this._abortController=new AbortController,this._eventSource.onerror=c=>{var u;if(c.code===401&&this._authProvider){this._authThenStart().then(i,s);return}const f=new zoe(c.code,c.message,c);s(f),(u=this.onerror)===null||u===void 0||u.call(this,f)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",c=>{var u;const f=c;try{if(this._endpoint=new URL(f.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(m){s(m),(u=this.onerror)===null||u===void 0||u.call(this,m),this.close();return}i()}),this._eventSource.onmessage=c=>{var u,f;const m=c;let h;try{h=Ob.parse(JSON.parse(m.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(f=this.onmessage)===null||f===void 0||f.call(this,h)}})}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 qa("No auth provider");if(await Co(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa("Failed to authorize")}async close(){var t,n,a;(t=this._abortController)===null||t===void 0||t.abort(),(n=this._eventSource)===null||n===void 0||n.close(),(a=this.onclose)===null||a===void 0||a.call(this)}async send(t){var n,a,r,i;if(!this._endpoint)throw new Error("Not connected");try{const s=await this._commonHeaders();s.set("content-type","application/json");const c={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:(n=this._abortController)===null||n===void 0?void 0:n.signal},u=await((a=this._fetch)!==null&&a!==void 0?a:fetch)(this._endpoint,c);if(!u.ok){const f=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:m,scope:h}=Mp(u);if(this._resourceMetadataUrl=m,this._scope=h,await Co(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new qa;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${f}`)}await((r=u.body)===null||r===void 0?void 0:r.cancel())}catch(s){throw(i=this.onerror)===null||i===void 0||i.call(this,s),s}}setProtocolVersion(t){this._protocolVersion=t}}var Wu,Foe=(Wu=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={},a){return this.connector.callTool(t,n,a)}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,a){return this.connector.request(t,n,a)}},ke(Wu,"MCPSession"),Wu),Ku,Boe=(Ku=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,Pi.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Pi.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 a=this.config.mcpServers??{};if(Object.keys(a).length===0&&$e.warn("No MCP servers defined in config"),!a[t])throw new Error(`Server '${t}' not found in config`);const r=this.createConnectorFromConfig(a[t]),i=new Foe(r);return n&&await i.initialize(),this.sessions[t]=i,this.activeSessions.includes(t)||this.activeSessions.push(t),i}async createAllSessions(t=!0){const n=this.config.mcpServers??{};Object.keys(n).length===0&&$e.warn("No MCP servers defined in config");for(const a of Object.keys(n))await this.createSession(a,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){$e.warn(`No session exists for server ${t}, nothing to close`);return}try{$e.debug(`Closing session for server ${t}`),await n.disconnect()}catch(a){$e.error(`Error closing session for server '${t}': ${a}`)}finally{delete this.sessions[t],this.activeSessions=this.activeSessions.filter(a=>a!==t)}}async closeAllSessions(){const t=Object.keys(this.sessions),n=[];for(const a of t)try{$e.debug(`Closing session for server ${a}`),await this.closeSession(a)}catch(r){const i=`Failed to close session for server '${a}': ${r}`;$e.error(i),n.push(i)}n.length?$e.error(`Encountered ${n.length} errors while closing sessions`):$e.debug("All sessions closed successfully")}},ke(Ku,"BaseMCPClient"),Ku),Zu,Hoe=(Zu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),$e.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){$e.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?$e.debug(`${this.constructor.name} task aborted successfully`):$e.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,$e.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(){$e.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),$e.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,$e.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){$e.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 a=this._abortController.signal;if(a.aborted){t();return}const r=ke(()=>{a.removeEventListener("abort",r),t()},"onAbort");a.addEventListener("abort",r)})}},ke(Zu,"ConnectionManager"),Zu),Yu,Voe=(Yu=class extends Hoe{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 Uoe(this.url,this.opts),n=t.send.bind(t);return t.send=async a=>{const r=ke(async i=>{if(Array.isArray(i))for(const s of i)await n(s);else await n(i)},"sendMessage");try{await r(a)}catch(i){if(i?.code===404&&t.sessionId&&!this.reinitializing){$e.warn("[SSE] Session not found (404), re-initializing per MCP spec..."),this.reinitializing=!0;try{t.sessionId=void 0,await this.reinitialize(t),$e.info("[SSE] Re-initialization successful, retrying request"),await r(a)}finally{this.reinitializing=!1}}else throw i}},this._transport=t,$e.debug(`${this.constructor.name} connected successfully`),t}async reinitialize(t){$e.debug("[SSE] Re-initialization triggered")}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){$e.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},ke(Yu,"SseConnectionManager"),Yu),qu,Goe=(qu=class extends Bae{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){$e.debug("Already connected to MCP implementation");return}const t=this.gatewayUrl?this.gatewayUrl.replace(/\/$/,""):this.baseUrl;if(this.preferSse){$e.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}$e.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{$e.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),$e.info("✅ Successfully connected via streamable HTTP")}catch(n){let a="Unknown error",r=!1;if(n instanceof _l){const i=n;r=i.code===401,i.code===400&&i.message.includes("Missing session ID")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",$e.warn(`⚠️ ${a}`)):i.code===404||i.code===405?(a=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,$e.debug(a)):(a=`Server returned ${i.code}: ${i.message}`,$e.debug(a))}else if(n instanceof Error){const i=n.toString(),s=n.message||"";r=i.includes("401")||s.includes("Unauthorized"),i.includes("Missing session ID")||i.includes("Bad Request: Missing session ID")||s.includes("FastMCP session ID error")?(a="Server requires session ID (FastMCP compatibility) - using SSE transport",$e.warn(`⚠️ ${a}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(a="Server doesn't support streamable HTTP (405/404)",$e.debug(a)):(a=`Streamable HTTP failed: ${n.message}`,$e.debug(a))}if(r){$e.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}if(this.disableSseFallback)throw $e.info("SSE fallback disabled - failing connection"),await this.cleanupResources(),new Error(`Streamable HTTP connection failed: ${a}`);$e.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if($e.error("Failed to connect with both transports:"),$e.error(` Streamable HTTP: ${a}`),$e.error(` SSE: ${i}`),await this.cleanupResources(),i?.message?.includes("401")||i?.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 $oe(new URL(t),{authProvider:this.opts.authProvider,requestInit:{headers:this.headers},reconnectionOptions:{maxReconnectionDelay:3e4,initialReconnectionDelay:1e3,reconnectionDelayGrowFactor:1.5,maxRetries:2}});let a=n;if(this.opts.wrapTransport){const i=this.baseUrl;a=this.opts.wrapTransport(a,i)}const r={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};$e.debug("Creating Client with capabilities:",JSON.stringify(r.capabilities,null,2)),this.client=new cz(this.clientInfo,r),this.setupRootsHandler(),$e.debug("Roots handler registered before connect");try{await this.client.connect(a,{timeout:this.timeout});const i=n.sessionId;i?$e.debug(`Session ID obtained: ${i}`):$e.warn("Session ID not available after connect - this may cause issues with SSE stream")}catch(i){if(i instanceof Error){const s=i.message||i.toString();if(s.includes("Missing session ID")||s.includes("Bad Request: Missing session ID")||s.includes("Mcp-Session-Id header is required")){const c=new Error(`Session ID error: ${s}. The SDK should automatically extract session ID from initialize response.`);throw c.cause=i,c}}throw i}this.streamableTransport=n,this.connectionManager={stop:ke(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){$e.warn(`Error closing Streamable HTTP transport: ${i}`)}finally{this.streamableTransport=null}},"stop")},this.connected=!0,this.transportType="streamable-http",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$e.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 Voe(t,{authProvider:this.opts.authProvider,requestInit:{headers:this.headers}});let n=await this.connectionManager.start();if(this.opts.wrapTransport){const r=this.baseUrl;n=this.opts.wrapTransport(n,r)}const a={...this.opts.clientOptions||{},capabilities:{...this.opts.clientOptions?.capabilities||{},roots:{listChanged:!0},...this.opts.samplingCallback?{sampling:{}}:{},...this.opts.elicitationCallback?{elicitation:{form:{},url:{}}}:{}}};$e.debug("Creating Client with capabilities (SSE):",JSON.stringify(a.capabilities,null,2)),this.client=new cz(this.clientInfo,a),this.setupRootsHandler(),$e.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),$e.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}},ke(qu,"HttpConnector"),qu),Bl,Woe=(Bl=class extends Boe{static getPackageVersion(){return wk()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Pi.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>$e.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new Bl(t)}createConnectorFromConfig(t){const{url:n,headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:f,disableSseFallback:m,preferSse:h}=t;if(!n)throw new Error("Server URL is required");const g={headers:a,authToken:r,authProvider:i,wrapTransport:s,clientOptions:c,samplingCallback:u,elicitationCallback:f,disableSseFallback:m,preferSse:h};return c?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(c,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),new Goe(n,g)}},ke(Bl,"BrowserMCPClient"),Bl);function fu(e){const t=ke(()=>{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(y9).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}ke(fu,"sanitizeUrl");function y9([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}ke(y9,"sanitizeParam");var Xu,$b=(Xu=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=fu(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 fu(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(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse client information:`,a),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(a){console.warn(`[${this.storageKeyPrefix}] Failed to parse tokens:`,a),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(),a=`${this.storageKeyPrefix}:state_${n}`,r={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(a,JSON.stringify(r)),t.searchParams.set("state",n);const i=t.toString(),s=fu(i);return localStorage.setItem(this.getKey("last_auth_url"),s),s}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 a="width=600,height=700,resizable=yes,scrollbars=yes,status=yes";try{const r=window.open(n,`mcp_auth_${this.serverUrlHash}`,a);this.onPopupWindow&&this.onPopupWindow(n,a,r),!r||r.closed||typeof r.closed>"u"?console.warn(`[${this.storageKeyPrefix}] Popup likely blocked by browser. Manual navigation might be required using the stored URL.`):(r.focus(),console.info(`[${this.storageKeyPrefix}] Redirecting to authorization URL in popup.`))}catch(r){console.error(`[${this.storageKeyPrefix}] Error opening popup window:`,r)}}getLastAttemptedAuthUrl(){const t=localStorage.getItem(this.getKey("last_auth_url"));return t?fu(t):null}clearStorage(){const t=`${this.storageKeyPrefix}_${this.serverUrlHash}_`,n=`${this.storageKeyPrefix}:state_`,a=[];let r=0;for(let s=0;s<localStorage.length;s++){const c=localStorage.key(s);if(c){if(c.startsWith(t))a.push(c);else if(c.startsWith(n))try{const u=localStorage.getItem(c);u&&JSON.parse(u).serverUrlHash===this.serverUrlHash&&a.push(c)}catch(u){console.warn(`[${this.storageKeyPrefix}] Error parsing state key ${c} during clearStorage:`,u)}}}return[...new Set(a)].forEach(s=>{localStorage.removeItem(s),r++}),r}hashString(t){let n=0;for(let a=0;a<t.length;a++){const r=t.charCodeAt(a);n=(n<<5)-n+r,n=n&n}return Math.abs(n).toString(16)}getKey(t){return`${this.storageKeyPrefix}_${this.serverUrlHash}_${t}`}},ke(Xu,"BrowserOAuthClientProvider"),Xu);async function DN(){const e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),a=e.get("error"),r=e.get("error_description"),i="[mcp-callback]";console.log(`${i} Handling callback...`,{code:t,state:n,error:a,errorDescription:r});let s=null,c=null;const u=n?`mcp:auth:state_${n}`:null;try{if(a)throw new Error(`OAuth error: ${a} - ${r||"No description provided."}`);if(!t)throw new Error("Authorization code not found in callback query parameters.");if(!n||!u)throw new Error("State parameter not found or invalid in callback query parameters.");const f=localStorage.getItem(u);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(u),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(`${i} Re-instantiating provider for server: ${m}`),s=new $b(m,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await Co(s,{serverUrl:g,authorizationCode:t});if(v==="AUTHORIZED")if(console.log(`${i} Authorization successful via SDK auth().`),c.flowType==="redirect"&&c.returnUrl)console.log(`${i} Redirect flow complete. Returning to: ${c.returnUrl}`),localStorage.removeItem(u),window.location.href=c.returnUrl;else if(window.opener&&!window.opener.closed)console.log(`${i} Popup flow complete. Notifying opener...`),window.opener.postMessage({type:"mcp_auth_callback",success:!0},window.location.origin),localStorage.removeItem(u),window.close();else{console.warn(`${i} No opener window or return URL detected. Redirecting to root.`),localStorage.removeItem(u);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(`${i} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(f){console.error(`${i} 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 S=document.createElement("p");S.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),S.appendChild(x),S.appendChild(document.createTextNode(".")),h.appendChild(S),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(`${i} Could not display error in callback window:`,h)}u&&localStorage.removeItem(u),s&&(localStorage.removeItem(s.getKey("code_verifier")),localStorage.removeItem(s.getKey("last_auth_url")))}}ke(DN,"onMcpAuthorization");var aS={exports:{}},Et={};var bz;function Koe(){if(bz)return Et;bz=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(L){return L===null||typeof L!="object"?null:(L=g&&L[g]||L["@@iterator"],typeof L=="function"?L:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,w={};function E(L,B,P){this.props=L,this.context=B,this.refs=w,this.updater=P||S}E.prototype.isReactComponent={},E.prototype.setState=function(L,B){if(typeof L!="object"&&typeof L!="function"&&L!=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,L,B,"setState")},E.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function _(){}_.prototype=E.prototype;function k(L,B,P){this.props=L,this.context=B,this.refs=w,this.updater=P||S}var R=k.prototype=new _;R.constructor=k,x(R,E.prototype),R.isPureReactComponent=!0;var N=Array.isArray;function I(){}var O={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function M(L,B,P){var $=P.ref;return{$$typeof:e,type:L,key:B,ref:$!==void 0?$:null,props:P}}function j(L,B){return M(L.type,B,L.props)}function F(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function V(L){var B={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(P){return B[P]})}var J=/\/+/g;function ee(L,B){return typeof L=="object"&&L!==null&&L.key!=null?V(""+L.key):B.toString(36)}function ie(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(I,I):(L.status="pending",L.then(function(B){L.status==="pending"&&(L.status="fulfilled",L.value=B)},function(B){L.status==="pending"&&(L.status="rejected",L.reason=B)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function W(L,B,P,$,z){var G=typeof L;(G==="undefined"||G==="boolean")&&(L=null);var K=!1;if(L===null)K=!0;else switch(G){case"bigint":case"string":case"number":K=!0;break;case"object":switch(L.$$typeof){case e:case t:K=!0;break;case m:return K=L._init,W(K(L._payload),B,P,$,z)}}if(K)return z=z(L),K=$===""?"."+ee(L,0):$,N(z)?(P="",K!=null&&(P=K.replace(J,"$&/")+"/"),W(z,B,P,"",function(ce){return ce})):z!=null&&(F(z)&&(z=j(z,P+(z.key==null||L&&L.key===z.key?"":(""+z.key).replace(J,"$&/")+"/")+K)),B.push(z)),1;K=0;var re=$===""?".":$+":";if(N(L))for(var fe=0;fe<L.length;fe++)$=L[fe],G=re+ee($,fe),K+=W($,B,P,G,z);else if(fe=v(L),typeof fe=="function")for(L=fe.call(L),fe=0;!($=L.next()).done;)$=$.value,G=re+ee($,fe++),K+=W($,B,P,G,z);else if(G==="object"){if(typeof L.then=="function")return W(ie(L),B,P,$,z);throw B=String(L),Error("Objects are not valid as a React child (found: "+(B==="[object Object]"?"object with keys {"+Object.keys(L).join(", ")+"}":B)+"). If you meant to render a collection of children, use an array instead.")}return K}function Z(L,B,P){if(L==null)return L;var $=[],z=0;return W(L,$,"","",function(G){return B.call(P,G,z++)}),$}function H(L){if(L._status===-1){var B=L._result;B=B(),B.then(function(P){(L._status===0||L._status===-1)&&(L._status=1,L._result=P)},function(P){(L._status===0||L._status===-1)&&(L._status=2,L._result=P)}),L._status===-1&&(L._status=0,L._result=B)}if(L._status===1)return L._result.default;throw L._result}var ae=typeof reportError=="function"?reportError:function(L){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var B=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof L=="object"&&L!==null&&typeof L.message=="string"?String(L.message):String(L),error:L});if(!window.dispatchEvent(B))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",L);return}console.error(L)},ne={map:Z,forEach:function(L,B,P){Z(L,function(){B.apply(this,arguments)},P)},count:function(L){var B=0;return Z(L,function(){B++}),B},toArray:function(L){return Z(L,function(B){return B})||[]},only:function(L){if(!F(L))throw Error("React.Children.only expected to receive a single React element child.");return L}};return Et.Activity=h,Et.Children=ne,Et.Component=E,Et.Fragment=n,Et.Profiler=r,Et.PureComponent=k,Et.StrictMode=a,Et.Suspense=u,Et.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,Et.__COMPILER_RUNTIME={__proto__:null,c:function(L){return O.H.useMemoCache(L)}},Et.cache=function(L){return function(){return L.apply(null,arguments)}},Et.cacheSignal=function(){return null},Et.cloneElement=function(L,B,P){if(L==null)throw Error("The argument must be a React element, but you passed "+L+".");var $=x({},L.props),z=L.key;if(B!=null)for(G in B.key!==void 0&&(z=""+B.key),B)!A.call(B,G)||G==="key"||G==="__self"||G==="__source"||G==="ref"&&B.ref===void 0||($[G]=B[G]);var G=arguments.length-2;if(G===1)$.children=P;else if(1<G){for(var K=Array(G),re=0;re<G;re++)K[re]=arguments[re+2];$.children=K}return M(L.type,z,$)},Et.createContext=function(L){return L={$$typeof:s,_currentValue:L,_currentValue2:L,_threadCount:0,Provider:null,Consumer:null},L.Provider=L,L.Consumer={$$typeof:i,_context:L},L},Et.createElement=function(L,B,P){var $,z={},G=null;if(B!=null)for($ in B.key!==void 0&&(G=""+B.key),B)A.call(B,$)&&$!=="key"&&$!=="__self"&&$!=="__source"&&(z[$]=B[$]);var K=arguments.length-2;if(K===1)z.children=P;else if(1<K){for(var re=Array(K),fe=0;fe<K;fe++)re[fe]=arguments[fe+2];z.children=re}if(L&&L.defaultProps)for($ in K=L.defaultProps,K)z[$]===void 0&&(z[$]=K[$]);return M(L,G,z)},Et.createRef=function(){return{current:null}},Et.forwardRef=function(L){return{$$typeof:c,render:L}},Et.isValidElement=F,Et.lazy=function(L){return{$$typeof:m,_payload:{_status:-1,_result:L},_init:H}},Et.memo=function(L,B){return{$$typeof:f,type:L,compare:B===void 0?null:B}},Et.startTransition=function(L){var B=O.T,P={};O.T=P;try{var $=L(),z=O.S;z!==null&&z(P,$),typeof $=="object"&&$!==null&&typeof $.then=="function"&&$.then(I,ae)}catch(G){ae(G)}finally{B!==null&&P.types!==null&&(B.types=P.types),O.T=B}},Et.unstable_useCacheRefresh=function(){return O.H.useCacheRefresh()},Et.use=function(L){return O.H.use(L)},Et.useActionState=function(L,B,P){return O.H.useActionState(L,B,P)},Et.useCallback=function(L,B){return O.H.useCallback(L,B)},Et.useContext=function(L){return O.H.useContext(L)},Et.useDebugValue=function(){},Et.useDeferredValue=function(L,B){return O.H.useDeferredValue(L,B)},Et.useEffect=function(L,B){return O.H.useEffect(L,B)},Et.useEffectEvent=function(L){return O.H.useEffectEvent(L)},Et.useId=function(){return O.H.useId()},Et.useImperativeHandle=function(L,B,P){return O.H.useImperativeHandle(L,B,P)},Et.useInsertionEffect=function(L,B){return O.H.useInsertionEffect(L,B)},Et.useLayoutEffect=function(L,B){return O.H.useLayoutEffect(L,B)},Et.useMemo=function(L,B){return O.H.useMemo(L,B)},Et.useOptimistic=function(L,B){return O.H.useOptimistic(L,B)},Et.useReducer=function(L,B,P){return O.H.useReducer(L,B,P)},Et.useRef=function(L){return O.H.useRef(L)},Et.useState=function(L){return O.H.useState(L)},Et.useSyncExternalStore=function(L,B,P){return O.H.useSyncExternalStore(L,B,P)},Et.useTransition=function(){return O.H.useTransition()},Et.version="19.2.3",Et}var vz;function jN(){return vz||(vz=1,aS.exports=Koe()),aS.exports}var y=jN();const X=iy(y),Rd=CJ({__proto__:null,default:X},[y]);function $E(e,t){if(!e)throw new Error(t)}ke($E,"assert");var yz=3e3,Zoe=5e3;function LN(e){const{url:t,enabled:n=!0,callbackUrl:a=typeof window<"u"?fu(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:r="mcp:auth",clientConfig:i={},customHeaders:s={},proxyConfig:c,debug:u=!1,autoRetry:f=!1,autoReconnect:m=yz,transportType:h="auto",preventAutoAuth:g=!1,useRedirectFlow:v=!1,onPopupWindow:S,timeout:x=3e4,sseReadTimeout:w=3e5,wrapTransport:E,onNotification:_,samplingCallback:k,onElicitation:R}=e,{url:N,headers:I}=y.useMemo(()=>yk(t||"",c),[t,c]),O=y.useMemo(()=>({...I,...s}),[I,s]),[A,M]=y.useState("discovering"),[j,F]=y.useState([]),[V,J]=y.useState([]),[ee,ie]=y.useState([]),[W,Z]=y.useState([]),[H,ae]=y.useState(),[ne,L]=y.useState(),[B,P]=y.useState(void 0),[$,z]=y.useState([]),[G,K]=y.useState(void 0),[re,fe]=y.useState(void 0),ce=y.useRef(null),q=y.useRef(null),te=y.useRef(null),se=y.useRef(!1),de=y.useRef(!0),ye=y.useRef(0),Te=y.useRef(null),Ge=y.useRef(!1),Ie=y.useRef(A),Me=y.useRef(m),nt=y.useRef(null),Ue=y.useRef(null),pe=y.useRef(null);y.useEffect(()=>{Ie.current=A,Me.current=m},[A,m]);const oe=y.useCallback((Pe,ze,...De)=>{const it=De.length>0?`${ze} ${De.map(at=>JSON.stringify(at)).join(" ")}`:ze;console[Pe](`[useMcp] ${it}`),de.current&&z(at=>[...at.slice(-100),{level:Pe,message:it,timestamp:Date.now()}])},[]),xe=y.useCallback(async(Pe=!1)=>{if(Pe||oe("info","Disconnecting..."),se.current=!1,Te.current&&clearTimeout(Te.current),Te.current=null,ce.current)try{const ze="inspector-server",De=ce.current.getSession(ze);De&&De._healthCheckCleanup&&(De._healthCheckCleanup(),De._healthCheckCleanup=null),await ce.current.closeSession(ze)}catch(ze){Pe||oe("warn","Error closing session:",ze)}ce.current=null,de.current&&!Pe&&(M("discovering"),F([]),J([]),ie([]),Z([]),P(void 0),K(void 0))},[oe]),Ee=y.useCallback((Pe,ze)=>{if(oe("error",Pe,ze??""),de.current){M("failed"),P(Pe);const De=q.current?.getLastAttemptedAuthUrl();De&&(K(De),oe("info","Manual authentication URL may be available.",De))}se.current=!1,t&&Pi.getInstance().trackUseMcpConnection({url:t,transportType:h,success:!1,errorType:ze?.name||"UnknownError",hasOAuth:!!q.current,hasSampling:!!k,hasElicitation:!!R}).catch(()=>{})},[oe,t,h,k,R]),je=y.useCallback(async()=>{if(!n||!t){oe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(se.current){oe("debug","Connection attempt already in progress.");return}if(!de.current){oe("debug","Connect called after unmount, aborting.");return}se.current=!0,ye.current+=1,P(void 0),K(void 0),nt.current=null,M("discovering"),oe("info",`Connecting attempt #${ye.current} to ${t}...`),q.current||(q.current=new $b(t,{storageKeyPrefix:r,clientName:i.name,clientUri:i.uri,logoUri:i.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:a,preventAutoAuth:g,useRedirectFlow:v,onPopupWindow:S}),oe("debug","BrowserOAuthClientProvider initialized in connect.")),ce.current||(ce.current=new Woe,oe("debug","BrowserMCPClient initialized in connect."));const Pe=ke(async(De,it=!1)=>{oe("info",`Attempting connection with transport: ${De}`);try{const at="inspector-server",Xe={url:N,transport:De==="sse"?"http":De,disableSseFallback:De==="http",preferSse:De==="sse"};if(O&&Object.keys(O).length>0&&(Xe.headers=O),q.current){const vt=await q.current.tokens();vt?.access_token&&(Xe.headers={...Xe.headers,Authorization:`Bearer ${vt.access_token}`})}ce.current.addServer(at,{...Xe,authProvider:q.current,clientOptions:i,samplingCallback:k,elicitationCallback:R,wrapTransport:E?vt=>(console.log("[useMcp] Applying transport wrapper for server:",at,"url:",t),E(vt,t)):void 0});const Mt=await ce.current.createSession(at,!1);Mt.on("notification",vt=>{_?.(vt),vt.method==="notifications/tools/list_changed"?(oe("info","Tools list changed, auto-refreshing..."),sn().catch(ut=>oe("warn","Auto-refresh tools failed:",ut))):vt.method==="notifications/resources/list_changed"?(oe("info","Resources list changed, auto-refreshing..."),He().catch(ut=>oe("warn","Auto-refresh resources failed:",ut))):vt.method==="notifications/prompts/list_changed"&&(oe("info","Prompts list changed, auto-refreshing..."),Fe().catch(ut=>oe("warn","Auto-refresh prompts failed:",ut)))}),await Mt.initialize(),oe("info","✅ Successfully connected to MCP server"),oe("info","Server info:",Mt.connector.serverInfo),oe("info","Server capabilities:",Mt.connector.serverCapabilities),console.log("[useMcp] Server info:",Mt.connector.serverInfo),console.log("[useMcp] Server capabilities:",Mt.connector.serverCapabilities),M("ready"),nt.current=De;const Zt=ke(()=>{let vt=null,ut=Date.now();const Gn=1e4,dr=3e4;return vt=setInterval(ke(async()=>{if(!de.current||Ie.current!=="ready"){vt&&(clearInterval(vt),vt=null);return}try{await Mt.connector.listTools(),ut=Date.now()}catch{const pn=Date.now()-ut;pn>dr&&(oe("warn",`Connection appears to be broken (no response for ${Math.round(pn/1e3)}s), attempting to reconnect...`),vt&&(clearInterval(vt),vt=null),Me.current&&de.current&&(M("discovering"),oe("info","Auto-reconnecting to MCP server..."),setTimeout(()=>{de.current&&Ie.current==="discovering"&&je()},typeof Me.current=="number"?Me.current:yz)))}},"checkConnectionHealth"),Gn),()=>{vt&&(clearInterval(vt),vt=null)}},"setupConnectionMonitoring");if(m){const vt=Zt();Mt._healthCheckCleanup=vt}Pi.getInstance().trackUseMcpConnection({url:t,transportType:De,success:!0,hasOAuth:!!q.current,hasSampling:!!k,hasElicitation:!!R}).catch(()=>{}),F(Mt.connector.tools||[]);const $n=await Mt.connector.listAllResources();J($n.resources||[]);const vn=await Mt.connector.listPrompts();Z(vn.prompts||[]);const ln=Mt.connector.serverInfo,rn=Mt.connector.serverCapabilities;if(ln){console.log("[useMcp] Server info:",ln),ae(ln);const vt=(async()=>{try{const ut=ln.icons;if(ut&&Array.isArray(ut)&&ut.length>0){const Gn=ut[0].src||ut[0].url;if(Gn){oe("info","Server provided icon:",Gn);const er=await(await fetch(Gn)).blob(),mt=await new Promise((pn,kr)=>{const Br=new FileReader;Br.onloadend=()=>pn(Br.result),Br.onerror=kr,Br.readAsDataURL(er)});return de.current&&(ae(pn=>pn?{...pn,icon:mt}:void 0),oe("debug","Server icon converted to base64")),mt}}if(t){const Gn=await _F(t);if(Gn&&de.current)return ae(dr=>dr?{...dr,icon:Gn}:void 0),oe("debug","Favicon detected and added to serverInfo"),Gn}return null}catch(ut){return oe("debug","Icon loading failed (non-critical):",ut),null}})();te.current=vt}if(rn&&(console.log("[useMcp] Server capabilities:",rn),L(rn)),q.current){const vt=await q.current.tokens();if(vt?.access_token){const ut=vt.expires_in?Date.now()+vt.expires_in*1e3:void 0;fe({access_token:vt.access_token,token_type:vt.token_type||"Bearer",expires_at:ut,refresh_token:vt.refresh_token,scope:vt.scope})}}return"success"}catch(at){const Xe=at,Mt=Xe?.message||String(at);if(Xe.code===401||Mt.includes("401")||Mt.includes("Unauthorized")){if(q.current){oe("info","Authentication required. OAuth provider available.");try{const{auth:Zt}=await ia(async()=>{const{auth:vn}=await Promise.resolve().then(()=>fz);return{auth:vn}},void 0),$n=new URL(t).origin;Zt(q.current,{serverUrl:$n}).catch(()=>{}),setTimeout(()=>{if(de.current){const vn=q.current?.getLastAttemptedAuthUrl();vn?(K(vn),oe("info","Manual authentication URL available:",vn)):oe("warn","Could not generate authentication URL")}},100)}catch(Zt){oe("warn","Error generating auth URL:",Zt)}return de.current&&M("pending_auth"),se.current=!1,"auth_redirect"}return s&&Object.keys(s).length>0?(Ee("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(Ee("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return Ee(Mt,Xe instanceof Error?Xe:new Error(String(Xe))),"failed"}},"tryConnectWithTransport");let ze="failed";if(h==="sse")oe("debug","Using SSE-only transport mode"),ze=await Pe("sse");else if(h==="http")oe("debug","Using HTTP-only transport mode"),ze=await Pe("http");else{oe("debug","Using auto transport mode (HTTP with SSE fallback)");const De=await Pe("http");De==="fallback"&&de.current&&Ie.current!=="authenticating"?(oe("info","HTTP failed, attempting SSE fallback..."),ze=await Pe("sse")):ze=De}(ze==="success"||ze==="failed"||ze==="auth_redirect")&&(se.current=!1),oe("debug",`Connection sequence finished with status: ${ze}`)},[oe,Ee,xe,t,r,a,i.name,i.version,i.uri,i.logo_uri,s,h,g,v,S,n,x,w]);y.useEffect(()=>{Ue.current=je,pe.current=Ee},[je,Ee]);const We=y.useCallback(async(Pe,ze,De)=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot call tool "${Pe}".`);oe("info",`Calling tool: ${Pe}`,ze);const it=Date.now();try{const Xe=ce.current.getSession("inspector-server");if(!Xe)throw new Error("No active session found");const Mt=await Xe.connector.callTool(Pe,ze||{},De);return oe("info",`Tool "${Pe}" call successful:`,Mt),Pi.getInstance().trackUseMcpToolCall({toolName:Pe,success:!0,executionTimeMs:Date.now()-it}).catch(()=>{}),Mt}catch(at){throw oe("error",`Tool "${Pe}" call failed:`,at),Pi.getInstance().trackUseMcpToolCall({toolName:Pe,success:!1,errorType:at instanceof Error?at.name:"UnknownError",executionTimeMs:Date.now()-it}).catch(()=>{}),at}},[A]),Ye=y.useCallback(()=>{Ie.current==="failed"?(oe("info","Retry requested..."),Ue.current?.()):oe("warn",`Retry called but state is not 'failed' (state: ${Ie.current}). Ignoring.`)},[oe]),ot=y.useCallback(async()=>{oe("info","Manual authentication requested...");const Pe=Ie.current;if(Pe==="failed")oe("info","Attempting to reconnect and authenticate via retry..."),Ye();else if(Pe==="pending_auth"){oe("info","Proceeding with authentication from pending state...");try{$E(q.current,"Auth Provider not available for manual auth"),$E(t,"Server URL is required for authentication"),oe("info","Clearing all OAuth state and initiating fresh flow...");const ze=`${r}:${q.current.serverUrlHash}`;Object.keys(localStorage).forEach(Xe=>{Xe.startsWith(ze)&&(oe("debug",`Removing stale OAuth key: ${Xe}`),localStorage.removeItem(Xe)),Xe.startsWith(`${r}:state_`)&&(oe("debug",`Removing orphaned state: ${Xe}`),localStorage.removeItem(Xe))}),M("authenticating");const De=new $b(t,{storageKeyPrefix:r,clientName:i.name,clientUri:i.uri,logoUri:i.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:a,preventAutoAuth:!1,useRedirectFlow:v,onPopupWindow:S});q.current=De,oe("info","Triggering fresh OAuth authorization...");const{auth:it}=await ia(async()=>{const{auth:Xe}=await Promise.resolve().then(()=>fz);return{auth:Xe}},void 0),at=new URL(t).origin;it(De,{serverUrl:at}).catch(Xe=>{oe("info","OAuth flow initiated:",Xe instanceof Error?Xe.message:"Redirecting...")})}catch(ze){if(!de.current)return;M("pending_auth"),oe("error",`Manual authentication failed: ${ze instanceof Error?ze.message:String(ze)}`)}}else if(Pe==="authenticating"){oe("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const ze=q.current?.getLastAttemptedAuthUrl();ze&&!G&&(K(ze),oe("info","Manual authentication URL retrieved:",ze))}else oe("info",`Client not in a state requiring manual authentication trigger (state: ${Pe}). If needed, try disconnecting and reconnecting.`)},[oe,Ye,G,t,v,S,r,i.name,i.uri,i.logo_uri,a]),kt=y.useCallback(()=>{if(q.current){const Pe=q.current.clearStorage();oe("info",`Cleared ${Pe} item(s) from localStorage for ${t}.`),K(void 0),xe()}else oe("warn","Auth provider not initialized, cannot clear storage.")},[t,oe,xe]),Ln=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list resources.`);oe("info","Listing resources");try{const ze=ce.current.getSession("inspector-server");if(!ze)throw new Error("No active session found");const De=await ze.connector.listAllResources();J(De.resources||[]),oe("info","Resources listed successfully")}catch(Pe){throw oe("error","List resources failed:",Pe),Pe}},[A]),pt=y.useCallback(async Pe=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot read resource.`);oe("info",`Reading resource: ${Pe}`);try{const De=ce.current.getSession("inspector-server");if(!De)throw new Error("No active session found");const it=await De.connector.readResource(Pe);return oe("info","Resource read successful:",it),Pi.getInstance().trackUseMcpResourceRead({resourceUri:Pe,success:!0}).catch(()=>{}),it}catch(ze){throw oe("error","Resource read failed:",ze),Pi.getInstance().trackUseMcpResourceRead({resourceUri:Pe,success:!1,errorType:ze instanceof Error?ze.name:"UnknownError"}).catch(()=>{}),ze}},[A]),Zn=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot list prompts.`);oe("info","Listing prompts");try{const ze=ce.current.getSession("inspector-server");if(!ze)throw new Error("No active session found");const De=await ze.connector.listPrompts();Z(De.prompts||[]),oe("info","Prompts listed successfully")}catch(Pe){throw oe("error","List prompts failed:",Pe),Pe}},[A]),sn=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current){oe("debug","Cannot refresh tools - client not ready");return}oe("debug","Refreshing tools list");try{const ze=ce.current.getSession("inspector-server");if(!ze){oe("warn","No active session found for tools refresh");return}const De=await ze.connector.listTools();F(De||[]),oe("info","Tools list refreshed successfully")}catch(Pe){oe("warn","Failed to refresh tools:",Pe)}},[oe]),He=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current){oe("debug","Cannot refresh resources - client not ready");return}oe("debug","Refreshing resources list");try{const ze=ce.current.getSession("inspector-server");if(!ze){oe("warn","No active session found for resources refresh");return}const De=await ze.connector.listAllResources();J(De.resources||[]),oe("info","Resources list refreshed successfully")}catch(Pe){oe("warn","Failed to refresh resources:",Pe)}},[oe]),Fe=y.useCallback(async()=>{if(Ie.current!=="ready"||!ce.current){oe("debug","Cannot refresh prompts - client not ready");return}oe("debug","Refreshing prompts list");try{const ze=ce.current.getSession("inspector-server");if(!ze){oe("warn","No active session found for prompts refresh");return}const De=await ze.connector.listPrompts();Z(De.prompts||[]),oe("info","Prompts list refreshed successfully")}catch(Pe){oe("warn","Failed to refresh prompts:",Pe)}},[oe]),Ze=y.useCallback(async()=>{oe("info","Refreshing all lists (tools, resources, prompts)"),await Promise.all([sn(),He(),Fe()])},[sn,He,Fe,oe]),wt=y.useCallback(async(Pe,ze)=>{if(Ie.current!=="ready"||!ce.current)throw new Error(`MCP client is not ready (current state: ${A}). Cannot get prompt.`);oe("info",`Getting prompt: ${Pe}`,ze);try{const it=ce.current.getSession("inspector-server");if(!it)throw new Error("No active session found");const at=await it.connector.getPrompt(Pe,ze||{});return oe("info",`Prompt "${Pe}" retrieved successfully:`,at),at}catch(De){throw oe("error",`Prompt "${Pe}" retrieval failed:`,De),De}},[A]);y.useEffect(()=>{const Pe=ke(ze=>{ze.origin===window.location.origin&&ze.data?.type==="mcp_auth_callback"&&(oe("info","Received auth callback message.",ze.data),Te.current&&clearTimeout(Te.current),Te.current=null,ze.data.success?(oe("info","Authentication successful via popup. Reconnecting client..."),se.current&&oe("debug","Connection attempt already in progress, resetting flag to allow reconnection."),se.current=!1,setTimeout(()=>{de.current&&(oe("debug","Initiating reconnection after successful auth callback."),Ue.current?.())},100)):pe.current?.(`Authentication failed in callback: ${ze.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",Pe),oe("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",Pe),oe("debug","Auth callback message listener removed."),Te.current&&clearTimeout(Te.current)}},[oe]),y.useEffect(()=>(de.current=!0,!n||!t?(oe("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),M("discovering"),()=>{de.current=!1}):(oe("debug","useMcp mounted, initiating connection."),ye.current=0,(!q.current||q.current.serverUrl!==t)&&(q.current=new $b(t,{storageKeyPrefix:r,clientName:i.name,clientUri:i.uri,logoUri:i.logo_uri||"https://mcp-use.com/logo.png",callbackUrl:a,preventAutoAuth:g,useRedirectFlow:v,onPopupWindow:S}),oe("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),je(),()=>{de.current=!1,oe("debug","useMcp unmounting, disconnecting."),xe(!0)})),[t,n,r,a,i.name,i.version,i.uri,i.logo_uri,v]);const xt=y.useRef(Ye),jt=y.useRef(oe);y.useEffect(()=>{xt.current=Ye,jt.current=oe},[Ye,oe]),y.useEffect(()=>{let Pe=null;if(A==="failed"&&f&&ye.current>0){if(!Ge.current){Ge.current=!0;const ze=typeof f=="number"?f:Zoe;jt.current("info",`Connection failed, auto-retrying in ${ze}ms...`),Pe=setTimeout(()=>{Ge.current=!1,de.current&&Ie.current==="failed"&&xt.current()},ze)}}else A!=="failed"&&(Ge.current=!1);return()=>{Pe&&(clearTimeout(Pe),Ge.current=!1)}},[A,f]);const St=y.useCallback(async()=>Ie.current!=="ready"?(oe("warn","Cannot ensure icon loaded - not connected"),null):H?.icon?H.icon:te.current?(oe("debug","Waiting for icon to finish loading..."),await te.current):(oe("debug","No icon available and no loading in progress"),null),[H,oe]);return{state:A,name:H?.name||t||"",tools:j,resources:V,resourceTemplates:ee,prompts:W,serverInfo:H,capabilities:ne,error:B,log:$,authUrl:G,authTokens:re,client:ce.current,callTool:We,readResource:pt,listResources:Ln,listPrompts:Zn,getPrompt:wt,refreshTools:sn,refreshResources:He,refreshPrompts:Fe,refreshAll:Ze,retry:Ye,disconnect:xe,authenticate:ot,clearStorage:kt,ensureIconLoaded:St}}ke(LN,"useMcp");function ME({serverConfig:e,additionalItems:t=[],showClients:n={cursor:!0,vsCode:!0,claudeDesktop:!0,claudeCode:!0,geminiCli:!0,codexCli:!0},className:a="",onSuccess:r,onError:i,trigger:s}){const[c,u]=y.useState(!1),[f,m]=y.useState(null),[h,g]=y.useState(!1),[v,S]=y.useState(!1),{url:x,name:w,headers:E}=e,_=ke(()=>{try{const j=pk(x,w,E);window.location.href=j,r?.("Cursor")}catch(j){console.error("Failed to generate Cursor deep link:",j),i?.(j)}},"handleCursorClick"),k=ke(()=>{try{const j=mk(x,w,E);window.location.href=j,r?.("VS Code")}catch(j){console.error("Failed to generate VS Code deep link:",j),i?.(j)}},"handleVSCodeClick"),R=ke(()=>{try{hk(x,w,E),r?.("Claude Desktop")}catch(j){console.error("Failed to download .mcpb file:",j),i?.(j)}},"handleClaudeDesktopClick"),N=ke(()=>{m("claude-code"),u(!0)},"handleClaudeCodeClick"),I=ke(()=>{m("gemini-cli"),u(!0)},"handleGeminiCLIClick"),O=ke(()=>{m("codex-cli"),u(!0)},"handleCodexCLIClick"),A=ke(async j=>{try{await navigator.clipboard.writeText(j),g(!0),setTimeout(()=>g(!1),2e3)}catch(F){console.error("Failed to copy:",F),i?.(F)}},"handleCopy"),M=ke(()=>{if(f==="claude-code"){const{command:j,envVars:F}=gk(x,w,E),V=iE(F);return X.createElement("div",{className:"space-y-4"},X.createElement("div",null,X.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Claude Code"),X.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Execute the following command in your shell to add this server to Claude Code.")),X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),X.createElement("ol",{className:"space-y-2 text-xs text-gray-600 dark:text-gray-400"},X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"1."),X.createElement("span",null,"Ensure the Claude Code executable is available in your path")),X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"2."),X.createElement("span",null,"Execute the following snippet in your shell:")))),X.createElement("div",{className:"relative"},X.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>A(j)},h?"✓ Copied":"Copy"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-bash"},j))),V&&X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Environment Variables"),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2"},"After installation, set these environment variables in your shell:"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-bash"},V))),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"The MCP configuration supports environment variable expansion using"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"${VAR}")," ","syntax."))}if(f==="gemini-cli"){const{command:j,envVars:F}=bk(x,w,E),V=iE(F);return X.createElement("div",{className:"space-y-4"},X.createElement("div",null,X.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Gemini CLI"),X.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Execute the following command in your shell to add this server to Gemini CLI.")),X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),X.createElement("ol",{className:"space-y-2 text-xs text-gray-600 dark:text-gray-400"},X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"1."),X.createElement("span",null,"Ensure the Gemini CLI executable is available in your path")),V&&X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},"2."),X.createElement("span",null,"Set these environment variables in your shell before running the command:")),X.createElement("li",{className:"flex gap-2"},X.createElement("span",{className:"font-semibold text-gray-900 dark:text-gray-100"},V?"3.":"2."),X.createElement("span",null,"Execute the following snippet in your shell:")))),V&&X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Environment Variables"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-bash"},V))),X.createElement("div",{className:"relative"},X.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>A(j)},h?"✓ Copied":"Copy"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-bash"},j))),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Restart Gemini CLI to load the new configuration."))}if(f==="codex-cli"){const{config:j,envVars:F}=vk(x,w,E);return X.createElement("div",{className:"space-y-4"},X.createElement("div",null,X.createElement("h3",{className:"font-semibold text-lg mb-2"},"Add to Codex CLI"),X.createElement("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4"},"Add this configuration to your"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"~/.codex/config.toml")," ","file.")),X.createElement("div",null,X.createElement("h5",{className:"font-semibold text-sm mb-2"},"Instructions"),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Add this configuration to your"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"~/.codex/config.toml"),":")),X.createElement("div",{className:"relative"},X.createElement("button",{className:"absolute top-2 right-2 z-10 px-2 py-1 text-xs rounded bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-300 dark:border-gray-600",onClick:()=>A(j)},h?"✓ Copied":"Copy"),X.createElement("pre",{className:"bg-gray-100 dark:bg-gray-900 p-3 pr-14 rounded-md text-xs overflow-x-auto border border-gray-300 dark:border-gray-700"},X.createElement("code",{className:"language-toml"},j))),F.length>0&&X.createElement("div",null,X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"(optional) If you would rather use variables from your system's environment, replace the"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"http_headers")," ","key with the"," ",X.createElement("code",{className:"text-gray-900 dark:text-gray-100"},"env_http_headers")," ","key as shown in the commented section above.")),X.createElement("p",{className:"text-xs text-gray-600 dark:text-gray-400"},"Restart Codex CLI to load the new configuration."))}return null},"renderModalContent");return X.createElement(X.Fragment,null,X.createElement("div",{className:"relative inline-block"},s?X.createElement("div",{onClick:j=>{j.stopPropagation(),S(!v)},className:"cursor-pointer"},typeof s=="function"?s({isOpen:v,onClick:ke(()=>S(!v),"onClick")}):X.isValidElement(s)?X.cloneElement(s,{onClick:ke(j=>{j.preventDefault(),j.stopPropagation(),S(!v)},"onClick")}):s):X.createElement("button",{onClick:()=>S(!v),className:`inline-flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${a}`},X.createElement("span",null,"Add to Client"),X.createElement("svg",{className:`w-4 h-4 transition-transform ${v?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},X.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"}))),v&&X.createElement(X.Fragment,null,X.createElement("div",{className:"fixed inset-0 z-40",onClick:()=>S(!1)}),X.createElement("div",{className:"absolute right-0 mt-2 w-auto min-w-[300px] rounded-md shadow-lg bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 z-50"},X.createElement("div",{className:"py-1"},t.map(j=>X.createElement("button",{key:j.id,onClick:async()=>{S(!1),await j.onClick()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},j.icon,X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},j.label))),t.length>0&&X.createElement("div",{className:"border-t border-gray-200 dark:border-gray-700 my-1"}),n.cursor&&X.createElement("button",{onClick:()=>{S(!1),_()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://cdn.simpleicons.org/cursor",alt:"Cursor",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Cursor")),n.claudeCode&&X.createElement("button",{onClick:()=>{S(!1),N()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Claude Code")),n.claudeDesktop&&X.createElement("button",{onClick:()=>{S(!1),R()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://cdn.simpleicons.org/claude",alt:"Claude",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Claude Desktop")),n.vsCode&&X.createElement("button",{onClick:()=>{S(!1),k()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor"},X.createElement("path",{d:"M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z"})),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"VS Code")),n.geminiCli&&X.createElement("button",{onClick:()=>{S(!1),I()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://cdn.simpleicons.org/googlegemini",alt:"Gemini",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Gemini CLI")),n.codexCli&&X.createElement("button",{onClick:()=>{S(!1),O()},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-2"},X.createElement("img",{src:"https://inspector-cdn.mcp-use.com/providers/openai.png",alt:"Codex",className:"h-4 w-4"}),X.createElement("span",{className:"min-w-0 max-w-full whitespace-nowrap"},"Codex CLI")))))),c&&X.createElement(X.Fragment,null,X.createElement("div",{className:"fixed inset-0 bg-black/50 z-50",onClick:()=>{u(!1),m(null)}}),X.createElement("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:()=>{u(!1),m(null)}},X.createElement("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl max-w-3xl w-full max-h-[80vh] overflow-y-auto border border-gray-200 dark:border-gray-700 p-6 relative",onClick:j=>j.stopPropagation()},X.createElement("button",{onClick:()=>{u(!1),m(null)},className:"absolute top-4 right-4 p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors","aria-label":"Close"},X.createElement("svg",{className:"w-5 h-5 text-gray-500 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},X.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"}))),M()))))}ke(ME,"AddToClientDropdown");var Ju,Yoe=(Ju=class extends X.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?X.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"},X.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),X.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},ke(Ju,"ErrorBoundary"),Ju),bp="openai:set_globals";function ui(e){return y.useSyncExternalStore(t=>{const n=ke(a=>{a.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(bp,n),()=>{typeof window<"u"&&window.removeEventListener(bp,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}ke(ui,"useOpenAiGlobal");function Ad(e){const[t,n]=y.useState(()=>typeof window<"u"&&!!window.openai);y.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const j=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(j))},100),F=ke(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(j))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(bp,F);const V=setTimeout(()=>{clearInterval(j),typeof window<"u"&&window.removeEventListener(bp,F)},5e3);return()=>{clearInterval(j),clearTimeout(V),typeof window<"u"&&window.removeEventListener(bp,F)}},[]);const a=y.useMemo(()=>t?"openai":"mcp-ui",[t]),r=typeof window<"u"?window.location.search:"",i=y.useMemo(()=>{const j=new URLSearchParams(r);return j.has("mcpUseParams")?JSON.parse(j.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[r]),s=a==="openai"?ui("toolInput"):i.toolInput,c=a==="openai"?ui("toolOutput"):i.toolOutput,u=ui("toolResponseMetadata"),f=y.useMemo(()=>{if(u&&typeof u=="object"){const j=u["mcp-use/props"];if(j)return j}return e||{}},[u,e]),m=ui("widgetState"),h=ui("theme"),g=ui("displayMode"),v=ui("safeArea"),S=ui("maxHeight"),x=ui("userAgent"),w=ui("locale"),E=y.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,k]=y.useState(null);y.useEffect(()=>{m!==void 0&&k(m)},[m]);const R=y.useCallback(async(j,F)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(j,F)},[]),N=y.useCallback(async j=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:j})},[]),I=y.useCallback(j=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:j})},[]),O=y.useCallback(async j=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:j})},[]),A=y.useCallback(async j=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const V=typeof j=="function"?j(m!==void 0?m:_):j;return k(V),window.openai.setWidgetState(V)},[m,_]),M=y.useMemo(()=>a==="openai"&&u===null,[a,u]);return{props:f,toolInput:s||{},output:c??null,metadata:u??null,state:_,setState:A,theme:h||"light",displayMode:g||"inline",safeArea:v||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:S||600,userAgent:x||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:w||"en",mcp_url:E,callTool:R,sendFollowUpMessage:N,openExternal:I,requestDisplayMode:O,isAvailable:t,isPending:M}}ke(Ad,"useWidget");function qoe(e){const{props:t}=Ad(e);return t}ke(qoe,"useWidgetProps");function Xoe(){const{theme:e}=Ad();return e}ke(Xoe,"useWidgetTheme");function Joe(e){const{state:t,setState:n}=Ad();return y.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}ke(Joe,"useWidgetState");var wz=ke(({children:e})=>{const{theme:t,isAvailable:n}=Ad();console.log("theme",t);const[a,r]=y.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");y.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),c=ke(u=>{r(u.matches?"dark":"light")},"handleChange");return s.addEventListener("change",c),()=>s.removeEventListener("change",c)},[]);const i=n?t:a;return y.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),X.createElement(X.Fragment,null,e)},"ThemeProvider");function w9({children:e,className:t="",position:n="top-right",attachTo:a,showLabels:r=!0,debugger:i=!1,viewControls:s=!1}){const{props:c,output:u,metadata:f,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:S,userAgent:x,locale:w,isAvailable:E,callTool:_,sendFollowUpMessage:k,openExternal:R,requestDisplayMode:N,setState:I}=Ad(),[O,A]=y.useState(!1),[M,j]=y.useState(!1),F=y.useRef(null),V=y.useRef(null),[J,ee]=y.useState([]),[ie,W]=y.useState(""),[Z,H]=y.useState("get-my-city"),[ae,ne]=y.useState("{}"),[L,B]=y.useState("Test follow-up message"),[P,$]=y.useState("https://docs.mcp-use.com"),z=g==="fullscreen"&&E,G=g==="pip"&&E,K=typeof window<"u"&&window.location.pathname.includes("/inspector/api/");y.useEffect(()=>{const xe=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const Ee=Object.keys(window.openai);ee(Ee)}catch{ee([])}else ee([])},100);return()=>{clearTimeout(xe)}},[]);const re=h==="dark",fe=ke(()=>{const xe=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",O?"opacity-100":"opacity-0",O?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...xe,"top-4","left-4"];case"top-center":return[...xe,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...xe,"top-4","right-4"];case"center-left":return[...xe,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...xe,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...xe,"bottom-4","left-4"];case"bottom-center":return[...xe,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...xe,"bottom-4","right-4"];default:return[...xe,"top-4","right-4"]}},"getPositionClasses"),ce=ke(()=>{const Ee=v?.insets?.top?Math.max(16,v.insets.top+8):16,je=v?.insets?.right?Math.max(16,v.insets.right+8):16,We=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Ye=v?.insets?.left?Math.max(16,v.insets.left+8):16,ot={};switch(n){case"top-left":ot.top=`${Ee}px`,ot.left=`${Ye}px`;break;case"top-center":ot.top=`${Ee}px`;break;case"top-right":ot.top=`${Ee}px`,ot.right=`${je}px`;break;case"center-left":ot.left=`${Ye}px`;break;case"center-right":ot.right=`${je}px`;break;case"bottom-left":ot.bottom=`${We}px`,ot.left=`${Ye}px`;break;case"bottom-center":ot.bottom=`${We}px`;break;case"bottom-right":ot.bottom=`${We}px`,ot.right=`${je}px`;break;default:ot.top=`${Ee}px`,ot.right=`${je}px`;break}return ot},"getPositionOffsetStyles");y.useEffect(()=>{if(!a)return;const xe=ke(()=>A(!0),"handleMouseEnter"),Ee=ke(()=>A(!1),"handleMouseLeave");return a.addEventListener("mouseenter",xe),a.addEventListener("mouseleave",Ee),()=>{a.removeEventListener("mouseenter",xe),a.removeEventListener("mouseleave",Ee)}},[a]),y.useEffect(()=>{if(!M)return;const xe=ke(Ee=>{V.current&&!V.current.contains(Ee.target)&&j(!1)},"handleClickOutside");return document.addEventListener("mousedown",xe),()=>{document.removeEventListener("mousedown",xe)}},[M]),y.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const q=ke(()=>{j(!M)},"handleToggleOverlay"),te=ke(async()=>{try{W("Calling tool...");const xe=ae.trim()?JSON.parse(ae):{},Ee=await _(Z,xe);W(`Success: ${JSON.stringify(Ee,null,2)}`)}catch(xe){W(`Error: ${xe.message}`)}},"handleCallTool"),se=ke(async()=>{try{W("Sending follow-up message..."),await k(L),W("Follow-up message sent successfully")}catch(xe){W(`Error: ${xe.message}`)}},"handleSendFollowUpMessage"),de=ke(()=>{try{R(P),W(`Opened external link: ${P}`)}catch(xe){W(`Error: ${xe.message}`)}},"handleOpenExternal"),ye=ke(async xe=>{try{W(`Requesting display mode: ${xe}...`);const Ee=await N(xe);W(`Display mode granted: ${Ee.mode}`)}catch(Ee){W(`Error: ${Ee.message}`)}},"handleRequestDisplayMode"),Te=ke(async()=>{try{const xe=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};W("Setting state..."),await I(xe),W(`State updated: ${JSON.stringify(xe,null,2)}`)}catch(xe){W(`Error: ${xe.message}`)}},"handleSetState"),Ge=ke(async()=>{try{await N("fullscreen")}catch(xe){console.error("Failed to go fullscreen:",xe)}},"handleFullscreen"),Ie=ke(async()=>{try{await N("pip")}catch(xe){console.error("Failed to go pip:",xe)}},"handlePip"),Me=ke(()=>{const xe=["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[...xe,"top-full","right-0","mt-2"];case"top-left":return[...xe,"top-full","left-0","mt-2"];case"top-center":return[...xe,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...xe,"bottom-full","right-0","mb-2"];case"bottom-left":return[...xe,"bottom-full","left-0","mb-2"];case"bottom-center":return[...xe,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...xe,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...xe,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...xe,"top-full","right-0","mt-2"]}},"getTooltipClasses"),nt=ke(({onClick:xe,label:Ee,children:je})=>{const[We,Ye]=y.useState(!1),ot=Me();return X.createElement("button",{className:`p-2 ${re?"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 ${re?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Ye(!0),onMouseLeave:()=>Ye(!1),onClick:xe,"aria-label":Ee},X.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"},je),r&&X.createElement("span",{className:`${ot.join(" ")} ${We?"opacity-100":"opacity-0"}`},Ee))},"IconButton"),Ue=ke(xe=>{if(xe===null)return"null";if(xe===void 0)return"undefined";if(typeof xe=="object")try{return JSON.stringify(xe,null,2)}catch{return String(xe)}return String(xe)},"formatValue"),pe=ke(xe=>xe?`${xe.device?.type||"unknown"}`:"N/A","formatUserAgent"),oe=ke(xe=>{if(!xe?.insets)return"N/A";const{top:Ee,bottom:je,left:We,right:Ye}=xe.insets;return`T:${Ee} B:${je} L:${We} R:${Ye}`},"formatSafeArea");return X.createElement(X.Fragment,null,X.createElement("div",{ref:F,className:`${t} relative h-fit`,onMouseEnter:()=>!a&&A(!0),onMouseLeave:()=>!a&&A(!1)},X.createElement("div",{className:fe().join(" "),style:ce()},!K&&X.createElement(X.Fragment,null,!z&&!G&&X.createElement(X.Fragment,null,(s===!0||s==="fullscreen")&&X.createElement(nt,{onClick:Ge,label:"Fullscreen"},X.createElement("path",{d:"M15 3h6v6"}),X.createElement("path",{d:"m21 3-7 7"}),X.createElement("path",{d:"m3 21 7-7"}),X.createElement("path",{d:"M9 21H3v-6"})),(s===!0||s==="pip")&&X.createElement(nt,{onClick:Ie,label:"Picture in Picture"},X.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),X.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&X.createElement(nt,{onClick:q,label:"Debug Info"},X.createElement("path",{d:"M12 20v-9"}),X.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),X.createElement("path",{d:"M14.12 3.88 16 2"}),X.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),X.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),X.createElement("path",{d:"M22 13h-4"}),X.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),X.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),X.createElement("path",{d:"M6 13H2"}),X.createElement("path",{d:"m8 2 1.88 1.88"}),X.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),M&&i&&X.createElement("div",{ref:V,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:xe=>{xe.target===V.current&&j(!1)}},X.createElement("button",{onClick:()=>j(!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"},"×"),X.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},X.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),X.createElement("table",{className:"w-full border-collapse border-spacing-0"},X.createElement("tbody",null,X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),X.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Ue(c))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),X.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Ue(u))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),X.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Ue(f))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),X.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},Ue(m))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),X.createElement("td",{className:"p-2"},h)),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),X.createElement("td",{className:"p-2"},g)),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),X.createElement("td",{className:"p-2"},w)),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),X.createElement("td",{className:"p-2"},S,"px")),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),X.createElement("td",{className:"p-2"},pe(x))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),X.createElement("td",{className:"p-2"},oe(v))),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),X.createElement("td",{className:"p-2"},E?"Yes":"No")),X.createElement("tr",{className:"border-b border-gray-700"},X.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),X.createElement("td",{className:"p-2"},J.length>0?J.join(", "):"N/A")))),X.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),X.createElement("div",{className:"flex flex-col gap-3"},X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("input",{type:"text",value:Z,onChange:xe=>H(xe.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]"}),X.createElement("input",{type:"text",value:ae,onChange:xe=>ne(xe.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"}),X.createElement("button",{onClick:te,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("input",{type:"text",value:L,onChange:xe=>B(xe.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"}),X.createElement("button",{onClick:se,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Send Follow-Up")),X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("input",{type:"text",value:P,onChange:xe=>$(xe.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"}),X.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")),X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),X.createElement("button",{onClick:()=>ye("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"),X.createElement("button",{onClick:()=>ye("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"),X.createElement("button",{onClick:()=>ye("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")),X.createElement("div",{className:"flex gap-2 items-center"},X.createElement("button",{onClick:Te,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)")),ie&&X.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"},X.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ie,X.createElement("button",{onClick:()=>W(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}ke(w9,"WidgetControls");function x9(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}ke(x9,"getBasename");var Qoe=150,ese=5;function tse({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=x9(),i=y.useRef(null),s=y.useRef(0),c=y.useRef(null),u=y.useRef(!1),[f,m]=y.useState(null),[h,g]=y.useState(null),[v,S]=y.useState(!0);y.useEffect(()=>{let _=!0;return(async()=>{try{const k=await ia(()=>import("./index-B8ArYgSz.js"),[]);_&&(m(()=>k.BrowserRouter),S(!1))}catch{_&&(g(new Error(`❌ react-router not installed!
99
99
 
100
100
  To use MCP widgets with McpUseProvider, you need to install:
101
101
 
@@ -151,7 +151,7 @@ Error generating stack: `+b.message+`
151
151
  `)},tU=function(){var e=parseInt(document.body.getAttribute(ku)||"0",10);return isFinite(e)?e:0},Bue=function(){y.useEffect(function(){return document.body.setAttribute(ku,(tU()+1).toString()),function(){var e=tU()-1;e<=0?document.body.removeAttribute(ku):document.body.setAttribute(ku,e.toString())}},[])},Hue=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,r=a===void 0?"margin":a;Bue();var i=y.useMemo(function(){return zue(r)},[r]);return y.createElement(Uue,{styles:Fue(i,!t,r,n?"":"!important")})},VE=!1;if(typeof window<"u")try{var pb=Object.defineProperty({},"passive",{get:function(){return VE=!0,!0}});window.addEventListener("test",pb,pb),window.removeEventListener("test",pb,pb)}catch{VE=!1}var qc=VE?{passive:!1}:!1,Vue=function(e){return e.tagName==="TEXTAREA"},A8=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Vue(e)&&n[t]==="visible")},Gue=function(e){return A8(e,"overflowY")},Wue=function(e){return A8(e,"overflowX")},nU=function(e,t){var n=t.ownerDocument,a=t;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var r=I8(e,a);if(r){var i=O8(e,a),s=i[1],c=i[2];if(s>c)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},Kue=function(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;return[t,n,a]},Zue=function(e){var t=e.scrollLeft,n=e.scrollWidth,a=e.clientWidth;return[t,n,a]},I8=function(e,t){return e==="v"?Gue(t):Wue(t)},O8=function(e,t){return e==="v"?Kue(t):Zue(t)},Yue=function(e,t){return e==="h"&&t==="rtl"?-1:1},que=function(e,t,n,a,r){var i=Yue(e,window.getComputedStyle(t).direction),s=i*a,c=n.target,u=t.contains(c),f=!1,m=s>0,h=0,g=0;do{if(!c)break;var v=O8(e,c),S=v[0],x=v[1],w=v[2],E=x-w-i*S;(S||E)&&I8(e,c)&&(h+=E,g+=S);var _=c.parentNode;c=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(m&&Math.abs(h)<1||!m&&Math.abs(g)<1)&&(f=!0),f},mb=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},rU=function(e){return[e.deltaX,e.deltaY]},aU=function(e){return e&&"current"in e?e.current:e},Xue=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Jue=function(e){return`
152
152
  .block-interactivity-`.concat(e,` {pointer-events: none;}
153
153
  .allow-interactivity-`).concat(e,` {pointer-events: all;}
154
- `)},Que=0,Xc=[];function ede(e){var t=y.useRef([]),n=y.useRef([0,0]),a=y.useRef(),r=y.useState(Que++)[0],i=y.useState(R8)[0],s=y.useRef(e);y.useEffect(function(){s.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var x=xue([e.lockRef.current],(e.shards||[]).map(aU),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(r))})}}},[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!s.current.allowPinchZoom;var E=mb(x),_=n.current,k="deltaX"in x?x.deltaX:_[0]-E[0],R="deltaY"in x?x.deltaY:_[1]-E[1],N,I=x.target,O=Math.abs(k)>Math.abs(R)?"h":"v";if("touches"in x&&O==="h"&&I.type==="range")return!1;var A=window.getSelection(),M=A&&A.anchorNode,j=M?M===I||M.contains(I):!1;if(j)return!1;var F=nU(O,I);if(!F)return!0;if(F?N=O:(N=O==="v"?"h":"v",F=nU(O,I)),!F)return!1;if(!a.current&&"changedTouches"in x&&(k||R)&&(a.current=N),!N)return!0;var V=a.current||N;return que(V,w,x,V==="h"?k:R)},[]),u=y.useCallback(function(x){var w=x;if(!(!Xc.length||Xc[Xc.length-1]!==i)){var E="deltaY"in w?rU(w):mb(w),_=t.current.filter(function(N){return N.name===w.type&&(N.target===w.target||w.target===N.shadowParent)&&Xue(N.delta,E)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var k=(s.current.shards||[]).map(aU).filter(Boolean).filter(function(N){return N.contains(w.target)}),R=k.length>0?c(w,k[0]):!s.current.noIsolation;R&&w.cancelable&&w.preventDefault()}}},[]),f=y.useCallback(function(x,w,E,_){var k={name:x,delta:w,target:E,should:_,shadowParent:tde(E)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(R){return R!==k})},1)},[]),m=y.useCallback(function(x){n.current=mb(x),a.current=void 0},[]),h=y.useCallback(function(x){f(x.type,rU(x),x.target,c(x,e.lockRef.current))},[]),g=y.useCallback(function(x){f(x.type,mb(x),x.target,c(x,e.lockRef.current))},[]);y.useEffect(function(){return Xc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,qc),document.addEventListener("touchmove",u,qc),document.addEventListener("touchstart",m,qc),function(){Xc=Xc.filter(function(x){return x!==i}),document.removeEventListener("wheel",u,qc),document.removeEventListener("touchmove",u,qc),document.removeEventListener("touchstart",m,qc)}},[]);var v=e.removeScrollBar,S=e.inert;return y.createElement(y.Fragment,null,S?y.createElement(i,{styles:Jue(r)}):null,v?y.createElement(Hue,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tde(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const nde=Aue(C8,ede);var Lm=y.forwardRef(function(e,t){return y.createElement(Hy,zi({},e,{ref:t,sideCar:nde}))});Lm.classNames=Hy.classNames;var GE=["Enter"," "],rde=["ArrowDown","PageUp","Home"],D8=["ArrowUp","PageDown","End"],ade=[...rde,...D8],ide={ltr:[...GE,"ArrowRight"],rtl:[...GE,"ArrowLeft"]},ode={ltr:["ArrowLeft"],rtl:["ArrowRight"]},$m="Menu",[Up,sde,lde]=zN($m),[ic,j8]=Ci($m,[lde,Zs,w8]),Vy=Zs(),L8=w8(),[cde,oc]=ic($m),[ude,Mm]=ic($m),$8=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=Vy(t),[u,f]=y.useState(null),m=y.useRef(!1),h=Ki(i),g=UN(r);return y.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),d.jsx(zy,{...c,children:d.jsx(cde,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:f,children:d.jsx(ude,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};$8.displayName=$m;var dde="MenuAnchor",qN=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Vy(n);return d.jsx(Dm,{...r,...a,ref:t})});qN.displayName=dde;var XN="MenuPortal",[fde,M8]=ic(XN,{forceMount:void 0}),P8=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=oc(XN,t);return d.jsx(fde,{scope:t,forceMount:n,children:d.jsx(za,{present:n||i.open,children:d.jsx(Md,{asChild:!0,container:r,children:a})})})};P8.displayName=XN;var Qa="MenuContent",[pde,JN]=ic(Qa),z8=y.forwardRef((e,t)=>{const n=M8(Qa,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=oc(Qa,e.__scopeMenu),s=Mm(Qa,e.__scopeMenu);return d.jsx(Up.Provider,{scope:e.__scopeMenu,children:d.jsx(za,{present:a||i.open,children:d.jsx(Up.Slot,{scope:e.__scopeMenu,children:s.modal?d.jsx(mde,{...r,ref:t}):d.jsx(hde,{...r,ref:t})})})})}),mde=y.forwardRef((e,t)=>{const n=oc(Qa,e.__scopeMenu),a=y.useRef(null),r=nn(t,a);return y.useEffect(()=>{const i=a.current;if(i)return By(i)},[]),d.jsx(QN,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ke(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),hde=y.forwardRef((e,t)=>{const n=oc(Qa,e.__scopeMenu);return d.jsx(QN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),gde=Wl("MenuContent.ScrollLock"),QN=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:S,...x}=e,w=oc(Qa,n),E=Mm(Qa,n),_=Vy(n),k=L8(n),R=sde(n),[N,I]=y.useState(null),O=y.useRef(null),A=nn(t,O,w.onContentChange),M=y.useRef(0),j=y.useRef(""),F=y.useRef(0),V=y.useRef(null),J=y.useRef("right"),ee=y.useRef(0),ie=S?Lm:y.Fragment,W=S?{as:gde,allowPinchZoom:!0}:void 0,Z=ae=>{const ne=j.current+ae,L=R().filter(K=>!K.disabled),B=document.activeElement,P=L.find(K=>K.ref.current===B)?.textValue,$=L.map(K=>K.textValue),z=Cde($,ne,P),G=L.find(K=>K.textValue===z)?.ref.current;(function K(re){j.current=re,window.clearTimeout(M.current),re!==""&&(M.current=window.setTimeout(()=>K(""),1e3))})(ne),G&&setTimeout(()=>G.focus())};y.useEffect(()=>()=>window.clearTimeout(M.current),[]),jy();const H=y.useCallback(ae=>J.current===V.current?.side&&Ade(ae,V.current?.area),[]);return d.jsx(pde,{scope:n,searchRef:j,onItemEnter:y.useCallback(ae=>{H(ae)&&ae.preventDefault()},[H]),onItemLeave:y.useCallback(ae=>{H(ae)||(O.current?.focus(),I(null))},[H]),onTriggerLeave:y.useCallback(ae=>{H(ae)&&ae.preventDefault()},[H]),pointerGraceTimerRef:F,onPointerGraceIntentChange:y.useCallback(ae=>{V.current=ae},[]),children:d.jsx(ie,{...W,children:d.jsx(Im,{asChild:!0,trapped:r,onMountAutoFocus:Ke(i,ae=>{ae.preventDefault(),O.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:d.jsx(jd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:d.jsx(gue,{asChild:!0,...k,dir:E.dir,orientation:"vertical",loop:a,currentTabStopId:N,onCurrentTabStopIdChange:I,onEntryFocus:Ke(u,ae=>{E.isUsingKeyboardRef.current||ae.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(Uy,{role:"menu","aria-orientation":"vertical","data-state":tG(w.open),"data-radix-menu-content":"",dir:E.dir,..._,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:Ke(x.onKeyDown,ae=>{const L=ae.target.closest("[data-radix-menu-content]")===ae.currentTarget,B=ae.ctrlKey||ae.altKey||ae.metaKey,P=ae.key.length===1;L&&(ae.key==="Tab"&&ae.preventDefault(),!B&&P&&Z(ae.key));const $=O.current;if(ae.target!==$||!ade.includes(ae.key))return;ae.preventDefault();const G=R().filter(K=>!K.disabled).map(K=>K.ref.current);D8.includes(ae.key)&&G.reverse(),Tde(G)}),onBlur:Ke(e.onBlur,ae=>{ae.currentTarget.contains(ae.target)||(window.clearTimeout(M.current),j.current="")}),onPointerMove:Ke(e.onPointerMove,Fp(ae=>{const ne=ae.target,L=ee.current!==ae.clientX;if(ae.currentTarget.contains(ne)&&L){const B=ae.clientX>ee.current?"right":"left";J.current=B,ee.current=ae.clientX}}))})})})})})})});z8.displayName=Qa;var bde="MenuGroup",eC=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(It.div,{role:"group",...a,ref:t})});eC.displayName=bde;var vde="MenuLabel",U8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(It.div,{...a,ref:t})});U8.displayName=vde;var Rv="MenuItem",iU="menu.itemSelect",Gy=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=y.useRef(null),s=Mm(Rv,e.__scopeMenu),c=JN(Rv,e.__scopeMenu),u=nn(t,i),f=y.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(iU,{bubbles:!0,cancelable:!0});h.addEventListener(iU,v=>a?.(v),{once:!0}),Z9(h,g),g.defaultPrevented?f.current=!1:s.onClose()}};return d.jsx(F8,{...r,ref:u,disabled:n,onClick:Ke(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:Ke(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:Ke(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||GE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Gy.displayName=Rv;var F8=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=JN(Rv,n),c=L8(n),u=y.useRef(null),f=nn(t,u),[m,h]=y.useState(!1),[g,v]=y.useState("");return y.useEffect(()=>{const S=u.current;S&&v((S.textContent??"").trim())},[i.children]),d.jsx(Up.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:d.jsx(bue,{asChild:!0,...c,focusable:!a,children:d.jsx(It.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:f,onPointerMove:Ke(e.onPointerMove,Fp(S=>{a?s.onItemLeave(S):(s.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ke(e.onPointerLeave,Fp(S=>s.onItemLeave(S))),onFocus:Ke(e.onFocus,()=>h(!0)),onBlur:Ke(e.onBlur,()=>h(!1))})})})}),yde="MenuCheckboxItem",B8=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return d.jsx(K8,{scope:e.__scopeMenu,checked:n,children:d.jsx(Gy,{role:"menuitemcheckbox","aria-checked":Av(n)?"mixed":n,...r,ref:t,"data-state":nC(n),onSelect:Ke(r.onSelect,()=>a?.(Av(n)?!0:!n),{checkForDefaultPrevented:!1})})})});B8.displayName=yde;var H8="MenuRadioGroup",[wde,xde]=ic(H8,{value:void 0,onValueChange:()=>{}}),V8=y.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Ki(a);return d.jsx(wde,{scope:e.__scopeMenu,value:n,onValueChange:i,children:d.jsx(eC,{...r,ref:t})})});V8.displayName=H8;var G8="MenuRadioItem",W8=y.forwardRef((e,t)=>{const{value:n,...a}=e,r=xde(G8,e.__scopeMenu),i=n===r.value;return d.jsx(K8,{scope:e.__scopeMenu,checked:i,children:d.jsx(Gy,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":nC(i),onSelect:Ke(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});W8.displayName=G8;var tC="MenuItemIndicator",[K8,Sde]=ic(tC,{checked:!1}),Z8=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=Sde(tC,n);return d.jsx(za,{present:a||Av(i.checked)||i.checked===!0,children:d.jsx(It.span,{...r,ref:t,"data-state":nC(i.checked)})})});Z8.displayName=tC;var Ede="MenuSeparator",Y8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(It.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});Y8.displayName=Ede;var _de="MenuArrow",q8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Vy(n);return d.jsx(Fy,{...r,...a,ref:t})});q8.displayName=_de;var kde="MenuSub",[yNe,X8]=ic(kde),op="MenuSubTrigger",J8=y.forwardRef((e,t)=>{const n=oc(op,e.__scopeMenu),a=Mm(op,e.__scopeMenu),r=X8(op,e.__scopeMenu),i=JN(op,e.__scopeMenu),s=y.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=i,f={__scopeMenu:e.__scopeMenu},m=y.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return y.useEffect(()=>m,[m]),y.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),u(null)}},[c,u]),d.jsx(qN,{asChild:!0,...f,children:d.jsx(F8,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":tG(n.open),...e,ref:Wi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ke(e.onPointerMove,Fp(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:Ke(e.onPointerLeave,Fp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,S=v==="right",x=S?-5:5,w=g[S?"left":"right"],E=g[S?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:w,y:g.top},{x:E,y:g.top},{x:E,y:g.bottom},{x:w,y:g.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ke(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||ide[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});J8.displayName=op;var Q8="MenuSubContent",eG=y.forwardRef((e,t)=>{const n=M8(Qa,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=oc(Qa,e.__scopeMenu),s=Mm(Qa,e.__scopeMenu),c=X8(Q8,e.__scopeMenu),u=y.useRef(null),f=nn(t,u);return d.jsx(Up.Provider,{scope:e.__scopeMenu,children:d.jsx(za,{present:a||i.open,children:d.jsx(Up.Slot,{scope:e.__scopeMenu,children:d.jsx(QN,{id:c.contentId,"aria-labelledby":c.triggerId,...r,ref:f,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{s.isUsingKeyboardRef.current&&u.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Ke(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ke(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ke(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=ode[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});eG.displayName=Q8;function tG(e){return e?"open":"closed"}function Av(e){return e==="indeterminate"}function nC(e){return Av(e)?"indeterminate":e?"checked":"unchecked"}function Tde(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Nde(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function Cde(e,t,n){const r=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Nde(e,Math.max(i,0));r.length===1&&(s=s.filter(f=>f!==n));const u=s.find(f=>f.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function Rde(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],f=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-f)*(a-m)/(g-m)+f&&(r=!r)}return r}function Ade(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Rde(n,t)}function Fp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Ide=$8,Ode=qN,Dde=P8,jde=z8,Lde=eC,$de=U8,Mde=Gy,Pde=B8,zde=V8,Ude=W8,Fde=Z8,Bde=Y8,Hde=q8,Vde=J8,Gde=eG,Wy="DropdownMenu",[Wde]=Ci(Wy,[j8]),ca=j8(),[Kde,nG]=Wde(Wy),rG=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ca(t),f=y.useRef(null),[m,h]=Lo({prop:r,defaultProp:i??!1,onChange:s,caller:Wy});return d.jsx(Kde,{scope:t,triggerId:Pr(),triggerRef:f,contentId:Pr(),open:m,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:c,children:d.jsx(Ide,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};rG.displayName=Wy;var aG="DropdownMenuTrigger",iG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=nG(aG,n),s=ca(n);return d.jsx(Ode,{asChild:!0,...s,children:d.jsx(It.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...r,ref:Wi(t,i.triggerRef),onPointerDown:Ke(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ke(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});iG.displayName=aG;var Zde="DropdownMenuPortal",oG=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ca(t);return d.jsx(Dde,{...a,...n})};oG.displayName=Zde;var sG="DropdownMenuContent",lG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=nG(sG,n),i=ca(n),s=y.useRef(!1);return d.jsx(jde,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ke(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ke(e.onInteractOutside,c=>{const u=c.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;(!r.modal||m)&&(s.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)"}})});lG.displayName=sG;var Yde="DropdownMenuGroup",qde=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Lde,{...r,...a,ref:t})});qde.displayName=Yde;var Xde="DropdownMenuLabel",cG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx($de,{...r,...a,ref:t})});cG.displayName=Xde;var Jde="DropdownMenuItem",uG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Mde,{...r,...a,ref:t})});uG.displayName=Jde;var Qde="DropdownMenuCheckboxItem",dG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Pde,{...r,...a,ref:t})});dG.displayName=Qde;var efe="DropdownMenuRadioGroup",tfe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(zde,{...r,...a,ref:t})});tfe.displayName=efe;var nfe="DropdownMenuRadioItem",fG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Ude,{...r,...a,ref:t})});fG.displayName=nfe;var rfe="DropdownMenuItemIndicator",afe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Fde,{...r,...a,ref:t})});afe.displayName=rfe;var ife="DropdownMenuSeparator",pG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Bde,{...r,...a,ref:t})});pG.displayName=ife;var ofe="DropdownMenuArrow",sfe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Hde,{...r,...a,ref:t})});sfe.displayName=ofe;var lfe="DropdownMenuSubTrigger",mG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Vde,{...r,...a,ref:t})});mG.displayName=lfe;var cfe="DropdownMenuSubContent",hG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Gde,{...r,...a,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)"}})});hG.displayName=cfe;var ufe=rG,dfe=iG,ffe=oG,gG=lG,bG=cG,vG=uG,pfe=dG,mfe=fG,yG=pG,hfe=mG,gfe=hG;const WE=ufe,KE=dfe;hfe.displayName;gfe.displayName;function Iv({ref:e,className:t,sideOffset:n=4,...a}){return d.jsx(ffe,{children:d.jsx(gG,{ref:e,sideOffset:n,className:Le("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),...a})})}Iv.displayName=gG.displayName;function Ui({ref:e,className:t,inset:n,...a}){return d.jsx(vG,{ref:e,className:Le("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),...a})}Ui.displayName=vG.displayName;pfe.displayName;mfe.displayName;function ZE({ref:e,className:t,inset:n,...a}){return d.jsx(bG,{ref:e,className:Le("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}ZE.displayName=bG.displayName;function sp({ref:e,className:t,...n}){return d.jsx(yG,{ref:e,className:Le("-mx-1 my-1 h-px bg-muted",t),...n})}sp.displayName=yG.displayName;var bfe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Vo=bfe.reduce((e,t)=>{const n=R9(`Primitive.${t}`),a=y.forwardRef((r,i)=>{const{asChild:s,...c}=r,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),vfe="Label",wG=y.forwardRef((e,t)=>d.jsx(Vo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));wG.displayName=vfe;var yfe=wG;function tn({className:e,...t}){return d.jsx(yfe,{"data-slot":"label",className:Le("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 Pd({message:e,className:t="",vertical:n,noBorder:a}){return d.jsx("div",{className:Le(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:d.jsxs("p",{className:Le("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[d.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:d.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:d.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[d.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"}),d.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),d.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function xG({className:e,color:t,children:n,grayscaled:a=!1}){const r=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return a?0:.2},[t,a]),i=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return a?.3:.4},[t,a]),s=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(i,1)} ${r} ${s})`,[s,r,i]),u=y.useMemo(()=>`oklch(${Math.min(i*2,1)} ${r} ${s})`,[s,r,i,t]),f=y.useMemo(()=>Math.floor(Math.random()*360),[s]),m=y.useMemo(()=>"1000%",[]);return d.jsx("section",{className:Le("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:d.jsxs("div",{className:"isolate relative w-full h-full",children:[d.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&&d.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function rC(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 Ky="Switch",[wfe]=Ci(Ky),[xfe,Sfe]=wfe(Ky),SG=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:f,form:m,...h}=e,[g,v]=y.useState(null),S=nn(t,k=>v(k)),x=y.useRef(!1),w=g?m||!!g.closest("form"):!0,[E,_]=Lo({prop:r,defaultProp:i??!1,onChange:f,caller:Ky});return d.jsxs(xfe,{scope:n,checked:E,disabled:c,children:[d.jsx(It.button,{type:"button",role:"switch","aria-checked":E,"aria-required":s,"data-state":TG(E),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:S,onClick:Ke(e.onClick,k=>{_(R=>!R),w&&(x.current=k.isPropagationStopped(),x.current||k.stopPropagation())})}),w&&d.jsx(kG,{control:g,bubbles:!x.current,name:a,value:u,checked:E,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});SG.displayName=Ky;var EG="SwitchThumb",_G=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=Sfe(EG,n);return d.jsx(It.span,{"data-state":TG(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});_G.displayName=EG;var Efe="SwitchBubbleInput",kG=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=y.useRef(null),c=nn(s,i),u=rC(n),f=KN(t);return y.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const S=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(S)}},[u,n,a]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...r,tabIndex:-1,ref:c,style:{...r.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});kG.displayName=Efe;function TG(e){return e?"checked":"unchecked"}var NG=SG,_fe=_G;function Zy({ref:e,className:t,...n}){return d.jsx(NG,{className:Le("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:d.jsx(_fe,{className:Le("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")})})}Zy.displayName=NG.displayName;var CG=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"}),kfe="VisuallyHidden",RG=y.forwardRef((e,t)=>d.jsx(It.span,{...e,ref:t,style:{...CG,...e.style}}));RG.displayName=kfe;var Tfe=RG,[Yy]=Ci("Tooltip",[Zs]),qy=Zs(),AG="TooltipProvider",Nfe=700,YE="tooltip.open",[Cfe,aC]=Yy(AG),IG=e=>{const{__scopeTooltip:t,delayDuration:n=Nfe,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=e,s=y.useRef(!0),c=y.useRef(!1),u=y.useRef(0);return y.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),d.jsx(Cfe,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,a)},[a]),isPointerInTransitRef:c,onPointerInTransitChange:y.useCallback(f=>{c.current=f},[]),disableHoverableContent:r,children:i})};IG.displayName=AG;var Bp="Tooltip",[Rfe,Pm]=Yy(Bp),OG=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=aC(Bp,e.__scopeTooltip),f=qy(t),[m,h]=y.useState(null),g=Pr(),v=y.useRef(0),S=s??u.disableHoverableContent,x=c??u.delayDuration,w=y.useRef(!1),[E,_]=Lo({prop:a,defaultProp:r??!1,onChange:O=>{O?(u.onOpen(),document.dispatchEvent(new CustomEvent(YE))):u.onClose(),i?.(O)},caller:Bp}),k=y.useMemo(()=>E?w.current?"delayed-open":"instant-open":"closed",[E]),R=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,w.current=!1,_(!0)},[_]),N=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_(!1)},[_]),I=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)},[]),d.jsx(zy,{...f,children:d.jsx(Rfe,{scope:t,contentId:g,open:E,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{u.isOpenDelayedRef.current?I():R()},[u.isOpenDelayedRef,I,R]),onTriggerLeave:y.useCallback(()=>{S?N():(window.clearTimeout(v.current),v.current=0)},[N,S]),onOpen:R,onClose:N,disableHoverableContent:S,children:n})})};OG.displayName=Bp;var qE="TooltipTrigger",DG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Pm(qE,n),i=aC(qE,n),s=qy(n),c=y.useRef(null),u=nn(t,c,r.onTriggerChange),f=y.useRef(!1),m=y.useRef(!1),h=y.useCallback(()=>f.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),d.jsx(Dm,{asChild:!0,...s,children:d.jsx(It.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ke(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ke(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ke(e.onPointerDown,()=>{r.open&&r.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ke(e.onFocus,()=>{f.current||r.onOpen()}),onBlur:Ke(e.onBlur,r.onClose),onClick:Ke(e.onClick,r.onClose)})})});DG.displayName=qE;var iC="TooltipPortal",[Afe,Ife]=Yy(iC,{forceMount:void 0}),jG=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=Pm(iC,t);return d.jsx(Afe,{scope:t,forceMount:n,children:d.jsx(za,{present:n||i.open,children:d.jsx(Md,{asChild:!0,container:r,children:a})})})};jG.displayName=iC;var gd="TooltipContent",LG=y.forwardRef((e,t)=>{const n=Ife(gd,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=Pm(gd,e.__scopeTooltip);return d.jsx(za,{present:a||s.open,children:s.disableHoverableContent?d.jsx($G,{side:r,...i,ref:t}):d.jsx(Ofe,{side:r,...i,ref:t})})}),Ofe=y.forwardRef((e,t)=>{const n=Pm(gd,e.__scopeTooltip),a=aC(gd,e.__scopeTooltip),r=y.useRef(null),i=nn(t,r),[s,c]=y.useState(null),{trigger:u,onClose:f}=n,m=r.current,{onPointerInTransitChange:h}=a,g=y.useCallback(()=>{c(null),h(!1)},[h]),v=y.useCallback((S,x)=>{const w=S.currentTarget,E={x:S.clientX,y:S.clientY},_=$fe(E,w.getBoundingClientRect()),k=Mfe(E,_),R=Pfe(x.getBoundingClientRect()),N=Ufe([...k,...R]);c(N),h(!0)},[h]);return y.useEffect(()=>()=>g(),[g]),y.useEffect(()=>{if(u&&m){const S=w=>v(w,m),x=w=>v(w,u);return u.addEventListener("pointerleave",S),m.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",S),m.removeEventListener("pointerleave",x)}}},[u,m,v,g]),y.useEffect(()=>{if(s){const S=x=>{const w=x.target,E={x:x.clientX,y:x.clientY},_=u?.contains(w)||m?.contains(w),k=!zfe(E,s);_?g():k&&(g(),f())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[u,m,s,f,g]),d.jsx($G,{...e,ref:i})}),[Dfe,jfe]=Yy(Bp,{isInside:!1}),Lfe=hle("TooltipContent"),$G=y.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=Pm(gd,n),f=qy(n),{onClose:m}=u;return y.useEffect(()=>(document.addEventListener(YE,m),()=>document.removeEventListener(YE,m)),[m]),y.useEffect(()=>{if(u.trigger){const h=g=>{g.target?.contains(u.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,m]),d.jsx(jd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:d.jsxs(Uy,{"data-state":u.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:[d.jsx(Lfe,{children:a}),d.jsx(Dfe,{scope:n,isInside:!0,children:d.jsx(Tfe,{id:u.contentId,role:"tooltip",children:r||a})})]})})});LG.displayName=gd;var MG="TooltipArrow",PG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=qy(n);return jfe(MG,n).isInside?null:d.jsx(Fy,{...r,...a,ref:t})});PG.displayName=MG;function $fe(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,a,r,i)){case i:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Mfe(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function Pfe(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function zfe(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],f=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-f)*(a-m)/(g-m)+f&&(r=!r)}return r}function Ufe(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),Ffe(t)}function Ffe(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Bfe=IG,Hfe=OG,Vfe=DG,Gfe=jG,Wfe=LG,Kfe=PG;function oC({delayDuration:e=0,...t}){return d.jsx(Bfe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Nt({...e}){return d.jsx(oC,{children:d.jsx(Hfe,{"data-slot":"tooltip",...e})})}function Ct({...e}){return d.jsx(Vfe,{"data-slot":"tooltip-trigger",...e})}function Rt({className:e,sideOffset:t=0,children:n,...a}){return d.jsx(Gfe,{children:d.jsxs(Wfe,{"data-slot":"tooltip-content",sideOffset:t,className:Le("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),...a,children:[n,d.jsx(Kfe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class Zfe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class oU{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 sU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class lU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class cU{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 Yfe{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 qfe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class Xfe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function xS(){try{return"0.14.0-canary.8"}catch{return"0.0.0"}}var Jfe={};function SS(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class uU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(a),!r.ok)throw new Error(`HTTP error! status: ${r.status}`)}catch{}}}function ws(e){return`mcp_inspector_telemetry_${e}`}class $r{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=SS(),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 uU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new uU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(ws("disabled"))==="true"||typeof process<"u"&&Jfe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(ws("source")):null}static getInstance(){return $r.instance||($r.instance=new $r),$r.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(ws("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!SS())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(ws("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(ws("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 a=Array.from(n).map(r=>r.toString(16).padStart(2,"0")).join("");return a.slice(0,8)+"-"+a.slice(8,12)+"-"+a.slice(12,16)+"-"+a.slice(16,20)+"-"+a.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const a=Math.random()*16|0;return(n==="x"?a:a&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:xS(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=xS(),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&&SS())try{const n=xS();let a=!1,r=!1;const i=localStorage.getItem(ws("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(ws("download_version"),n)):(a=!0,r=!0,localStorage.setItem(ws("download_version"),n)),a){const s={...t||{}};s.mcp_use_version=n,s.user_id=this.userId,s.event="package_download",s.first_download=r,s.language="typescript",s.source=this._source,s.package="inspector",await this._scarfClient.logEvent(s)}}catch{}}async trackInspectorOpen(t){const n=new Zfe(t);await this.capture(n)}}const Qfe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),epe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),dU=e=>{const t=epe(e);return t.charAt(0).toUpperCase()+t.slice(1)},zG=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),tpe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var npe={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 rpe=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...c},u)=>y.createElement("svg",{ref:u,...npe,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:zG("lucide",r),...!i&&!tpe(c)&&{"aria-hidden":"true"},...c},[...s.map(([f,m])=>y.createElement(f,m)),...Array.isArray(i)?i:[i]]));const et=(e,t)=>{const n=y.forwardRef(({className:a,...r},i)=>y.createElement(rpe,{ref:i,iconNode:t,className:zG(`lucide-${Qfe(dU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=dU(e),n};const ape=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],ipe=et("arrow-down-to-line",ape);const ope=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],spe=et("arrow-up-from-line",ope);const lpe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],cpe=et("arrow-up",lpe);const upe=[["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"}]],sC=et("bell",upe);const dpe=[["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"}]],UG=et("brush",dpe);const fpe=[["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"}]],ppe=et("bug",fpe);const mpe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],zr=et("check",mpe);const hpe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Po=et("chevron-down",hpe);const gpe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Xy=et("chevron-left",gpe);const bpe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],FG=et("chevron-right",bpe);const vpe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ype=et("chevron-up",vpe);const wpe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],xpe=et("chevrons-up-down",wpe);const Spe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],fU=et("circle-minus",Spe);const Epe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Hp=et("clock",Epe);const _pe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],lC=et("code",_pe);const kpe=[["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"}]],Tpe=et("cog",kpe);const Npe=[["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"}]],Cpe=et("command",Npe);const Rpe=[["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"}]],br=et("copy",Rpe);const Ape=[["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"}]],Jy=et("database",Ape);const Ipe=[["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"}]],zm=et("download",Ipe);const Ope=[["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"}]],Dpe=et("ellipsis-vertical",Ope);const jpe=[["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"}]],XE=et("external-link",jpe);const Lpe=[["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"}]],BG=et("eye-off",Lpe);const $pe=[["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"}]],JE=et("eye",$pe);const Mpe=[["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"}]],Ppe=et("file-code",Mpe);const zpe=[["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"}]],Upe=et("file-image",zpe);const Fpe=[["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"}]],cC=et("file-text",Fpe);const Bpe=[["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"}]],Hpe=et("file",Bpe);const Vpe=[["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"}]],Gpe=et("folder-open",Vpe);const Wpe=[["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"}]],Kpe=et("globe",Wpe);const Zpe=[["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"}]],Ype=et("grip-vertical",Zpe);const qpe=[["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"}]],HG=et("hash",qpe);const Xpe=[["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"}]],Vp=et("history",Xpe);const Jpe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],vp=et("info",Jpe);const Qpe=[["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"}]],VG=et("key",Qpe);const eme=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Fs=et("loader-circle",eme);const tme=[["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"}]],uC=et("maximize-2",tme);const nme=[["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"}]],Gp=et("maximize",nme);const rme=[["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"}]],ame=et("message-circle",rme);const ime=[["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"}]],Wp=et("message-square",ime);const ome=[["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"}]],GG=et("minimize",ome);const sme=[["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"}]],pU=et("monitor",sme);const lme=[["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"}]],cme=et("moon",lme);const ume=[["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"}]],dme=et("picture-in-picture",ume);const fme=[["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"}]],WG=et("play",fme);const pme=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ov=et("plus",pme);const mme=[["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"}]],mU=et("rotate-ccw",mme);const hme=[["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"}]],dC=et("save",hme);const gme=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],zd=et("search",gme);const bme=[["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"}]],vme=et("send",bme);const yme=[["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"}]],KG=et("server",yme);const wme=[["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"}]],Tu=et("settings",wme);const xme=[["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"}]],Sme=et("shield",xme);const Eme=[["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"}]],_me=et("sparkles",Eme);const kme=[["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"}]],ZG=et("square-check-big",kme);const Tme=[["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"}]],Nme=et("square-pen",Tme);const Cme=[["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"}]],Rme=et("sun-dim",Cme);const Ame=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ES=et("terminal",Ame);const Ime=[["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"}]],zo=et("trash-2",Ime);const Ome=[["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"}]],Dme=et("trash",Ome);const jme=[["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"}]],Zl=et("wrench",jme);const Lme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qi=et("x",Lme);const $me=[["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=et("zap",$me);var hU="popstate";function Mme(e={}){function t(a,r){let{pathname:i,search:s,hash:c}=a.location;return QE("",{pathname:i,search:s,hash:c},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(a,r){return typeof r=="string"?r:Zp(r)}return zme(t,n,null,e)}function Kn(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ei(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Pme(){return Math.random().toString(36).substring(2,10)}function gU(e,t){return{usr:e.state,key:e.key,idx:t}}function QE(e,t,n=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Ud(t):t,state:n,key:t&&t.key||a||Pme()}}function Zp({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 Ud(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function zme(e,t,n,a={}){let{window:r=document.defaultView,v5Compat:i=!1}=a,s=r.history,c="POP",u=null,f=m();f==null&&(f=0,s.replaceState({...s.state,idx:f},""));function m(){return(s.state||{idx:null}).idx}function h(){c="POP";let w=m(),E=w==null?null:w-f;f=w,u&&u({action:c,location:x.location,delta:E})}function g(w,E){c="PUSH";let _=QE(x.location,w,E);f=m()+1;let k=gU(_,f),R=x.createHref(_);try{s.pushState(k,"",R)}catch(N){if(N instanceof DOMException&&N.name==="DataCloneError")throw N;r.location.assign(R)}i&&u&&u({action:c,location:x.location,delta:1})}function v(w,E){c="REPLACE";let _=QE(x.location,w,E);f=m();let k=gU(_,f),R=x.createHref(_);s.replaceState(k,"",R),i&&u&&u({action:c,location:x.location,delta:0})}function S(w){return Ume(w)}let x={get action(){return c},get location(){return e(r,s)},listen(w){if(u)throw new Error("A history only accepts one active listener");return r.addEventListener(hU,h),u=w,()=>{r.removeEventListener(hU,h),u=null}},createHref(w){return t(r,w)},createURL:S,encodeLocation(w){let E=S(w);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:g,replace:v,go(w){return s.go(w)}};return x}function Ume(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Kn(n,"No window.location.(origin|href) available to create URL");let a=typeof e=="string"?e:Zp(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=n+a),new URL(a,n)}function YG(e,t,n="/"){return Fme(e,t,n,!1)}function Fme(e,t,n,a){let r=typeof t=="string"?Ud(t):t,i=Uo(r.pathname||"/",n);if(i==null)return null;let s=qG(e);Bme(s);let c=null;for(let u=0;c==null&&u<s.length;++u){let f=Qme(i);c=Xme(s[u],f,a)}return c}function qG(e,t=[],n=[],a="",r=!1){let i=(s,c,u=r,f)=>{let m={relativePath:f===void 0?s.path||"":f,caseSensitive:s.caseSensitive===!0,childrenIndex:c,route:s};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(a)&&u)return;Kn(m.relativePath.startsWith(a),`Absolute route path "${m.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(a.length)}let h=Ro([a,m.relativePath]),g=n.concat(m);s.children&&s.children.length>0&&(Kn(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),qG(s.children,t,g,h,u)),!(s.path==null&&!s.index)&&t.push({path:h,score:Yme(h,s.index),routesMeta:g})};return e.forEach((s,c)=>{if(s.path===""||!s.path?.includes("?"))i(s,c);else for(let u of XG(s.path))i(s,c,!0,u)}),t}function XG(e){let t=e.split("/");if(t.length===0)return[];let[n,...a]=t,r=n.endsWith("?"),i=n.replace(/\?$/,"");if(a.length===0)return r?[i,""]:[i];let s=XG(a.join("/")),c=[];return c.push(...s.map(u=>u===""?i:[i,u].join("/"))),r&&c.push(...s),c.map(u=>e.startsWith("/")&&u===""?"/":u)}function Bme(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:qme(t.routesMeta.map(a=>a.childrenIndex),n.routesMeta.map(a=>a.childrenIndex)))}var Hme=/^:[\w-]+$/,Vme=3,Gme=2,Wme=1,Kme=10,Zme=-2,bU=e=>e==="*";function Yme(e,t){let n=e.split("/"),a=n.length;return n.some(bU)&&(a+=Zme),t&&(a+=Gme),n.filter(r=>!bU(r)).reduce((r,i)=>r+(Hme.test(i)?Vme:i===""?Wme:Kme),a)}function qme(e,t){return e.length===t.length&&e.slice(0,-1).every((a,r)=>a===t[r])?e[e.length-1]-t[t.length-1]:0}function Xme(e,t,n=!1){let{routesMeta:a}=e,r={},i="/",s=[];for(let c=0;c<a.length;++c){let u=a[c],f=c===a.length-1,m=i==="/"?t:t.slice(i.length)||"/",h=Dv({path:u.relativePath,caseSensitive:u.caseSensitive,end:f},m),g=u.route;if(!h&&f&&n&&!a[a.length-1].route.index&&(h=Dv({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!h)return null;Object.assign(r,h.params),s.push({params:r,pathname:Ro([i,h.pathname]),pathnameBase:ahe(Ro([i,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(i=Ro([i,h.pathnameBase]))}return s}function Dv(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=Jme(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let i=r[0],s=i.replace(/(.)\/+$/,"$1"),c=r.slice(1);return{params:a.reduce((f,{paramName:m,isOptional:h},g)=>{if(m==="*"){let S=c[g]||"";s=i.slice(0,i.length-S.length).replace(/(.)\/+$/,"$1")}const v=c[g];return h&&!v?f[m]=void 0:f[m]=(v||"").replace(/%2F/g,"/"),f},{}),pathname:i,pathnameBase:s,pattern:e}}function Jme(e,t=!1,n=!0){Ei(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 a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,c,u)=>(a.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),a]}function Qme(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ei(!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,a=e.charAt(n);return a&&a!=="/"?null:e.slice(n)||"/"}var ehe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,the=e=>ehe.test(e);function nhe(e,t="/"){let{pathname:n,search:a="",hash:r=""}=typeof e=="string"?Ud(e):e,i;if(n)if(the(n))i=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),Ei(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?i=vU(n.substring(1),"/"):i=vU(n,t)}else i=t;return{pathname:i,search:ihe(a),hash:ohe(r)}}function vU(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function _S(e,t,n,a){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(a)}]. 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 rhe(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function JG(e){let t=rhe(e);return t.map((n,a)=>a===t.length-1?n.pathname:n.pathnameBase)}function QG(e,t,n,a=!1){let r;typeof e=="string"?r=Ud(e):(r={...e},Kn(!r.pathname||!r.pathname.includes("?"),_S("?","pathname","search",r)),Kn(!r.pathname||!r.pathname.includes("#"),_S("#","pathname","hash",r)),Kn(!r.search||!r.search.includes("#"),_S("#","search","hash",r)));let i=e===""||r.pathname==="",s=i?"/":r.pathname,c;if(s==null)c=n;else{let h=t.length-1;if(!a&&s.startsWith("..")){let g=s.split("/");for(;g[0]==="..";)g.shift(),h-=1;r.pathname=g.join("/")}c=h>=0?t[h]:"/"}let u=nhe(r,c),f=s&&s!=="/"&&s.endsWith("/"),m=(i||s===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(f||m)&&(u.pathname+="/"),u}var Ro=e=>e.join("/").replace(/\/\/+/g,"/"),ahe=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),ihe=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ohe=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function she(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function lhe(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var e7=["POST","PUT","PATCH","DELETE"];new Set(e7);var che=["GET",...e7];new Set(che);var Fd=y.createContext(null);Fd.displayName="DataRouter";var Qy=y.createContext(null);Qy.displayName="DataRouterState";y.createContext(!1);var t7=y.createContext({isTransitioning:!1});t7.displayName="ViewTransition";var uhe=y.createContext(new Map);uhe.displayName="Fetchers";var dhe=y.createContext(null);dhe.displayName="Await";var Ri=y.createContext(null);Ri.displayName="Navigation";var Um=y.createContext(null);Um.displayName="Location";var Go=y.createContext({outlet:null,matches:[],isDataRoute:!1});Go.displayName="Route";var fC=y.createContext(null);fC.displayName="RouteError";function fhe(e,{relative:t}={}){Kn(Fm(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:a}=y.useContext(Ri),{hash:r,pathname:i,search:s}=Bm(e,{relative:t}),c=i;return n!=="/"&&(c=i==="/"?n:Ro([n,i])),a.createHref({pathname:c,search:s,hash:r})}function Fm(){return y.useContext(Um)!=null}function Wo(){return Kn(Fm(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(Um).location}var n7="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function r7(e){y.useContext(Ri).static||y.useLayoutEffect(e)}function Bd(){let{isDataRoute:e}=y.useContext(Go);return e?khe():phe()}function phe(){Kn(Fm(),"useNavigate() may be used only in the context of a <Router> component.");let e=y.useContext(Fd),{basename:t,navigator:n}=y.useContext(Ri),{matches:a}=y.useContext(Go),{pathname:r}=Wo(),i=JSON.stringify(JG(a)),s=y.useRef(!1);return r7(()=>{s.current=!0}),y.useCallback((u,f={})=>{if(Ei(s.current,n7),!s.current)return;if(typeof u=="number"){n.go(u);return}let m=QG(u,JSON.parse(i),r,f.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ro([t,m.pathname])),(f.replace?n.replace:n.push)(m,f.state,f)},[t,n,i,r,e])}y.createContext(null);function Bm(e,{relative:t}={}){let{matches:n}=y.useContext(Go),{pathname:a}=Wo(),r=JSON.stringify(JG(n));return y.useMemo(()=>QG(e,JSON.parse(r),a,t==="path"),[e,r,a,t])}function mhe(e,t){return a7(e,t)}function a7(e,t,n,a,r){Kn(Fm(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=y.useContext(Ri),{matches:s}=y.useContext(Go),c=s[s.length-1],u=c?c.params:{},f=c?c.pathname:"/",m=c?c.pathnameBase:"/",h=c&&c.route;{let _=h&&h.path||"";i7(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.
154
+ `)},Que=0,Xc=[];function ede(e){var t=y.useRef([]),n=y.useRef([0,0]),a=y.useRef(),r=y.useState(Que++)[0],i=y.useState(R8)[0],s=y.useRef(e);y.useEffect(function(){s.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var x=xue([e.lockRef.current],(e.shards||[]).map(aU),!0).filter(Boolean);return x.forEach(function(w){return w.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),x.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(r))})}}},[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!s.current.allowPinchZoom;var E=mb(x),_=n.current,k="deltaX"in x?x.deltaX:_[0]-E[0],R="deltaY"in x?x.deltaY:_[1]-E[1],N,I=x.target,O=Math.abs(k)>Math.abs(R)?"h":"v";if("touches"in x&&O==="h"&&I.type==="range")return!1;var A=window.getSelection(),M=A&&A.anchorNode,j=M?M===I||M.contains(I):!1;if(j)return!1;var F=nU(O,I);if(!F)return!0;if(F?N=O:(N=O==="v"?"h":"v",F=nU(O,I)),!F)return!1;if(!a.current&&"changedTouches"in x&&(k||R)&&(a.current=N),!N)return!0;var V=a.current||N;return que(V,w,x,V==="h"?k:R)},[]),u=y.useCallback(function(x){var w=x;if(!(!Xc.length||Xc[Xc.length-1]!==i)){var E="deltaY"in w?rU(w):mb(w),_=t.current.filter(function(N){return N.name===w.type&&(N.target===w.target||w.target===N.shadowParent)&&Xue(N.delta,E)})[0];if(_&&_.should){w.cancelable&&w.preventDefault();return}if(!_){var k=(s.current.shards||[]).map(aU).filter(Boolean).filter(function(N){return N.contains(w.target)}),R=k.length>0?c(w,k[0]):!s.current.noIsolation;R&&w.cancelable&&w.preventDefault()}}},[]),f=y.useCallback(function(x,w,E,_){var k={name:x,delta:w,target:E,should:_,shadowParent:tde(E)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(R){return R!==k})},1)},[]),m=y.useCallback(function(x){n.current=mb(x),a.current=void 0},[]),h=y.useCallback(function(x){f(x.type,rU(x),x.target,c(x,e.lockRef.current))},[]),g=y.useCallback(function(x){f(x.type,mb(x),x.target,c(x,e.lockRef.current))},[]);y.useEffect(function(){return Xc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,qc),document.addEventListener("touchmove",u,qc),document.addEventListener("touchstart",m,qc),function(){Xc=Xc.filter(function(x){return x!==i}),document.removeEventListener("wheel",u,qc),document.removeEventListener("touchmove",u,qc),document.removeEventListener("touchstart",m,qc)}},[]);var v=e.removeScrollBar,S=e.inert;return y.createElement(y.Fragment,null,S?y.createElement(i,{styles:Jue(r)}):null,v?y.createElement(Hue,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tde(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const nde=Aue(C8,ede);var Lm=y.forwardRef(function(e,t){return y.createElement(Hy,zi({},e,{ref:t,sideCar:nde}))});Lm.classNames=Hy.classNames;var GE=["Enter"," "],rde=["ArrowDown","PageUp","Home"],D8=["ArrowUp","PageDown","End"],ade=[...rde,...D8],ide={ltr:[...GE,"ArrowRight"],rtl:[...GE,"ArrowLeft"]},ode={ltr:["ArrowLeft"],rtl:["ArrowRight"]},$m="Menu",[Up,sde,lde]=zN($m),[ic,j8]=Ci($m,[lde,Zs,w8]),Vy=Zs(),L8=w8(),[cde,oc]=ic($m),[ude,Mm]=ic($m),$8=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=Vy(t),[u,f]=y.useState(null),m=y.useRef(!1),h=Ki(i),g=UN(r);return y.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),d.jsx(zy,{...c,children:d.jsx(cde,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:f,children:d.jsx(ude,{scope:t,onClose:y.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};$8.displayName=$m;var dde="MenuAnchor",qN=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Vy(n);return d.jsx(Dm,{...r,...a,ref:t})});qN.displayName=dde;var XN="MenuPortal",[fde,M8]=ic(XN,{forceMount:void 0}),P8=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=oc(XN,t);return d.jsx(fde,{scope:t,forceMount:n,children:d.jsx(za,{present:n||i.open,children:d.jsx(Md,{asChild:!0,container:r,children:a})})})};P8.displayName=XN;var Qa="MenuContent",[pde,JN]=ic(Qa),z8=y.forwardRef((e,t)=>{const n=M8(Qa,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=oc(Qa,e.__scopeMenu),s=Mm(Qa,e.__scopeMenu);return d.jsx(Up.Provider,{scope:e.__scopeMenu,children:d.jsx(za,{present:a||i.open,children:d.jsx(Up.Slot,{scope:e.__scopeMenu,children:s.modal?d.jsx(mde,{...r,ref:t}):d.jsx(hde,{...r,ref:t})})})})}),mde=y.forwardRef((e,t)=>{const n=oc(Qa,e.__scopeMenu),a=y.useRef(null),r=nn(t,a);return y.useEffect(()=>{const i=a.current;if(i)return By(i)},[]),d.jsx(QN,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ke(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),hde=y.forwardRef((e,t)=>{const n=oc(Qa,e.__scopeMenu);return d.jsx(QN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),gde=Wl("MenuContent.ScrollLock"),QN=y.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:S,...x}=e,w=oc(Qa,n),E=Mm(Qa,n),_=Vy(n),k=L8(n),R=sde(n),[N,I]=y.useState(null),O=y.useRef(null),A=nn(t,O,w.onContentChange),M=y.useRef(0),j=y.useRef(""),F=y.useRef(0),V=y.useRef(null),J=y.useRef("right"),ee=y.useRef(0),ie=S?Lm:y.Fragment,W=S?{as:gde,allowPinchZoom:!0}:void 0,Z=ae=>{const ne=j.current+ae,L=R().filter(K=>!K.disabled),B=document.activeElement,P=L.find(K=>K.ref.current===B)?.textValue,$=L.map(K=>K.textValue),z=Cde($,ne,P),G=L.find(K=>K.textValue===z)?.ref.current;(function K(re){j.current=re,window.clearTimeout(M.current),re!==""&&(M.current=window.setTimeout(()=>K(""),1e3))})(ne),G&&setTimeout(()=>G.focus())};y.useEffect(()=>()=>window.clearTimeout(M.current),[]),jy();const H=y.useCallback(ae=>J.current===V.current?.side&&Ade(ae,V.current?.area),[]);return d.jsx(pde,{scope:n,searchRef:j,onItemEnter:y.useCallback(ae=>{H(ae)&&ae.preventDefault()},[H]),onItemLeave:y.useCallback(ae=>{H(ae)||(O.current?.focus(),I(null))},[H]),onTriggerLeave:y.useCallback(ae=>{H(ae)&&ae.preventDefault()},[H]),pointerGraceTimerRef:F,onPointerGraceIntentChange:y.useCallback(ae=>{V.current=ae},[]),children:d.jsx(ie,{...W,children:d.jsx(Im,{asChild:!0,trapped:r,onMountAutoFocus:Ke(i,ae=>{ae.preventDefault(),O.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:d.jsx(jd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:d.jsx(gue,{asChild:!0,...k,dir:E.dir,orientation:"vertical",loop:a,currentTabStopId:N,onCurrentTabStopIdChange:I,onEntryFocus:Ke(u,ae=>{E.isUsingKeyboardRef.current||ae.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(Uy,{role:"menu","aria-orientation":"vertical","data-state":tG(w.open),"data-radix-menu-content":"",dir:E.dir,..._,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:Ke(x.onKeyDown,ae=>{const L=ae.target.closest("[data-radix-menu-content]")===ae.currentTarget,B=ae.ctrlKey||ae.altKey||ae.metaKey,P=ae.key.length===1;L&&(ae.key==="Tab"&&ae.preventDefault(),!B&&P&&Z(ae.key));const $=O.current;if(ae.target!==$||!ade.includes(ae.key))return;ae.preventDefault();const G=R().filter(K=>!K.disabled).map(K=>K.ref.current);D8.includes(ae.key)&&G.reverse(),Tde(G)}),onBlur:Ke(e.onBlur,ae=>{ae.currentTarget.contains(ae.target)||(window.clearTimeout(M.current),j.current="")}),onPointerMove:Ke(e.onPointerMove,Fp(ae=>{const ne=ae.target,L=ee.current!==ae.clientX;if(ae.currentTarget.contains(ne)&&L){const B=ae.clientX>ee.current?"right":"left";J.current=B,ee.current=ae.clientX}}))})})})})})})});z8.displayName=Qa;var bde="MenuGroup",eC=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(It.div,{role:"group",...a,ref:t})});eC.displayName=bde;var vde="MenuLabel",U8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(It.div,{...a,ref:t})});U8.displayName=vde;var Rv="MenuItem",iU="menu.itemSelect",Gy=y.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=y.useRef(null),s=Mm(Rv,e.__scopeMenu),c=JN(Rv,e.__scopeMenu),u=nn(t,i),f=y.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(iU,{bubbles:!0,cancelable:!0});h.addEventListener(iU,v=>a?.(v),{once:!0}),Z9(h,g),g.defaultPrevented?f.current=!1:s.onClose()}};return d.jsx(F8,{...r,ref:u,disabled:n,onClick:Ke(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),f.current=!0},onPointerUp:Ke(e.onPointerUp,h=>{f.current||h.currentTarget?.click()}),onKeyDown:Ke(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||GE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Gy.displayName=Rv;var F8=y.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=JN(Rv,n),c=L8(n),u=y.useRef(null),f=nn(t,u),[m,h]=y.useState(!1),[g,v]=y.useState("");return y.useEffect(()=>{const S=u.current;S&&v((S.textContent??"").trim())},[i.children]),d.jsx(Up.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:d.jsx(bue,{asChild:!0,...c,focusable:!a,children:d.jsx(It.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:f,onPointerMove:Ke(e.onPointerMove,Fp(S=>{a?s.onItemLeave(S):(s.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ke(e.onPointerLeave,Fp(S=>s.onItemLeave(S))),onFocus:Ke(e.onFocus,()=>h(!0)),onBlur:Ke(e.onBlur,()=>h(!1))})})})}),yde="MenuCheckboxItem",B8=y.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return d.jsx(K8,{scope:e.__scopeMenu,checked:n,children:d.jsx(Gy,{role:"menuitemcheckbox","aria-checked":Av(n)?"mixed":n,...r,ref:t,"data-state":nC(n),onSelect:Ke(r.onSelect,()=>a?.(Av(n)?!0:!n),{checkForDefaultPrevented:!1})})})});B8.displayName=yde;var H8="MenuRadioGroup",[wde,xde]=ic(H8,{value:void 0,onValueChange:()=>{}}),V8=y.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Ki(a);return d.jsx(wde,{scope:e.__scopeMenu,value:n,onValueChange:i,children:d.jsx(eC,{...r,ref:t})})});V8.displayName=H8;var G8="MenuRadioItem",W8=y.forwardRef((e,t)=>{const{value:n,...a}=e,r=xde(G8,e.__scopeMenu),i=n===r.value;return d.jsx(K8,{scope:e.__scopeMenu,checked:i,children:d.jsx(Gy,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":nC(i),onSelect:Ke(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});W8.displayName=G8;var tC="MenuItemIndicator",[K8,Sde]=ic(tC,{checked:!1}),Z8=y.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=Sde(tC,n);return d.jsx(za,{present:a||Av(i.checked)||i.checked===!0,children:d.jsx(It.span,{...r,ref:t,"data-state":nC(i.checked)})})});Z8.displayName=tC;var Ede="MenuSeparator",Y8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return d.jsx(It.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});Y8.displayName=Ede;var _de="MenuArrow",q8=y.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Vy(n);return d.jsx(Fy,{...r,...a,ref:t})});q8.displayName=_de;var kde="MenuSub",[yNe,X8]=ic(kde),op="MenuSubTrigger",J8=y.forwardRef((e,t)=>{const n=oc(op,e.__scopeMenu),a=Mm(op,e.__scopeMenu),r=X8(op,e.__scopeMenu),i=JN(op,e.__scopeMenu),s=y.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=i,f={__scopeMenu:e.__scopeMenu},m=y.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return y.useEffect(()=>m,[m]),y.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),u(null)}},[c,u]),d.jsx(qN,{asChild:!0,...f,children:d.jsx(F8,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":tG(n.open),...e,ref:Wi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ke(e.onPointerMove,Fp(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(i.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),m()},100))})),onPointerLeave:Ke(e.onPointerLeave,Fp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,S=v==="right",x=S?-5:5,w=g[S?"left":"right"],E=g[S?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:w,y:g.top},{x:E,y:g.top},{x:E,y:g.bottom},{x:w,y:g.bottom}],side:v}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ke(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||ide[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});J8.displayName=op;var Q8="MenuSubContent",eG=y.forwardRef((e,t)=>{const n=M8(Qa,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=oc(Qa,e.__scopeMenu),s=Mm(Qa,e.__scopeMenu),c=X8(Q8,e.__scopeMenu),u=y.useRef(null),f=nn(t,u);return d.jsx(Up.Provider,{scope:e.__scopeMenu,children:d.jsx(za,{present:a||i.open,children:d.jsx(Up.Slot,{scope:e.__scopeMenu,children:d.jsx(QN,{id:c.contentId,"aria-labelledby":c.triggerId,...r,ref:f,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{s.isUsingKeyboardRef.current&&u.current?.focus(),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Ke(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ke(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ke(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=ode[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});eG.displayName=Q8;function tG(e){return e?"open":"closed"}function Av(e){return e==="indeterminate"}function nC(e){return Av(e)?"indeterminate":e?"checked":"unchecked"}function Tde(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Nde(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function Cde(e,t,n){const r=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Nde(e,Math.max(i,0));r.length===1&&(s=s.filter(f=>f!==n));const u=s.find(f=>f.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function Rde(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],f=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-f)*(a-m)/(g-m)+f&&(r=!r)}return r}function Ade(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Rde(n,t)}function Fp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Ide=$8,Ode=qN,Dde=P8,jde=z8,Lde=eC,$de=U8,Mde=Gy,Pde=B8,zde=V8,Ude=W8,Fde=Z8,Bde=Y8,Hde=q8,Vde=J8,Gde=eG,Wy="DropdownMenu",[Wde]=Ci(Wy,[j8]),ca=j8(),[Kde,nG]=Wde(Wy),rG=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ca(t),f=y.useRef(null),[m,h]=Lo({prop:r,defaultProp:i??!1,onChange:s,caller:Wy});return d.jsx(Kde,{scope:t,triggerId:Pr(),triggerRef:f,contentId:Pr(),open:m,onOpenChange:h,onOpenToggle:y.useCallback(()=>h(g=>!g),[h]),modal:c,children:d.jsx(Ide,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};rG.displayName=Wy;var aG="DropdownMenuTrigger",iG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=nG(aG,n),s=ca(n);return d.jsx(Ode,{asChild:!0,...s,children:d.jsx(It.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":a?"":void 0,disabled:a,...r,ref:Wi(t,i.triggerRef),onPointerDown:Ke(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ke(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});iG.displayName=aG;var Zde="DropdownMenuPortal",oG=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ca(t);return d.jsx(Dde,{...a,...n})};oG.displayName=Zde;var sG="DropdownMenuContent",lG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=nG(sG,n),i=ca(n),s=y.useRef(!1);return d.jsx(jde,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ke(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ke(e.onInteractOutside,c=>{const u=c.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;(!r.modal||m)&&(s.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)"}})});lG.displayName=sG;var Yde="DropdownMenuGroup",qde=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Lde,{...r,...a,ref:t})});qde.displayName=Yde;var Xde="DropdownMenuLabel",cG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx($de,{...r,...a,ref:t})});cG.displayName=Xde;var Jde="DropdownMenuItem",uG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Mde,{...r,...a,ref:t})});uG.displayName=Jde;var Qde="DropdownMenuCheckboxItem",dG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Pde,{...r,...a,ref:t})});dG.displayName=Qde;var efe="DropdownMenuRadioGroup",tfe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(zde,{...r,...a,ref:t})});tfe.displayName=efe;var nfe="DropdownMenuRadioItem",fG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Ude,{...r,...a,ref:t})});fG.displayName=nfe;var rfe="DropdownMenuItemIndicator",afe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Fde,{...r,...a,ref:t})});afe.displayName=rfe;var ife="DropdownMenuSeparator",pG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Bde,{...r,...a,ref:t})});pG.displayName=ife;var ofe="DropdownMenuArrow",sfe=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Hde,{...r,...a,ref:t})});sfe.displayName=ofe;var lfe="DropdownMenuSubTrigger",mG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Vde,{...r,...a,ref:t})});mG.displayName=lfe;var cfe="DropdownMenuSubContent",hG=y.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ca(n);return d.jsx(Gde,{...r,...a,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)"}})});hG.displayName=cfe;var ufe=rG,dfe=iG,ffe=oG,gG=lG,bG=cG,vG=uG,pfe=dG,mfe=fG,yG=pG,hfe=mG,gfe=hG;const WE=ufe,KE=dfe;hfe.displayName;gfe.displayName;function Iv({ref:e,className:t,sideOffset:n=4,...a}){return d.jsx(ffe,{children:d.jsx(gG,{ref:e,sideOffset:n,className:Le("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),...a})})}Iv.displayName=gG.displayName;function Ui({ref:e,className:t,inset:n,...a}){return d.jsx(vG,{ref:e,className:Le("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),...a})}Ui.displayName=vG.displayName;pfe.displayName;mfe.displayName;function ZE({ref:e,className:t,inset:n,...a}){return d.jsx(bG,{ref:e,className:Le("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}ZE.displayName=bG.displayName;function sp({ref:e,className:t,...n}){return d.jsx(yG,{ref:e,className:Le("-mx-1 my-1 h-px bg-muted",t),...n})}sp.displayName=yG.displayName;var bfe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Vo=bfe.reduce((e,t)=>{const n=R9(`Primitive.${t}`),a=y.forwardRef((r,i)=>{const{asChild:s,...c}=r,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),d.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),vfe="Label",wG=y.forwardRef((e,t)=>d.jsx(Vo.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));wG.displayName=vfe;var yfe=wG;function tn({className:e,...t}){return d.jsx(yfe,{"data-slot":"label",className:Le("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 Pd({message:e,className:t="",vertical:n,noBorder:a}){return d.jsx("div",{className:Le(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:d.jsxs("p",{className:Le("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[d.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:d.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:d.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[d.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"}),d.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),d.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function xG({className:e,color:t,children:n,grayscaled:a=!1}){const r=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[1]||"0")}return a?0:.2},[t,a]),i=y.useMemo(()=>{if(t){const h=t.split("(")[1].split(")")[0].trim().split(/\s+/);return Number.parseFloat(h[0]||"0.5")}return a?.3:.4},[t,a]),s=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(i,1)} ${r} ${s})`,[s,r,i]),u=y.useMemo(()=>`oklch(${Math.min(i*2,1)} ${r} ${s})`,[s,r,i,t]),f=y.useMemo(()=>Math.floor(Math.random()*360),[s]),m=y.useMemo(()=>"1000%",[]);return d.jsx("section",{className:Le("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:d.jsxs("div",{className:"isolate relative w-full h-full",children:[d.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&&d.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function rC(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 Ky="Switch",[wfe]=Ci(Ky),[xfe,Sfe]=wfe(Ky),SG=y.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:f,form:m,...h}=e,[g,v]=y.useState(null),S=nn(t,k=>v(k)),x=y.useRef(!1),w=g?m||!!g.closest("form"):!0,[E,_]=Lo({prop:r,defaultProp:i??!1,onChange:f,caller:Ky});return d.jsxs(xfe,{scope:n,checked:E,disabled:c,children:[d.jsx(It.button,{type:"button",role:"switch","aria-checked":E,"aria-required":s,"data-state":TG(E),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:S,onClick:Ke(e.onClick,k=>{_(R=>!R),w&&(x.current=k.isPropagationStopped(),x.current||k.stopPropagation())})}),w&&d.jsx(kG,{control:g,bubbles:!x.current,name:a,value:u,checked:E,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});SG.displayName=Ky;var EG="SwitchThumb",_G=y.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=Sfe(EG,n);return d.jsx(It.span,{"data-state":TG(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});_G.displayName=EG;var Efe="SwitchBubbleInput",kG=y.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=y.useRef(null),c=nn(s,i),u=rC(n),f=KN(t);return y.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const S=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(S)}},[u,n,a]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...r,tabIndex:-1,ref:c,style:{...r.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});kG.displayName=Efe;function TG(e){return e?"checked":"unchecked"}var NG=SG,_fe=_G;function Zy({ref:e,className:t,...n}){return d.jsx(NG,{className:Le("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:d.jsx(_fe,{className:Le("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")})})}Zy.displayName=NG.displayName;var CG=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"}),kfe="VisuallyHidden",RG=y.forwardRef((e,t)=>d.jsx(It.span,{...e,ref:t,style:{...CG,...e.style}}));RG.displayName=kfe;var Tfe=RG,[Yy]=Ci("Tooltip",[Zs]),qy=Zs(),AG="TooltipProvider",Nfe=700,YE="tooltip.open",[Cfe,aC]=Yy(AG),IG=e=>{const{__scopeTooltip:t,delayDuration:n=Nfe,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=e,s=y.useRef(!0),c=y.useRef(!1),u=y.useRef(0);return y.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),d.jsx(Cfe,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:y.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,a)},[a]),isPointerInTransitRef:c,onPointerInTransitChange:y.useCallback(f=>{c.current=f},[]),disableHoverableContent:r,children:i})};IG.displayName=AG;var Bp="Tooltip",[Rfe,Pm]=Yy(Bp),OG=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=aC(Bp,e.__scopeTooltip),f=qy(t),[m,h]=y.useState(null),g=Pr(),v=y.useRef(0),S=s??u.disableHoverableContent,x=c??u.delayDuration,w=y.useRef(!1),[E,_]=Lo({prop:a,defaultProp:r??!1,onChange:O=>{O?(u.onOpen(),document.dispatchEvent(new CustomEvent(YE))):u.onClose(),i?.(O)},caller:Bp}),k=y.useMemo(()=>E?w.current?"delayed-open":"instant-open":"closed",[E]),R=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,w.current=!1,_(!0)},[_]),N=y.useCallback(()=>{window.clearTimeout(v.current),v.current=0,_(!1)},[_]),I=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)},[]),d.jsx(zy,{...f,children:d.jsx(Rfe,{scope:t,contentId:g,open:E,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:y.useCallback(()=>{u.isOpenDelayedRef.current?I():R()},[u.isOpenDelayedRef,I,R]),onTriggerLeave:y.useCallback(()=>{S?N():(window.clearTimeout(v.current),v.current=0)},[N,S]),onOpen:R,onClose:N,disableHoverableContent:S,children:n})})};OG.displayName=Bp;var qE="TooltipTrigger",DG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Pm(qE,n),i=aC(qE,n),s=qy(n),c=y.useRef(null),u=nn(t,c,r.onTriggerChange),f=y.useRef(!1),m=y.useRef(!1),h=y.useCallback(()=>f.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),d.jsx(Dm,{asChild:!0,...s,children:d.jsx(It.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ke(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ke(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ke(e.onPointerDown,()=>{r.open&&r.onClose(),f.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ke(e.onFocus,()=>{f.current||r.onOpen()}),onBlur:Ke(e.onBlur,r.onClose),onClick:Ke(e.onClick,r.onClose)})})});DG.displayName=qE;var iC="TooltipPortal",[Afe,Ife]=Yy(iC,{forceMount:void 0}),jG=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=Pm(iC,t);return d.jsx(Afe,{scope:t,forceMount:n,children:d.jsx(za,{present:n||i.open,children:d.jsx(Md,{asChild:!0,container:r,children:a})})})};jG.displayName=iC;var gd="TooltipContent",LG=y.forwardRef((e,t)=>{const n=Ife(gd,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=Pm(gd,e.__scopeTooltip);return d.jsx(za,{present:a||s.open,children:s.disableHoverableContent?d.jsx($G,{side:r,...i,ref:t}):d.jsx(Ofe,{side:r,...i,ref:t})})}),Ofe=y.forwardRef((e,t)=>{const n=Pm(gd,e.__scopeTooltip),a=aC(gd,e.__scopeTooltip),r=y.useRef(null),i=nn(t,r),[s,c]=y.useState(null),{trigger:u,onClose:f}=n,m=r.current,{onPointerInTransitChange:h}=a,g=y.useCallback(()=>{c(null),h(!1)},[h]),v=y.useCallback((S,x)=>{const w=S.currentTarget,E={x:S.clientX,y:S.clientY},_=$fe(E,w.getBoundingClientRect()),k=Mfe(E,_),R=Pfe(x.getBoundingClientRect()),N=Ufe([...k,...R]);c(N),h(!0)},[h]);return y.useEffect(()=>()=>g(),[g]),y.useEffect(()=>{if(u&&m){const S=w=>v(w,m),x=w=>v(w,u);return u.addEventListener("pointerleave",S),m.addEventListener("pointerleave",x),()=>{u.removeEventListener("pointerleave",S),m.removeEventListener("pointerleave",x)}}},[u,m,v,g]),y.useEffect(()=>{if(s){const S=x=>{const w=x.target,E={x:x.clientX,y:x.clientY},_=u?.contains(w)||m?.contains(w),k=!zfe(E,s);_?g():k&&(g(),f())};return document.addEventListener("pointermove",S),()=>document.removeEventListener("pointermove",S)}},[u,m,s,f,g]),d.jsx($G,{...e,ref:i})}),[Dfe,jfe]=Yy(Bp,{isInside:!1}),Lfe=hle("TooltipContent"),$G=y.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=Pm(gd,n),f=qy(n),{onClose:m}=u;return y.useEffect(()=>(document.addEventListener(YE,m),()=>document.removeEventListener(YE,m)),[m]),y.useEffect(()=>{if(u.trigger){const h=g=>{g.target?.contains(u.trigger)&&m()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[u.trigger,m]),d.jsx(jd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:d.jsxs(Uy,{"data-state":u.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:[d.jsx(Lfe,{children:a}),d.jsx(Dfe,{scope:n,isInside:!0,children:d.jsx(Tfe,{id:u.contentId,role:"tooltip",children:r||a})})]})})});LG.displayName=gd;var MG="TooltipArrow",PG=y.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=qy(n);return jfe(MG,n).isInside?null:d.jsx(Fy,{...r,...a,ref:t})});PG.displayName=MG;function $fe(e,t){const n=Math.abs(t.top-e.y),a=Math.abs(t.bottom-e.y),r=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,a,r,i)){case i:return"left";case r:return"right";case n:return"top";case a:return"bottom";default:throw new Error("unreachable")}}function Mfe(e,t,n=5){const a=[];switch(t){case"top":a.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":a.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":a.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":a.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return a}function Pfe(e){const{top:t,right:n,bottom:a,left:r}=e;return[{x:r,y:t},{x:n,y:t},{x:n,y:a},{x:r,y:a}]}function zfe(e,t){const{x:n,y:a}=e;let r=!1;for(let i=0,s=t.length-1;i<t.length;s=i++){const c=t[i],u=t[s],f=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-f)*(a-m)/(g-m)+f&&(r=!r)}return r}function Ufe(e){const t=e.slice();return t.sort((n,a)=>n.x<a.x?-1:n.x>a.x?1:n.y<a.y?-1:n.y>a.y?1:0),Ffe(t)}function Ffe(e){if(e.length<=1)return e.slice();const t=[];for(let a=0;a<e.length;a++){const r=e[a];for(;t.length>=2;){const i=t[t.length-1],s=t[t.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))t.pop();else break}t.push(r)}t.pop();const n=[];for(let a=e.length-1;a>=0;a--){const r=e[a];for(;n.length>=2;){const i=n[n.length-1],s=n[n.length-2];if((i.x-s.x)*(r.y-s.y)>=(i.y-s.y)*(r.x-s.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Bfe=IG,Hfe=OG,Vfe=DG,Gfe=jG,Wfe=LG,Kfe=PG;function oC({delayDuration:e=0,...t}){return d.jsx(Bfe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Nt({...e}){return d.jsx(oC,{children:d.jsx(Hfe,{"data-slot":"tooltip",...e})})}function Ct({...e}){return d.jsx(Vfe,{"data-slot":"tooltip-trigger",...e})}function Rt({className:e,sideOffset:t=0,children:n,...a}){return d.jsx(Gfe,{children:d.jsxs(Wfe,{"data-slot":"tooltip-content",sideOffset:t,className:Le("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),...a,children:[n,d.jsx(Kfe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class Zfe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class oU{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 sU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class lU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class cU{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 Yfe{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 qfe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class Xfe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function xS(){try{return"0.14.0-canary.9"}catch{return"0.0.0"}}var Jfe={};function SS(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class uU{endpoint;timeout;constructor(t,n=3e3){this.endpoint=t,this.timeout=n}async logEvent(t){try{const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal});if(clearTimeout(a),!r.ok)throw new Error(`HTTP error! status: ${r.status}`)}catch{}}}function ws(e){return`mcp_inspector_telemetry_${e}`}class $r{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=SS(),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 uU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new uU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(ws("disabled"))==="true"||typeof process<"u"&&Jfe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(ws("source")):null}static getInstance(){return $r.instance||($r.instance=new $r),$r.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(ws("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!SS())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(ws("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(ws("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 a=Array.from(n).map(r=>r.toString(16).padStart(2,"0")).join("");return a.slice(0,8)+"-"+a.slice(8,12)+"-"+a.slice(12,16)+"-"+a.slice(16,20)+"-"+a.slice(20,32)}else return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const a=Math.random()*16|0;return(n==="x"?a:a&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:xS(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=xS(),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&&SS())try{const n=xS();let a=!1,r=!1;const i=localStorage.getItem(ws("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(ws("download_version"),n)):(a=!0,r=!0,localStorage.setItem(ws("download_version"),n)),a){const s={...t||{}};s.mcp_use_version=n,s.user_id=this.userId,s.event="package_download",s.first_download=r,s.language="typescript",s.source=this._source,s.package="inspector",await this._scarfClient.logEvent(s)}}catch{}}async trackInspectorOpen(t){const n=new Zfe(t);await this.capture(n)}}const Qfe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),epe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),dU=e=>{const t=epe(e);return t.charAt(0).toUpperCase()+t.slice(1)},zG=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),tpe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var npe={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 rpe=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...c},u)=>y.createElement("svg",{ref:u,...npe,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:zG("lucide",r),...!i&&!tpe(c)&&{"aria-hidden":"true"},...c},[...s.map(([f,m])=>y.createElement(f,m)),...Array.isArray(i)?i:[i]]));const et=(e,t)=>{const n=y.forwardRef(({className:a,...r},i)=>y.createElement(rpe,{ref:i,iconNode:t,className:zG(`lucide-${Qfe(dU(e))}`,`lucide-${e}`,a),...r}));return n.displayName=dU(e),n};const ape=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],ipe=et("arrow-down-to-line",ape);const ope=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],spe=et("arrow-up-from-line",ope);const lpe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],cpe=et("arrow-up",lpe);const upe=[["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"}]],sC=et("bell",upe);const dpe=[["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"}]],UG=et("brush",dpe);const fpe=[["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"}]],ppe=et("bug",fpe);const mpe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],zr=et("check",mpe);const hpe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Po=et("chevron-down",hpe);const gpe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Xy=et("chevron-left",gpe);const bpe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],FG=et("chevron-right",bpe);const vpe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ype=et("chevron-up",vpe);const wpe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],xpe=et("chevrons-up-down",wpe);const Spe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],fU=et("circle-minus",Spe);const Epe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Hp=et("clock",Epe);const _pe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],lC=et("code",_pe);const kpe=[["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"}]],Tpe=et("cog",kpe);const Npe=[["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"}]],Cpe=et("command",Npe);const Rpe=[["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"}]],br=et("copy",Rpe);const Ape=[["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"}]],Jy=et("database",Ape);const Ipe=[["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"}]],zm=et("download",Ipe);const Ope=[["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"}]],Dpe=et("ellipsis-vertical",Ope);const jpe=[["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"}]],XE=et("external-link",jpe);const Lpe=[["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"}]],BG=et("eye-off",Lpe);const $pe=[["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"}]],JE=et("eye",$pe);const Mpe=[["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"}]],Ppe=et("file-code",Mpe);const zpe=[["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"}]],Upe=et("file-image",zpe);const Fpe=[["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"}]],cC=et("file-text",Fpe);const Bpe=[["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"}]],Hpe=et("file",Bpe);const Vpe=[["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"}]],Gpe=et("folder-open",Vpe);const Wpe=[["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"}]],Kpe=et("globe",Wpe);const Zpe=[["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"}]],Ype=et("grip-vertical",Zpe);const qpe=[["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"}]],HG=et("hash",qpe);const Xpe=[["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"}]],Vp=et("history",Xpe);const Jpe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],vp=et("info",Jpe);const Qpe=[["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"}]],VG=et("key",Qpe);const eme=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Fs=et("loader-circle",eme);const tme=[["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"}]],uC=et("maximize-2",tme);const nme=[["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"}]],Gp=et("maximize",nme);const rme=[["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"}]],ame=et("message-circle",rme);const ime=[["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"}]],Wp=et("message-square",ime);const ome=[["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"}]],GG=et("minimize",ome);const sme=[["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"}]],pU=et("monitor",sme);const lme=[["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"}]],cme=et("moon",lme);const ume=[["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"}]],dme=et("picture-in-picture",ume);const fme=[["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"}]],WG=et("play",fme);const pme=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ov=et("plus",pme);const mme=[["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"}]],mU=et("rotate-ccw",mme);const hme=[["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"}]],dC=et("save",hme);const gme=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],zd=et("search",gme);const bme=[["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"}]],vme=et("send",bme);const yme=[["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"}]],KG=et("server",yme);const wme=[["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"}]],Tu=et("settings",wme);const xme=[["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"}]],Sme=et("shield",xme);const Eme=[["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"}]],_me=et("sparkles",Eme);const kme=[["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"}]],ZG=et("square-check-big",kme);const Tme=[["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"}]],Nme=et("square-pen",Tme);const Cme=[["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"}]],Rme=et("sun-dim",Cme);const Ame=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ES=et("terminal",Ame);const Ime=[["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"}]],zo=et("trash-2",Ime);const Ome=[["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"}]],Dme=et("trash",Ome);const jme=[["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"}]],Zl=et("wrench",jme);const Lme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Qi=et("x",Lme);const $me=[["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=et("zap",$me);var hU="popstate";function Mme(e={}){function t(a,r){let{pathname:i,search:s,hash:c}=a.location;return QE("",{pathname:i,search:s,hash:c},r.state&&r.state.usr||null,r.state&&r.state.key||"default")}function n(a,r){return typeof r=="string"?r:Zp(r)}return zme(t,n,null,e)}function Kn(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Ei(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Pme(){return Math.random().toString(36).substring(2,10)}function gU(e,t){return{usr:e.state,key:e.key,idx:t}}function QE(e,t,n=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Ud(t):t,state:n,key:t&&t.key||a||Pme()}}function Zp({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 Ud(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function zme(e,t,n,a={}){let{window:r=document.defaultView,v5Compat:i=!1}=a,s=r.history,c="POP",u=null,f=m();f==null&&(f=0,s.replaceState({...s.state,idx:f},""));function m(){return(s.state||{idx:null}).idx}function h(){c="POP";let w=m(),E=w==null?null:w-f;f=w,u&&u({action:c,location:x.location,delta:E})}function g(w,E){c="PUSH";let _=QE(x.location,w,E);f=m()+1;let k=gU(_,f),R=x.createHref(_);try{s.pushState(k,"",R)}catch(N){if(N instanceof DOMException&&N.name==="DataCloneError")throw N;r.location.assign(R)}i&&u&&u({action:c,location:x.location,delta:1})}function v(w,E){c="REPLACE";let _=QE(x.location,w,E);f=m();let k=gU(_,f),R=x.createHref(_);s.replaceState(k,"",R),i&&u&&u({action:c,location:x.location,delta:0})}function S(w){return Ume(w)}let x={get action(){return c},get location(){return e(r,s)},listen(w){if(u)throw new Error("A history only accepts one active listener");return r.addEventListener(hU,h),u=w,()=>{r.removeEventListener(hU,h),u=null}},createHref(w){return t(r,w)},createURL:S,encodeLocation(w){let E=S(w);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:g,replace:v,go(w){return s.go(w)}};return x}function Ume(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),Kn(n,"No window.location.(origin|href) available to create URL");let a=typeof e=="string"?e:Zp(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=n+a),new URL(a,n)}function YG(e,t,n="/"){return Fme(e,t,n,!1)}function Fme(e,t,n,a){let r=typeof t=="string"?Ud(t):t,i=Uo(r.pathname||"/",n);if(i==null)return null;let s=qG(e);Bme(s);let c=null;for(let u=0;c==null&&u<s.length;++u){let f=Qme(i);c=Xme(s[u],f,a)}return c}function qG(e,t=[],n=[],a="",r=!1){let i=(s,c,u=r,f)=>{let m={relativePath:f===void 0?s.path||"":f,caseSensitive:s.caseSensitive===!0,childrenIndex:c,route:s};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(a)&&u)return;Kn(m.relativePath.startsWith(a),`Absolute route path "${m.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(a.length)}let h=Ro([a,m.relativePath]),g=n.concat(m);s.children&&s.children.length>0&&(Kn(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),qG(s.children,t,g,h,u)),!(s.path==null&&!s.index)&&t.push({path:h,score:Yme(h,s.index),routesMeta:g})};return e.forEach((s,c)=>{if(s.path===""||!s.path?.includes("?"))i(s,c);else for(let u of XG(s.path))i(s,c,!0,u)}),t}function XG(e){let t=e.split("/");if(t.length===0)return[];let[n,...a]=t,r=n.endsWith("?"),i=n.replace(/\?$/,"");if(a.length===0)return r?[i,""]:[i];let s=XG(a.join("/")),c=[];return c.push(...s.map(u=>u===""?i:[i,u].join("/"))),r&&c.push(...s),c.map(u=>e.startsWith("/")&&u===""?"/":u)}function Bme(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:qme(t.routesMeta.map(a=>a.childrenIndex),n.routesMeta.map(a=>a.childrenIndex)))}var Hme=/^:[\w-]+$/,Vme=3,Gme=2,Wme=1,Kme=10,Zme=-2,bU=e=>e==="*";function Yme(e,t){let n=e.split("/"),a=n.length;return n.some(bU)&&(a+=Zme),t&&(a+=Gme),n.filter(r=>!bU(r)).reduce((r,i)=>r+(Hme.test(i)?Vme:i===""?Wme:Kme),a)}function qme(e,t){return e.length===t.length&&e.slice(0,-1).every((a,r)=>a===t[r])?e[e.length-1]-t[t.length-1]:0}function Xme(e,t,n=!1){let{routesMeta:a}=e,r={},i="/",s=[];for(let c=0;c<a.length;++c){let u=a[c],f=c===a.length-1,m=i==="/"?t:t.slice(i.length)||"/",h=Dv({path:u.relativePath,caseSensitive:u.caseSensitive,end:f},m),g=u.route;if(!h&&f&&n&&!a[a.length-1].route.index&&(h=Dv({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},m)),!h)return null;Object.assign(r,h.params),s.push({params:r,pathname:Ro([i,h.pathname]),pathnameBase:ahe(Ro([i,h.pathnameBase])),route:g}),h.pathnameBase!=="/"&&(i=Ro([i,h.pathnameBase]))}return s}function Dv(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,a]=Jme(e.path,e.caseSensitive,e.end),r=t.match(n);if(!r)return null;let i=r[0],s=i.replace(/(.)\/+$/,"$1"),c=r.slice(1);return{params:a.reduce((f,{paramName:m,isOptional:h},g)=>{if(m==="*"){let S=c[g]||"";s=i.slice(0,i.length-S.length).replace(/(.)\/+$/,"$1")}const v=c[g];return h&&!v?f[m]=void 0:f[m]=(v||"").replace(/%2F/g,"/"),f},{}),pathname:i,pathnameBase:s,pattern:e}}function Jme(e,t=!1,n=!0){Ei(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 a=[],r="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,c,u)=>(a.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),r+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?r+="\\/*$":e!==""&&e!=="/"&&(r+="(?:(?=\\/|$))"),[new RegExp(r,t?void 0:"i"),a]}function Qme(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Ei(!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,a=e.charAt(n);return a&&a!=="/"?null:e.slice(n)||"/"}var ehe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,the=e=>ehe.test(e);function nhe(e,t="/"){let{pathname:n,search:a="",hash:r=""}=typeof e=="string"?Ud(e):e,i;if(n)if(the(n))i=n;else{if(n.includes("//")){let s=n;n=n.replace(/\/\/+/g,"/"),Ei(!1,`Pathnames cannot have embedded double slashes - normalizing ${s} -> ${n}`)}n.startsWith("/")?i=vU(n.substring(1),"/"):i=vU(n,t)}else i=t;return{pathname:i,search:ihe(a),hash:ohe(r)}}function vU(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(r=>{r===".."?n.length>1&&n.pop():r!=="."&&n.push(r)}),n.length>1?n.join("/"):"/"}function _S(e,t,n,a){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(a)}]. 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 rhe(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function JG(e){let t=rhe(e);return t.map((n,a)=>a===t.length-1?n.pathname:n.pathnameBase)}function QG(e,t,n,a=!1){let r;typeof e=="string"?r=Ud(e):(r={...e},Kn(!r.pathname||!r.pathname.includes("?"),_S("?","pathname","search",r)),Kn(!r.pathname||!r.pathname.includes("#"),_S("#","pathname","hash",r)),Kn(!r.search||!r.search.includes("#"),_S("#","search","hash",r)));let i=e===""||r.pathname==="",s=i?"/":r.pathname,c;if(s==null)c=n;else{let h=t.length-1;if(!a&&s.startsWith("..")){let g=s.split("/");for(;g[0]==="..";)g.shift(),h-=1;r.pathname=g.join("/")}c=h>=0?t[h]:"/"}let u=nhe(r,c),f=s&&s!=="/"&&s.endsWith("/"),m=(i||s===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(f||m)&&(u.pathname+="/"),u}var Ro=e=>e.join("/").replace(/\/\/+/g,"/"),ahe=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),ihe=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,ohe=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function she(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function lhe(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var e7=["POST","PUT","PATCH","DELETE"];new Set(e7);var che=["GET",...e7];new Set(che);var Fd=y.createContext(null);Fd.displayName="DataRouter";var Qy=y.createContext(null);Qy.displayName="DataRouterState";y.createContext(!1);var t7=y.createContext({isTransitioning:!1});t7.displayName="ViewTransition";var uhe=y.createContext(new Map);uhe.displayName="Fetchers";var dhe=y.createContext(null);dhe.displayName="Await";var Ri=y.createContext(null);Ri.displayName="Navigation";var Um=y.createContext(null);Um.displayName="Location";var Go=y.createContext({outlet:null,matches:[],isDataRoute:!1});Go.displayName="Route";var fC=y.createContext(null);fC.displayName="RouteError";function fhe(e,{relative:t}={}){Kn(Fm(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:a}=y.useContext(Ri),{hash:r,pathname:i,search:s}=Bm(e,{relative:t}),c=i;return n!=="/"&&(c=i==="/"?n:Ro([n,i])),a.createHref({pathname:c,search:s,hash:r})}function Fm(){return y.useContext(Um)!=null}function Wo(){return Kn(Fm(),"useLocation() may be used only in the context of a <Router> component."),y.useContext(Um).location}var n7="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function r7(e){y.useContext(Ri).static||y.useLayoutEffect(e)}function Bd(){let{isDataRoute:e}=y.useContext(Go);return e?khe():phe()}function phe(){Kn(Fm(),"useNavigate() may be used only in the context of a <Router> component.");let e=y.useContext(Fd),{basename:t,navigator:n}=y.useContext(Ri),{matches:a}=y.useContext(Go),{pathname:r}=Wo(),i=JSON.stringify(JG(a)),s=y.useRef(!1);return r7(()=>{s.current=!0}),y.useCallback((u,f={})=>{if(Ei(s.current,n7),!s.current)return;if(typeof u=="number"){n.go(u);return}let m=QG(u,JSON.parse(i),r,f.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Ro([t,m.pathname])),(f.replace?n.replace:n.push)(m,f.state,f)},[t,n,i,r,e])}y.createContext(null);function Bm(e,{relative:t}={}){let{matches:n}=y.useContext(Go),{pathname:a}=Wo(),r=JSON.stringify(JG(n));return y.useMemo(()=>QG(e,JSON.parse(r),a,t==="path"),[e,r,a,t])}function mhe(e,t){return a7(e,t)}function a7(e,t,n,a,r){Kn(Fm(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=y.useContext(Ri),{matches:s}=y.useContext(Go),c=s[s.length-1],u=c?c.params:{},f=c?c.pathname:"/",m=c?c.pathnameBase:"/",h=c&&c.route;{let _=h&&h.path||"";i7(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.
155
155
 
156
156
  Please change the parent <Route path="${_}"> to <Route path="${_==="/"?"*":`${_}/*`}">.`)}let g=Wo(),v;if(t){let _=typeof t=="string"?Ud(t):t;Kn(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 S=v.pathname||"/",x=S;if(m!=="/"){let _=m.replace(/^\//,"").split("/");x="/"+S.replace(/^\//,"").split("/").slice(_.length).join("/")}let w=YG(e,{pathname:x});Ei(h||w!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Ei(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 E=yhe(w&&w.map(_=>Object.assign({},_,{params:Object.assign({},u,_.params),pathname:Ro([m,i.encodeLocation?i.encodeLocation(_.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathname]),pathnameBase:_.pathnameBase==="/"?m:Ro([m,i.encodeLocation?i.encodeLocation(_.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:_.pathnameBase])})),s,n,a,r);return t&&E?y.createElement(Um.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...v},navigationType:"POP"}},E):E}function hhe(){let e=_he(),t=she(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,a="rgba(200,200,200, 0.5)",r={padding:"0.5rem",backgroundColor:a},i={padding:"2px 4px",backgroundColor:a},s=null;return console.error("Error handled by React Router default ErrorBoundary:",e),s=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:i},"ErrorBoundary")," or"," ",y.createElement("code",{style:i},"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:r},n):null,s)}var ghe=y.createElement(hhe,null),bhe=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(Go.Provider,{value:this.props.routeContext},y.createElement(fC.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function vhe({routeContext:e,match:t,children:n}){let a=y.useContext(Fd);return a&&a.static&&a.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=t.route.id),y.createElement(Go.Provider,{value:e},n)}function yhe(e,t=[],n=null,a=null,r=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 i=e,s=n?.errors;if(s!=null){let m=i.findIndex(h=>h.route.id&&s?.[h.route.id]!==void 0);Kn(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(s).join(",")}`),i=i.slice(0,Math.min(i.length,m+1))}let c=!1,u=-1;if(n)for(let m=0;m<i.length;m++){let h=i[m];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(u=m),h.route.id){let{loaderData:g,errors:v}=n,S=h.route.loader&&!g.hasOwnProperty(h.route.id)&&(!v||v[h.route.id]===void 0);if(h.route.lazy||S){c=!0,u>=0?i=i.slice(0,u+1):i=[i[0]];break}}}let f=n&&a?(m,h)=>{a(m,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:lhe(n.matches),errorInfo:h})}:void 0;return i.reduceRight((m,h,g)=>{let v,S=!1,x=null,w=null;n&&(v=s&&h.route.id?s[h.route.id]:void 0,x=h.route.errorElement||ghe,c&&(u<0&&g===0?(i7("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),S=!0,w=null):u===g&&(S=!0,w=h.route.hydrateFallbackElement||null)));let E=t.concat(i.slice(0,g+1)),_=()=>{let k;return v?k=x:S?k=w:h.route.Component?k=y.createElement(h.route.Component,null):h.route.element?k=h.route.element:k=m,y.createElement(vhe,{match:h,routeContext:{outlet:m,matches:E,isDataRoute:n!=null},children:k})};return n&&(h.route.ErrorBoundary||h.route.errorElement||g===0)?y.createElement(bhe,{location:n.location,revalidation:n.revalidation,component:x,error:v,children:_(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:f}):_()},null)}function pC(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function whe(e){let t=y.useContext(Fd);return Kn(t,pC(e)),t}function xhe(e){let t=y.useContext(Qy);return Kn(t,pC(e)),t}function She(e){let t=y.useContext(Go);return Kn(t,pC(e)),t}function mC(e){let t=She(e),n=t.matches[t.matches.length-1];return Kn(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Ehe(){return mC("useRouteId")}function _he(){let e=y.useContext(fC),t=xhe("useRouteError"),n=mC("useRouteError");return e!==void 0?e:t.errors?.[n]}function khe(){let{router:e}=whe("useNavigate"),t=mC("useNavigate"),n=y.useRef(!1);return r7(()=>{n.current=!0}),y.useCallback(async(r,i={})=>{Ei(n.current,n7),n.current&&(typeof r=="number"?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var yU={};function i7(e,t,n){!t&&!yU[e]&&(yU[e]=!0,Ei(!1,n))}y.memo(The);function The({routes:e,future:t,state:n,unstable_onError:a}){return a7(e,void 0,n,a,t)}function e_(e){Kn(!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 Nhe({basename:e="/",children:t=null,location:n,navigationType:a="POP",navigator:r,static:i=!1,unstable_useTransitions:s}){Kn(!Fm(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),u=y.useMemo(()=>({basename:c,navigator:r,static:i,unstable_useTransitions:s,future:{}}),[c,r,i,s]);typeof n=="string"&&(n=Ud(n));let{pathname:f="/",search:m="",hash:h="",state:g=null,key:v="default"}=n,S=y.useMemo(()=>{let x=Uo(f,c);return x==null?null:{location:{pathname:x,search:m,hash:h,state:g,key:v},navigationType:a}},[c,f,m,h,g,v,a]);return Ei(S!=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.`),S==null?null:y.createElement(Ri.Provider,{value:u},y.createElement(Um.Provider,{children:t,value:S}))}function Che({children:e,location:t}){return mhe(t_(e),t)}function t_(e,t=[]){let n=[];return y.Children.forEach(e,(a,r)=>{if(!y.isValidElement(a))return;let i=[...t,r];if(a.type===y.Fragment){n.push.apply(n,t_(a.props.children,i));return}Kn(a.type===e_,`[${typeof a.type=="string"?a.type:a.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Kn(!a.props.index||!a.props.children,"An index route cannot have child routes.");let s={id:a.props.id||i.join("-"),caseSensitive:a.props.caseSensitive,element:a.props.element,Component:a.props.Component,index:a.props.index,path:a.props.path,middleware:a.props.middleware,loader:a.props.loader,action:a.props.action,hydrateFallbackElement:a.props.hydrateFallbackElement,HydrateFallback:a.props.HydrateFallback,errorElement:a.props.errorElement,ErrorBoundary:a.props.ErrorBoundary,hasErrorBoundary:a.props.hasErrorBoundary===!0||a.props.ErrorBoundary!=null||a.props.errorElement!=null,shouldRevalidate:a.props.shouldRevalidate,handle:a.props.handle,lazy:a.props.lazy};a.props.children&&(s.children=t_(a.props.children,i)),n.push(s)}),n}var Ub="get",Fb="application/x-www-form-urlencoded";function e0(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Rhe(e){return e0(e)&&e.tagName.toLowerCase()==="button"}function Ahe(e){return e0(e)&&e.tagName.toLowerCase()==="form"}function Ihe(e){return e0(e)&&e.tagName.toLowerCase()==="input"}function Ohe(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Dhe(e,t){return e.button===0&&(!t||t==="_self")&&!Ohe(e)}var hb=null;function jhe(){if(hb===null)try{new FormData(document.createElement("form"),0),hb=!1}catch{hb=!0}return hb}var Lhe=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function kS(e){return e!=null&&!Lhe.has(e)?(Ei(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Fb}"`),null):e}function $he(e,t){let n,a,r,i,s;if(Ahe(e)){let c=e.getAttribute("action");a=c?Uo(c,t):null,n=e.getAttribute("method")||Ub,r=kS(e.getAttribute("enctype"))||Fb,i=new FormData(e)}else if(Rhe(e)||Ihe(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 u=e.getAttribute("formaction")||c.getAttribute("action");if(a=u?Uo(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||Ub,r=kS(e.getAttribute("formenctype"))||kS(c.getAttribute("enctype"))||Fb,i=new FormData(c,e),!jhe()){let{name:f,type:m,value:h}=e;if(m==="image"){let g=f?`${f}.`:"";i.append(`${g}x`,"0"),i.append(`${g}y`,"0")}else f&&i.append(f,h)}}else{if(e0(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=Ub,a=null,r=Fb,s=e}return i&&r==="text/plain"&&(s=i,i=void 0),{action:a,method:n.toLowerCase(),encType:r,formData:i,body:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function hC(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Mhe(e,t,n){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return a.pathname==="/"?a.pathname=`_root.${n}`:t&&Uo(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${n}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${n}`,a}async function Phe(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 zhe(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 Uhe(e,t,n){let a=await Promise.all(e.map(async r=>{let i=t.routes[r.route.id];if(i){let s=await Phe(i,n);return s.links?s.links():[]}return[]}));return Vhe(a.flat(1).filter(zhe).filter(r=>r.rel==="stylesheet"||r.rel==="preload").map(r=>r.rel==="stylesheet"?{...r,rel:"prefetch",as:"style"}:{...r,rel:"prefetch"}))}function wU(e,t,n,a,r,i){let s=(u,f)=>n[f]?u.route.id!==n[f].route.id:!0,c=(u,f)=>n[f].pathname!==u.pathname||n[f].route.path?.endsWith("*")&&n[f].params["*"]!==u.params["*"];return i==="assets"?t.filter((u,f)=>s(u,f)||c(u,f)):i==="data"?t.filter((u,f)=>{let m=a.routes[u.route.id];if(!m||!m.hasLoader)return!1;if(s(u,f)||c(u,f))return!0;if(u.route.shouldRevalidate){let h=u.route.shouldRevalidate({currentUrl:new URL(r.pathname+r.search+r.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function Fhe(e,t,{includeHydrateFallback:n}={}){return Bhe(e.map(a=>{let r=t.routes[a.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Bhe(e){return[...new Set(e)]}function Hhe(e){let t={},n=Object.keys(e).sort();for(let a of n)t[a]=e[a];return t}function Vhe(e,t){let n=new Set;return new Set(t),e.reduce((a,r)=>{let i=JSON.stringify(Hhe(r));return n.has(i)||(n.add(i),a.push({key:i,link:r})),a},[])}function o7(){let e=y.useContext(Fd);return hC(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Ghe(){let e=y.useContext(Qy);return hC(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var gC=y.createContext(void 0);gC.displayName="FrameworkContext";function s7(){let e=y.useContext(gC);return hC(e,"You must render this element inside a <HydratedRouter> element"),e}function Whe(e,t){let n=y.useContext(gC),[a,r]=y.useState(!1),[i,s]=y.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:f,onMouseLeave:m,onTouchStart:h}=t,g=y.useRef(null);y.useEffect(()=>{if(e==="render"&&s(!0),e==="viewport"){let x=E=>{E.forEach(_=>{s(_.isIntersecting)})},w=new IntersectionObserver(x,{threshold:.5});return g.current&&w.observe(g.current),()=>{w.disconnect()}}},[e]),y.useEffect(()=>{if(a){let x=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(x)}}},[a]);let v=()=>{r(!0)},S=()=>{r(!1),s(!1)};return n?e!=="intent"?[i,g,{}]:[i,g,{onFocus:qf(c,v),onBlur:qf(u,S),onMouseEnter:qf(f,v),onMouseLeave:qf(m,S),onTouchStart:qf(h,v)}]:[!1,g,{}]}function qf(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Khe({page:e,...t}){let{router:n}=o7(),a=y.useMemo(()=>YG(n.routes,e,n.basename),[n.routes,e,n.basename]);return a?y.createElement(Yhe,{page:e,matches:a,...t}):null}function Zhe(e){let{manifest:t,routeModules:n}=s7(),[a,r]=y.useState([]);return y.useEffect(()=>{let i=!1;return Uhe(e,t,n).then(s=>{i||r(s)}),()=>{i=!0}},[e,t,n]),a}function Yhe({page:e,matches:t,...n}){let a=Wo(),{manifest:r,routeModules:i}=s7(),{basename:s}=o7(),{loaderData:c,matches:u}=Ghe(),f=y.useMemo(()=>wU(e,t,u,r,a,"data"),[e,t,u,r,a]),m=y.useMemo(()=>wU(e,t,u,r,a,"assets"),[e,t,u,r,a]),h=y.useMemo(()=>{if(e===a.pathname+a.search+a.hash)return[];let S=new Set,x=!1;if(t.forEach(E=>{let _=r.routes[E.route.id];!_||!_.hasLoader||(!f.some(k=>k.route.id===E.route.id)&&E.route.id in c&&i[E.route.id]?.shouldRevalidate||_.hasClientLoader?x=!0:S.add(E.route.id))}),S.size===0)return[];let w=Mhe(e,s,"data");return x&&S.size>0&&w.searchParams.set("_routes",t.filter(E=>S.has(E.route.id)).map(E=>E.route.id).join(",")),[w.pathname+w.search]},[s,c,a,r,f,t,e,i]),g=y.useMemo(()=>Fhe(m,r),[m,r]),v=Zhe(m);return y.createElement(y.Fragment,null,h.map(S=>y.createElement("link",{key:S,rel:"prefetch",as:"fetch",href:S,...n})),g.map(S=>y.createElement("link",{key:S,rel:"modulepreload",href:S,...n})),v.map(({key:S,link:x})=>y.createElement("link",{key:S,nonce:n.nonce,...x})))}function qhe(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var l7=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{l7&&(window.__reactRouterVersion="7.10.1")}catch{}function Xhe({basename:e,children:t,unstable_useTransitions:n,window:a}){let r=y.useRef();r.current==null&&(r.current=Mme({window:a,v5Compat:!0}));let i=r.current,[s,c]=y.useState({action:i.action,location:i.location}),u=y.useCallback(f=>{n===!1?c(f):y.startTransition(()=>c(f))},[n]);return y.useLayoutEffect(()=>i.listen(u),[i,u]),y.createElement(Nhe,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:i,unstable_useTransitions:n===!0})}var c7=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,u7=y.forwardRef(function({onClick:t,discover:n="render",prefetch:a="none",relative:r,reloadDocument:i,replace:s,state:c,target:u,to:f,preventScrollReset:m,viewTransition:h,...g},v){let{basename:S,unstable_useTransitions:x}=y.useContext(Ri),w=typeof f=="string"&&c7.test(f),E,_=!1;if(typeof f=="string"&&w&&(E=f,l7))try{let j=new URL(window.location.href),F=f.startsWith("//")?new URL(j.protocol+f):new URL(f),V=Uo(F.pathname,S);F.origin===j.origin&&V!=null?f=V+F.search+F.hash:_=!0}catch{Ei(!1,`<Link to="${f}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let k=fhe(f,{relative:r}),[R,N,I]=Whe(a,g),O=tge(f,{replace:s,state:c,target:u,preventScrollReset:m,relative:r,viewTransition:h,unstable_useTransitions:x});function A(j){t&&t(j),j.defaultPrevented||O(j)}let M=y.createElement("a",{...g,...I,href:E||k,onClick:_||i?t:A,ref:qhe(v,N),target:u,"data-discover":!w&&n==="render"?"true":void 0});return R&&!w?y.createElement(y.Fragment,null,M,y.createElement(Khe,{page:k})):M});u7.displayName="Link";var Jhe=y.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:a="",end:r=!1,style:i,to:s,viewTransition:c,children:u,...f},m){let h=Bm(s,{relative:f.relative}),g=Wo(),v=y.useContext(Qy),{navigator:S,basename:x}=y.useContext(Ri),w=v!=null&&oge(h)&&c===!0,E=S.encodeLocation?S.encodeLocation(h).pathname:h.pathname,_=g.pathname,k=v&&v.navigation&&v.navigation.location?v.navigation.location.pathname:null;n||(_=_.toLowerCase(),k=k?k.toLowerCase():null,E=E.toLowerCase()),k&&x&&(k=Uo(k,x)||k);const R=E!=="/"&&E.endsWith("/")?E.length-1:E.length;let N=_===E||!r&&_.startsWith(E)&&_.charAt(R)==="/",I=k!=null&&(k===E||!r&&k.startsWith(E)&&k.charAt(E.length)==="/"),O={isActive:N,isPending:I,isTransitioning:w},A=N?t:void 0,M;typeof a=="function"?M=a(O):M=[a,N?"active":null,I?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let j=typeof i=="function"?i(O):i;return y.createElement(u7,{...f,"aria-current":A,className:M,ref:m,style:j,to:s,viewTransition:c},typeof u=="function"?u(O):u)});Jhe.displayName="NavLink";var Qhe=y.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:a,replace:r,state:i,method:s=Ub,action:c,onSubmit:u,relative:f,preventScrollReset:m,viewTransition:h,...g},v)=>{let{unstable_useTransitions:S}=y.useContext(Ri),x=age(),w=ige(c,{relative:f}),E=s.toLowerCase()==="get"?"get":"post",_=typeof c=="string"&&c7.test(c),k=R=>{if(u&&u(R),R.defaultPrevented)return;R.preventDefault();let N=R.nativeEvent.submitter,I=N?.getAttribute("formmethod")||s,O=()=>x(N||R.currentTarget,{fetcherKey:t,method:I,navigate:n,replace:r,state:i,relative:f,preventScrollReset:m,viewTransition:h});S&&n!==!1?y.startTransition(()=>O()):O()};return y.createElement("form",{ref:v,method:E,action:w,onSubmit:a?u:k,...g,"data-discover":!_&&e==="render"?"true":void 0})});Qhe.displayName="Form";function ege(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function d7(e){let t=y.useContext(Fd);return Kn(t,ege(e)),t}function tge(e,{target:t,replace:n,state:a,preventScrollReset:r,relative:i,viewTransition:s,unstable_useTransitions:c}={}){let u=Bd(),f=Wo(),m=Bm(e,{relative:i});return y.useCallback(h=>{if(Dhe(h,t)){h.preventDefault();let g=n!==void 0?n:Zp(f)===Zp(m),v=()=>u(e,{replace:g,state:a,preventScrollReset:r,relative:i,viewTransition:s});c?y.startTransition(()=>v()):v()}},[f,u,m,n,a,t,e,r,i,s,c])}var nge=0,rge=()=>`__${String(++nge)}__`;function age(){let{router:e}=d7("useSubmit"),{basename:t}=y.useContext(Ri),n=Ehe(),a=e.fetch,r=e.navigate;return y.useCallback(async(i,s={})=>{let{action:c,method:u,encType:f,formData:m,body:h}=$he(i,t);if(s.navigate===!1){let g=s.fetcherKey||rge();await a(g,n,s.action||c,{preventScrollReset:s.preventScrollReset,formData:m,body:h,formMethod:s.method||u,formEncType:s.encType||f,flushSync:s.flushSync})}else await r(s.action||c,{preventScrollReset:s.preventScrollReset,formData:m,body:h,formMethod:s.method||u,formEncType:s.encType||f,replace:s.replace,state:s.state,fromRouteId:n,flushSync:s.flushSync,viewTransition:s.viewTransition})},[a,r,t,n])}function ige(e,{relative:t}={}){let{basename:n}=y.useContext(Ri),a=y.useContext(Go);Kn(a,"useFormAction must be used inside a RouteContext");let[r]=a.matches.slice(-1),i={...Bm(e||".",{relative:t})},s=Wo();if(e==null){i.search=s.search;let c=new URLSearchParams(i.search),u=c.getAll("index");if(u.some(m=>m==="")){c.delete("index"),u.filter(h=>h).forEach(h=>c.append("index",h));let m=c.toString();i.search=m?`?${m}`:""}}return(!e||e===".")&&r.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(i.pathname=i.pathname==="/"?n:Ro([n,i.pathname])),Zp(i)}function oge(e,{relative:t}={}){let n=y.useContext(t7);Kn(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:a}=d7("useViewTransitionState"),r=Bm(e,{relative:t});if(!n.isTransitioning)return!1;let i=Uo(n.currentLocation.pathname,a)||n.currentLocation.pathname,s=Uo(n.nextLocation.pathname,a)||n.nextLocation.pathname;return Dv(r.pathname,s)!=null||Dv(r.pathname,i)!=null}function sge(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 lge=e=>{switch(e){case"success":return dge;case"info":return pge;case"warning":return fge;case"error":return mge;default:return null}},cge=Array(12).fill(0),uge=({visible:e,className:t})=>X.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},X.createElement("div",{className:"sonner-spinner"},cge.map((n,a)=>X.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),dge=X.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},X.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"})),fge=X.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},X.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"})),pge=X.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},X.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"})),mge=X.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},X.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"})),hge=X.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"},X.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),X.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),gge=()=>{const[e,t]=X.useState(document.hidden);return X.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let n_=1;class bge{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:a,...r}=t,i=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:n_++,s=this.toasts.find(u=>u.id===i),c=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),s?this.toasts=this.toasts.map(u=>u.id===i?(this.publish({...u,...t,id:i,title:a}),{...u,...t,id:i,dismissible:c,title:a}):u):this.addToast({title:a,...r,dismissible:c,id:i}),i},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(a=>a({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 a;n.loading!==void 0&&(a=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const r=Promise.resolve(t instanceof Function?t():t);let i=a!==void 0,s;const c=r.then(async f=>{if(s=["resolve",f],X.isValidElement(f))i=!1,this.create({id:a,type:"default",message:f});else if(yge(f)&&!f.ok){i=!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,S=typeof h=="object"&&!X.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...S})}else if(f instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(f):n.error,g=typeof n.description=="function"?await n.description(f):n.description,S=typeof h=="object"&&!X.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...S})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(f):n.success,g=typeof n.description=="function"?await n.description(f):n.description,S=typeof h=="object"&&!X.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...S})}}).catch(async f=>{if(s=["reject",f],n.error!==void 0){i=!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"&&!X.isValidElement(m)?m:{message:m};this.create({id:a,type:"error",description:h,...v})}}).finally(()=>{i&&(this.dismiss(a),a=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((f,m)=>c.then(()=>s[0]==="reject"?m(s[1]):f(s[1])).catch(m));return typeof a!="string"&&typeof a!="number"?{unwrap:u}:Object.assign(a,{unwrap:u})},this.custom=(t,n)=>{const a=n?.id||n_++;return this.create({jsx:t(a),id:a,...n}),a},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const va=new bge,vge=(e,t)=>{const n=t?.id||n_++;return va.addToast({title:e,...t,id:n}),n},yge=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",wge=vge,xge=()=>va.toasts,Sge=()=>va.getActiveToasts(),st=Object.assign(wge,{success:va.success,info:va.info,warning:va.warning,error:va.error,custom:va.custom,message:va.message,promise:va.promise,dismiss:va.dismiss,loading:va.loading},{getHistory:xge,getToasts:Sge});sge("[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 gb(e){return e.label!==void 0}const Ege=3,_ge="24px",kge="16px",xU=4e3,Tge=356,Nge=14,Cge=45,Rge=200;function Mi(...e){return e.filter(Boolean).join(" ")}function Age(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const Ige=e=>{var t,n,a,r,i,s,c,u,f;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:S,visibleToasts:x,heights:w,index:E,toasts:_,expanded:k,removeToast:R,defaultRichColors:N,closeButton:I,style:O,cancelButtonStyle:A,actionButtonStyle:M,className:j="",descriptionClassName:F="",duration:V,position:J,gap:ee,expandByDefault:ie,classNames:W,icons:Z,closeButtonAriaLabel:H="Close toast"}=e,[ae,ne]=X.useState(null),[L,B]=X.useState(null),[P,$]=X.useState(!1),[z,G]=X.useState(!1),[K,re]=X.useState(!1),[fe,ce]=X.useState(!1),[q,te]=X.useState(!1),[se,de]=X.useState(0),[ye,Te]=X.useState(0),Ge=X.useRef(h.duration||V||xU),Ie=X.useRef(null),Me=X.useRef(null),nt=E===0,Ue=E+1<=x,pe=h.type,oe=h.dismissible!==!1,xe=h.className||"",Ee=h.descriptionClassName||"",je=X.useMemo(()=>w.findIndex(De=>De.toastId===h.id)||0,[w,h.id]),We=X.useMemo(()=>{var De;return(De=h.closeButton)!=null?De:I},[h.closeButton,I]),Ye=X.useMemo(()=>h.duration||V||xU,[h.duration,V]),ot=X.useRef(0),kt=X.useRef(0),Ln=X.useRef(0),pt=X.useRef(null),[Zn,sn]=J.split("-"),He=X.useMemo(()=>w.reduce((De,it,at)=>at>=je?De:De+it.height,0),[w,je]),Fe=gge(),Ze=h.invert||m,wt=pe==="loading";kt.current=X.useMemo(()=>je*ee+He,[je,He]),X.useEffect(()=>{Ge.current=Ye},[Ye]),X.useEffect(()=>{$(!0)},[]),X.useEffect(()=>{const De=Me.current;if(De){const it=De.getBoundingClientRect().height;return Te(it),S(at=>[{toastId:h.id,height:it,position:h.position},...at]),()=>S(at=>at.filter(Xe=>Xe.toastId!==h.id))}},[S,h.id]),X.useLayoutEffect(()=>{if(!P)return;const De=Me.current,it=De.style.height;De.style.height="auto";const at=De.getBoundingClientRect().height;De.style.height=it,Te(at),S(Xe=>Xe.find(Zt=>Zt.toastId===h.id)?Xe.map(Zt=>Zt.toastId===h.id?{...Zt,height:at}:Zt):[{toastId:h.id,height:at,position:h.position},...Xe])},[P,h.title,h.description,S,h.id,h.jsx,h.action,h.cancel]);const xt=X.useCallback(()=>{G(!0),de(kt.current),S(De=>De.filter(it=>it.toastId!==h.id)),setTimeout(()=>{R(h)},Rge)},[h,R,S,kt]);X.useEffect(()=>{if(h.promise&&pe==="loading"||h.duration===1/0||h.type==="loading")return;let De;return k||v||Fe?(()=>{if(Ln.current<ot.current){const Xe=new Date().getTime()-ot.current;Ge.current=Ge.current-Xe}Ln.current=new Date().getTime()})():Ge.current!==1/0&&(ot.current=new Date().getTime(),De=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),xt()},Ge.current)),()=>clearTimeout(De)},[k,v,h,pe,Fe,xt]),X.useEffect(()=>{h.delete&&(xt(),h.onDismiss==null||h.onDismiss.call(h,h))},[xt,h.delete]);function jt(){var De;if(Z?.loading){var it;return X.createElement("div",{className:Mi(W?.loader,h==null||(it=h.classNames)==null?void 0:it.loader,"sonner-loader"),"data-visible":pe==="loading"},Z.loading)}return X.createElement(uge,{className:Mi(W?.loader,h==null||(De=h.classNames)==null?void 0:De.loader),visible:pe==="loading"})}const St=h.icon||Z?.[pe]||lge(pe);var Pe,ze;return X.createElement("li",{tabIndex:0,ref:Me,className:Mi(j,xe,W?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,W?.default,W?.[pe],h==null||(n=h.classNames)==null?void 0:n[pe]),"data-sonner-toast":"","data-rich-colors":(Pe=h.richColors)!=null?Pe:N,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":P,"data-promise":!!h.promise,"data-swiped":q,"data-removed":z,"data-visible":Ue,"data-y-position":Zn,"data-x-position":sn,"data-index":E,"data-front":nt,"data-swiping":K,"data-dismissible":oe,"data-type":pe,"data-invert":Ze,"data-swipe-out":fe,"data-swipe-direction":L,"data-expanded":!!(k||ie&&P),"data-testid":h.testId,style:{"--index":E,"--toasts-before":E,"--z-index":_.length-E,"--offset":`${z?se:kt.current}px`,"--initial-height":ie?"auto":`${ye}px`,...O,...h.style},onDragEnd:()=>{re(!1),ne(null),pt.current=null},onPointerDown:De=>{De.button!==2&&(wt||!oe||(Ie.current=new Date,de(kt.current),De.target.setPointerCapture(De.pointerId),De.target.tagName!=="BUTTON"&&(re(!0),pt.current={x:De.clientX,y:De.clientY})))},onPointerUp:()=>{var De,it,at;if(fe||!oe)return;pt.current=null;const Xe=Number(((De=Me.current)==null?void 0:De.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Mt=Number(((it=Me.current)==null?void 0:it.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Zt=new Date().getTime()-((at=Ie.current)==null?void 0:at.getTime()),$n=ae==="x"?Xe:Mt,vn=Math.abs($n)/Zt;if(Math.abs($n)>=Cge||vn>.11){de(kt.current),h.onDismiss==null||h.onDismiss.call(h,h),B(ae==="x"?Xe>0?"right":"left":Mt>0?"down":"up"),xt(),ce(!0);return}else{var ln,rn;(ln=Me.current)==null||ln.style.setProperty("--swipe-amount-x","0px"),(rn=Me.current)==null||rn.style.setProperty("--swipe-amount-y","0px")}te(!1),re(!1),ne(null)},onPointerMove:De=>{var it,at,Xe;if(!pt.current||!oe||((it=window.getSelection())==null?void 0:it.toString().length)>0)return;const Zt=De.clientY-pt.current.y,$n=De.clientX-pt.current.x;var vn;const ln=(vn=e.swipeDirections)!=null?vn:Age(J);!ae&&(Math.abs($n)>1||Math.abs(Zt)>1)&&ne(Math.abs($n)>Math.abs(Zt)?"x":"y");let rn={x:0,y:0};const vt=ut=>1/(1.5+Math.abs(ut)/20);if(ae==="y"){if(ln.includes("top")||ln.includes("bottom"))if(ln.includes("top")&&Zt<0||ln.includes("bottom")&&Zt>0)rn.y=Zt;else{const ut=Zt*vt(Zt);rn.y=Math.abs(ut)<Math.abs(Zt)?ut:Zt}}else if(ae==="x"&&(ln.includes("left")||ln.includes("right")))if(ln.includes("left")&&$n<0||ln.includes("right")&&$n>0)rn.x=$n;else{const ut=$n*vt($n);rn.x=Math.abs(ut)<Math.abs($n)?ut:$n}(Math.abs(rn.x)>0||Math.abs(rn.y)>0)&&te(!0),(at=Me.current)==null||at.style.setProperty("--swipe-amount-x",`${rn.x}px`),(Xe=Me.current)==null||Xe.style.setProperty("--swipe-amount-y",`${rn.y}px`)}},We&&!h.jsx&&pe!=="loading"?X.createElement("button",{"aria-label":H,"data-disabled":wt,"data-close-button":!0,onClick:wt||!oe?()=>{}:()=>{xt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:Mi(W?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(ze=Z?.close)!=null?ze:hge):null,(pe||h.icon||h.promise)&&h.icon!==null&&(Z?.[pe]!==null||h.icon)?X.createElement("div",{"data-icon":"",className:Mi(W?.icon,h==null||(r=h.classNames)==null?void 0:r.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||jt():null,h.type!=="loading"?St:null):null,X.createElement("div",{"data-content":"",className:Mi(W?.content,h==null||(i=h.classNames)==null?void 0:i.content)},X.createElement("div",{"data-title":"",className:Mi(W?.title,h==null||(s=h.classNames)==null?void 0:s.title)},h.jsx?h.jsx:typeof h.title=="function"?h.title():h.title),h.description?X.createElement("div",{"data-description":"",className:Mi(F,Ee,W?.description,h==null||(c=h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),X.isValidElement(h.cancel)?h.cancel:h.cancel&&gb(h.cancel)?X.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||A,onClick:De=>{gb(h.cancel)&&oe&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,De),xt())},className:Mi(W?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,X.isValidElement(h.action)?h.action:h.action&&gb(h.action)?X.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:De=>{gb(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,De),!De.defaultPrevented&&xt())},className:Mi(W?.actionButton,h==null||(f=h.classNames)==null?void 0:f.actionButton)},h.action.label):null)};function SU(){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 Oge(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?kge:_ge;function u(f){["top","right","bottom","left"].forEach(m=>{n[`${s}-${m}`]=typeof f=="number"?`${f}px`:f})}typeof a=="number"||typeof a=="string"?u(a):typeof a=="object"?["top","right","bottom","left"].forEach(f=>{a[f]===void 0?n[`${s}-${f}`]=c:n[`${s}-${f}`]=typeof a[f]=="number"?`${a[f]}px`:a[f]}):u(c)}),n}const Dge=X.forwardRef(function(t,n){const{id:a,invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:c,closeButton:u,className:f,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:S,style:x,visibleToasts:w=Ege,toastOptions:E,dir:_=SU(),gap:k=Nge,icons:R,containerAriaLabel:N="Notifications"}=t,[I,O]=X.useState([]),A=X.useMemo(()=>a?I.filter(P=>P.toasterId===a):I.filter(P=>!P.toasterId),[I,a]),M=X.useMemo(()=>Array.from(new Set([i].concat(A.filter(P=>P.position).map(P=>P.position)))),[A,i]),[j,F]=X.useState([]),[V,J]=X.useState(!1),[ee,ie]=X.useState(!1),[W,Z]=X.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),H=X.useRef(null),ae=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),ne=X.useRef(null),L=X.useRef(!1),B=X.useCallback(P=>{O($=>{var z;return(z=$.find(G=>G.id===P.id))!=null&&z.delete||va.dismiss(P.id),$.filter(({id:G})=>G!==P.id)})},[]);return X.useEffect(()=>va.subscribe(P=>{if(P.dismiss){requestAnimationFrame(()=>{O($=>$.map(z=>z.id===P.id?{...z,delete:!0}:z))});return}setTimeout(()=>{W9.flushSync(()=>{O($=>{const z=$.findIndex(G=>G.id===P.id);return z!==-1?[...$.slice(0,z),{...$[z],...P},...$.slice(z+1)]:[P,...$]})})})}),[I]),X.useEffect(()=>{if(g!=="system"){Z(g);return}if(g==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?Z("dark"):Z("light")),typeof window>"u")return;const P=window.matchMedia("(prefers-color-scheme: dark)");try{P.addEventListener("change",({matches:$})=>{Z($?"dark":"light")})}catch{P.addListener(({matches:z})=>{try{Z(z?"dark":"light")}catch(G){console.error(G)}})}},[g]),X.useEffect(()=>{I.length<=1&&J(!1)},[I]),X.useEffect(()=>{const P=$=>{var z;if(s.every(re=>$[re]||$.code===re)){var K;J(!0),(K=H.current)==null||K.focus()}$.code==="Escape"&&(document.activeElement===H.current||(z=H.current)!=null&&z.contains(document.activeElement))&&J(!1)};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[s]),X.useEffect(()=>{if(H.current)return()=>{ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null,L.current=!1)}},[H.current]),X.createElement("section",{ref:n,"aria-label":`${N} ${ae}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((P,$)=>{var z;const[G,K]=P.split("-");return A.length?X.createElement("ol",{key:P,dir:_==="auto"?SU():_,tabIndex:-1,ref:H,className:f,"data-sonner-toaster":!0,"data-sonner-theme":W,"data-y-position":G,"data-x-position":K,style:{"--front-toast-height":`${((z=j[0])==null?void 0:z.height)||0}px`,"--width":`${Tge}px`,"--gap":`${k}px`,...x,...Oge(m,h)},onBlur:re=>{L.current&&!re.currentTarget.contains(re.relatedTarget)&&(L.current=!1,ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null))},onFocus:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||L.current||(L.current=!0,ne.current=re.relatedTarget)},onMouseEnter:()=>J(!0),onMouseMove:()=>J(!0),onMouseLeave:()=>{ee||J(!1)},onDragEnd:()=>J(!1),onPointerDown:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||ie(!0)},onPointerUp:()=>ie(!1)},A.filter(re=>!re.position&&$===0||re.position===P).map((re,fe)=>{var ce,q;return X.createElement(Ige,{key:re.id,icons:R,index:fe,toast:re,defaultRichColors:v,duration:(ce=E?.duration)!=null?ce:S,className:E?.className,descriptionClassName:E?.descriptionClassName,invert:r,visibleToasts:w,closeButton:(q=E?.closeButton)!=null?q:u,interacting:ee,position:P,style:E?.style,unstyled:E?.unstyled,classNames:E?.classNames,cancelButtonStyle:E?.cancelButtonStyle,actionButtonStyle:E?.actionButtonStyle,closeButtonAriaLabel:E?.closeButtonAriaLabel,removeToast:B,toasts:A.filter(te=>te.position==re.position),heights:j.filter(te=>te.position==re.position),setHeights:F,expandByDefault:c,gap:k,expanded:V,swipeDirections:t.swipeDirections})})):null}))});var t0="Dialog",[f7]=Ci(t0),[jge,Ai]=f7(t0),p7=e=>{const{__scopeDialog:t,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:s=!0}=e,c=y.useRef(null),u=y.useRef(null),[f,m]=Lo({prop:a,defaultProp:r??!1,onChange:i,caller:t0});return d.jsx(jge,{scope:t,triggerRef:c,contentRef:u,contentId:Pr(),titleId:Pr(),descriptionId:Pr(),open:f,onOpenChange:m,onOpenToggle:y.useCallback(()=>m(h=>!h),[m]),modal:s,children:n})};p7.displayName=t0;var m7="DialogTrigger",h7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ai(m7,n),i=nn(t,r.triggerRef);return d.jsx(It.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":yC(r.open),...a,ref:i,onClick:Ke(e.onClick,r.onOpenToggle)})});h7.displayName=m7;var bC="DialogPortal",[Lge,g7]=f7(bC,{forceMount:void 0}),b7=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Ai(bC,t);return d.jsx(Lge,{scope:t,forceMount:n,children:y.Children.map(a,s=>d.jsx(za,{present:n||i.open,children:d.jsx(Md,{asChild:!0,container:r,children:s})}))})};b7.displayName=bC;var jv="DialogOverlay",v7=y.forwardRef((e,t)=>{const n=g7(jv,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ai(jv,e.__scopeDialog);return i.modal?d.jsx(za,{present:a||i.open,children:d.jsx(Mge,{...r,ref:t})}):null});v7.displayName=jv;var $ge=Wl("DialogOverlay.RemoveScroll"),Mge=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ai(jv,n);return d.jsx(Lm,{as:$ge,allowPinchZoom:!0,shards:[r.contentRef],children:d.jsx(It.div,{"data-state":yC(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),Yl="DialogContent",y7=y.forwardRef((e,t)=>{const n=g7(Yl,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ai(Yl,e.__scopeDialog);return d.jsx(za,{present:a||i.open,children:i.modal?d.jsx(Pge,{...r,ref:t}):d.jsx(zge,{...r,ref:t})})});y7.displayName=Yl;var Pge=y.forwardRef((e,t)=>{const n=Ai(Yl,e.__scopeDialog),a=y.useRef(null),r=nn(t,n.contentRef,a);return y.useEffect(()=>{const i=a.current;if(i)return By(i)},[]),d.jsx(w7,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ke(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ke(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:Ke(e.onFocusOutside,i=>i.preventDefault())})}),zge=y.forwardRef((e,t)=>{const n=Ai(Yl,e.__scopeDialog),a=y.useRef(!1),r=y.useRef(!1);return d.jsx(w7,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(a.current||n.triggerRef.current?.focus(),i.preventDefault()),a.current=!1,r.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(a.current=!0,i.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const s=i.target;n.triggerRef.current?.contains(s)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&r.current&&i.preventDefault()}})}),w7=y.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=e,c=Ai(Yl,n),u=y.useRef(null),f=nn(t,u);return jy(),d.jsxs(d.Fragment,{children:[d.jsx(Im,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:d.jsx(jd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":yC(c.open),...s,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),d.jsxs(d.Fragment,{children:[d.jsx(Uge,{titleId:c.titleId}),d.jsx(Bge,{contentRef:u,descriptionId:c.descriptionId})]})]})}),vC="DialogTitle",x7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ai(vC,n);return d.jsx(It.h2,{id:r.titleId,...a,ref:t})});x7.displayName=vC;var S7="DialogDescription",E7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ai(S7,n);return d.jsx(It.p,{id:r.descriptionId,...a,ref:t})});E7.displayName=S7;var _7="DialogClose",k7=y.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ai(_7,n);return d.jsx(It.button,{type:"button",...a,ref:t,onClick:Ke(e.onClick,()=>r.onOpenChange(!1))})});k7.displayName=_7;function yC(e){return e?"open":"closed"}var T7="DialogTitleWarning",[wNe,N7]=cle(T7,{contentName:Yl,titleName:vC,docsSlug:"dialog"}),Uge=({titleId:e})=>{const t=N7(T7),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
157
157
 
@@ -1720,7 +1720,7 @@ Example: https://${e.url}`}y.useEffect(()=>{s&&n(s)},[s,n]);const c=LN({url:s?vo
1720
1720
  <\/script>
1721
1721
  </body>
1722
1722
  </html>`,IY=1,A2=2,OY=3,I2=4,DY=5,O2=Symbol.for("quilt.threads.serialize"),kke=Symbol.for("quilt.threads.transferable");class Tke extends AbortController{constructor(...t){super();const n=t.find(a=>a.aborted);if(n)this.abort(n.reason);else{const a=i=>this.abort(i.target.reason),r={signal:this.signal};for(const i of t)i.addEventListener("abort",a,r)}}}class D2 extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let Nke="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function jY(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let a=0;a<e;a++)t+=Nke[63&n[a]];return t}var dp,ou,fp,Qb,ok,LY;class Cke{constructor(){mi(this,ok),mi(this,dp,new Map),mi(this,ou,new Map),mi(this,fp,new Map),mi(this,Qb,new WeakMap)}get(t){return Bn(this,ou).get(t)}release(t){const n=Bn(this,ou).get(t);return n&&(Bn(this,ou).delete(t),Bn(this,dp).delete(n)),!!n}serialize(t){let n=Bn(this,dp).get(t);return n==null&&(n=jY(),Bn(this,dp).set(t,n),Bn(this,ou).set(n,t)),n}deserialize(t,n){var a,r;let i=(a=Bn(this,fp).get(t))==null?void 0:a.deref();return i||(i=(...s)=>{if(!Bn(this,fp).has(t))throw new Error("You attempted to call a function that was already revoked.");return n.call((c,u,f)=>{n.messages.send([OY,c,t,u],f)},s)},(r=Or(this,ok,LY).call(this,n))==null||r.register(i,t),Bn(this,fp).set(t,new WeakRef(i)),i)}}dp=new WeakMap,ou=new WeakMap,fp=new WeakMap,Qb=new WeakMap,ok=new WeakSet,LY=function(e){let t=Bn(this,Qb).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([DY,n])}),Bn(this,Qb).set(e,t)),t};function Rke(e){return e!=null&&(Symbol.asyncIterator in e||Symbol.iterator in e)&&typeof e.next=="function"}function j2(e){if(e==null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t==null||t===Object.prototype}const QS="_@f",L2="_@i";var Cp,Rp,Ya,ev,_s;class Ake{constructor(t){mi(this,Ya),mi(this,Cp),mi(this,Rp),ak(this,Cp,t?.serialize),ak(this,Rp,t?.deserialize)}serialize(t,n,a){return Or(this,Ya,ev).call(this,t,n,a)}deserialize(t,n){return Or(this,Ya,_s).call(this,t,n)}}Cp=new WeakMap,Rp=new WeakMap,Ya=new WeakSet,ev=function(e,t,n,a=new Map,r=!1){if(e==null)return e;if(a.has(e))return a.get(e);if(a.set(e,void 0),typeof e=="object"){if(Bn(this,Cp)&&!r){const c=Bn(this,Cp).call(this,e,u=>Or(this,Ya,ev).call(this,u,t,n,a,!0),t,n);if(c!==void 0)return a.set(e,c),c}if(e[kke])return n?.push(e),a.set(e,e),e;const i=c=>Or(this,Ya,ev).call(this,c,t,n,a);if(typeof e[O2]=="function"){const c=e[O2]({serialize:i});return a.set(e,c),c}if(Array.isArray(e)){const c=e.map(u=>i(u));return a.set(e,c),c}if(e instanceof Map){const c=[...e.entries()].map(([f,m])=>[i(f),i(m)]),u=new Map(c);return a.set(e,u),u}if(e instanceof Set){const c=[...e].map(f=>i(f)),u=new Set(c);return a.set(e,u),u}const s=Rke(e);if(j2(e)||s){const c={};for(const u of Object.keys(e))c[u]=i(e[u]);return s&&(c.next??(c.next=i(e.next.bind(e))),c.return??(c.return=i(e.return.bind(e))),c.throw??(c.throw=i(e.throw.bind(e))),c[L2]=!0),a.set(e,c),c}}if(typeof e=="function"){const i=t.functions.serialize(e,t,n),s={[QS]:i};return a.set(e,s),s}return a.set(e,e),e},_s=function(e,t,n=!1){if(e==null)return e;if(typeof e=="object"){if(Bn(this,Rp)&&!n){const r=Bn(this,Rp).call(this,e,i=>Or(this,Ya,_s).call(this,i,t,!0),t);if(r!==void 0)return r}if(e==null)return e;if(Array.isArray(e))return e.map(r=>Or(this,Ya,_s).call(this,r,t));if(e instanceof Map)return new Map([...e].map(([r,i])=>[Or(this,Ya,_s).call(this,r,t),Or(this,Ya,_s).call(this,i,t)]));if(e instanceof Set)return new Set([...e].map(r=>Or(this,Ya,_s).call(this,r,t)));if(QS in e)return t.functions.deserialize(e[QS],t);if(!j2(e))return e;const a={};for(const r of Object.keys(e))r===L2?a[Symbol.asyncIterator]=()=>a:a[r]=Or(this,Ya,_s).call(this,e[r],t);return a}return e};var su,Ol,ks,sk,$Y,lk,MY;class Ike{constructor(t,{imports:n,exports:a,functions:r=new Cke,serialization:i=new Ake,signal:s}={}){mi(this,ks),mi(this,su),mi(this,Ol,new Map);var c,u,f,m;this.messages=t,ak(this,su,s?new Tke(s):new AbortController),this.exports=a??{},this.imports=Oke(Or(this,ks,$Y).bind(this),n),this.functions=r,this.serialization=i,(u=(c=this.functions).start)==null||u.call(c,this),(m=(f=this.serialization).start)==null||m.call(f,this),this.signal.addEventListener("abort",()=>{for(const h of Bn(this,Ol).keys())Or(this,ks,lk).call(this,h,void 0,new D2);Bn(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 IY:{const[,v,S,x]=g,w=this.exports[S]??(()=>{throw new Error(`No '${S}' method is exported from this thread`)});await Or(this,ks,sk).call(this,w,x,(E,_,k)=>{this.messages.send([A2,v,E,_],k)});break}case OY:{const[,v,S,x]=g,w=this.functions.get(S,this)??Dke;await Or(this,ks,sk).call(this,w,x,(E,_,k)=>{this.messages.send([I2,v,E,_],k)});break}case A2:case I2:{Or(this,ks,lk).call(this,...g.slice(1));break}case DY:{const v=g[1];this.functions.release(v,this);break}}},{signal:this.signal})}get signal(){return Bn(this,su).signal}get closed(){return Bn(this,su).signal.aborted}close(){Bn(this,su).abort()}call(t,n){if(this.closed)return Promise.reject(new D2);const a=[],r=this.serialization.serialize(n,this,a),i=jY(),s=Or(this,ks,MY).call(this,i);return t(i,r,a),s}}su=new WeakMap,Ol=new WeakMap,ks=new WeakSet,sk=async function(e,t,n){try{const a=this.functions.call?await this.functions.call(e,t,this):await e(...this.serialization.deserialize(t,this)),r=[],i=this.serialization.serialize(a,this,r);n(i,void 0,r)}catch(a){n(void 0,this.serialization.serialize(a,this))}},$Y=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,a,r)=>{this.messages.send([IY,n,e,a],r)},t)}catch(n){return Promise.reject(n)}}},lk=function(...e){const t=e[0],n=Bn(this,Ol).get(t);n&&(n(...e),Bn(this,Ol).delete(t))},MY=function(e){const t=new Promise((n,a)=>{Bn(this,Ol).set(e,(r,i,s)=>{s==null?n(this.serialization.deserialize(i,this)):a(this.serialization.deserialize(s,this))})});return Object.defineProperty(t,Symbol.asyncIterator,{async*value(){const n=await t;Object.defineProperty(n,Symbol.asyncIterator,{value:()=>n}),yield*n}}),t};function Oke(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 a=new Map;n=new Proxy({},{get(r,i){if(a.has(i))return a.get(i);const s=e(i);return a.set(i,s),s}})}else{n={};for(const a of t)Object.defineProperty(n,a,{value:e(a),writable:!1,configurable:!0,enumerable:!0})}return n}function Dke(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const jke="quilt.threads.ping",$2="quilt.threads.pong";function Lke(e,{targetOrigin:t="*"}={}){let n=!1;const a=function(i,s){e.postMessage(i,t,s)},r=new Promise(i=>{const s=new AbortController;globalThis.window.addEventListener("message",c=>{c.source===e&&c.data===$2&&(n=!0,s.abort(),i())},{signal:s.signal}),s.signal.addEventListener("abort",()=>i(),{once:!0}),a(jke)});return{send(i,s){return n?a(i,s):r.then(()=>{if(n)return a(i,s)})},listen(i,{signal:s}){self.addEventListener("message",c=>{c.source===e&&c.data!==$2&&i(c.data)},{signal:s})}}}class $ke extends Ike{constructor(t,{targetOrigin:n="*",...a}={}){super(Lke(t.contentWindow,{targetOrigin:n}),a),this.iframe=t}}const PY=X.forwardRef(({content:e,children:t,...n},a)=>d.jsx("span",{ref:a,...n,children:e||t}));PY.displayName="UIText";const zY=X.forwardRef(({label:e,onPress:t,onClick:n,children:a,...r},i)=>d.jsx("button",{ref:i,onClick:s=>{t&&t(),n&&n(s)},style:{padding:"8px 16px",backgroundColor:"#007bff",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},...r,children:e||a}));zY.displayName="UIButton";const UY=X.forwardRef(({direction:e="vertical",spacing:t="8",align:n="stretch",justify:a="flex-start",children:r,...i},s)=>d.jsx("div",{ref:s,style:{display:"flex",flexDirection:e==="horizontal"?"row":"column",gap:`${t}px`,alignItems:n,justifyContent:a},...i,children:r}));UY.displayName="UIStack";const FY=X.forwardRef(({src:e,alt:t,width:n,height:a,children:r,...i},s)=>d.jsx("img",{ref:s,src:e,alt:t,width:n,height:a,style:{maxWidth:"100%",height:"auto",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)"},...i}));FY.displayName="UIImage";const jD={name:"basic",elements:[{tagName:"ui-text",component:PY,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:zY,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:UY,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:FY,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},Mke=({receiver:e})=>{const t=y.useRef(null);return y.useEffect(()=>{if(t.current)return e.connect(t.current),()=>{e.disconnect()}},[e]),d.jsx("div",{ref:t,"data-testid":"standard-dom-renderer-container"})},Pke=({resource:e,library:t,remoteElements:n=[],onUIAction:a})=>{const r=y.useRef(null),i=y.useRef(null),[s,c]=y.useState(null),u=y.useMemo(()=>(e.mimeType||"").includes("framework=react")?"react":"webcomponents",[e.mimeType]),f=`${t?.name}-${u}`,{receiver:m,components:h}=y.useMemo(()=>{switch(u){case"react":{const v=new hke,S=t||jD,x=new Map;return S&&S.elements.forEach(w=>{const E=xke(w.component);x.set(w.tagName,E)}),{receiver:v,components:x}}case"webcomponents":default:return{receiver:new gke,components:null}}},[e,t,n]);y.useEffect(()=>{function v(S){var x;if(r.current&&S.source===r.current.contentWindow){const w=S.data;if(!w)return;(x=a?.(w))==null||x.catch(E=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",E)})}}return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[a]),y.useEffect(()=>{const v=i.current;return i.current=null,()=>{v?.close()}},[f]);const g=()=>{const v=r.current;if(!v||i.current)return;const S=new $ke(v);i.current=S;const{code:x,error:w}=oke(e);if(w){c(w);return}if(x&&m!=null&&m.connection){const E={code:x,remoteElements:n,useReactRenderer:u==="react",componentLibrary:t?.name};S.imports.render(E,m.connection).catch(_=>console.error("Error calling remote render:",_))}};return s?d.jsx("p",{className:"text-red-500",children:s}):d.jsxs(d.Fragment,{children:[d.jsx("iframe",{ref:r,srcDoc:_ke,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},f),u==="react"&&h?d.jsx(Eke,{receiver:m,components:h}):d.jsx(Mke,{receiver:m})]})};function zke(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 LD=e=>{const{resource:t,onUIAction:n,supportedContentTypes:a,htmlProps:r,remoteDomProps:i}=e,s=zke(t);if(a&&s&&!a.includes(s))return d.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",s,"."]});switch(s){case"rawHtml":case"externalUrl":return d.jsx(kY,{resource:t,onUIAction:n,...r});case"remoteDom":return d.jsx(Pke,{resource:t,onUIAction:n,library:i?.library||jD,...i});default:return d.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};LD.displayName="UIResourceRenderer";const Uke={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},Fke={tagName:"ui-text",remoteAttributes:["content"]},Bke={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},Hke={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},Vke=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://")?d.jsx("div",{className:"my-4 p-0 border h-[350px] rounded-2xl border-zinc-200 overflow-hidden bg-card",children:d.jsx(LD,{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 M2({toolName:e,toolArgs:t,result:n,serverId:a,readResource:r,toolMeta:i}){const[s,c]=y.useState(null);y.useEffect(()=>{console.log("[ToolResultRenderer] Rendering:",{toolName:e,hasToolMeta:!!i,outputTemplate:i?.["openai/outputTemplate"],hasResult:!!n,hasServerId:!!a,hasReadResource:!!r})},[e,i,n,a,r]);const u=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(()=>!!i?.["openai/outputTemplate"],[i]),m=y.useMemo(()=>!!(u?.content&&Array.isArray(u.content)&&u.content.some(v=>v.type==="resource"&&v.resource?.uri?.startsWith("ui://")&&v.resource?.mimeType==="text/html+skybridge")),[u]),h=y.useMemo(()=>m&&u.content.find(S=>S.type==="resource"&&S.resource?.uri?.startsWith("ui://")&&S.resource?.mimeType==="text/html+skybridge")?.resource||null,[m,u]);if(y.useEffect(()=>{if(h){c(h);return}if(f&&i&&r){const v=i["openai/outputTemplate"];console.log("[ToolResultRenderer] Fetching resource for Apps SDK tool:",v),r(v).then(S=>{console.log("[ToolResultRenderer] Resource fetched:",S),S?.contents&&Array.isArray(S.contents)&&S.contents.length>0?c(S.contents[0]):console.warn("[ToolResultRenderer] No contents in fetched resource:",S)}).catch(S=>{console.error("[ToolResultRenderer] Failed to fetch resource:",S)})}},[h,f,i,r]),(f||m)&&s&&a&&r)return d.jsx(RD,{componentUrl:s.uri,toolName:e,toolArgs:t,toolResult:u,serverId:a,readResource:r,noWrapper:!0,className:"my-4",showConsole:!1});if((f||m)&&!s)return d.jsx("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:d.jsx(Yi,{className:"size-5"})});if(f&&(!a||!r))return console.error("[ToolResultRenderer] Apps SDK tool but missing serverId or readResource:",{toolName:e,hasServerId:!!a,hasReadResource:!!r}),d.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:d.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(u?.content&&Array.isArray(u.content))for(const v of u.content)v.type==="resource"&&v.resource?.uri?.startsWith("ui://")&&v.resource?.mimeType!=="text/html+skybridge"&&g.push(v.resource);return g.length>0?d.jsx(d.Fragment,{children:g.map(v=>d.jsx(Vke,{resource:v},`${e}-mcp-ui-${v.uri}`))}):(console.log("[ToolResultRenderer] Not rendering (no UI resources found):",{toolName:e,isAppsSdkTool:f,hasAppsSdkComponent:m,hasResourceData:!!s,contentLength:u?.content?.length}),null)}function Gke({content:e,timestamp:t}){return!e||e.length===0?null:d.jsx("div",{className:"flex items-start gap-3 justify-end group/user-message",children:d.jsxs("div",{className:"flex-1 min-w-0 flex flex-col items-end",children:[d.jsx("div",{className:"bg-zinc-200 dark:bg-zinc-800 text-primary rounded-3xl px-4 py-2 max-w-[80%] break-words",children:d.jsx("p",{className:"text-base leading-7 font-sans text-start break-words",children:e})}),t&&d.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:new Date(t).toLocaleTimeString()})]})})}const Wke=y.memo(({messages:e,isLoading:t,serverId:n,readResource:a,tools:r})=>{const i=y.useRef(null),s=f=>r?.find(h=>h.name===f)?._meta;y.useEffect(()=>{e.length>0&&i.current&&i.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})(),u=f=>{if(!t)return!1;const m=e[e.length-1];return f.id===m.id&&m.role==="assistant"};return d.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"?d.jsx(Gke,{content:m,timestamp:f.timestamp},f.id):f.role==="assistant"?d.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"?d.jsx(w2,{content:h.text||"",timestamp:g===f.parts.length-1?f.timestamp:void 0,_isStreaming:u(f)},v):h.type==="tool-invocation"&&h.toolInvocation?d.jsxs("div",{children:[d.jsx(x2,{toolName:h.toolInvocation.toolName,args:h.toolInvocation.args,result:h.toolInvocation.result,state:h.toolInvocation.result?"result":"call"}),h.toolInvocation.result&&d.jsx(M2,{toolName:h.toolInvocation.toolName,toolArgs:h.toolInvocation.args,result:h.toolInvocation.result,serverId:n,readResource:a,toolMeta:s(h.toolInvocation.toolName)})]},v):null}):d.jsxs(d.Fragment,{children:[d.jsx(w2,{content:m,timestamp:f.timestamp,_isStreaming:u(f)}),f.toolCalls&&f.toolCalls.length>0&&d.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 d.jsxs("div",{children:[d.jsx(x2,{toolName:h.toolName,args:h.args,result:h.result,state:h.result?"result":"call"}),h.result&&d.jsx(M2,{toolName:h.toolName,toolArgs:h.args,result:h.result,serverId:n,readResource:a,toolMeta:s(h.toolName)})]},g)})})]})},f.id):null}),c&&d.jsx("div",{className:"flex items-start gap-3",children:d.jsx("div",{className:"flex-1",children:d.jsx("div",{className:"rounded-lg p-4 max-w-fit",children:d.jsx("div",{className:"flex items-center gap-2",children:d.jsx("span",{className:"text-sm",children:d.jsx(kEe,{duration:2,spread:1,children:"Thinking..."})})})})})}),d.jsx("div",{ref:i})]})});function BY(e){let t=0;for(let n=0;n<e.length;n++){const a=e.charCodeAt(n);t=(t<<5)-t+a,t=t&t}return Math.abs(t).toString(16)}function Kke({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:a}){const[r,i]=y.useState([]),[s,c]=y.useState(!1),u=y.useCallback(async m=>{if(!m.trim()||!t||!a)return;const h={id:`user-${Date.now()}`,role:"user",content:m.trim(),timestamp:Date.now()};i(g=>[...g,h]),c(!0);try{let g=n;if(n?.type==="oauth")try{const R="mcp:auth",N=BY(e),I=`${R}_${N}_tokens`,O=localStorage.getItem(I);if(O){const A=JSON.parse(O);g={...n,oauthTokens:A}}else console.warn("No OAuth tokens found in localStorage for key:",I)}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:[...r,h].map(R=>({role:R.role,content:R.content}))})});if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);const S=`assistant-${Date.now()}`;let x="";const w=[];i(R=>[...R,{id:S,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);const E=v.body?.getReader(),_=new TextDecoder;if(!E)throw new Error("No response body");let k="";for(;;){const{done:R,value:N}=await E.read();if(R)break;k+=_.decode(N,{stream:!0});const I=k.split(`
1723
- `);k=I.pop()||"";for(const O of I)if(O.trim()&&O.startsWith("data: "))try{const A=JSON.parse(O.slice(6));if(console.log("[Client received event]",A.type,A.toolName||A.content?.slice?.(0,30)),A.type==="message")console.log("[Message started]",A.id);else if(A.type==="text"){x+=A.content;const M=w[w.length-1];M&&M.type==="text"?M.text=x:w.push({type:"text",text:x}),console.log("[Parts after text]",w.length,"parts, text length:",x.length),i(j=>j.map(F=>F.id===S?{...F,parts:[...w]}:F))}else if(A.type==="tool-call")x&&(x=""),w.push({type:"tool-invocation",toolInvocation:{toolName:A.toolName,args:A.args,state:"pending"}}),console.log("[Parts after tool-call]",w.length,"parts, tool:",A.toolName),i(M=>M.map(j=>j.id===S?{...j,parts:[...w]}:j));else if(A.type==="tool-result"){const M=w.find(j=>j.type==="tool-invocation"&&j.toolInvocation?.toolName===A.toolName&&!j.toolInvocation?.result);M&&M.toolInvocation?(M.toolInvocation.result=A.result,M.toolInvocation.state="result",console.log("[Parts after tool-result]",w.length,"parts, updated:",A.toolName),i(j=>j.map(F=>F.id===S?{...F,parts:[...w]}:F))):console.warn("[tool-result] Could not find matching tool part for",A.toolName)}else if(A.type==="done")console.log("[Done] Final parts:",w.length),i(M=>M.map(j=>j.id===S?{...j,parts:[...w],content:""}:j));else if(A.type==="error")throw new Error(A.message||"Streaming error")}catch(A){console.error("Failed to parse streaming event:",A,O)}}}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 S={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(x=>[...x,S])}finally{c(!1)}},[t,a,e,r,n]),f=y.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:f}}function Zke({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=y.useState([]),[s,c]=y.useState(!1),u=y.useRef(null),f=y.useRef(null),m=y.useRef(null),h=y.useCallback(async v=>{if(!v.trim()||!t||!n)return;const S={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(E=>[...E,S]),c(!0),u.current=new AbortController;const x=Date.now();let w=0;try{const E=`assistant-${Date.now()}`;let _="";const k=[];if(i(R=>[...R,{id:E,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:N}=await ia(async()=>{const{ChatOpenAI:I}=await import("./index-BHWuEnDp.js");return{ChatOpenAI:I}},__vite__mapDeps([0,1,2,3,4,5]));R=new N({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:N}=await ia(async()=>{const{ChatAnthropic:I}=await import("./index-CZ1ZJ4DA.js");return{ChatAnthropic:I}},__vite__mapDeps([6,2,1,5]));R=new N({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:N}=await ia(async()=>{const{ChatGoogleGenerativeAI:I}=await import("./index-CEc6a116.js");return{ChatGoogleGenerativeAI:I}},__vite__mapDeps([7,2,1,4]));R=new N({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 ia(async()=>{const{MCPAgent:N}=await import("./browser-C2Fn0YFm.js");return{MCPAgent:N}},__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(u.current?.signal.aborted)break;if(R.event==="on_chat_model_stream"&&R.data?.chunk?.text){const N=R.data.chunk.text;if(typeof N=="string"&&N.length>0){_+=N;const I=k[k.length-1];I&&I.type==="text"?I.text=_:k.push({type:"text",text:_}),i(O=>O.map(A=>A.id===E?{...A,parts:[...k]}:A))}}else if(R.event==="on_tool_start"){_&&(_="");let N={};R.data?.input?N=R.data.input:R.data?.tool_input?N=R.data.tool_input:R.data&&(N=R.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:R.name,eventData:R.data,extractedArgs:N}),w++,k.push({type:"tool-invocation",toolInvocation:{toolName:R.name||"unknown",args:N,state:"pending"}}),i(I=>I.map(O=>O.id===E?{...O,parts:[...k]}:O))}else if(R.event==="on_tool_end"){const N=k.find(I=>I.type==="tool-invocation"&&I.toolInvocation?.toolName===R.name&&!I.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:R.name,hasToolPart:!!N,output:R.data?.output}),N&&N.toolInvocation){let I=R.data?.output;if(I?.kwargs?.content&&typeof I.kwargs.content=="string")try{I=JSON.parse(I.kwargs.content)}catch(A){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",A),I=I.kwargs.content}else if(I?.content&&typeof I.content=="string")try{I=JSON.parse(I.content)}catch{I=I.content}N.toolInvocation.result=I,N.toolInvocation.state="result";const O=I?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:R.name,hasMeta:!!I?._meta,hasStructuredContent:!!I?.structuredContent,appsSdkUri:O}),O&&typeof O=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",O);try{const A=await a(O);console.log("[useChatMessagesClientSide] Resource fetched:",A);const M=I?.structuredContent||null;if(A?.contents&&Array.isArray(A.contents)){const j=A.contents.map(V=>({type:"resource",resource:V}));console.log("[useChatMessagesClientSide] Created MCP resources:",j);const F={...I,content:[...I.content||[],...j],structuredContent:M};N.toolInvocation.result=F,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",A)}catch(A){console.error("Failed to fetch Apps SDK resource:",A)}}i(A=>A.map(M=>M.id===E?{...M,parts:[...k]}:M))}}}i(R=>R.map(N=>N.id===E?{...N,parts:[...k],content:""}:N)),t&&$r.getInstance().capture(new cU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:w,success:!0,executionMode:"client-side",duration:Date.now()-x})).catch(()=>{})}catch(E){console.error("Client-side agent error:",E);let _="Unknown error occurred";if(E instanceof Error){_=E.message;const R=E;R.status&&(_=`HTTP ${R.status}: ${_}`),(R.code===401||_.includes("401")||_.includes("Unauthorized"))&&(_="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&$r.getInstance().capture(new cU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:w,success:!1,executionMode:"client-side",duration:Date.now()-x,error:_})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${_}`,timestamp:Date.now()};i(R=>[...R,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=y.useCallback(()=>{i([]),f.current&&f.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const P2={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function HY({mcpServerUrl:e}){const[t,n]=y.useState(null),[a,r]=y.useState(null),[i,s]=y.useState(!1),[c,u]=y.useState("openai"),[f,m]=y.useState(""),[h,g]=y.useState(P2.openai),v=y.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(j){return console.error("Failed to load API keys:",j),{}}return{}},[]),S=y.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[x,w]=y.useState("none"),[E,_]=y.useState(""),[k,R]=y.useState(""),[N,I]=y.useState("");y.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),j=v();if(M)try{const F=JSON.parse(M);n(F),u(F.provider),m(j[F.provider]||F.apiKey||""),g(F.model)}catch(F){console.error("Failed to load LLM config:",F)}},[v]),y.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const j=JSON.parse(M);r(j),w(j.type),j.username&&_(j.username),j.password&&R(j.password),j.token&&I(j.token)}catch(j){console.error("Failed to load auth config:",j)}else try{const j="mcp:auth",F=BY(e),V=`${j}_${F}_tokens`;localStorage.getItem(V)&&(r({type:"oauth"}),w("oauth"))}catch(j){console.error("Failed to check for OAuth tokens:",j)}},[e]),y.useEffect(()=>{g(P2[c]);const M=v();m(M[c]||"")},[c,v]);const O=y.useCallback(()=>{if(!f.trim())return;const M=v();M[c]=f,S(M);const j={provider:c,apiKey:f,model:h},F={type:x,...x==="basic"&&{username:E.trim(),password:k.trim()},...x==="bearer"&&{token:N.trim()}};n(j),r(F),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(j)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(F)),s(!1)},[c,f,h,x,E,k,N,v,S]),A=y.useCallback(()=>{n(null),r(null);const M=v();delete M[c],S(M),m(""),_(""),R(""),I(""),w("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,S]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:f,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:O,clearConfig:A}}function Yke({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=y.useState(""),s=y.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:f,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:S,tempModel:x,setTempModel:w,saveLLMConfig:E,clearConfig:_}=HY({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},R=Kke({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),N=Zke(k),{messages:I,isLoading:O,sendMessage:A,clearMessages:M}=n?N:R;lZ({onNewChat:M}),y.useEffect(()=>{c&&I.length===0&&s.current&&s.current.focus()},[c,I.length]),y.useEffect(()=>{!O&&I.length>0&&s.current&&s.current.focus()},[O,I.length]);const j=y.useCallback(()=>{r.trim()&&(A(r),i(""))},[r,A]),F=y.useCallback(J=>{J.key==="Enter"&&!J.shiftKey&&(J.preventDefault(),j())},[j]),V=y.useCallback(()=>{_(),M()},[_,M]);return c&&I.length===0?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx("div",{className:"absolute top-4 right-4 z-10",children:d.jsx(B_,{open:f,onOpenChange:m,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:S,onSave:E,onClear:V,showClearButton:!0,buttonLabel:"Change API Key"})}),d.jsx(EEe,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:O,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:F,onSubmit:J=>{J.preventDefault(),j()},onConfigDialogOpenChange:m})]}):d.jsxs("div",{className:"flex flex-col h-full relative",children:[d.jsx(wEe,{llmConfig:c,hasMessages:I.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:S,onSaveConfig:E,onClearConfig:V}),d.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?d.jsx(Wke,{messages:I,isLoading:O,serverId:e.url,readResource:a,tools:e.tools}):d.jsx(_Ee,{onConfigureClick:()=>m(!0)})}),c&&d.jsx(xEe,{inputValue:r,isConnected:t,isLoading:O,textareaRef:s,onInputChange:i,onKeyDown:F,onSendMessage:j})]})}const N0=y.createContext(null);N0.displayName="PanelGroupContext";const Jn={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"},$D=10,Fl=y.useLayoutEffect,z2=Rd.useId,qke=typeof z2=="function"?z2:()=>null;let Xke=0;function MD(e=null){const t=qke(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+Xke++),e??n.current}function VY({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:f,onExpand:m,onResize:h,order:g,style:v,tagName:S="div",...x}){const w=y.useContext(N0);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:E,expandPanel:_,getPanelSize:k,getPanelStyle:R,groupId:N,isPanelCollapsed:I,reevaluatePanelConstraints:O,registerPanel:A,resizePanel:M,unregisterPanel:j}=w,F=MD(s),V=y.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:a,defaultSize:r,maxSize:c,minSize:u},id:F,idIsFromProps:s!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),Fl(()=>{const{callbacks:ee,constraints:ie}=V.current,W={...ie};V.current.id=F,V.current.idIsFromProps=s!==void 0,V.current.order=g,ee.onCollapse=f,ee.onExpand=m,ee.onResize=h,ie.collapsedSize=n,ie.collapsible=a,ie.defaultSize=r,ie.maxSize=c,ie.minSize=u,(W.collapsedSize!==ie.collapsedSize||W.collapsible!==ie.collapsible||W.maxSize!==ie.maxSize||W.minSize!==ie.minSize)&&O(V.current,W)}),Fl(()=>{const ee=V.current;return A(ee),()=>{j(ee)}},[g,F,A,j]),y.useImperativeHandle(i,()=>({collapse:()=>{E(V.current)},expand:ee=>{_(V.current,ee)},getId(){return F},getSize(){return k(V.current)},isCollapsed(){return I(V.current)},isExpanded(){return!I(V.current)},resize:ee=>{M(V.current,ee)}}),[E,_,k,I,F,M]);const J=R(V.current,r);return y.createElement(S,{...x,children:e,className:t,id:F,style:{...J,...v},[Jn.groupId]:N,[Jn.panel]:"",[Jn.panelCollapsible]:a||void 0,[Jn.panelId]:F,[Jn.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const GY=y.forwardRef((e,t)=>y.createElement(VY,{...e,forwardedRef:t}));VY.displayName="Panel";GY.displayName="forwardRef(Panel)";let ck=null,tv=-1,Rs=null;function Jke(e,t,n){const a=(t&qY)!==0,r=(t&XY)!==0,i=(t&JY)!==0,s=(t&QY)!==0;if(t){if(a)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Qke(){Rs!==null&&(document.head.removeChild(Rs),ck=null,Rs=null,tv=-1)}function eE(e,t,n){var a,r;const i=Jke(e,t);if(ck!==i){if(ck=i,Rs===null&&(Rs=document.createElement("style"),document.head.appendChild(Rs)),tv>=0){var s;(s=Rs.sheet)===null||s===void 0||s.removeRule(tv)}tv=(a=(r=Rs.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function WY(e){return e.type==="keydown"}function KY(e){return e.type.startsWith("pointer")}function ZY(e){return e.type.startsWith("mouse")}function C0(e){if(KY(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(ZY(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function eTe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function tTe(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 nTe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:B2(e),b:B2(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;Lt(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:F2(U2(n.a)),b:F2(U2(n.b))};if(r.a===r.b){const i=a.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let c=i.length;for(;c--;){const u=i[c];if(u===s.a)return 1;if(u===s.b)return-1}}return Math.sign(r.a-r.b)}const rTe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function aTe(e){var t;const n=getComputedStyle((t=YY(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function iTe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||aTe(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"||rTe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function U2(e){let t=e.length;for(;t--;){const n=e[t];if(Lt(n,"Missing node"),iTe(n))return n}return null}function F2(e){return e&&Number(getComputedStyle(e).zIndex)||0}function B2(e){const t=[];for(;e;)t.push(e),e=YY(e);return t}function YY(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const qY=1,XY=2,JY=4,QY=8,oTe=eTe()==="coarse";let yi=[],Au=!1,As=new Map,R0=new Map;const fm=new Set;function sTe(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=As.get(s))!==null&&i!==void 0?i:0;return As.set(s,u+1),fm.add(c),ny(),function(){var m;R0.delete(e),fm.delete(c);const h=(m=As.get(s))!==null&&m!==void 0?m:1;if(As.set(s,h-1),ny(),h===1&&As.delete(s),yi.includes(c)){const g=yi.indexOf(c);g>=0&&yi.splice(g,1),A0(),r("up",!0,null)}}}function lTe(e){const{target:t}=e,{x:n,y:a}=C0(e);Au=!0,PD({target:t,x:n,y:a}),ny(),yi.length>0&&(ry("down",e),A0(),e.preventDefault(),eq(t)||e.stopImmediatePropagation())}function tE(e){const{x:t,y:n}=C0(e);if(Au&&e.type!=="pointerleave"&&e.buttons===0&&(Au=!1,ry("up",e)),!Au){const{target:a}=e;PD({target:a,x:t,y:n})}ry("move",e),A0(),yi.length>0&&e.preventDefault()}function nE(e){const{target:t}=e,{x:n,y:a}=C0(e);R0.clear(),Au=!1,yi.length>0&&(e.preventDefault(),eq(t)||e.stopImmediatePropagation()),ry("up",e),PD({target:t,x:n,y:a}),A0(),ny()}function eq(e){let t=e;for(;t;){if(t.hasAttribute(Jn.resizeHandle))return!0;t=t.parentElement}return!1}function PD({target:e,x:t,y:n}){yi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),fm.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:f,right:m,top:h}=c,g=oTe?s.coarse:s.fine;if(t>=f-g&&t<=m+g&&n>=h-g&&n<=u+g){if(a!==null&&document.contains(a)&&i!==a&&!i.contains(a)&&!a.contains(i)&&nTe(a,i)>0){let S=a,x=!1;for(;S&&!S.contains(i);){if(tTe(S.getBoundingClientRect(),c)){x=!0;break}S=S.parentElement}if(x)return}yi.push(r)}})}function rE(e,t){R0.set(e,t)}function A0(){let e=!1,t=!1;yi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;R0.forEach(a=>{n|=a}),e&&t?eE("intersection",n):e?eE("horizontal",n):t?eE("vertical",n):Qke()}let aE;function ny(){var e;(e=aE)===null||e===void 0||e.abort(),aE=new AbortController;const t={capture:!0,signal:aE.signal};fm.size&&(Au?(yi.length>0&&As.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",nE,t),r.addEventListener("pointerleave",tE,t),r.addEventListener("pointermove",tE,t))}),As.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",nE,t),r.addEventListener("pointercancel",nE,t)})):As.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",lTe,t),r.addEventListener("pointermove",tE,t))}))}function ry(e,t){fm.forEach(n=>{const{setResizeHandlerState:a}=n,r=yi.includes(n);a(e,r,t)})}function cTe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function Lt(e,t){if(!e)throw console.error(t),Error(t)}function tc(e,t,n=$D){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function To(e,t,n=$D){return tc(e,t,n)===0}function Da(e,t,n){return tc(e,t,n)===0}function uTe(e,t,n){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++){const r=e[a],i=t[a];if(!Da(r,i,n))return!1}return!0}function Su({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];Lt(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(tc(n,c)<0)if(i){const u=(r+c)/2;tc(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed($D)),n}function pp({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Da(e,0))return t;const s=[...t],[c,u]=a;Lt(c!=null,"Invalid first pivot index"),Lt(u!=null,"Invalid second pivot index");let f=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];Lt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:S,minSize:x=0}=g;if(S){const w=t[h];if(Lt(w!=null,`Previous layout not found for panel index ${h}`),Da(w,v)){const E=x-w;tc(E,Math.abs(e))>0&&(e=e<0?0-E:E)}}}{const h=e<0?c:u,g=n[h];Lt(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:S,minSize:x=0}=g;if(S){const w=t[h];if(Lt(w!=null,`Previous layout not found for panel index ${h}`),Da(w,x)){const E=w-v;tc(E,Math.abs(e))>0&&(e=e<0?0-E:E)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const x=t[g];Lt(x!=null,`Previous layout not found for panel index ${g}`);const E=Su({panelConstraints:n,panelIndex:g,size:100})-x;if(v+=E,g+=h,g<0||g>=n.length)break}const S=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-S:S}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(f),S=t[g];Lt(S!=null,`Previous layout not found for panel index ${g}`);const x=S-v,w=Su({panelConstraints:n,panelIndex:g,size:x});if(!Da(S,w)&&(f+=S-w,s[g]=w,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(uTe(r,s))return r;{const h=e<0?u:c,g=t[h];Lt(g!=null,`Previous layout not found for panel index ${h}`);const v=g+f,S=Su({panelConstraints:n,panelIndex:h,size:v});if(s[h]=S,!Da(S,v)){let x=v-S,E=e<0?u:c;for(;E>=0&&E<n.length;){const _=s[E];Lt(_!=null,`Previous layout not found for panel index ${E}`);const k=_+x,R=Su({panelConstraints:n,panelIndex:E,size:k});if(Da(_,R)||(x-=R-_,s[E]=R),Da(x,0))break;e>0?E--:E++}}}const m=s.reduce((h,g)=>g+h,0);return Da(m,100)?s:r}function dTe({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];Lt(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:S=100,minSize:x=0}=v;g===c?(a=x,r=S):(i+=x,s+=S)});const u=Math.min(r,100-i),f=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:f,valueNow:m}}function pm(e,t=document){return Array.from(t.querySelectorAll(`[${Jn.resizeHandleId}][data-panel-group-id="${e}"]`))}function tq(e,t,n=document){const r=pm(e,n).findIndex(i=>i.getAttribute(Jn.resizeHandleId)===t);return r??null}function nq(e,t,n){const a=tq(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function fTe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function rq(e,t=document){if(fTe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function I0(e,t=document){const n=t.querySelector(`[${Jn.resizeHandleId}="${e}"]`);return n||null}function pTe(e,t,n,a=document){var r,i,s,c;const u=I0(t,a),f=pm(e,a),m=u?f.indexOf(u):-1,h=(r=(i=n[m])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,g=(s=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[h,g]}function mTe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){y.useRef({didWarnAboutMissingResizeHandle:!1}),Fl(()=>{if(!i)return;const c=pm(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:f,valueMin:m,valueNow:h}=dTe({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];Lt(v,`No panel data found for index "${u}"`),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((u,f)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,a,r,i]),y.useEffect(()=>{if(!i)return;const c=t.current;Lt(c,"Eager values not found");const{panelDataArray:u}=c,f=rq(n,i);Lt(f!=null,`No group found for id "${n}"`);const m=pm(n,i);Lt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Jn.resizeHandleId);Lt(v,"Resize handle element has no handle id attribute");const[S,x]=pTe(n,v,u,i);if(S==null||x==null)return()=>{};const w=E=>{if(!E.defaultPrevented)switch(E.key){case"Enter":{E.preventDefault();const _=u.findIndex(k=>k.id===S);if(_>=0){const k=u[_];Lt(k,`No panel data found for index ${_}`);const R=a[_],{collapsedSize:N=0,collapsible:I,minSize:O=0}=k.constraints;if(R!=null&&I){const A=pp({delta:Da(R,N)?O-N:N-R,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:nq(n,v,i),prevLayout:a,trigger:"keyboard"});a!==A&&s(A)}}break}}};return g.addEventListener("keydown",w),()=>{g.removeEventListener("keydown",w)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,a,r,s])}function H2(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 aq(e,t){const n=e==="horizontal",{x:a,y:r}=C0(t);return n?a:r}function hTe(e,t,n,a,r){const i=n==="horizontal",s=I0(t,r);Lt(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Jn.groupId);Lt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const f=aq(n,e),m=rq(c,r);Lt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(f-u)/g*100}function gTe(e,t,n,a,r,i){if(WY(e)){const s=n==="horizontal";let c=0;e.shiftKey?c=100:r!=null?c=r:c=10;let u=0;switch(e.key){case"ArrowDown":u=s?0:c;break;case"ArrowLeft":u=s?-c:0;break;case"ArrowRight":u=s?c:0;break;case"ArrowUp":u=s?0:-c;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return a==null?0:hTe(e,t,n,a,i)}function bTe({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let a=0,r=100;for(let i=0;i<e.length;i++){const s=n[i];Lt(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;c!=null&&(a++,t[i]=c,r-=c)}for(let i=0;i<e.length;i++){const s=n[i];Lt(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;if(c!=null)continue;const u=e.length-a,f=r/u;a++,t[i]=f,r-=f}return t}function Qc(e,t,n){t.forEach((a,r)=>{const i=e[r];Lt(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:f=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:S}=s;S&&S(a,h),m&&(g||v)&&(v&&(h==null||To(h,f))&&!To(a,f)&&v(),g&&(h==null||!To(h,f))&&To(a,f)&&g())}})}function Nb(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 vTe({defaultSize:e,dragState:t,layout:n,panelData:a,panelIndex:r,precision:i=3}){const s=n[r];let c;return s==null?c=e!=null?e.toFixed(i):"1":a.length===1?c="1":c=s.toFixed(i),{flexBasis:0,flexGrow:c,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function yTe(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function V2(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 iq(e){return`react-resizable-panels:${e}`}function oq(e){return e.map(t=>{const{constraints:n,id:a,idIsFromProps:r,order:i}=t;return r?a:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function sq(e,t){try{const n=iq(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function wTe(e,t,n){var a,r;const i=(a=sq(e,n))!==null&&a!==void 0?a:{},s=oq(t);return(r=i[s])!==null&&r!==void 0?r:null}function xTe(e,t,n,a,r){var i;const s=iq(e),c=oq(t),u=(i=sq(e,r))!==null&&i!==void 0?i:{};u[c]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{r.setItem(s,JSON.stringify(u))}catch(f){console.error(f)}}function G2({layout:e,panelConstraints:t}){const n=[...e],a=n.reduce((i,s)=>i+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Da(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];Lt(s!=null,`No layout data found for index ${i}`);const c=100/a*s;n[i]=c}let r=0;for(let i=0;i<t.length;i++){const s=n[i];Lt(s!=null,`No layout data found for index ${i}`);const c=Su({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Da(r,0))for(let i=0;i<t.length;i++){const s=n[i];Lt(s!=null,`No layout data found for index ${i}`);const c=s+r,u=Su({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Da(r,0)))break}return n}const STe=100,mp={getItem:e=>(V2(mp),mp.getItem(e)),setItem:(e,t)=>{V2(mp),mp.setItem(e,t)}},W2={};function lq({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=mp,style:f,tagName:m="div",...h}){const g=MD(i),v=y.useRef(null),[S,x]=y.useState(null),[w,E]=y.useState([]),_=cTe(),k=y.useRef({}),R=y.useRef(new Map),N=y.useRef(0),I=y.useRef({autoSaveId:e,direction:a,dragState:S,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),O=y.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});y.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),y.useImperativeHandle(r,()=>({getId:()=>I.current.id,getLayout:()=>{const{layout:P}=O.current;return P},setLayout:P=>{const{onLayout:$}=I.current,{layout:z,panelDataArray:G}=O.current,K=G2({layout:P,panelConstraints:G.map(re=>re.constraints)});H2(z,K)||(E(K),O.current.layout=K,$&&$(K),Qc(G,K,k.current))}}),[]),Fl(()=>{I.current.autoSaveId=e,I.current.direction=a,I.current.dragState=S,I.current.id=g,I.current.onLayout=s,I.current.storage=u}),mTe({committedValuesRef:I,eagerValuesRef:O,groupId:g,layout:w,panelDataArray:O.current.panelDataArray,setLayout:E,panelGroupElement:v.current}),y.useEffect(()=>{const{panelDataArray:P}=O.current;if(e){if(w.length===0||w.length!==P.length)return;let $=W2[e];$==null&&($=yTe(xTe,STe),W2[e]=$);const z=[...P],G=new Map(R.current);$(e,z,G,w,u)}},[e,w,u]),y.useEffect(()=>{});const A=y.useCallback(P=>{const{onLayout:$}=I.current,{layout:z,panelDataArray:G}=O.current;if(P.constraints.collapsible){const K=G.map(q=>q.constraints),{collapsedSize:re=0,panelSize:fe,pivotIndices:ce}=El(G,P,z);if(Lt(fe!=null,`Panel size not found for panel "${P.id}"`),!To(fe,re)){R.current.set(P.id,fe);const te=lu(G,P)===G.length-1?fe-re:re-fe,se=pp({delta:te,initialLayout:z,panelConstraints:K,pivotIndices:ce,prevLayout:z,trigger:"imperative-api"});Nb(z,se)||(E(se),O.current.layout=se,$&&$(se),Qc(G,se,k.current))}}},[]),M=y.useCallback((P,$)=>{const{onLayout:z}=I.current,{layout:G,panelDataArray:K}=O.current;if(P.constraints.collapsible){const re=K.map(de=>de.constraints),{collapsedSize:fe=0,panelSize:ce=0,minSize:q=0,pivotIndices:te}=El(K,P,G),se=$??q;if(To(ce,fe)){const de=R.current.get(P.id),ye=de!=null&&de>=se?de:se,Ge=lu(K,P)===K.length-1?ce-ye:ye-ce,Ie=pp({delta:Ge,initialLayout:G,panelConstraints:re,pivotIndices:te,prevLayout:G,trigger:"imperative-api"});Nb(G,Ie)||(E(Ie),O.current.layout=Ie,z&&z(Ie),Qc(K,Ie,k.current))}}},[]),j=y.useCallback(P=>{const{layout:$,panelDataArray:z}=O.current,{panelSize:G}=El(z,P,$);return Lt(G!=null,`Panel size not found for panel "${P.id}"`),G},[]),F=y.useCallback((P,$)=>{const{panelDataArray:z}=O.current,G=lu(z,P);return vTe({defaultSize:$,dragState:S,layout:w,panelData:z,panelIndex:G})},[S,w]),V=y.useCallback(P=>{const{layout:$,panelDataArray:z}=O.current,{collapsedSize:G=0,collapsible:K,panelSize:re}=El(z,P,$);return Lt(re!=null,`Panel size not found for panel "${P.id}"`),K===!0&&To(re,G)},[]),J=y.useCallback(P=>{const{layout:$,panelDataArray:z}=O.current,{collapsedSize:G=0,collapsible:K,panelSize:re}=El(z,P,$);return Lt(re!=null,`Panel size not found for panel "${P.id}"`),!K||tc(re,G)>0},[]),ee=y.useCallback(P=>{const{panelDataArray:$}=O.current;$.push(P),$.sort((z,G)=>{const K=z.order,re=G.order;return K==null&&re==null?0:K==null?-1:re==null?1:K-re}),O.current.panelDataArrayChanged=!0,_()},[_]);Fl(()=>{if(O.current.panelDataArrayChanged){O.current.panelDataArrayChanged=!1;const{autoSaveId:P,onLayout:$,storage:z}=I.current,{layout:G,panelDataArray:K}=O.current;let re=null;if(P){const ce=wTe(P,K,z);ce&&(R.current=new Map(Object.entries(ce.expandToSizes)),re=ce.layout)}re==null&&(re=bTe({panelDataArray:K}));const fe=G2({layout:re,panelConstraints:K.map(ce=>ce.constraints)});H2(G,fe)||(E(fe),O.current.layout=fe,$&&$(fe),Qc(K,fe,k.current))}}),Fl(()=>{const P=O.current;return()=>{P.layout=[]}},[]);const ie=y.useCallback(P=>{let $=!1;const z=v.current;return z&&window.getComputedStyle(z,null).getPropertyValue("direction")==="rtl"&&($=!0),function(K){K.preventDefault();const re=v.current;if(!re)return()=>null;const{direction:fe,dragState:ce,id:q,keyboardResizeBy:te,onLayout:se}=I.current,{layout:de,panelDataArray:ye}=O.current,{initialLayout:Te}=ce??{},Ge=nq(q,P,re);let Ie=gTe(K,P,fe,ce,te,re);const Me=fe==="horizontal";Me&&$&&(Ie=-Ie);const nt=ye.map(oe=>oe.constraints),Ue=pp({delta:Ie,initialLayout:Te??de,panelConstraints:nt,pivotIndices:Ge,prevLayout:de,trigger:WY(K)?"keyboard":"mouse-or-touch"}),pe=!Nb(de,Ue);(KY(K)||ZY(K))&&N.current!=Ie&&(N.current=Ie,!pe&&Ie!==0?Me?rE(P,Ie<0?qY:XY):rE(P,Ie<0?JY:QY):rE(P,0)),pe&&(E(Ue),O.current.layout=Ue,se&&se(Ue),Qc(ye,Ue,k.current))}},[]),W=y.useCallback((P,$)=>{const{onLayout:z}=I.current,{layout:G,panelDataArray:K}=O.current,re=K.map(de=>de.constraints),{panelSize:fe,pivotIndices:ce}=El(K,P,G);Lt(fe!=null,`Panel size not found for panel "${P.id}"`);const te=lu(K,P)===K.length-1?fe-$:$-fe,se=pp({delta:te,initialLayout:G,panelConstraints:re,pivotIndices:ce,prevLayout:G,trigger:"imperative-api"});Nb(G,se)||(E(se),O.current.layout=se,z&&z(se),Qc(K,se,k.current))},[]),Z=y.useCallback((P,$)=>{const{layout:z,panelDataArray:G}=O.current,{collapsedSize:K=0,collapsible:re}=$,{collapsedSize:fe=0,collapsible:ce,maxSize:q=100,minSize:te=0}=P.constraints,{panelSize:se}=El(G,P,z);se!=null&&(re&&ce&&To(se,K)?To(K,fe)||W(P,fe):se<te?W(P,te):se>q&&W(P,q))},[W]),H=y.useCallback((P,$)=>{const{direction:z}=I.current,{layout:G}=O.current;if(!v.current)return;const K=I0(P,v.current);Lt(K,`Drag handle element not found for id "${P}"`);const re=aq(z,$);x({dragHandleId:P,dragHandleRect:K.getBoundingClientRect(),initialCursorPosition:re,initialLayout:G})},[]),ae=y.useCallback(()=>{x(null)},[]),ne=y.useCallback(P=>{const{panelDataArray:$}=O.current,z=lu($,P);z>=0&&($.splice(z,1),delete k.current[P.id],O.current.panelDataArrayChanged=!0,_())},[_]),L=y.useMemo(()=>({collapsePanel:A,direction:a,dragState:S,expandPanel:M,getPanelSize:j,getPanelStyle:F,groupId:g,isPanelCollapsed:V,isPanelExpanded:J,reevaluatePanelConstraints:Z,registerPanel:ee,registerResizeHandle:ie,resizePanel:W,startDragging:H,stopDragging:ae,unregisterPanel:ne,panelGroupElement:v.current}),[A,S,a,M,j,F,g,V,J,Z,ee,ie,W,H,ae,ne]),B={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return y.createElement(N0.Provider,{value:L},y.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...B,...f},[Jn.group]:"",[Jn.groupDirection]:a,[Jn.groupId]:g}))}const cq=y.forwardRef((e,t)=>y.createElement(lq,{...e,forwardedRef:t}));lq.displayName="PanelGroup";cq.displayName="forwardRef(PanelGroup)";function lu(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function El(e,t,n){const a=lu(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function ETe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){y.useEffect(()=>{if(e||n==null||a==null)return;const r=I0(t,a);if(r==null)return;const i=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),n(s);break}case"F6":{s.preventDefault();const c=r.getAttribute(Jn.groupId);Lt(c,`No group element found for id "${c}"`);const u=pm(c,a),f=tq(c,t,a);Lt(f!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?f>0?f-1:u.length-1:f+1<u.length?f+1:0;u[m].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[a,e,t,n])}function uq({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:f,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...S}){var x,w;const E=y.useRef(null),_=y.useRef({onClick:s,onDragging:c,onPointerDown:f,onPointerUp:m});y.useEffect(()=>{_.current.onClick=s,_.current.onDragging=c,_.current.onPointerDown=f,_.current.onPointerUp=m});const k=y.useContext(N0);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:R,groupId:N,registerResizeHandle:I,startDragging:O,stopDragging:A,panelGroupElement:M}=k,j=MD(r),[F,V]=y.useState("inactive"),[J,ee]=y.useState(!1),[ie,W]=y.useState(null),Z=y.useRef({state:F});Fl(()=>{Z.current.state=F}),y.useEffect(()=>{if(n)W(null);else{const L=I(j);W(()=>L)}},[n,j,I]);const H=(x=a?.coarse)!==null&&x!==void 0?x:15,ae=(w=a?.fine)!==null&&w!==void 0?w:5;y.useEffect(()=>{if(n||ie==null)return;const L=E.current;Lt(L,"Element ref not attached");let B=!1;return sTe(j,L,R,{coarse:H,fine:ae},($,z,G)=>{if(!z){V("inactive");return}switch($){case"down":{V("drag"),B=!1,Lt(G,'Expected event to be defined for "down" action'),O(j,G);const{onDragging:K,onPointerDown:re}=_.current;K?.(!0),re?.();break}case"move":{const{state:K}=Z.current;B=!0,K!=="drag"&&V("hover"),Lt(G,'Expected event to be defined for "move" action'),ie(G);break}case"up":{V("hover"),A();const{onClick:K,onDragging:re,onPointerUp:fe}=_.current;re?.(!1),fe?.(),B||K?.();break}}})},[H,R,n,ae,I,j,ie,O,A]),ETe({disabled:n,handleId:j,resizeHandler:ie,panelGroupElement:M});const ne={touchAction:"none",userSelect:"none"};return y.createElement(v,{...S,children:e,className:t,id:r,onBlur:()=>{ee(!1),i?.()},onFocus:()=>{ee(!0),u?.()},ref:E,role:"separator",style:{...ne,...h},tabIndex:g,[Jn.groupDirection]:R,[Jn.groupId]:N,[Jn.resizeHandle]:"",[Jn.resizeHandleActive]:F==="drag"?"pointer":J?"keyboard":void 0,[Jn.resizeHandleEnabled]:!n,[Jn.resizeHandleId]:j,[Jn.resizeHandleState]:F})}uq.displayName="PanelResizeHandle";function sa({className:e,...t}){return d.jsx(cq,{"data-slot":"resizable-panel-group",className:Le("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function On({...e}){return d.jsx(GY,{"data-slot":"resizable-panel",...e})}function wi({withHandle:e,className:t,...n}){return d.jsx(uq,{"data-slot":"resizable-handle",className:Le("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&&d.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:d.jsx(Ype,{className:"size-2.5"})})})}function oh({className:e,...t}){return d.jsx("kbd",{"data-slot":"kbd",className:Le("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 _Te({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Nn,{ref:u,placeholder:"Search notifications...",value:t,onChange:f=>i(f.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),d.jsx(vr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(zd,{className:"h-4 w-4"})})}),d.jsxs(Rt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(oh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(zo,{className:"h-4 w-4"})})}),d.jsx(Rt,{side:"bottom",children:"Clear all"})]})})]})}function Qs({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return d.jsx("button",{id:e,type:"button",onClick:c,className:Le("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",u),children:d.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[a&&d.jsx("div",{className:"flex-shrink-0 mt-1",children:d.jsx("div",{className:Le("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:a})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"flex items-center gap-2 mb-1",children:d.jsx("h3",{className:Le("font-medium truncate font-mono text-sm"),children:r})}),i&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function kTe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Pd,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>d.jsx(Qs,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=r(s.timestamp),f=s.params&&Object.keys(s.params).length>0?Object.keys(s.params).length:0,m=f>0?` | ${f} param${f>1?"s":""}`:"";return u+m})(),onClick:()=>n(s)},s.id))})}function TTe({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Hp,{className:"h-3 w-3 text-gray-400"}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs(Oe,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?d.jsx(lC,{className:"h-4 w-4 mr-1"}):d.jsx(UG,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:a,children:s?d.jsx(zr,{className:"h-4 w-4"}):d.jsx(br,{className:"h-4 w-4"})}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,children:d.jsx(zm,{className:"h-4 w-4"})}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:i,children:d.jsx(Gp,{className:"h-4 w-4"})}),c&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,children:d.jsx(Qi,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx("div",{className:"px-4 pt-4",children:d.jsx(Qn,{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`})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(sC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function ay(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<60?"just now":r<60?`${r}m ago`:i<24?`${i}h ago`:s<7?`${s}d ago`:new Date(e).toLocaleDateString()}function NTe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,S]=y.useState(!0),[x,w]=y.useState(!1),[E,_]=y.useState(!0),[k,R]=y.useState(!1),N=y.useRef(null),I=y.useRef(null),O=y.useRef(null),A=y.useRef(!1);y.useEffect(()=>{v&&e.length>0&&N.current&&!A.current&&(N.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const Z=N.current;if(!Z)return;const H=()=>{Z.scrollTop>0&&(A.current=!0,S(!1))};return Z.addEventListener("scroll",H),()=>Z.removeEventListener("scroll",H)},[]),y.useEffect(()=>{e.length===0&&(A.current=!1,S(!0))},[e.length]),y.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),y.useEffect(()=>{x&&O.current&&O.current.focus()},[x]);const M=y.useCallback(()=>{f.trim()||w(!1)},[f]),j=y.useMemo(()=>{if(!f.trim())return e;const Z=f.toLowerCase();return e.filter(H=>H.method.toLowerCase().includes(Z)||JSON.stringify(H.params||{}).toLowerCase().includes(Z))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const Z=H=>{const ae=H.target;if(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.contentEditable==="true"||H.metaKey||H.ctrlKey||H.altKey)return;const L=j;if(H.key==="ArrowDown")H.preventDefault(),g(B=>{const P=B+1;return P>=L.length?0:P});else if(H.key==="ArrowUp")H.preventDefault(),g(B=>{const P=B-1;return P<0?L.length-1:P});else if(H.key==="Enter"&&h>=0){H.preventDefault();const B=j[h];B&&F(B)}};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[h,j]),y.useEffect(()=>{if(h>=0){const Z=`notification-${j[h]?.id}`,H=document.getElementById(Z);H&&H.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,j]);const F=y.useCallback(Z=>{u(Z)},[]),V=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),J=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(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[c]),ee=y.useCallback(()=>{if(c)try{const Z=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),H=URL.createObjectURL(Z),ae=document.createElement("a");ae.href=H,ae.download=`notification-${Date.now()}.json`,document.body.appendChild(ae),ae.click(),document.body.removeChild(ae),URL.revokeObjectURL(H)}catch(Z){console.error("[NotificationsTab] Failed to download notification:",Z)}},[c]),ie=y.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(Z){console.error("[NotificationsTab] Failed to toggle fullscreen:",Z)}},[]),W=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:ay}:null;return s?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(On,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(On,{defaultSize:75,minSize:30,children:[d.jsx(_Te,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:j.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onClearAll:V,searchInputRef:O}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(kTe,{notifications:j,selectedNotification:c,onNotificationSelect:F,focusedIndex:h,formatRelativeTime:ay,listRef:N})})]})})}),d.jsx(wi,{}),d.jsx(On,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(TTe,{notification:W,previewMode:E,onTogglePreview:()=>_(!E),onCopy:J,onDownload:ee,onFullscreen:ie,onClose:()=>u(null),isCopied:k})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(sC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function zD({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=y.useState([]),i=y.useRef(null),[s,c]=y.useState(new Set),[u]=y.useState(""),f=v=>{c(S=>{const x=new Set(S);return x.has(v)?x.delete(v):x.add(v),x})},m=async()=>{r([]),c(new Set),t?.(0),e&&e.length>0?e.forEach(v=>Sv(v)):Sv()},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?.(a.length)},[a.length,t]),y.useEffect(()=>{console.log("[RPC Logger] Subscribing to RPC logs for servers:",e);const v=$N(),x=(e&&e.length>0?v.filter(E=>e.includes(E.serverId)):v).map(E=>{const _=E.message,k=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown";return{id:`${E.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:E.serverId,direction:E.direction.toUpperCase(),method:k,timestamp:E.timestamp,payload:E.message}}).reverse();r(x),t?.(x.length);const w=MN(E=>{if(e&&e.length>0&&!e.includes(E.serverId))return;const _=E.message,k=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown",R={id:`${E.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:E.serverId,direction:E.direction.toUpperCase(),method:k,timestamp:E.timestamp,payload:E.message};console.log("[RPC Logger] New RPC log:",{method:k,direction:E.direction,serverId:E.serverId}),r(N=>{const I=[R,...N].slice(0,1e3);return t?.(I.length),I})});return()=>{w(),console.log("[RPC Logger] Unsubscribed from RPC logs")}},[h,t]);const g=y.useMemo(()=>{let v=a;if(e&&e.length>0){const S=new Set(e);v=v.filter(x=>S.has(x.serverId))}if(u.trim()){const S=u.toLowerCase();v=v.filter(x=>x.serverId.toLowerCase().includes(S)||x.method.toLowerCase().includes(S)||x.direction.toLowerCase().includes(S)||JSON.stringify(x.payload).toLowerCase().includes(S))}return v=[...v].sort((S,x)=>new Date(x.timestamp).getTime()-new Date(S.timestamp).getTime()),v},[a,u,e]);return d.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:d.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?d.jsxs("div",{className:"text-center py-8",children:[d.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),d.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const S=s.has(v.id);return d.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[d.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:[d.jsx("div",{className:"flex-shrink-0",children:S?d.jsx(Po,{className:"h-3 w-3 text-muted-foreground transition-transform"}):d.jsx(FG,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[d.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),d.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"?d.jsx(ipe,{className:"h-3 w-3"}):d.jsx(spe,{className:"h-3 w-3"})}),d.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),S&&d.jsx("div",{className:"border-t bg-muted/20",children:d.jsx("div",{className:"p-3",children:d.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:d.jsx(Qn,{data:v.payload})})})})]},v.id)})})})}function dq({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:f="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:S,primaryTabName:x}){const w=e===x;return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?d.jsx(Nn,{ref:S,placeholder:f,value:n,onChange:E=>h(E.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:w?a:r}),w&&d.jsxs(d.Fragment,{children:[d.jsx(vr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:d.jsx(zd,{className:"h-4 w-4"})})}),d.jsxs(Rt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(oh,{children:"F"})]})]})]})]})}),d.jsxs(Oe,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[w?d.jsx(c,{}):d.jsx(u,{}),d.jsx("span",{className:"hidden sm:inline",children:w?r:a}),w&&s>0&&d.jsx(vr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function K2({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:a}){return e.length===0?d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(Wp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):d.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((r,i)=>d.jsx(Qs,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:d.jsx(Wp,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&d.jsxs(vr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[r.arguments.length," args"]}),onClick:()=>n(r)},r.name))})}function Z2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:f}){return d.jsx(dq,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:Wp,secondaryIcon:Hp,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:f})}function Y2({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,focusedIndex:r}){return e.length===0?d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(Hp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),d.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):d.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,s)=>d.jsx(Qs,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:d.jsx(Hp,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function CTe({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.length>0))return d.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const i=s=>{const c=s.name,u=t[c],f=typeof u=="string"?u:JSON.stringify(u);return s.type==="boolean"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx("input",{id:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),d.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Nn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Ql,{id:c,value:f,onChange:m=>{try{const h=JSON.parse(m.target.value);n(c,h)}catch{n(c,m.target.value)}},placeholder:s.description||`Enter ${c} as JSON`,className:"font-mono text-sm min-h-[100px]"}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Nn,{id:c,value:f,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return d.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function q2({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return y.useEffect(()=>{const c=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&a&&(u.preventDefault(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,a,i]),e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:d.jsxs("div",{children:[d.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[d.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),d.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[d.jsx(Oe,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?d.jsxs(d.Fragment,{children:[d.jsx(Yi,{className:"mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):d.jsxs(d.Fragment,{children:[d.jsx(WG,{className:"h-4 w-4 sm:mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Execute"}),d.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:"⌘↵"})]})}),d.jsxs(Oe,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[d.jsx(dC,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),d.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:d.jsx(CTe,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),d.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 RTe(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function ATe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ITe(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 OTe({message:e,index:t}){const[n,a]=y.useState(!1),r=async()=>{const s=ITe(e.content);await navigator.clipboard.writeText(s),a(!0),setTimeout(()=>a(!1),2e3)},i=()=>{const s=e.content;return typeof s=="string"?d.jsx(Jb,{content:s}):s.type==="text"&&s.text?d.jsx(Jb,{content:s.text}):s.type==="image"?d.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d.jsxs("span",{className:"font-mono bg-muted px-2 py-1 rounded",children:["Image: ",s.mimeType||"unknown type"]}),s.data&&d.jsx("img",{src:`data:${s.mimeType};base64,${s.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):s.type==="resource"&&s.resource?d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[d.jsx("span",{className:"text-muted-foreground font-medium",children:"Resource:"}),d.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs font-mono",children:s.resource.uri})]}),s.resource.text&&d.jsx("div",{className:"mt-2",children:d.jsx(Jb,{content:s.resource.text})})]}):d.jsx("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:d.jsx("code",{children:JSON.stringify(s,null,2)})})};return d.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border",children:[d.jsx(vr,{variant:RTe(e.role),children:ATe(e.role)}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,className:"h-6 px-2",title:"Copy message content",children:n?d.jsx(zr,{className:"h-3.5 w-3.5"}):d.jsx(br,{className:"h-3.5 w-3.5"})})]}),d.jsx("div",{className:"px-4 py-3",children:i()})]})}function DTe(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<10?"now":a<60?`${a}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${s}d ago`}function jTe(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 X2({results:e,copiedResult:t,previewMode:n=!0,onCopy:a,onDelete:r,onFullscreen:i,onTogglePreview:s,onMaximize:c,isMaximized:u=!1}){const[f,m]=y.useState(0),[h,g]=y.useState(""),[v,S]=y.useState(!0),x=e[0],w=x?e.filter(N=>N.promptName===x.promptName):[],E=w[f]||w[0],_=e.findIndex(N=>N===E);if(y.useEffect(()=>{w.length>0&&f>=w.length&&m(0)},[w.length,f]),y.useEffect(()=>{const N=()=>{E&&g(DTe(E.timestamp))};N();const I=setInterval(N,1e3);return()=>clearInterval(I)},[E]),e.length===0)return d.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:d.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx("div",{className:"text-center",children:d.jsx(Pd,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const k=E.error||jTe(E.result),R="messages"in E.result&&Array.isArray(E.result.messages);return d.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:d.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:d.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[d.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[d.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),E.duration!==void 0&&d.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[d.jsx(Kp,{className:"h-3 w-3 text-gray-400"}),d.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[E.duration,"ms"]})]}),R&&d.jsx("div",{className:"flex items-center gap-4 sm:ml-4",children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:()=>S(!0),className:`text-xs font-medium ${v?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),d.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),d.jsx("button",{onClick:()=>S(!1),className:`text-xs font-medium ${v?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]})}),d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[w.length>1&&d.jsxs("div",{className:"flex items-center gap-2 mr-2",children:[d.jsx(Vp,{className:"h-3 w-3 text-gray-400"}),d.jsxs(Ao,{value:f.toString(),onValueChange:N=>m(parseInt(N)),children:[d.jsx(Oo,{className:"h-7 w-[120px] text-xs",children:d.jsx(Io,{})}),d.jsx(Do,{children:w.map((N,I)=>d.jsx(Kr,{value:I.toString(),children:I===0?"Latest":`${I+1} call ago`},I))})]})]}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-2",children:h}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>a(_,E.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?d.jsx(zr,{className:"h-4 w-4"}):d.jsx(br,{className:"h-4 w-4"})}),r&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>r(_),className:"h-7 w-7 p-0",title:"Delete result",children:d.jsx(zo,{className:"h-4 w-4"})}),i&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>i(_),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:d.jsx(Gp,{className:"h-4 w-4"})}),c&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,className:"h-7 w-7 p-0 hidden sm:flex",title:u?"Restore":"Maximize",children:u?d.jsx(GG,{className:"h-4 w-4"}):d.jsx(Gp,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:k?d.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[d.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),d.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:k})]}):v&&R?d.jsx("div",{className:"space-y-3",children:E.result.messages.map((N,I)=>d.jsx(OTe,{message:N,index:I},I))}):d.jsx(Qn,{data:E.result,filename:`prompt-result-${E.promptName}-${Date.now()}.json`})})]})})})}const J2="mcp-inspector-saved-prompts";function fq({ref:e,prompts:t,callPrompt:n,serverId:a,isConnected:r}){const[i,s]=y.useState(null),[c,u]=y.useState(null),{selectedPromptName:f,setSelectedPromptName:m}=cc(),[h,g]=y.useState({}),[v,S]=y.useState([]),[x,w]=y.useState(!1),[E,_]=y.useState(null),[k,R]=y.useState(""),[N,I]=y.useState("prompts"),[O,A]=y.useState([]),[M,j]=y.useState(!1),[F,V]=y.useState(""),[J,ee]=y.useState(!1),[ie,W]=y.useState(-1),Z=y.useRef(null),[H,ae]=y.useState(!1),[ne,L]=y.useState("list"),[B,P]=y.useState(0),[$,z]=y.useState(!0),[G,K]=y.useState(!1),re=y.useRef(null),fe=y.useRef(null),ce=y.useRef(null),q=y.useRef(null);y.useEffect(()=>{const Ee=()=>{ae(window.innerWidth<1024)};return Ee(),window.addEventListener("resize",Ee),()=>window.removeEventListener("resize",Ee)},[]),y.useEffect(()=>{L(i?"detail":"list")},[i]),y.useEffect(()=>{H&&v.length>0&&!x&&L("response")},[v,x,H]),y.useImperativeHandle(e,()=>({focusSearch:()=>{ee(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{R(""),ee(!1),Z.current&&Z.current.blur()}})),y.useEffect(()=>{try{const Ee=localStorage.getItem(J2);if(Ee){const je=JSON.parse(Ee);A(je)}}catch(Ee){console.error("[PromptsTab] Failed to load saved prompts:",Ee)}},[]);const te=y.useCallback(Ee=>{try{localStorage.setItem(J2,JSON.stringify(Ee))}catch(je){console.error("[PromptsTab] Failed to save prompts:",je)}},[]);y.useEffect(()=>{J&&Z.current&&Z.current.focus()},[J]);const se=y.useCallback(()=>{k.trim()||ee(!1)},[k]),de=y.useMemo(()=>{if(!k.trim())return t;const Ee=k.toLowerCase();return t.filter(je=>je.name.toLowerCase().includes(Ee)||je.description?.toLowerCase().includes(Ee))},[t,k]),ye=y.useCallback(Ee=>{s(Ee);const je={};Ee.arguments&&Ee.arguments.forEach(We=>{je[We.name]=""}),g(je)},[]),Te=y.useCallback(Ee=>{const je=t.find(We=>We.name===Ee.promptName);je&&(s(je),g(Ee.args),u(Ee))},[t]);y.useEffect(()=>{W(-1)},[k,N]),y.useEffect(()=>{const Ee=je=>{const We=je.target;if(We.tagName==="INPUT"||We.tagName==="TEXTAREA"||We.contentEditable==="true"||je.metaKey||je.ctrlKey||je.altKey)return;const ot=N==="prompts"?de:O;if(je.key==="ArrowDown")je.preventDefault(),W(kt=>{const Ln=kt+1;return Ln>=ot.length?0:Ln});else if(je.key==="ArrowUp")je.preventDefault(),W(kt=>{const Ln=kt-1;return Ln<0?ot.length-1:Ln});else if(je.key==="Enter"&&ie>=0)if(je.preventDefault(),N==="prompts"){const kt=de[ie];kt&&ye(kt)}else{const kt=O[ie];kt&&Te(kt)}};return document.addEventListener("keydown",Ee),()=>document.removeEventListener("keydown",Ee)},[ie,de,O,N,ye,Te]),y.useEffect(()=>{if(ie>=0){const Ee=N==="prompts"?`prompt-${de[ie]?.name}`:`saved-prompt-${O[ie]?.id}`,je=document.getElementById(Ee);je&&je.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ie,de,O,N]),y.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:f,promptsCount:t.length,currentSelectedPrompt:i?.name}),f&&t.length>0){const Ee=t.find(je=>je.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!Ee,promptName:Ee?.name,shouldSelect:Ee&&i?.name!==Ee.name}),Ee&&i?.name!==Ee.name){console.warn("[PromptsTab] Selecting prompt:",Ee.name),m(null);const je=setTimeout(()=>{ye(Ee);const We=document.getElementById(`prompt-${Ee.name}`);We&&(console.warn("[PromptsTab] Scrolling to prompt element"),We.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(je)}}},[f,t,i,ye,m]);const Ge=y.useCallback((Ee,je)=>{g(We=>({...We,[Ee]:je}))},[]),Ie=y.useCallback(async()=>{if(!i||x)return;w(!0);const Ee=Date.now();try{const je=await n(i.name,h),We=Date.now()-Ee;$r.getInstance().capture(new lU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),S(ot=>[{promptName:i.name,args:h,result:je,timestamp:Ee,duration:We},...ot])}catch(je){$r.getInstance().capture(new lU({promptName:i.name,serverId:a,success:!1,error:je instanceof Error?je.message:"Unknown error"})).catch(()=>{});const Ye={promptName:i.name,args:h,result:null,error:je instanceof Error?je.message:String(je),timestamp:Ee,duration:Date.now()-Ee};S(ot=>[...ot,{...Ye,result:{messages:[]}}])}finally{w(!1)}},[i,h,x,n,a]),Me=y.useCallback(async(Ee,je)=>{try{await navigator.clipboard.writeText(JSON.stringify(je,null,2)),_(Ee),setTimeout(()=>_(null),2e3)}catch(We){console.error("[PromptsTab] Failed to copy result:",We)}},[]),nt=y.useCallback(Ee=>{S(je=>je.filter((We,Ye)=>Ye!==Ee))},[]),Ue=y.useCallback(Ee=>{if(H)L("response");else{const je=v[Ee];if(je){const We=window.open("","_blank","width=800,height=600");if(We){const Ye=je.result;We.document.write(`
1723
+ `);k=I.pop()||"";for(const O of I)if(O.trim()&&O.startsWith("data: "))try{const A=JSON.parse(O.slice(6));if(console.log("[Client received event]",A.type,A.toolName||A.content?.slice?.(0,30)),A.type==="message")console.log("[Message started]",A.id);else if(A.type==="text"){x+=A.content;const M=w[w.length-1];M&&M.type==="text"?M.text=x:w.push({type:"text",text:x}),console.log("[Parts after text]",w.length,"parts, text length:",x.length),i(j=>j.map(F=>F.id===S?{...F,parts:[...w]}:F))}else if(A.type==="tool-call")x&&(x=""),w.push({type:"tool-invocation",toolInvocation:{toolName:A.toolName,args:A.args,state:"pending"}}),console.log("[Parts after tool-call]",w.length,"parts, tool:",A.toolName),i(M=>M.map(j=>j.id===S?{...j,parts:[...w]}:j));else if(A.type==="tool-result"){const M=w.find(j=>j.type==="tool-invocation"&&j.toolInvocation?.toolName===A.toolName&&!j.toolInvocation?.result);M&&M.toolInvocation?(M.toolInvocation.result=A.result,M.toolInvocation.state="result",console.log("[Parts after tool-result]",w.length,"parts, updated:",A.toolName),i(j=>j.map(F=>F.id===S?{...F,parts:[...w]}:F))):console.warn("[tool-result] Could not find matching tool part for",A.toolName)}else if(A.type==="done")console.log("[Done] Final parts:",w.length),i(M=>M.map(j=>j.id===S?{...j,parts:[...w],content:""}:j));else if(A.type==="error")throw new Error(A.message||"Streaming error")}catch(A){console.error("Failed to parse streaming event:",A,O)}}}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 S={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(x=>[...x,S])}finally{c(!1)}},[t,a,e,r,n]),f=y.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:f}}function Zke({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=y.useState([]),[s,c]=y.useState(!1),u=y.useRef(null),f=y.useRef(null),m=y.useRef(null),h=y.useCallback(async v=>{if(!v.trim()||!t||!n)return;const S={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(E=>[...E,S]),c(!0),u.current=new AbortController;const x=Date.now();let w=0;try{const E=`assistant-${Date.now()}`;let _="";const k=[];if(i(R=>[...R,{id:E,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:N}=await ia(async()=>{const{ChatOpenAI:I}=await import("./index-Meiz2XrK.js");return{ChatOpenAI:I}},__vite__mapDeps([0,1,2,3,4,5]));R=new N({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:N}=await ia(async()=>{const{ChatAnthropic:I}=await import("./index-BghX1ooe.js");return{ChatAnthropic:I}},__vite__mapDeps([6,2,1,5]));R=new N({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:N}=await ia(async()=>{const{ChatGoogleGenerativeAI:I}=await import("./index-hiNxmj9U.js");return{ChatGoogleGenerativeAI:I}},__vite__mapDeps([7,2,1,4]));R=new N({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 ia(async()=>{const{MCPAgent:N}=await import("./browser-CAet5h5U.js");return{MCPAgent:N}},__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(u.current?.signal.aborted)break;if(R.event==="on_chat_model_stream"&&R.data?.chunk?.text){const N=R.data.chunk.text;if(typeof N=="string"&&N.length>0){_+=N;const I=k[k.length-1];I&&I.type==="text"?I.text=_:k.push({type:"text",text:_}),i(O=>O.map(A=>A.id===E?{...A,parts:[...k]}:A))}}else if(R.event==="on_tool_start"){_&&(_="");let N={};R.data?.input?N=R.data.input:R.data?.tool_input?N=R.data.tool_input:R.data&&(N=R.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:R.name,eventData:R.data,extractedArgs:N}),w++,k.push({type:"tool-invocation",toolInvocation:{toolName:R.name||"unknown",args:N,state:"pending"}}),i(I=>I.map(O=>O.id===E?{...O,parts:[...k]}:O))}else if(R.event==="on_tool_end"){const N=k.find(I=>I.type==="tool-invocation"&&I.toolInvocation?.toolName===R.name&&!I.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:R.name,hasToolPart:!!N,output:R.data?.output}),N&&N.toolInvocation){let I=R.data?.output;if(I?.kwargs?.content&&typeof I.kwargs.content=="string")try{I=JSON.parse(I.kwargs.content)}catch(A){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",A),I=I.kwargs.content}else if(I?.content&&typeof I.content=="string")try{I=JSON.parse(I.content)}catch{I=I.content}N.toolInvocation.result=I,N.toolInvocation.state="result";const O=I?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:R.name,hasMeta:!!I?._meta,hasStructuredContent:!!I?.structuredContent,appsSdkUri:O}),O&&typeof O=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",O);try{const A=await a(O);console.log("[useChatMessagesClientSide] Resource fetched:",A);const M=I?.structuredContent||null;if(A?.contents&&Array.isArray(A.contents)){const j=A.contents.map(V=>({type:"resource",resource:V}));console.log("[useChatMessagesClientSide] Created MCP resources:",j);const F={...I,content:[...I.content||[],...j],structuredContent:M};N.toolInvocation.result=F,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",A)}catch(A){console.error("Failed to fetch Apps SDK resource:",A)}}i(A=>A.map(M=>M.id===E?{...M,parts:[...k]}:M))}}}i(R=>R.map(N=>N.id===E?{...N,parts:[...k],content:""}:N)),t&&$r.getInstance().capture(new cU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:w,success:!0,executionMode:"client-side",duration:Date.now()-x})).catch(()=>{})}catch(E){console.error("Client-side agent error:",E);let _="Unknown error occurred";if(E instanceof Error){_=E.message;const R=E;R.status&&(_=`HTTP ${R.status}: ${_}`),(R.code===401||_.includes("401")||_.includes("Unauthorized"))&&(_="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&$r.getInstance().capture(new cU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:w,success:!1,executionMode:"client-side",duration:Date.now()-x,error:_})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${_}`,timestamp:Date.now()};i(R=>[...R,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=y.useCallback(()=>{i([]),f.current&&f.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const P2={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function HY({mcpServerUrl:e}){const[t,n]=y.useState(null),[a,r]=y.useState(null),[i,s]=y.useState(!1),[c,u]=y.useState("openai"),[f,m]=y.useState(""),[h,g]=y.useState(P2.openai),v=y.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(j){return console.error("Failed to load API keys:",j),{}}return{}},[]),S=y.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[x,w]=y.useState("none"),[E,_]=y.useState(""),[k,R]=y.useState(""),[N,I]=y.useState("");y.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),j=v();if(M)try{const F=JSON.parse(M);n(F),u(F.provider),m(j[F.provider]||F.apiKey||""),g(F.model)}catch(F){console.error("Failed to load LLM config:",F)}},[v]),y.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const j=JSON.parse(M);r(j),w(j.type),j.username&&_(j.username),j.password&&R(j.password),j.token&&I(j.token)}catch(j){console.error("Failed to load auth config:",j)}else try{const j="mcp:auth",F=BY(e),V=`${j}_${F}_tokens`;localStorage.getItem(V)&&(r({type:"oauth"}),w("oauth"))}catch(j){console.error("Failed to check for OAuth tokens:",j)}},[e]),y.useEffect(()=>{g(P2[c]);const M=v();m(M[c]||"")},[c,v]);const O=y.useCallback(()=>{if(!f.trim())return;const M=v();M[c]=f,S(M);const j={provider:c,apiKey:f,model:h},F={type:x,...x==="basic"&&{username:E.trim(),password:k.trim()},...x==="bearer"&&{token:N.trim()}};n(j),r(F),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(j)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(F)),s(!1)},[c,f,h,x,E,k,N,v,S]),A=y.useCallback(()=>{n(null),r(null);const M=v();delete M[c],S(M),m(""),_(""),R(""),I(""),w("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,S]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:f,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:x,saveLLMConfig:O,clearConfig:A}}function Yke({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=y.useState(""),s=y.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:f,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:S,tempModel:x,setTempModel:w,saveLLMConfig:E,clearConfig:_}=HY({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},R=Kke({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),N=Zke(k),{messages:I,isLoading:O,sendMessage:A,clearMessages:M}=n?N:R;lZ({onNewChat:M}),y.useEffect(()=>{c&&I.length===0&&s.current&&s.current.focus()},[c,I.length]),y.useEffect(()=>{!O&&I.length>0&&s.current&&s.current.focus()},[O,I.length]);const j=y.useCallback(()=>{r.trim()&&(A(r),i(""))},[r,A]),F=y.useCallback(J=>{J.key==="Enter"&&!J.shiftKey&&(J.preventDefault(),j())},[j]),V=y.useCallback(()=>{_(),M()},[_,M]);return c&&I.length===0?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx("div",{className:"absolute top-4 right-4 z-10",children:d.jsx(B_,{open:f,onOpenChange:m,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:S,onSave:E,onClear:V,showClearButton:!0,buttonLabel:"Change API Key"})}),d.jsx(EEe,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:O,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:F,onSubmit:J=>{J.preventDefault(),j()},onConfigDialogOpenChange:m})]}):d.jsxs("div",{className:"flex flex-col h-full relative",children:[d.jsx(wEe,{llmConfig:c,hasMessages:I.length>0,configDialogOpen:f,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:x,tempApiKey:v,onProviderChange:g,onModelChange:w,onApiKeyChange:S,onSaveConfig:E,onClearConfig:V}),d.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?d.jsx(Wke,{messages:I,isLoading:O,serverId:e.url,readResource:a,tools:e.tools}):d.jsx(_Ee,{onConfigureClick:()=>m(!0)})}),c&&d.jsx(xEe,{inputValue:r,isConnected:t,isLoading:O,textareaRef:s,onInputChange:i,onKeyDown:F,onSendMessage:j})]})}const N0=y.createContext(null);N0.displayName="PanelGroupContext";const Jn={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"},$D=10,Fl=y.useLayoutEffect,z2=Rd.useId,qke=typeof z2=="function"?z2:()=>null;let Xke=0;function MD(e=null){const t=qke(),n=y.useRef(e||t||null);return n.current===null&&(n.current=""+Xke++),e??n.current}function VY({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:f,onExpand:m,onResize:h,order:g,style:v,tagName:S="div",...x}){const w=y.useContext(N0);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:E,expandPanel:_,getPanelSize:k,getPanelStyle:R,groupId:N,isPanelCollapsed:I,reevaluatePanelConstraints:O,registerPanel:A,resizePanel:M,unregisterPanel:j}=w,F=MD(s),V=y.useRef({callbacks:{onCollapse:f,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:a,defaultSize:r,maxSize:c,minSize:u},id:F,idIsFromProps:s!==void 0,order:g});y.useRef({didLogMissingDefaultSizeWarning:!1}),Fl(()=>{const{callbacks:ee,constraints:ie}=V.current,W={...ie};V.current.id=F,V.current.idIsFromProps=s!==void 0,V.current.order=g,ee.onCollapse=f,ee.onExpand=m,ee.onResize=h,ie.collapsedSize=n,ie.collapsible=a,ie.defaultSize=r,ie.maxSize=c,ie.minSize=u,(W.collapsedSize!==ie.collapsedSize||W.collapsible!==ie.collapsible||W.maxSize!==ie.maxSize||W.minSize!==ie.minSize)&&O(V.current,W)}),Fl(()=>{const ee=V.current;return A(ee),()=>{j(ee)}},[g,F,A,j]),y.useImperativeHandle(i,()=>({collapse:()=>{E(V.current)},expand:ee=>{_(V.current,ee)},getId(){return F},getSize(){return k(V.current)},isCollapsed(){return I(V.current)},isExpanded(){return!I(V.current)},resize:ee=>{M(V.current,ee)}}),[E,_,k,I,F,M]);const J=R(V.current,r);return y.createElement(S,{...x,children:e,className:t,id:F,style:{...J,...v},[Jn.groupId]:N,[Jn.panel]:"",[Jn.panelCollapsible]:a||void 0,[Jn.panelId]:F,[Jn.panelSize]:parseFloat(""+J.flexGrow).toFixed(1)})}const GY=y.forwardRef((e,t)=>y.createElement(VY,{...e,forwardedRef:t}));VY.displayName="Panel";GY.displayName="forwardRef(Panel)";let ck=null,tv=-1,Rs=null;function Jke(e,t,n){const a=(t&qY)!==0,r=(t&XY)!==0,i=(t&JY)!==0,s=(t&QY)!==0;if(t){if(a)return i?"se-resize":s?"ne-resize":"e-resize";if(r)return i?"sw-resize":s?"nw-resize":"w-resize";if(i)return"s-resize";if(s)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Qke(){Rs!==null&&(document.head.removeChild(Rs),ck=null,Rs=null,tv=-1)}function eE(e,t,n){var a,r;const i=Jke(e,t);if(ck!==i){if(ck=i,Rs===null&&(Rs=document.createElement("style"),document.head.appendChild(Rs)),tv>=0){var s;(s=Rs.sheet)===null||s===void 0||s.removeRule(tv)}tv=(a=(r=Rs.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function WY(e){return e.type==="keydown"}function KY(e){return e.type.startsWith("pointer")}function ZY(e){return e.type.startsWith("mouse")}function C0(e){if(KY(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(ZY(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function eTe(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function tTe(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 nTe(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:B2(e),b:B2(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;Lt(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:F2(U2(n.a)),b:F2(U2(n.b))};if(r.a===r.b){const i=a.childNodes,s={a:n.a.at(-1),b:n.b.at(-1)};let c=i.length;for(;c--;){const u=i[c];if(u===s.a)return 1;if(u===s.b)return-1}}return Math.sign(r.a-r.b)}const rTe=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function aTe(e){var t;const n=getComputedStyle((t=YY(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function iTe(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||aTe(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"||rTe.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function U2(e){let t=e.length;for(;t--;){const n=e[t];if(Lt(n,"Missing node"),iTe(n))return n}return null}function F2(e){return e&&Number(getComputedStyle(e).zIndex)||0}function B2(e){const t=[];for(;e;)t.push(e),e=YY(e);return t}function YY(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const qY=1,XY=2,JY=4,QY=8,oTe=eTe()==="coarse";let yi=[],Au=!1,As=new Map,R0=new Map;const fm=new Set;function sTe(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=As.get(s))!==null&&i!==void 0?i:0;return As.set(s,u+1),fm.add(c),ny(),function(){var m;R0.delete(e),fm.delete(c);const h=(m=As.get(s))!==null&&m!==void 0?m:1;if(As.set(s,h-1),ny(),h===1&&As.delete(s),yi.includes(c)){const g=yi.indexOf(c);g>=0&&yi.splice(g,1),A0(),r("up",!0,null)}}}function lTe(e){const{target:t}=e,{x:n,y:a}=C0(e);Au=!0,PD({target:t,x:n,y:a}),ny(),yi.length>0&&(ry("down",e),A0(),e.preventDefault(),eq(t)||e.stopImmediatePropagation())}function tE(e){const{x:t,y:n}=C0(e);if(Au&&e.type!=="pointerleave"&&e.buttons===0&&(Au=!1,ry("up",e)),!Au){const{target:a}=e;PD({target:a,x:t,y:n})}ry("move",e),A0(),yi.length>0&&e.preventDefault()}function nE(e){const{target:t}=e,{x:n,y:a}=C0(e);R0.clear(),Au=!1,yi.length>0&&(e.preventDefault(),eq(t)||e.stopImmediatePropagation()),ry("up",e),PD({target:t,x:n,y:a}),A0(),ny()}function eq(e){let t=e;for(;t;){if(t.hasAttribute(Jn.resizeHandle))return!0;t=t.parentElement}return!1}function PD({target:e,x:t,y:n}){yi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),fm.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:f,right:m,top:h}=c,g=oTe?s.coarse:s.fine;if(t>=f-g&&t<=m+g&&n>=h-g&&n<=u+g){if(a!==null&&document.contains(a)&&i!==a&&!i.contains(a)&&!a.contains(i)&&nTe(a,i)>0){let S=a,x=!1;for(;S&&!S.contains(i);){if(tTe(S.getBoundingClientRect(),c)){x=!0;break}S=S.parentElement}if(x)return}yi.push(r)}})}function rE(e,t){R0.set(e,t)}function A0(){let e=!1,t=!1;yi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;R0.forEach(a=>{n|=a}),e&&t?eE("intersection",n):e?eE("horizontal",n):t?eE("vertical",n):Qke()}let aE;function ny(){var e;(e=aE)===null||e===void 0||e.abort(),aE=new AbortController;const t={capture:!0,signal:aE.signal};fm.size&&(Au?(yi.length>0&&As.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",nE,t),r.addEventListener("pointerleave",tE,t),r.addEventListener("pointermove",tE,t))}),As.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",nE,t),r.addEventListener("pointercancel",nE,t)})):As.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",lTe,t),r.addEventListener("pointermove",tE,t))}))}function ry(e,t){fm.forEach(n=>{const{setResizeHandlerState:a}=n,r=yi.includes(n);a(e,r,t)})}function cTe(){const[e,t]=y.useState(0);return y.useCallback(()=>t(n=>n+1),[])}function Lt(e,t){if(!e)throw console.error(t),Error(t)}function tc(e,t,n=$D){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function To(e,t,n=$D){return tc(e,t,n)===0}function Da(e,t,n){return tc(e,t,n)===0}function uTe(e,t,n){if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++){const r=e[a],i=t[a];if(!Da(r,i,n))return!1}return!0}function Su({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];Lt(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(tc(n,c)<0)if(i){const u=(r+c)/2;tc(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed($D)),n}function pp({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Da(e,0))return t;const s=[...t],[c,u]=a;Lt(c!=null,"Invalid first pivot index"),Lt(u!=null,"Invalid second pivot index");let f=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];Lt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:S,minSize:x=0}=g;if(S){const w=t[h];if(Lt(w!=null,`Previous layout not found for panel index ${h}`),Da(w,v)){const E=x-w;tc(E,Math.abs(e))>0&&(e=e<0?0-E:E)}}}{const h=e<0?c:u,g=n[h];Lt(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:S,minSize:x=0}=g;if(S){const w=t[h];if(Lt(w!=null,`Previous layout not found for panel index ${h}`),Da(w,x)){const E=w-v;tc(E,Math.abs(e))>0&&(e=e<0?0-E:E)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const x=t[g];Lt(x!=null,`Previous layout not found for panel index ${g}`);const E=Su({panelConstraints:n,panelIndex:g,size:100})-x;if(v+=E,g+=h,g<0||g>=n.length)break}const S=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-S:S}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(f),S=t[g];Lt(S!=null,`Previous layout not found for panel index ${g}`);const x=S-v,w=Su({panelConstraints:n,panelIndex:g,size:x});if(!Da(S,w)&&(f+=S-w,s[g]=w,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(uTe(r,s))return r;{const h=e<0?u:c,g=t[h];Lt(g!=null,`Previous layout not found for panel index ${h}`);const v=g+f,S=Su({panelConstraints:n,panelIndex:h,size:v});if(s[h]=S,!Da(S,v)){let x=v-S,E=e<0?u:c;for(;E>=0&&E<n.length;){const _=s[E];Lt(_!=null,`Previous layout not found for panel index ${E}`);const k=_+x,R=Su({panelConstraints:n,panelIndex:E,size:k});if(Da(_,R)||(x-=R-_,s[E]=R),Da(x,0))break;e>0?E--:E++}}}const m=s.reduce((h,g)=>g+h,0);return Da(m,100)?s:r}function dTe({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];Lt(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:S=100,minSize:x=0}=v;g===c?(a=x,r=S):(i+=x,s+=S)});const u=Math.min(r,100-i),f=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:f,valueNow:m}}function pm(e,t=document){return Array.from(t.querySelectorAll(`[${Jn.resizeHandleId}][data-panel-group-id="${e}"]`))}function tq(e,t,n=document){const r=pm(e,n).findIndex(i=>i.getAttribute(Jn.resizeHandleId)===t);return r??null}function nq(e,t,n){const a=tq(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function fTe(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function rq(e,t=document){if(fTe(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function I0(e,t=document){const n=t.querySelector(`[${Jn.resizeHandleId}="${e}"]`);return n||null}function pTe(e,t,n,a=document){var r,i,s,c;const u=I0(t,a),f=pm(e,a),m=u?f.indexOf(u):-1,h=(r=(i=n[m])===null||i===void 0?void 0:i.id)!==null&&r!==void 0?r:null,g=(s=(c=n[m+1])===null||c===void 0?void 0:c.id)!==null&&s!==void 0?s:null;return[h,g]}function mTe({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){y.useRef({didWarnAboutMissingResizeHandle:!1}),Fl(()=>{if(!i)return;const c=pm(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:f,valueMin:m,valueNow:h}=dTe({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];Lt(v,`No panel data found for index "${u}"`),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((u,f)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,a,r,i]),y.useEffect(()=>{if(!i)return;const c=t.current;Lt(c,"Eager values not found");const{panelDataArray:u}=c,f=rq(n,i);Lt(f!=null,`No group found for id "${n}"`);const m=pm(n,i);Lt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Jn.resizeHandleId);Lt(v,"Resize handle element has no handle id attribute");const[S,x]=pTe(n,v,u,i);if(S==null||x==null)return()=>{};const w=E=>{if(!E.defaultPrevented)switch(E.key){case"Enter":{E.preventDefault();const _=u.findIndex(k=>k.id===S);if(_>=0){const k=u[_];Lt(k,`No panel data found for index ${_}`);const R=a[_],{collapsedSize:N=0,collapsible:I,minSize:O=0}=k.constraints;if(R!=null&&I){const A=pp({delta:Da(R,N)?O-N:N-R,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:nq(n,v,i),prevLayout:a,trigger:"keyboard"});a!==A&&s(A)}}break}}};return g.addEventListener("keydown",w),()=>{g.removeEventListener("keydown",w)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,a,r,s])}function H2(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 aq(e,t){const n=e==="horizontal",{x:a,y:r}=C0(t);return n?a:r}function hTe(e,t,n,a,r){const i=n==="horizontal",s=I0(t,r);Lt(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Jn.groupId);Lt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const f=aq(n,e),m=rq(c,r);Lt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(f-u)/g*100}function gTe(e,t,n,a,r,i){if(WY(e)){const s=n==="horizontal";let c=0;e.shiftKey?c=100:r!=null?c=r:c=10;let u=0;switch(e.key){case"ArrowDown":u=s?0:c;break;case"ArrowLeft":u=s?-c:0;break;case"ArrowRight":u=s?c:0;break;case"ArrowUp":u=s?0:-c;break;case"End":u=100;break;case"Home":u=-100;break}return u}else return a==null?0:hTe(e,t,n,a,i)}function bTe({panelDataArray:e}){const t=Array(e.length),n=e.map(i=>i.constraints);let a=0,r=100;for(let i=0;i<e.length;i++){const s=n[i];Lt(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;c!=null&&(a++,t[i]=c,r-=c)}for(let i=0;i<e.length;i++){const s=n[i];Lt(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;if(c!=null)continue;const u=e.length-a,f=r/u;a++,t[i]=f,r-=f}return t}function Qc(e,t,n){t.forEach((a,r)=>{const i=e[r];Lt(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:f=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:S}=s;S&&S(a,h),m&&(g||v)&&(v&&(h==null||To(h,f))&&!To(a,f)&&v(),g&&(h==null||!To(h,f))&&To(a,f)&&g())}})}function Nb(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 vTe({defaultSize:e,dragState:t,layout:n,panelData:a,panelIndex:r,precision:i=3}){const s=n[r];let c;return s==null?c=e!=null?e.toFixed(i):"1":a.length===1?c="1":c=s.toFixed(i),{flexBasis:0,flexGrow:c,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function yTe(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function V2(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 iq(e){return`react-resizable-panels:${e}`}function oq(e){return e.map(t=>{const{constraints:n,id:a,idIsFromProps:r,order:i}=t;return r?a:i?`${i}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function sq(e,t){try{const n=iq(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function wTe(e,t,n){var a,r;const i=(a=sq(e,n))!==null&&a!==void 0?a:{},s=oq(t);return(r=i[s])!==null&&r!==void 0?r:null}function xTe(e,t,n,a,r){var i;const s=iq(e),c=oq(t),u=(i=sq(e,r))!==null&&i!==void 0?i:{};u[c]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{r.setItem(s,JSON.stringify(u))}catch(f){console.error(f)}}function G2({layout:e,panelConstraints:t}){const n=[...e],a=n.reduce((i,s)=>i+s,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(i=>`${i}%`).join(", ")}`);if(!Da(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];Lt(s!=null,`No layout data found for index ${i}`);const c=100/a*s;n[i]=c}let r=0;for(let i=0;i<t.length;i++){const s=n[i];Lt(s!=null,`No layout data found for index ${i}`);const c=Su({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Da(r,0))for(let i=0;i<t.length;i++){const s=n[i];Lt(s!=null,`No layout data found for index ${i}`);const c=s+r,u=Su({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Da(r,0)))break}return n}const STe=100,mp={getItem:e=>(V2(mp),mp.getItem(e)),setItem:(e,t)=>{V2(mp),mp.setItem(e,t)}},W2={};function lq({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=mp,style:f,tagName:m="div",...h}){const g=MD(i),v=y.useRef(null),[S,x]=y.useState(null),[w,E]=y.useState([]),_=cTe(),k=y.useRef({}),R=y.useRef(new Map),N=y.useRef(0),I=y.useRef({autoSaveId:e,direction:a,dragState:S,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),O=y.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});y.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),y.useImperativeHandle(r,()=>({getId:()=>I.current.id,getLayout:()=>{const{layout:P}=O.current;return P},setLayout:P=>{const{onLayout:$}=I.current,{layout:z,panelDataArray:G}=O.current,K=G2({layout:P,panelConstraints:G.map(re=>re.constraints)});H2(z,K)||(E(K),O.current.layout=K,$&&$(K),Qc(G,K,k.current))}}),[]),Fl(()=>{I.current.autoSaveId=e,I.current.direction=a,I.current.dragState=S,I.current.id=g,I.current.onLayout=s,I.current.storage=u}),mTe({committedValuesRef:I,eagerValuesRef:O,groupId:g,layout:w,panelDataArray:O.current.panelDataArray,setLayout:E,panelGroupElement:v.current}),y.useEffect(()=>{const{panelDataArray:P}=O.current;if(e){if(w.length===0||w.length!==P.length)return;let $=W2[e];$==null&&($=yTe(xTe,STe),W2[e]=$);const z=[...P],G=new Map(R.current);$(e,z,G,w,u)}},[e,w,u]),y.useEffect(()=>{});const A=y.useCallback(P=>{const{onLayout:$}=I.current,{layout:z,panelDataArray:G}=O.current;if(P.constraints.collapsible){const K=G.map(q=>q.constraints),{collapsedSize:re=0,panelSize:fe,pivotIndices:ce}=El(G,P,z);if(Lt(fe!=null,`Panel size not found for panel "${P.id}"`),!To(fe,re)){R.current.set(P.id,fe);const te=lu(G,P)===G.length-1?fe-re:re-fe,se=pp({delta:te,initialLayout:z,panelConstraints:K,pivotIndices:ce,prevLayout:z,trigger:"imperative-api"});Nb(z,se)||(E(se),O.current.layout=se,$&&$(se),Qc(G,se,k.current))}}},[]),M=y.useCallback((P,$)=>{const{onLayout:z}=I.current,{layout:G,panelDataArray:K}=O.current;if(P.constraints.collapsible){const re=K.map(de=>de.constraints),{collapsedSize:fe=0,panelSize:ce=0,minSize:q=0,pivotIndices:te}=El(K,P,G),se=$??q;if(To(ce,fe)){const de=R.current.get(P.id),ye=de!=null&&de>=se?de:se,Ge=lu(K,P)===K.length-1?ce-ye:ye-ce,Ie=pp({delta:Ge,initialLayout:G,panelConstraints:re,pivotIndices:te,prevLayout:G,trigger:"imperative-api"});Nb(G,Ie)||(E(Ie),O.current.layout=Ie,z&&z(Ie),Qc(K,Ie,k.current))}}},[]),j=y.useCallback(P=>{const{layout:$,panelDataArray:z}=O.current,{panelSize:G}=El(z,P,$);return Lt(G!=null,`Panel size not found for panel "${P.id}"`),G},[]),F=y.useCallback((P,$)=>{const{panelDataArray:z}=O.current,G=lu(z,P);return vTe({defaultSize:$,dragState:S,layout:w,panelData:z,panelIndex:G})},[S,w]),V=y.useCallback(P=>{const{layout:$,panelDataArray:z}=O.current,{collapsedSize:G=0,collapsible:K,panelSize:re}=El(z,P,$);return Lt(re!=null,`Panel size not found for panel "${P.id}"`),K===!0&&To(re,G)},[]),J=y.useCallback(P=>{const{layout:$,panelDataArray:z}=O.current,{collapsedSize:G=0,collapsible:K,panelSize:re}=El(z,P,$);return Lt(re!=null,`Panel size not found for panel "${P.id}"`),!K||tc(re,G)>0},[]),ee=y.useCallback(P=>{const{panelDataArray:$}=O.current;$.push(P),$.sort((z,G)=>{const K=z.order,re=G.order;return K==null&&re==null?0:K==null?-1:re==null?1:K-re}),O.current.panelDataArrayChanged=!0,_()},[_]);Fl(()=>{if(O.current.panelDataArrayChanged){O.current.panelDataArrayChanged=!1;const{autoSaveId:P,onLayout:$,storage:z}=I.current,{layout:G,panelDataArray:K}=O.current;let re=null;if(P){const ce=wTe(P,K,z);ce&&(R.current=new Map(Object.entries(ce.expandToSizes)),re=ce.layout)}re==null&&(re=bTe({panelDataArray:K}));const fe=G2({layout:re,panelConstraints:K.map(ce=>ce.constraints)});H2(G,fe)||(E(fe),O.current.layout=fe,$&&$(fe),Qc(K,fe,k.current))}}),Fl(()=>{const P=O.current;return()=>{P.layout=[]}},[]);const ie=y.useCallback(P=>{let $=!1;const z=v.current;return z&&window.getComputedStyle(z,null).getPropertyValue("direction")==="rtl"&&($=!0),function(K){K.preventDefault();const re=v.current;if(!re)return()=>null;const{direction:fe,dragState:ce,id:q,keyboardResizeBy:te,onLayout:se}=I.current,{layout:de,panelDataArray:ye}=O.current,{initialLayout:Te}=ce??{},Ge=nq(q,P,re);let Ie=gTe(K,P,fe,ce,te,re);const Me=fe==="horizontal";Me&&$&&(Ie=-Ie);const nt=ye.map(oe=>oe.constraints),Ue=pp({delta:Ie,initialLayout:Te??de,panelConstraints:nt,pivotIndices:Ge,prevLayout:de,trigger:WY(K)?"keyboard":"mouse-or-touch"}),pe=!Nb(de,Ue);(KY(K)||ZY(K))&&N.current!=Ie&&(N.current=Ie,!pe&&Ie!==0?Me?rE(P,Ie<0?qY:XY):rE(P,Ie<0?JY:QY):rE(P,0)),pe&&(E(Ue),O.current.layout=Ue,se&&se(Ue),Qc(ye,Ue,k.current))}},[]),W=y.useCallback((P,$)=>{const{onLayout:z}=I.current,{layout:G,panelDataArray:K}=O.current,re=K.map(de=>de.constraints),{panelSize:fe,pivotIndices:ce}=El(K,P,G);Lt(fe!=null,`Panel size not found for panel "${P.id}"`);const te=lu(K,P)===K.length-1?fe-$:$-fe,se=pp({delta:te,initialLayout:G,panelConstraints:re,pivotIndices:ce,prevLayout:G,trigger:"imperative-api"});Nb(G,se)||(E(se),O.current.layout=se,z&&z(se),Qc(K,se,k.current))},[]),Z=y.useCallback((P,$)=>{const{layout:z,panelDataArray:G}=O.current,{collapsedSize:K=0,collapsible:re}=$,{collapsedSize:fe=0,collapsible:ce,maxSize:q=100,minSize:te=0}=P.constraints,{panelSize:se}=El(G,P,z);se!=null&&(re&&ce&&To(se,K)?To(K,fe)||W(P,fe):se<te?W(P,te):se>q&&W(P,q))},[W]),H=y.useCallback((P,$)=>{const{direction:z}=I.current,{layout:G}=O.current;if(!v.current)return;const K=I0(P,v.current);Lt(K,`Drag handle element not found for id "${P}"`);const re=aq(z,$);x({dragHandleId:P,dragHandleRect:K.getBoundingClientRect(),initialCursorPosition:re,initialLayout:G})},[]),ae=y.useCallback(()=>{x(null)},[]),ne=y.useCallback(P=>{const{panelDataArray:$}=O.current,z=lu($,P);z>=0&&($.splice(z,1),delete k.current[P.id],O.current.panelDataArrayChanged=!0,_())},[_]),L=y.useMemo(()=>({collapsePanel:A,direction:a,dragState:S,expandPanel:M,getPanelSize:j,getPanelStyle:F,groupId:g,isPanelCollapsed:V,isPanelExpanded:J,reevaluatePanelConstraints:Z,registerPanel:ee,registerResizeHandle:ie,resizePanel:W,startDragging:H,stopDragging:ae,unregisterPanel:ne,panelGroupElement:v.current}),[A,S,a,M,j,F,g,V,J,Z,ee,ie,W,H,ae,ne]),B={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return y.createElement(N0.Provider,{value:L},y.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...B,...f},[Jn.group]:"",[Jn.groupDirection]:a,[Jn.groupId]:g}))}const cq=y.forwardRef((e,t)=>y.createElement(lq,{...e,forwardedRef:t}));lq.displayName="PanelGroup";cq.displayName="forwardRef(PanelGroup)";function lu(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function El(e,t,n){const a=lu(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function ETe({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){y.useEffect(()=>{if(e||n==null||a==null)return;const r=I0(t,a);if(r==null)return;const i=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),n(s);break}case"F6":{s.preventDefault();const c=r.getAttribute(Jn.groupId);Lt(c,`No group element found for id "${c}"`);const u=pm(c,a),f=tq(c,t,a);Lt(f!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?f>0?f-1:u.length-1:f+1<u.length?f+1:0;u[m].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[a,e,t,n])}function uq({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:f,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...S}){var x,w;const E=y.useRef(null),_=y.useRef({onClick:s,onDragging:c,onPointerDown:f,onPointerUp:m});y.useEffect(()=>{_.current.onClick=s,_.current.onDragging=c,_.current.onPointerDown=f,_.current.onPointerUp=m});const k=y.useContext(N0);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:R,groupId:N,registerResizeHandle:I,startDragging:O,stopDragging:A,panelGroupElement:M}=k,j=MD(r),[F,V]=y.useState("inactive"),[J,ee]=y.useState(!1),[ie,W]=y.useState(null),Z=y.useRef({state:F});Fl(()=>{Z.current.state=F}),y.useEffect(()=>{if(n)W(null);else{const L=I(j);W(()=>L)}},[n,j,I]);const H=(x=a?.coarse)!==null&&x!==void 0?x:15,ae=(w=a?.fine)!==null&&w!==void 0?w:5;y.useEffect(()=>{if(n||ie==null)return;const L=E.current;Lt(L,"Element ref not attached");let B=!1;return sTe(j,L,R,{coarse:H,fine:ae},($,z,G)=>{if(!z){V("inactive");return}switch($){case"down":{V("drag"),B=!1,Lt(G,'Expected event to be defined for "down" action'),O(j,G);const{onDragging:K,onPointerDown:re}=_.current;K?.(!0),re?.();break}case"move":{const{state:K}=Z.current;B=!0,K!=="drag"&&V("hover"),Lt(G,'Expected event to be defined for "move" action'),ie(G);break}case"up":{V("hover"),A();const{onClick:K,onDragging:re,onPointerUp:fe}=_.current;re?.(!1),fe?.(),B||K?.();break}}})},[H,R,n,ae,I,j,ie,O,A]),ETe({disabled:n,handleId:j,resizeHandler:ie,panelGroupElement:M});const ne={touchAction:"none",userSelect:"none"};return y.createElement(v,{...S,children:e,className:t,id:r,onBlur:()=>{ee(!1),i?.()},onFocus:()=>{ee(!0),u?.()},ref:E,role:"separator",style:{...ne,...h},tabIndex:g,[Jn.groupDirection]:R,[Jn.groupId]:N,[Jn.resizeHandle]:"",[Jn.resizeHandleActive]:F==="drag"?"pointer":J?"keyboard":void 0,[Jn.resizeHandleEnabled]:!n,[Jn.resizeHandleId]:j,[Jn.resizeHandleState]:F})}uq.displayName="PanelResizeHandle";function sa({className:e,...t}){return d.jsx(cq,{"data-slot":"resizable-panel-group",className:Le("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function On({...e}){return d.jsx(GY,{"data-slot":"resizable-panel",...e})}function wi({withHandle:e,className:t,...n}){return d.jsx(uq,{"data-slot":"resizable-handle",className:Le("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&&d.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:d.jsx(Ype,{className:"size-2.5"})})})}function oh({className:e,...t}){return d.jsx("kbd",{"data-slot":"kbd",className:Le("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 _Te({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Nn,{ref:u,placeholder:"Search notifications...",value:t,onChange:f=>i(f.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),d.jsx(vr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(zd,{className:"h-4 w-4"})})}),d.jsxs(Rt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(oh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(zo,{className:"h-4 w-4"})})}),d.jsx(Rt,{side:"bottom",children:"Clear all"})]})})]})}function Qs({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return d.jsx("button",{id:e,type:"button",onClick:c,className:Le("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",u),children:d.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[a&&d.jsx("div",{className:"flex-shrink-0 mt-1",children:d.jsx("div",{className:Le("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:a})}),d.jsxs("div",{className:"flex-1 min-w-0",children:[d.jsx("div",{className:"flex items-center gap-2 mb-1",children:d.jsx("h3",{className:Le("font-medium truncate font-mono text-sm"),children:r})}),i&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function kTe({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Pd,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>d.jsx(Qs,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=r(s.timestamp),f=s.params&&Object.keys(s.params).length>0?Object.keys(s.params).length:0,m=f>0?` | ${f} param${f>1?"s":""}`:"";return u+m})(),onClick:()=>n(s)},s.id))})}function TTe({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.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:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Hp,{className:"h-3 w-3 text-gray-400"}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsxs(Oe,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?d.jsx(lC,{className:"h-4 w-4 mr-1"}):d.jsx(UG,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:a,children:s?d.jsx(zr,{className:"h-4 w-4"}):d.jsx(br,{className:"h-4 w-4"})}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,children:d.jsx(zm,{className:"h-4 w-4"})}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:i,children:d.jsx(Gp,{className:"h-4 w-4"})}),c&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,children:d.jsx(Qi,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto",children:d.jsx("div",{className:"px-4 pt-4",children:d.jsx(Qn,{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`})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(sC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function ay(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<60?"just now":r<60?`${r}m ago`:i<24?`${i}h ago`:s<7?`${s}d ago`:new Date(e).toLocaleDateString()}function NTe({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,S]=y.useState(!0),[x,w]=y.useState(!1),[E,_]=y.useState(!0),[k,R]=y.useState(!1),N=y.useRef(null),I=y.useRef(null),O=y.useRef(null),A=y.useRef(!1);y.useEffect(()=>{v&&e.length>0&&N.current&&!A.current&&(N.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const Z=N.current;if(!Z)return;const H=()=>{Z.scrollTop>0&&(A.current=!0,S(!1))};return Z.addEventListener("scroll",H),()=>Z.removeEventListener("scroll",H)},[]),y.useEffect(()=>{e.length===0&&(A.current=!1,S(!0))},[e.length]),y.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),y.useEffect(()=>{x&&O.current&&O.current.focus()},[x]);const M=y.useCallback(()=>{f.trim()||w(!1)},[f]),j=y.useMemo(()=>{if(!f.trim())return e;const Z=f.toLowerCase();return e.filter(H=>H.method.toLowerCase().includes(Z)||JSON.stringify(H.params||{}).toLowerCase().includes(Z))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const Z=H=>{const ae=H.target;if(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.contentEditable==="true"||H.metaKey||H.ctrlKey||H.altKey)return;const L=j;if(H.key==="ArrowDown")H.preventDefault(),g(B=>{const P=B+1;return P>=L.length?0:P});else if(H.key==="ArrowUp")H.preventDefault(),g(B=>{const P=B-1;return P<0?L.length-1:P});else if(H.key==="Enter"&&h>=0){H.preventDefault();const B=j[h];B&&F(B)}};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[h,j]),y.useEffect(()=>{if(h>=0){const Z=`notification-${j[h]?.id}`,H=document.getElementById(Z);H&&H.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,j]);const F=y.useCallback(Z=>{u(Z)},[]),V=y.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),J=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(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[c]),ee=y.useCallback(()=>{if(c)try{const Z=new globalThis.Blob([JSON.stringify({method:c.method,timestamp:c.timestamp,read:c.read,params:c.params},null,2)],{type:"application/json"}),H=URL.createObjectURL(Z),ae=document.createElement("a");ae.href=H,ae.download=`notification-${Date.now()}.json`,document.body.appendChild(ae),ae.click(),document.body.removeChild(ae),URL.revokeObjectURL(H)}catch(Z){console.error("[NotificationsTab] Failed to download notification:",Z)}},[c]),ie=y.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(Z){console.error("[NotificationsTab] Failed to toggle fullscreen:",Z)}},[]),W=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:ay}:null;return s?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(On,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(On,{defaultSize:75,minSize:30,children:[d.jsx(_Te,{isSearchExpanded:x,searchQuery:f,filteredNotificationsCount:j.length,notificationsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onClearAll:V,searchInputRef:O}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(kTe,{notifications:j,selectedNotification:c,onNotificationSelect:F,focusedIndex:h,formatRelativeTime:ay,listRef:N})})]})})}),d.jsx(wi,{}),d.jsx(On,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(TTe,{notification:W,previewMode:E,onTogglePreview:()=>_(!E),onCopy:J,onDownload:ee,onFullscreen:ie,onClose:()=>u(null),isCopied:k})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(sC,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function zD({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=y.useState([]),i=y.useRef(null),[s,c]=y.useState(new Set),[u]=y.useState(""),f=v=>{c(S=>{const x=new Set(S);return x.has(v)?x.delete(v):x.add(v),x})},m=async()=>{r([]),c(new Set),t?.(0),e&&e.length>0?e.forEach(v=>Sv(v)):Sv()},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?.(a.length)},[a.length,t]),y.useEffect(()=>{console.log("[RPC Logger] Subscribing to RPC logs for servers:",e);const v=$N(),x=(e&&e.length>0?v.filter(E=>e.includes(E.serverId)):v).map(E=>{const _=E.message,k=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown";return{id:`${E.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:E.serverId,direction:E.direction.toUpperCase(),method:k,timestamp:E.timestamp,payload:E.message}}).reverse();r(x),t?.(x.length);const w=MN(E=>{if(e&&e.length>0&&!e.includes(E.serverId))return;const _=E.message,k=typeof _?.method=="string"?_.method:_?.result!==void 0?"result":_?.error!==void 0?"error":"unknown",R={id:`${E.timestamp}-${Math.random().toString(36).slice(2)}`,serverId:E.serverId,direction:E.direction.toUpperCase(),method:k,timestamp:E.timestamp,payload:E.message};console.log("[RPC Logger] New RPC log:",{method:k,direction:E.direction,serverId:E.serverId}),r(N=>{const I=[R,...N].slice(0,1e3);return t?.(I.length),I})});return()=>{w(),console.log("[RPC Logger] Unsubscribed from RPC logs")}},[h,t]);const g=y.useMemo(()=>{let v=a;if(e&&e.length>0){const S=new Set(e);v=v.filter(x=>S.has(x.serverId))}if(u.trim()){const S=u.toLowerCase();v=v.filter(x=>x.serverId.toLowerCase().includes(S)||x.method.toLowerCase().includes(S)||x.direction.toLowerCase().includes(S)||JSON.stringify(x.payload).toLowerCase().includes(S))}return v=[...v].sort((S,x)=>new Date(x.timestamp).getTime()-new Date(S.timestamp).getTime()),v},[a,u,e]);return d.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:d.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?d.jsxs("div",{className:"text-center py-8",children:[d.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),d.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const S=s.has(v.id);return d.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[d.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:[d.jsx("div",{className:"flex-shrink-0",children:S?d.jsx(Po,{className:"h-3 w-3 text-muted-foreground transition-transform"}):d.jsx(FG,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),d.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[d.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),d.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"?d.jsx(ipe,{className:"h-3 w-3"}):d.jsx(spe,{className:"h-3 w-3"})}),d.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),S&&d.jsx("div",{className:"border-t bg-muted/20",children:d.jsx("div",{className:"p-3",children:d.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:d.jsx(Qn,{data:v.payload})})})})]},v.id)})})})}function dq({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:f="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:S,primaryTabName:x}){const w=e===x;return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?d.jsx(Nn,{ref:S,placeholder:f,value:n,onChange:E=>h(E.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:w?a:r}),w&&d.jsxs(d.Fragment,{children:[d.jsx(vr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:d.jsx(zd,{className:"h-4 w-4"})})}),d.jsxs(Rt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(oh,{children:"F"})]})]})]})]})}),d.jsxs(Oe,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[w?d.jsx(c,{}):d.jsx(u,{}),d.jsx("span",{className:"hidden sm:inline",children:w?r:a}),w&&s>0&&d.jsx(vr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function K2({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:a}){return e.length===0?d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(Wp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):d.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((r,i)=>d.jsx(Qs,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:d.jsx(Wp,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&d.jsxs(vr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[r.arguments.length," args"]}),onClick:()=>n(r)},r.name))})}function Z2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:f}){return d.jsx(dq,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:Wp,secondaryIcon:Hp,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:f})}function Y2({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,focusedIndex:r}){return e.length===0?d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(Hp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),d.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):d.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,s)=>d.jsx(Qs,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:d.jsx(Hp,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function CTe({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.length>0))return d.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No arguments required"});const i=s=>{const c=s.name,u=t[c],f=typeof u=="string"?u:JSON.stringify(u);return s.type==="boolean"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx("input",{id:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),d.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Nn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Ql,{id:c,value:f,onChange:m=>{try{const h=JSON.parse(m.target.value);n(c,h)}catch{n(c,m.target.value)}},placeholder:s.description||`Enter ${c} as JSON`,className:"font-mono text-sm min-h-[100px]"}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),d.jsx(Nn,{id:c,value:f,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&d.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return d.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function q2({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return y.useEffect(()=>{const c=u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&e&&!n&&a&&(u.preventDefault(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[e,n,a,i]),e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:d.jsxs("div",{children:[d.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[d.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),d.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[d.jsx(Oe,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?d.jsxs(d.Fragment,{children:[d.jsx(Yi,{className:"mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):d.jsxs(d.Fragment,{children:[d.jsx(WG,{className:"h-4 w-4 sm:mr-2"}),d.jsx("span",{className:"hidden sm:inline",children:"Execute"}),d.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:"⌘↵"})]})}),d.jsxs(Oe,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[d.jsx(dC,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&d.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),d.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:d.jsx(CTe,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),d.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 RTe(e){switch(e){case"system":return"default";case"user":return"outline";case"assistant":return"secondary";default:return"outline"}}function ATe(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ITe(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 OTe({message:e,index:t}){const[n,a]=y.useState(!1),r=async()=>{const s=ITe(e.content);await navigator.clipboard.writeText(s),a(!0),setTimeout(()=>a(!1),2e3)},i=()=>{const s=e.content;return typeof s=="string"?d.jsx(Jb,{content:s}):s.type==="text"&&s.text?d.jsx(Jb,{content:s.text}):s.type==="image"?d.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d.jsxs("span",{className:"font-mono bg-muted px-2 py-1 rounded",children:["Image: ",s.mimeType||"unknown type"]}),s.data&&d.jsx("img",{src:`data:${s.mimeType};base64,${s.data}`,alt:"Prompt image",className:"max-w-full max-h-[300px] object-contain rounded-lg border border-border mt-2"})]}):s.type==="resource"&&s.resource?d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[d.jsx("span",{className:"text-muted-foreground font-medium",children:"Resource:"}),d.jsx("code",{className:"bg-muted px-2 py-0.5 rounded text-xs font-mono",children:s.resource.uri})]}),s.resource.text&&d.jsx("div",{className:"mt-2",children:d.jsx(Jb,{content:s.resource.text})})]}):d.jsx("pre",{className:"bg-muted p-3 rounded-lg text-sm overflow-x-auto",children:d.jsx("code",{children:JSON.stringify(s,null,2)})})};return d.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[d.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-muted/30 border-b border-border",children:[d.jsx(vr,{variant:RTe(e.role),children:ATe(e.role)}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,className:"h-6 px-2",title:"Copy message content",children:n?d.jsx(zr,{className:"h-3.5 w-3.5"}):d.jsx(br,{className:"h-3.5 w-3.5"})})]}),d.jsx("div",{className:"px-4 py-3",children:i()})]})}function DTe(e){const n=Date.now()-e,a=Math.floor(n/1e3),r=Math.floor(a/60),i=Math.floor(r/60),s=Math.floor(i/24);return a<10?"now":a<60?`${a}s ago`:r<60?`${r}m ago`:i<24?`${i}h ago`:`${s}d ago`}function jTe(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 X2({results:e,copiedResult:t,previewMode:n=!0,onCopy:a,onDelete:r,onFullscreen:i,onTogglePreview:s,onMaximize:c,isMaximized:u=!1}){const[f,m]=y.useState(0),[h,g]=y.useState(""),[v,S]=y.useState(!0),x=e[0],w=x?e.filter(N=>N.promptName===x.promptName):[],E=w[f]||w[0],_=e.findIndex(N=>N===E);if(y.useEffect(()=>{w.length>0&&f>=w.length&&m(0)},[w.length,f]),y.useEffect(()=>{const N=()=>{E&&g(DTe(E.timestamp))};N();const I=setInterval(N,1e3);return()=>clearInterval(I)},[E]),e.length===0)return d.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:d.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:d.jsx("div",{className:"flex items-center justify-center h-full",children:d.jsx("div",{className:"text-center",children:d.jsx(Pd,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const k=E.error||jTe(E.result),R="messages"in E.result&&Array.isArray(E.result.messages);return d.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:d.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:d.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[d.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[d.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),E.duration!==void 0&&d.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[d.jsx(Kp,{className:"h-3 w-3 text-gray-400"}),d.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[E.duration,"ms"]})]}),R&&d.jsx("div",{className:"flex items-center gap-4 sm:ml-4",children:d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:()=>S(!0),className:`text-xs font-medium ${v?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),d.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),d.jsx("button",{onClick:()=>S(!1),className:`text-xs font-medium ${v?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]})}),d.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[w.length>1&&d.jsxs("div",{className:"flex items-center gap-2 mr-2",children:[d.jsx(Vp,{className:"h-3 w-3 text-gray-400"}),d.jsxs(Ao,{value:f.toString(),onValueChange:N=>m(parseInt(N)),children:[d.jsx(Oo,{className:"h-7 w-[120px] text-xs",children:d.jsx(Io,{})}),d.jsx(Do,{children:w.map((N,I)=>d.jsx(Kr,{value:I.toString(),children:I===0?"Latest":`${I+1} call ago`},I))})]})]}),d.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 mr-2",children:h}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>a(_,E.result),className:"h-7 w-7 p-0",title:"Copy result",children:t===_?d.jsx(zr,{className:"h-4 w-4"}):d.jsx(br,{className:"h-4 w-4"})}),r&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>r(_),className:"h-7 w-7 p-0",title:"Delete result",children:d.jsx(zo,{className:"h-4 w-4"})}),i&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>i(_),className:"h-7 w-7 p-0 sm:hidden",title:"Fullscreen",children:d.jsx(Gp,{className:"h-4 w-4"})}),c&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,className:"h-7 w-7 p-0 hidden sm:flex",title:u?"Restore":"Maximize",children:u?d.jsx(GG,{className:"h-4 w-4"}):d.jsx(Gp,{className:"h-4 w-4"})})]})]}),d.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:k?d.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[d.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),d.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:k})]}):v&&R?d.jsx("div",{className:"space-y-3",children:E.result.messages.map((N,I)=>d.jsx(OTe,{message:N,index:I},I))}):d.jsx(Qn,{data:E.result,filename:`prompt-result-${E.promptName}-${Date.now()}.json`})})]})})})}const J2="mcp-inspector-saved-prompts";function fq({ref:e,prompts:t,callPrompt:n,serverId:a,isConnected:r}){const[i,s]=y.useState(null),[c,u]=y.useState(null),{selectedPromptName:f,setSelectedPromptName:m}=cc(),[h,g]=y.useState({}),[v,S]=y.useState([]),[x,w]=y.useState(!1),[E,_]=y.useState(null),[k,R]=y.useState(""),[N,I]=y.useState("prompts"),[O,A]=y.useState([]),[M,j]=y.useState(!1),[F,V]=y.useState(""),[J,ee]=y.useState(!1),[ie,W]=y.useState(-1),Z=y.useRef(null),[H,ae]=y.useState(!1),[ne,L]=y.useState("list"),[B,P]=y.useState(0),[$,z]=y.useState(!0),[G,K]=y.useState(!1),re=y.useRef(null),fe=y.useRef(null),ce=y.useRef(null),q=y.useRef(null);y.useEffect(()=>{const Ee=()=>{ae(window.innerWidth<1024)};return Ee(),window.addEventListener("resize",Ee),()=>window.removeEventListener("resize",Ee)},[]),y.useEffect(()=>{L(i?"detail":"list")},[i]),y.useEffect(()=>{H&&v.length>0&&!x&&L("response")},[v,x,H]),y.useImperativeHandle(e,()=>({focusSearch:()=>{ee(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{R(""),ee(!1),Z.current&&Z.current.blur()}})),y.useEffect(()=>{try{const Ee=localStorage.getItem(J2);if(Ee){const je=JSON.parse(Ee);A(je)}}catch(Ee){console.error("[PromptsTab] Failed to load saved prompts:",Ee)}},[]);const te=y.useCallback(Ee=>{try{localStorage.setItem(J2,JSON.stringify(Ee))}catch(je){console.error("[PromptsTab] Failed to save prompts:",je)}},[]);y.useEffect(()=>{J&&Z.current&&Z.current.focus()},[J]);const se=y.useCallback(()=>{k.trim()||ee(!1)},[k]),de=y.useMemo(()=>{if(!k.trim())return t;const Ee=k.toLowerCase();return t.filter(je=>je.name.toLowerCase().includes(Ee)||je.description?.toLowerCase().includes(Ee))},[t,k]),ye=y.useCallback(Ee=>{s(Ee);const je={};Ee.arguments&&Ee.arguments.forEach(We=>{je[We.name]=""}),g(je)},[]),Te=y.useCallback(Ee=>{const je=t.find(We=>We.name===Ee.promptName);je&&(s(je),g(Ee.args),u(Ee))},[t]);y.useEffect(()=>{W(-1)},[k,N]),y.useEffect(()=>{const Ee=je=>{const We=je.target;if(We.tagName==="INPUT"||We.tagName==="TEXTAREA"||We.contentEditable==="true"||je.metaKey||je.ctrlKey||je.altKey)return;const ot=N==="prompts"?de:O;if(je.key==="ArrowDown")je.preventDefault(),W(kt=>{const Ln=kt+1;return Ln>=ot.length?0:Ln});else if(je.key==="ArrowUp")je.preventDefault(),W(kt=>{const Ln=kt-1;return Ln<0?ot.length-1:Ln});else if(je.key==="Enter"&&ie>=0)if(je.preventDefault(),N==="prompts"){const kt=de[ie];kt&&ye(kt)}else{const kt=O[ie];kt&&Te(kt)}};return document.addEventListener("keydown",Ee),()=>document.removeEventListener("keydown",Ee)},[ie,de,O,N,ye,Te]),y.useEffect(()=>{if(ie>=0){const Ee=N==="prompts"?`prompt-${de[ie]?.name}`:`saved-prompt-${O[ie]?.id}`,je=document.getElementById(Ee);je&&je.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ie,de,O,N]),y.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:f,promptsCount:t.length,currentSelectedPrompt:i?.name}),f&&t.length>0){const Ee=t.find(je=>je.name===f);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:f,promptFound:!!Ee,promptName:Ee?.name,shouldSelect:Ee&&i?.name!==Ee.name}),Ee&&i?.name!==Ee.name){console.warn("[PromptsTab] Selecting prompt:",Ee.name),m(null);const je=setTimeout(()=>{ye(Ee);const We=document.getElementById(`prompt-${Ee.name}`);We&&(console.warn("[PromptsTab] Scrolling to prompt element"),We.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(je)}}},[f,t,i,ye,m]);const Ge=y.useCallback((Ee,je)=>{g(We=>({...We,[Ee]:je}))},[]),Ie=y.useCallback(async()=>{if(!i||x)return;w(!0);const Ee=Date.now();try{const je=await n(i.name,h),We=Date.now()-Ee;$r.getInstance().capture(new lU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),S(ot=>[{promptName:i.name,args:h,result:je,timestamp:Ee,duration:We},...ot])}catch(je){$r.getInstance().capture(new lU({promptName:i.name,serverId:a,success:!1,error:je instanceof Error?je.message:"Unknown error"})).catch(()=>{});const Ye={promptName:i.name,args:h,result:null,error:je instanceof Error?je.message:String(je),timestamp:Ee,duration:Date.now()-Ee};S(ot=>[...ot,{...Ye,result:{messages:[]}}])}finally{w(!1)}},[i,h,x,n,a]),Me=y.useCallback(async(Ee,je)=>{try{await navigator.clipboard.writeText(JSON.stringify(je,null,2)),_(Ee),setTimeout(()=>_(null),2e3)}catch(We){console.error("[PromptsTab] Failed to copy result:",We)}},[]),nt=y.useCallback(Ee=>{S(je=>je.filter((We,Ye)=>Ye!==Ee))},[]),Ue=y.useCallback(Ee=>{if(H)L("response");else{const je=v[Ee];if(je){const We=window.open("","_blank","width=800,height=600");if(We){const Ye=je.result;We.document.write(`
1724
1724
  <html>
1725
1725
  <head>
1726
1726
  <title>${je.promptName} Result</title>
@@ -1750,4 +1750,4 @@ Example: https://${e.url}`}y.useEffect(()=>{s&&n(s)},[s,n]);const c=LN({url:s?vo
1750
1750
  <pre>${JSON.stringify(Fe.result,null,2)}</pre>
1751
1751
  </body>
1752
1752
  </html>
1753
- `),Ze.document.close())}},[S]),Ln=y.useCallback(()=>{K?(ye.current&&ye.current.expand(),Te.current&&Te.current.expand(),re(!1)):(ye.current&&ye.current.collapse(),Te.current&&Te.current.collapse(),re(!0))},[K]),pt=y.useCallback(()=>{s&&(ie(""),J(!0))},[s]),Zn=y.useCallback(()=>{if(!s)return;const He={id:`${Date.now()}-${Math.random()}`,name:ee.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};nt([...j,He]),$r.getInstance().capture(new Xfe({toolName:s.name,serverId:r})).catch(()=>{}),J(!1),ie("")},[s,ee,g,j,nt,r]),sn=y.useCallback(He=>{nt(j.filter(Fe=>Fe.id!==He)),u?.id===He&&f(null)},[j,nt,u]);return P?d.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[z!=="list"&&d.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[d.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{z==="response"?G("detail"):(c(null),G("list"))},className:"p-0 h-8 w-8",children:d.jsx(Xy,{className:"h-4 w-4"})}),d.jsxs("div",{className:"flex items-center text-sm font-medium",children:[d.jsx("button",{onClick:()=>{c(null),G("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),z==="detail"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("button",{onClick:()=>{G("response")},className:z==="detail"?"text-foreground hover:underline":z==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),z==="response"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),d.jsx("div",{className:"flex-1 relative overflow-hidden",children:d.jsxs(g0,{initial:!1,mode:"popLayout",children:[z==="list"&&d.jsxs(xa.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:[d.jsx(cF,{activeTab:A,isSearchExpanded:H,searchQuery:I,filteredToolsCount:Ue.length,savedRequestsCount:j.length,onSearchExpand:()=>ae(!0),onSearchChange:O,onSearchBlur:xe,onTabSwitch:()=>M(A==="tools"?"saved":"tools"),searchInputRef:B}),A==="tools"?d.jsx(lF,{tools:Ue,selectedTool:s,onToolSelect:pe,focusedIndex:ne}):d.jsx(nF,{savedRequests:j,selectedRequest:u,onLoadRequest:oe,onDeleteRequest:sn,focusedIndex:ne})]},"list"),z==="detail"&&d.jsx(xa.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:d.jsx(iF,{selectedTool:s,toolArgs:g,isExecuting:w,isConnected:i,onArgChange:Ee,onExecute:je,onSave:pt})},"detail"),z==="response"&&d.jsx(xa.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:d.jsx(sF,{results:ot,copiedResult:_,previewMode:W,serverId:r,readResource:a,onCopy:We,onDelete:Ye,onFullscreen:kt,onTogglePreview:()=>Z(!W)})},"response")]})}),d.jsx(rF,{isOpen:V,requestName:ee,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ie,onSave:Zn,onCancel:()=>J(!1)})]}):d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(On,{ref:ye,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:d.jsxs(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[d.jsx(On,{defaultSize:75,minSize:30,children:d.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[d.jsx(cF,{activeTab:A,isSearchExpanded:H,searchQuery:I,filteredToolsCount:Ue.length,savedRequestsCount:j.length,onSearchExpand:()=>ae(!0),onSearchChange:O,onSearchBlur:xe,onTabSwitch:()=>M(A==="tools"?"saved":"tools"),searchInputRef:B}),A==="tools"?d.jsx(lF,{tools:Ue,selectedTool:s,onToolSelect:pe,focusedIndex:ne}):d.jsx(nF,{savedRequests:j,selectedRequest:u,onLoadRequest:oe,onDeleteRequest:sn,focusedIndex:ne})]})}),d.jsx(wi,{withHandle:!0}),d.jsxs(On,{ref:Ie,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,style:{minHeight:45},onCollapse:()=>{te(!0)},onExpand:()=>{te(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[d.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:He=>{He.preventDefault(),He.stopPropagation(),q?(Ie.current?.resize(25),te(!1)):(Ie.current?.resize(5),te(!0))},children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),fe>0&&d.jsx(vr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:fe}),fe>0&&!q&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:He=>{He.preventDefault(),He.stopPropagation(),Me.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:d.jsx(zo,{className:"h-3.5 w-3.5"})})]}),d.jsx(Po,{className:`h-4 w-4 text-muted-foreground transition-transform ${q?"":"rotate-180"}`})]}),d.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${q?"hidden":""}`,children:d.jsx(zD,{serverIds:[r],onCountChange:ce,onClearRef:Me})})]})]})}),d.jsx(wi,{withHandle:!0}),d.jsx(On,{defaultSize:67,children:d.jsxs(sa,{direction:"vertical",children:[d.jsx(On,{ref:Te,defaultSize:40,collapsible:!0,children:d.jsx(iF,{selectedTool:s,toolArgs:g,isExecuting:w,isConnected:i,onArgChange:Ee,onExecute:je,onSave:pt,onCancel:()=>{R&&R.abort()}})}),d.jsx(wi,{withHandle:!0}),d.jsx(On,{ref:Ge,defaultSize:60,children:d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(sF,{results:ot,copiedResult:_,previewMode:W,serverId:r,readResource:a,onCopy:We,onDelete:Ye,onFullscreen:kt,onTogglePreview:()=>Z(!W),onMaximize:Ln,isMaximized:K})})})]})}),d.jsx(rF,{isOpen:V,requestName:ee,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ie,onSave:Zn,onCancel:()=>J(!1)})]})}gq.displayName="ToolsTab";function HTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Nn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>i(f.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),d.jsx(vr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(zd,{className:"h-4 w-4"})})}),d.jsxs(Rt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(oh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(zo,{className:"h-4 w-4"})})}),d.jsx(Rt,{side:"bottom",children:"Reject all"})]})})]})}function VTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Pd,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.params?.messages?.length||0,f=s.request.params?.maxTokens;return d.jsx(Qs,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=r(s.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),f&&h.push(`max ${f} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function GTe({llmConfig:e}){const t=y.useRef(null);return{generateResponse:y.useCallback(async({request:a})=>{if(!e)throw new Error("LLM config is not available");const r=a.params||{},i=r.maxTokens,s=r.temperature;r.modelPreferences;const c=r.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!r,messagesCount:c.length,messages:c,params:r}),c.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:f,AIMessage:m}=await ia(async()=>{const{HumanMessage:S,AIMessage:x}=await import("./index-B66nJ4Ui.js").then(w=>w.bI);return{HumanMessage:S,AIMessage:x}},[]);for(const S of c){if(!S||!S.role){console.warn("Skipping invalid message:",S);continue}const x=Array.isArray(S.content)?S.content[0]:S.content;if(!x){console.warn("Skipping message with no content:",S);continue}x.type==="text"&&x.text?S.role==="user"?u.push(new f(x.text)):S.role==="assistant"&&u.push(new m(x.text)):console.warn("Skipping message with unsupported content type:",x)}if(u.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 S;const x={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(x.maxTokens=i),s!==void 0?x.temperature=s:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:w}=await ia(async()=>{const{ChatOpenAI:E}=await import("./index-BHWuEnDp.js");return{ChatOpenAI:E}},__vite__mapDeps([0,1,2,3,4,5]));S=new w(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:w}=await ia(async()=>{const{ChatAnthropic:E}=await import("./index-CZ1ZJ4DA.js");return{ChatAnthropic:E}},__vite__mapDeps([6,2,1,5]));S=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await ia(async()=>{const{ChatGoogleGenerativeAI:E}=await import("./index-CEc6a116.js");return{ChatGoogleGenerativeAI:E}},__vite__mapDeps([7,2,1,4]));S=new w(x)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:S,provider:e.provider,model:e.model,apiKey:e.apiKey}}const h=await t.current.instance.invoke(u);return{role:"assistant",content:{type:"text",text:h.content||h.text||""},model:e.model,stopReason:"endTurn"}},[e]),isAvailable:e!==null}}function WTe({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:f,llmConfig:m}){const[h,g]=y.useState("manual"),[v,S]=y.useState("stub-model"),[x,w]=y.useState("endTurn"),[E,_]=y.useState("assistant"),[k,R]=y.useState("text"),[N,I]=y.useState("positive"),[O,A]=y.useState(""),[M,j]=y.useState("image/png"),[F,V]=y.useState(!1),[J,ee]=y.useState(null),{generateResponse:ie,isAvailable:W}=GTe({llmConfig:m});y.useEffect(()=>{e&&(S("stub-model"),w("endTurn"),_("assistant"),R("text"),I("positive"),A(""),j("image/png"),ee(null))},[e?.id]);const Z=async()=>{if(!(!e||!W)){V(!0),ee(null);try{const L=await ie({request:e.request});S(L.model||m?.model||"stub-model"),w(L.stopReason||"endTurn"),_(L.role||"assistant");const B=Array.isArray(L.content)?L.content[0]:L.content;B.type==="text"?(R("text"),I(B.text||"")):B.type==="image"&&(R("image"),A(B.data||""),j(B.mimeType||"image/png"))}catch(L){const B=L instanceof Error?L.message:"Failed to generate response";ee(B),st.error("LLM Generation Failed",{description:B})}finally{V(!1)}}},H=y.useMemo(()=>{const L={model:v,stopReason:x,role:E,content:{type:k}};return k==="text"?L.content.text=N:k==="image"&&(L.content.data=O,L.content.mimeType=M),L},[v,x,E,k,N,O,M]),ae=()=>{if(!e)return;const L=_N.safeParse(H);if(!L.success){st.error("Invalid response",{description:`Validation failed: ${L.error.message}`});return}t(e.id,L.data),a(),ia(()=>Promise.resolve().then(()=>Rd),void 0).then(B=>{const P=st(B.createElement("div",{className:"space-y-3"},B.createElement("div",null,B.createElement("strong",null,"Sampling Response Sent"),B.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),B.createElement("div",{className:"flex gap-2"},B.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const $=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent($),st.dismiss(P)}},"View Tool Result"))),{duration:5e3})})},ne=()=>{e&&(n(e.id,"User rejected sampling request"),a())};return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),d.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?d.jsx(zr,{className:"h-4 w-4 text-green-600"}):d.jsx(br,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Copy request"})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(zm,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Download request"})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(uC,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Fullscreen"})]}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(Qi,{className:"h-4 w-4"})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),d.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:d.jsx(Qn,{data:e.request})})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(tn,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),d.jsxs(Ao,{value:h,onValueChange:L=>g(L),children:[d.jsx(Oo,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:d.jsx(Io,{})}),d.jsxs(Do,{children:[d.jsx(Kr,{value:"manual",children:"Manual"}),d.jsx(Kr,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&d.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[W?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Oe,{onClick:Z,disabled:F,size:"sm",className:"flex items-center gap-2",children:F?d.jsxs(d.Fragment,{children:[d.jsx(Fs,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):d.jsxs(d.Fragment,{children:[d.jsx(_me,{className:"h-4 w-4"}),"Generate with LLM"]})}),d.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):d.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),J&&d.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:J})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`model-${e.id}`,children:"Model"}),d.jsx(Nn,{id:`model-${e.id}`,value:v,onChange:L=>S(L.target.value),placeholder:"stub-model",disabled:h==="llm"&&F})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),d.jsx(Nn,{id:`stopReason-${e.id}`,value:x,onChange:L=>w(L.target.value),placeholder:"endTurn",disabled:h==="llm"&&F})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`role-${e.id}`,children:"Role"}),d.jsxs(Ao,{value:E,onValueChange:L=>_(L),disabled:h==="llm"&&F,children:[d.jsx(Oo,{id:`role-${e.id}`,children:d.jsx(Io,{})}),d.jsxs(Do,{children:[d.jsx(Kr,{value:"assistant",children:"assistant"}),d.jsx(Kr,{value:"user",children:"user"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),d.jsxs(Ao,{value:k,onValueChange:L=>R(L),disabled:h==="llm"&&F,children:[d.jsx(Oo,{id:`contentType-${e.id}`,children:d.jsx(Io,{})}),d.jsxs(Do,{children:[d.jsx(Kr,{value:"text",children:"text"}),d.jsx(Kr,{value:"image",children:"image"})]})]})]}),k==="text"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`text-${e.id}`,children:"Text Content"}),d.jsx(Ql,{id:`text-${e.id}`,value:N,onChange:L=>I(L.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&F})]}),k==="image"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),d.jsx(Ql,{id:`imageData-${e.id}`,value:O,onChange:L=>A(L.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&F})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),d.jsx(Nn,{id:`mimeType-${e.id}`,value:M,onChange:L=>j(L.target.value),placeholder:"image/png",disabled:h==="llm"&&F})]})]})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Oe,{onClick:ae,className:"flex-1",disabled:h==="llm"&&F,children:"Approve"}),d.jsx(Oe,{onClick:ne,variant:"outline",className:"flex-1",disabled:h==="llm"&&F,children:"Reject"})]})]}):d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}const KTe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function ZTe({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){return d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Sampling Request Received"}),d.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),n()},children:"View Details"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),a(KTe)},children:"Approve"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),r()},children:"Deny"})]})]})}function YTe({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=cc(),{llmConfig:u}=HY({mcpServerUrl:i}),[f,m]=y.useState(null),[h,g]=y.useState(""),[v,S]=y.useState(-1),[x,w]=y.useState(!0),[E,_]=y.useState(!1),[k,R]=y.useState(!0),[N,I]=y.useState(!1),O=y.useRef(null),A=y.useRef(null),M=y.useRef(null),j=y.useRef(!1);y.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:s,pendingRequestsCount:e.length,currentSelectedId:f?.id}),s&&e.length>0){const H=e.find(ae=>ae.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!H,H?.id),H&&(console.log("[SamplingTab] Auto-selecting request:",H.id),c(null),m(H),setTimeout(()=>{const ae=document.getElementById(`sampling-request-${H.id}`);console.log("[SamplingTab] Scrolling to element:",!!ae),ae&&ae.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),y.useEffect(()=>{const H=ae=>{const L=ae.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",L);const B=e.find(P=>P.id===L);B&&(console.log("[SamplingTab] Selecting request from event:",L),m(B),setTimeout(()=>{const P=document.getElementById(`sampling-request-${L}`);P&&P.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",H),()=>window.removeEventListener("navigate-to-sampling",H)},[e]),y.useEffect(()=>{x&&e.length>0&&O.current&&!j.current&&(O.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const H=O.current;if(!H)return;const ae=()=>{H.scrollTop>0&&(j.current=!0,w(!1))};return H.addEventListener("scroll",ae),()=>H.removeEventListener("scroll",ae)},[]),y.useEffect(()=>{e.length===0&&(j.current=!1,w(!0))},[e.length]),y.useEffect(()=>{E&&M.current&&M.current.focus()},[E]);const F=y.useCallback(()=>{h.trim()||_(!1)},[h]),V=y.useMemo(()=>{if(!h.trim())return e;const H=h.toLowerCase();return e.filter(ae=>ae.serverName.toLowerCase().includes(H)||JSON.stringify(ae.request||{}).toLowerCase().includes(H))},[e,h]);y.useEffect(()=>{S(-1)},[h]),y.useEffect(()=>{const H=ae=>{const ne=ae.target;if(ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.contentEditable==="true"||ae.metaKey||ae.ctrlKey||ae.altKey)return;const B=V;if(ae.key==="ArrowDown")ae.preventDefault(),S(P=>{const $=P+1;return $>=B.length?0:$});else if(ae.key==="ArrowUp")ae.preventDefault(),S(P=>{const $=P-1;return $<0?B.length-1:$});else if(ae.key==="Enter"&&v>=0){ae.preventDefault();const P=V[v];P&&J(P)}};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[v,V]),y.useEffect(()=>{if(v>=0){const H=`sampling-request-${V[v]?.id}`,ae=document.getElementById(H);ae&&ae.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,V]);const J=y.useCallback(H=>{m(H)},[]),ee=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(H=>{n(H.id,"User rejected all requests")}),m(null))},[e,n]),ie=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)),I(!0),setTimeout(()=>I(!1),2e3)}catch(H){console.error("[SamplingTab] Failed to copy request:",H)}},[f]),W=y.useCallback(()=>{if(f)try{const H=new globalThis.Blob([JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)],{type:"application/json"}),ae=URL.createObjectURL(H),ne=document.createElement("a");ne.href=ae,ne.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(ae)}catch(H){console.error("[SamplingTab] Failed to download request:",H)}},[f]),Z=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(H){console.error("[SamplingTab] Failed to toggle fullscreen:",H)}},[]);return r?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(On,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(On,{defaultSize:75,minSize:30,children:[d.jsx(HTe,{isSearchExpanded:E,searchQuery:h,filteredRequestsCount:V.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:F,onRejectAll:ee,searchInputRef:M}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(VTe,{requests:V,selectedRequest:f,onRequestSelect:J,focusedIndex:v,formatRelativeTime:ay,listRef:O})})]})})}),d.jsx(wi,{}),d.jsx(On,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(WTe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>R(!k),isCopied:N,onCopy:ie,onDownload:W,onFullscreen:Z,llmConfig:u})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(HG,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function qTe({requestId:e,serverName:t,mode:n,message:a,url:r,onViewDetails:i,onOpenUrl:s,onCancel:c}){return d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Elicitation Request Received"}),d.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",a]}),n==="url"&&r&&d.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:r})]}),d.jsxs("div",{className:"flex gap-2 flex-wrap",children:[d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),i()},children:"View Details"}),n==="url"&&s&&d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),s()},children:"Open URL"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),c()},children:"Cancel"})]})]})}function XTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onCancelAll:c,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Nn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>i(f.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),d.jsx(vr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(zd,{className:"h-4 w-4"})})}),d.jsxs(Rt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(oh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(Qi,{className:"h-4 w-4"})})}),d.jsx(Rt,{side:"bottom",children:"Cancel all"})]})})]})}function JTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Pd,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.mode||"form",f=u==="form"&&"requestedSchema"in s.request&&s.request.requestedSchema;return d.jsx(Qs,{id:`elicitation-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,d.jsx(vr,{variant:"outline",className:u==="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:u})]}),description:(()=>{const m=r(s.timestamp),h=[];f&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function QTe({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:f}){const[m,h]=y.useState({}),[g,v]=y.useState(!1),S=e?.request.mode||"form",x=S==="form",w=S==="url";y.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const O=e.request.requestedSchema,A={};if(O?.type==="object"&&O.properties)for(const[M,j]of Object.entries(O.properties)){const F=j;F.default!==void 0?A[M]=F.default:F.type==="boolean"?A[M]=!1:F.type==="number"||F.type==="integer"?A[M]=0:A[M]=""}h(A)}v(!1)},[e?.id,x]);const E=(O,A)=>{h(M=>({...M,[O]:A}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const O=e.request.requestedSchema;if(O?.required){const A=O.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(A.length>0){st.error("Missing required fields",{description:`Please fill in: ${A.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else w&&t(e.id,{action:"accept"});a(),ia(()=>Promise.resolve().then(()=>Rd),void 0).then(O=>{const A=st(O.createElement("div",{className:"space-y-3"},O.createElement("div",null,O.createElement("strong",null,"Elicitation Response Sent"),O.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),O.createElement("div",{className:"flex gap-2"},O.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 M=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent(M),st.dismiss(A)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),a())},R=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},N=()=>{e&&w&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},I=y.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const O=e.request.requestedSchema;if(!O||O.type!=="object"||!O.properties)return d.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const A=O.properties,M=O.required||[];return d.jsx("div",{className:"space-y-4",children:Object.entries(A).map(([j,F])=>{const V=F,J=M.includes(j),ee=V.type||"string",ie=V.title||j,W=V.description;return d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:`field-${j}`,children:[ie,J&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),W&&d.jsx("p",{className:"text-xs text-muted-foreground",children:W}),ee==="boolean"?d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(um,{id:`field-${j}`,checked:m[j]||!1,onCheckedChange:Z=>E(j,Z)}),d.jsx(tn,{htmlFor:`field-${j}`,className:"text-sm font-normal cursor-pointer",children:V.title||j})]}):ee==="number"||ee==="integer"?d.jsx(Nn,{id:`field-${j}`,type:"number",value:m[j]||"",onChange:Z=>E(j,ee==="integer"?parseInt(Z.target.value,10):parseFloat(Z.target.value)),placeholder:V.default?.toString()||""}):V.enum?d.jsxs("select",{id:`field-${j}`,value:m[j]||"",onChange:Z=>E(j,Z.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:[d.jsx("option",{value:"",children:"Select..."}),V.enum.map(Z=>d.jsx("option",{value:Z,children:Z},Z))]}):ee==="string"&&(V.format==="textarea"||V.maxLength>100)?d.jsx(Ql,{id:`field-${j}`,value:m[j]||"",onChange:Z=>E(j,Z.target.value),placeholder:V.default||"",rows:4}):d.jsx(Nn,{id:`field-${j}`,type:"text",value:m[j]||"",onChange:Z=>E(j,Z.target.value),placeholder:V.default||""})]},j)})})},[e,m,x]);return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),d.jsx(vr,{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:S}),d.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?d.jsx(zr,{className:"h-4 w-4 text-green-600"}):d.jsx(br,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Copy request"})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(zm,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Download request"})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(uC,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Fullscreen"})]}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(Qi,{className:"h-4 w-4"})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),d.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),w&&"url"in e.request&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),d.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[d.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),d.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[d.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),d.jsxs(Oe,{size:"sm",variant:"outline",onClick:N,className:"flex items-center gap-2",children:[d.jsx(XE,{className:"h-4 w-4"}),"Open URL"]})]}),d.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[d.jsx(um,{id:"url-completed",checked:g,onCheckedChange:O=>v(!!O)}),d.jsx(tn,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),x&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),I]}),x&&"requestedSchema"in e.request&&e.request.requestedSchema&&d.jsxs("details",{className:"space-y-2",children:[d.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),d.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:d.jsx(Qn,{data:e.request.requestedSchema})})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Oe,{onClick:_,className:"flex-1",children:"Accept"}),d.jsx(Oe,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),d.jsx(Oe,{onClick:R,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function eNe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=cc(),[c,u]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,S]=y.useState(!0),[x,w]=y.useState(!1),[E,_]=y.useState(!0),[k,R]=y.useState(!1),N=y.useRef(null),I=y.useRef(null),O=y.useRef(null),A=y.useRef(!1);y.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:c?.id}),i&&e.length>0){const W=e.find(Z=>Z.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!W,W?.id),W&&(console.log("[ElicitationTab] Auto-selecting request:",W.id),s(null),u(W),setTimeout(()=>{const Z=document.getElementById(`elicitation-request-${W.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Z),Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,s]),y.useEffect(()=>{const W=Z=>{const ae=Z.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",ae);const ne=e.find(L=>L.id===ae);ne&&(console.log("[ElicitationTab] Selecting request from event:",ae),u(ne),setTimeout(()=>{const L=document.getElementById(`elicitation-request-${ae}`);L&&L.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",W),()=>window.removeEventListener("navigate-to-elicitation",W)},[e]),y.useEffect(()=>{v&&e.length>0&&N.current&&!A.current&&(N.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const W=N.current;if(!W)return;const Z=()=>{W.scrollTop>0&&(A.current=!0,S(!1))};return W.addEventListener("scroll",Z),()=>W.removeEventListener("scroll",Z)},[]),y.useEffect(()=>{e.length===0&&(A.current=!1,S(!0))},[e.length]),y.useEffect(()=>{x&&O.current&&O.current.focus()},[x]);const M=y.useCallback(()=>{f.trim()||w(!1)},[f]),j=y.useMemo(()=>{if(!f.trim())return e;const W=f.toLowerCase();return e.filter(Z=>Z.serverName.toLowerCase().includes(W)||Z.request.message.toLowerCase().includes(W)||JSON.stringify(Z.request||{}).toLowerCase().includes(W))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const W=Z=>{const H=Z.target;if(H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const ne=j;if(Z.key==="ArrowDown")Z.preventDefault(),g(L=>{const B=L+1;return B>=ne.length?0:B});else if(Z.key==="ArrowUp")Z.preventDefault(),g(L=>{const B=L-1;return B<0?ne.length-1:B});else if(Z.key==="Enter"&&h>=0){Z.preventDefault();const L=j[h];L&&F(L)}};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[h,j]),y.useEffect(()=>{if(h>=0){const W=`elicitation-request-${j[h]?.id}`,Z=document.getElementById(W);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,j]);const F=y.useCallback(W=>{u(W)},[]),V=y.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(W=>{n(W.id,"User cancelled all requests")}),u(null))},[e,n]),J=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(W){console.error("[ElicitationTab] Failed to copy request:",W)}},[c]),ee=y.useCallback(()=>{if(c)try{const W=new globalThis.Blob([JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)],{type:"application/json"}),Z=URL.createObjectURL(W),H=document.createElement("a");H.href=Z,H.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(H),H.click(),document.body.removeChild(H),URL.revokeObjectURL(Z)}catch(W){console.error("[ElicitationTab] Failed to download request:",W)}},[c]),ie=y.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(W){console.error("[ElicitationTab] Failed to toggle fullscreen:",W)}},[]);return r?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(On,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(On,{defaultSize:75,minSize:30,children:[d.jsx(XTe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:j.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:V,searchInputRef:O}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(JTe,{requests:j,selectedRequest:c,onRequestSelect:F,focusedIndex:h,formatRelativeTime:ay,listRef:N})})]})})}),d.jsx(wi,{}),d.jsx(On,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(QTe,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:E,onTogglePreview:()=>_(!E),isCopied:k,onCopy:J,onDownload:ee,onFullscreen:ie})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZG,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function tNe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:d.jsx(gq,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:d.jsx(fq,{ref:a,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:d.jsx(mq,{ref:r,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:d.jsx(Yke,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),d.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:d.jsx(YTe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),d.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:d.jsx(eNe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:d.jsx(NTe,{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"&&d.jsx(d.Fragment,{children:i})]}):d.jsx(d.Fragment,{children:i})}function dF({className:e}){return d.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:[d.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"}),d.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const bq=y.createContext(void 0);function vq(){const e=y.use(bq);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const yq=y.createContext(void 0);function nNe(){return y.use(yq)}function uk({ref:e,children:t,defaultValue:n,value:a,onValueChange:r,className:i,collapsed:s,onCollapsedChange:c,...u}){const[f,m]=y.useState(n||""),h=a!==void 0,g=s!==void 0,[v,S]=y.useState(!1),x=y.useCallback(k=>{h||m(k),r?.(k)},[h,r]),w=h?a:f,E=g?s:v,_=y.useCallback(k=>{g||S(k),c?.(k)},[g,c]);return d.jsx(bq,{value:{activeValue:w,handleValueChange:x,collapsed:E,handleCollapsedChange:_},children:d.jsx("div",{ref:e,className:Le("flex flex-col gap-2",i),...u,children:t})})}uk.displayName="Tabs";function dk({ref:e,children:t,className:n,variant:a="default",collapsible:r=!1,...i}){const{activeValue:s,collapsed:c,handleCollapsedChange:u}=vq(),[f,m]=y.useState({width:0,left:0}),h=y.useRef(null),g=y.useRef(null),v=y.useRef(null),S=y.useCallback(()=>{const E=h.current;if(!E)return;const _=E.querySelector("div:first-child");if(!_)return;const k=_.querySelector(`button[data-tab-value="${s}"]`);if(k&&s){const R=_.getBoundingClientRect(),N=k.getBoundingClientRect();m({width:N.width,left:N.left-R.left})}else m({width:0,left:0})},[s]),x=y.useCallback(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(S,16)},[S]);y.useEffect(()=>{const E=setTimeout(S,10);return()=>clearTimeout(E)},[S,c]),y.useEffect(()=>{const E=h.current;if(!E)return;g.current=new ResizeObserver(()=>{x()}),g.current.observe(E);const _=E.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 E=()=>{x()};return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[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]),d.jsx(yq,{value:{variant:a,collapsed:c,handleCollapsedChange:u},children:d.jsx("div",{ref:h,className:Le("relative flex items-center bg-none gap-1",a==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",a==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...i,children:d.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,d.jsx("span",{ref:w,className:Le("absolute transition-all duration-500 ease-in-out z-0",a==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",a==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}dk.displayName="TabsList";const rNe=({children:e,title:t,collapsed:n})=>!t||!n?e:d.jsx(oC,{children:d.jsxs(Nt,{children:[d.jsx(Ct,{children:e}),d.jsx(Rt,{children:t})]})}),fk=y.forwardRef(({children:e,value:t,className:n,disabled:a,icon:r,title:i,...s},c)=>{const{activeValue:u,handleValueChange:f,collapsed:m}=vq(),g=nNe()?.variant||"default",v=u===t,S=m&&i?i:void 0;return d.jsx(rNe,{title:i,collapsed:m,children:d.jsxs("button",{ref:c,disabled:a,onClick:()=>f(t),"data-tab-value":t,"data-tab-active":v,role:"tab","aria-selected":v?"true":"false",title:S,className:Le("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",g==="default"&&"py-2.5",g==="default"&&"rounded-md px-4",g==="underline"&&"px-6 py-3 border-b-2 border-transparent",v&&"text-foreground",!v&&"text-muted-foreground hover:text-foreground",n),...s,children:[r&&d.jsx(r,{className:Le("h-4 w-4 transition-all duration-500 ease-in-out",!m&&"mr-2",m&&"mr-0!")}),d.jsx("span",{className:Le("transition-all duration-500 ease-in-out overflow-hidden",m?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});fk.displayName="TabsTrigger";function fF({className:e}){const{theme:t,setTheme:n}=m0(),a=y.useRef(null),[r,i]=y.useState(!1);y.useEffect(()=>{i(!0)},[]);const s=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?d.jsx(pU,{className:"size-4"}):t==="light"?d.jsx(Rme,{className:"size-5"}):d.jsx(cme,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",f=async()=>{if(!a.current)return;const m=s();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{Dd.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:S}=a.current.getBoundingClientRect(),x=h+S/2,w=g+v/2,E=window.innerWidth-g,_=window.innerHeight-h,k=Math.hypot(Math.max(g,E),Math.max(h,_));document.documentElement.animate({clipPath:[`circle(0px at ${w}px ${x}px)`,`circle(${k}px at ${w}px ${x}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?d.jsx("button",{ref:a,onClick:f,className:Le(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):d.jsx("button",{ref:a,className:Le(e),"aria-label":"Toggle theme",children:d.jsx(pU,{className:"size-4"})})}function pF({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[a,r]=y.useState(!1),i=.2,s=.7,c=.6,u=4,f=i+s+c,m=0,h=i/f,g=(i+s)/f,v=1;return d.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Le("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[d.jsx("div",{className:"relative",children:d.jsxs(xa.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:Le("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[d.jsxs(xa.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:u,strokeLinecap:"round",strokeLinejoin:"round",children:[d.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"}),d.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),d.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),d.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx(aNe,{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}),d.jsx(mF,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f}),d.jsx(mF,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f})]})]})}),t==="expanded"&&d.jsxs("div",{className:"font-ubuntu flex-col items-start -space-y-1 mr-3 hidden xl:flex",children:[d.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),d.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function aNe({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return d.jsx(xa.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[a,r,i,s],ease:"easeInOut"}}}})}function mF({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return d.jsx(xa.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:r,times:[i,s,c,u],ease:"easeInOut"}}}})}function Cb({open:e,onOpenChange:t,serverUrl:n,serverName:a,serverId:r,headers:i,language:s}){const{prismStyle:c}=TO(),[u,f]=y.useState(!1),m=s==="typescript"?TF(n,a,r,i):NF(n,a,r,i),h=async()=>{await navigator.clipboard.writeText(m),f(!0),setTimeout(()=>f(!1),2e3)},g=s==="typescript"?"TypeScript":"Python",v=s==="typescript"?"npm install mcp-use":"pip install mcp-use";return d.jsx(Ll,{open:e,onOpenChange:t,children:d.jsxs($l,{className:"max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col",children:[d.jsxs(Ml,{children:[d.jsxs(Pl,{children:["Add to ",g," SDK"]}),d.jsxs(O7,{children:["Copy the following code to integrate this server into your"," ",g," application using the mcp-use SDK."]})]}),d.jsxs("div",{className:"space-y-4 overflow-y-auto flex-1 min-h-0",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsxs("span",{children:["Install the mcp-use package:"," ",d.jsx("code",{className:"text-foreground",children:v})]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsxs("span",{children:["Copy the following code into your ",g," project:"]})]})]})]}),d.jsxs("div",{className:"relative w-full overflow-x-auto overflow-y-auto max-h-[60vh]",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:h,children:u?d.jsx(zr,{className:"size-3.5 text-green-600"}):d.jsx(br,{className:"size-3.5"})})}),d.jsx(Xp,{language:s,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 wq({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:f}=m0(),m=f==="dark"?"#000000":"#ffffff",h=f==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=i||h;return d.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":r,"--speed":a,"--cut":n,"--bg":v},className:Le("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",s),ref:e,...u,children:[d.jsx("div",{className:Le("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:d.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:d.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,d.jsx("div",{className:Le("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]")}),d.jsx("div",{className:Le("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}wq.displayName="ShimmerButton";function hF({status:e}){const t=i=>{switch(i){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:i}}},{color:n,ringColor:a,tooltip:r}=t(e);return d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),d.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),d.jsx(Rt,{children:d.jsx("p",{children:r})})]})}function gF({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=Bd(),[s,c]=y.useState(!1),[u,f]=y.useState(null),m=h=>{const g=e.find(v=>v.id===h);if(!g||g.state!=="ready"){st.error("Server is not connected and cannot be inspected");return}n(h)};return r?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"relative",children:d.jsxs(WE,{children:[d.jsx(KE,{asChild:!0,children:d.jsxs(Oe,{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?d.jsx(yu,{server:t,size:"md"}):d.jsx(KG,{className:"h-5 w-5"}),d.jsx(Po,{className:"h-4 w-4"})]})}),d.jsxs(Iv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(ZE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),d.jsx(sp,{}),e.length===0?d.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=>d.jsxs(Ui,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[d.jsx(yu,{server:h,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:h.name}),d.jsx(hF,{status:h.state})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Oe,{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:d.jsx(vp,{className:"h-3 w-3"})}),d.jsx(Oe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),a(h.id)},children:d.jsx(Tu,{className:"h-3 w-3"})})]})]},h.id)),d.jsx(sp,{}),d.jsx(Ui,{onClick:()=>i("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})}),d.jsx(g_,{open:s,onOpenChange:c,connection:u})]}):d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs("div",{className:"relative",children:[d.jsxs(WE,{children:[d.jsx(KE,{asChild:!0,children:d.jsxs(wq,{className:Le("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&&d.jsx(yu,{server:t,size:"md",className:"mr-2"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.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&&d.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.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"})}),d.jsx(Rt,{children:d.jsx("p",{className:"max-w-xs",children:t.error})})]}):d.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&&d.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.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:d.jsx(vp,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:d.jsx("p",{children:"View server info"})})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx("button",{type:"button",onClick:()=>{a(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:d.jsx(Tu,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:d.jsx("p",{children:"Edit connection settings"})})]})]}),d.jsxs(Iv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(ZE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),d.jsx(sp,{}),e.length===0?d.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=>d.jsxs(Ui,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[d.jsx(yu,{server:h,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:h.serverInfo?.title||h.serverInfo?.name||h.name}),d.jsx(hF,{status:h.state})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Oe,{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:d.jsx(vp,{className:"h-3 w-3"})}),d.jsx(Oe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),a(h.id)},children:d.jsx(Tu,{className:"h-3 w-3"})})]})]},h.id)),d.jsx(sp,{}),d.jsx(Ui,{onClick:()=>i("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]}),d.jsx(g_,{open:s,onOpenChange:c,connection:u})]})})}const bF=[{id:"tools",label:"Tools",icon:Zl},{id:"prompts",label:"Prompts",icon:Wp},{id:"resources",label:"Resources",icon:Gpe},{id:"sampling",label:"Sampling",icon:HG},{id:"elicitation",label:"Elicitation",icon:ZG},{id:"notifications",label:"Notifications",icon:sC},{id:"chat",label:"Chat",icon:ame}];function vF(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 iNe({collapsed:e,onToggle:t}){return d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx("button",{onClick:t,className:Le("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?d.jsx(FG,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):d.jsx(Xy,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),d.jsx(Rt,{children:d.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function oNe({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s,embedded:c=!1}){const{tunnelUrl:u}=cc(),f=t&&u,[m,h]=y.useState(!1),[g,v]=y.useState(!1),[S,x]=y.useState(!1),[w,E]=y.useState(!0),_=async()=>{if(u)try{await navigator.clipboard.writeText(`${u}/mcp`),h(!0),st.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{st.error("Failed to copy URL")}};return d.jsxs("header",{className:"w-full mx-auto",children:[d.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between w-full",children:[!c&&d.jsx("div",{className:"flex-1 flex justify-start",children:d.jsx(gF,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),!c&&d.jsx("div",{className:"flex-shrink-0 flex justify-center",children:d.jsx("div",{className:"scale-150",children:d.jsx(pF,{state:"collapsed"})})}),!c&&d.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[t&&(()=>{const k=t.serverInfo?.title||t.serverInfo?.name||t.name;return d.jsxs(d.Fragment,{children:[d.jsx(ME,{serverConfig:{url:u?`${u}/mcp`:t.url,name:k,headers:t.customHeaders,serverId:t.id},onSuccess:R=>st.success(`Opening in ${R}...`),onError:R=>st.error(`Failed: ${R.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:d.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:d.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:d.jsxs(Oe,{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:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(Ov,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(Po,{className:"size-3"})]})]})}),d.jsx(Cb,{open:g,onOpenChange:v,serverUrl:u?`${u}/mcp`:t.url,serverName:k,serverId:void 0,headers:t.customHeaders,language:"typescript"}),d.jsx(Cb,{open:S,onOpenChange:x,serverUrl:u?`${u}/mcp`:t.url,serverName:k,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",asChild:!0,children:d.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:d.jsx(dF,{className:"h-4 w-4"})})})}),d.jsx(Rt,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(fF,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&d.jsx("div",{className:"w-full",children:d.jsx(uk,{value:n,onValueChange:k=>r(k),collapsed:w,onCollapsedChange:E,children:d.jsx(dk,{className:"w-full justify-center",children:bF.map(k=>{const R=vF(k.id,t);return d.jsxs(fk,{value:k.id,icon:k.icon,className:Le("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",w&&"pl-2"),children:[R>0&&d.jsx("span",{className:Le(n===k.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}),d.jsx("span",{className:"sr-only",children:k.label})]},k.id)})})})})]}),d.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[!c&&d.jsx(gF,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(uk,{value:n,onValueChange:k=>r(k),collapsed:w,onCollapsedChange:E,children:d.jsx(dk,{className:"overflow-x-auto",collapsible:!0,children:bF.map(k=>{const R=vF(k.id,t),N=R>0?`${k.label} (${R})`:k.label;return d.jsx(fk,{value:k.id,icon:k.icon,className:Le("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",w&&"pl-4"),title:N,children:d.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[k.label,R>0&&d.jsx("span",{className:Le(n===k.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})]})})})})}),d.jsx(iNe,{collapsed:w,onToggle:()=>E(!w)})]}),f&&d.jsxs(jZ,{children:[d.jsx(LZ,{asChild:!0,children:d.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:[d.jsx(Kp,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),d.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),d.jsx(lD,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[d.jsx(Kp,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),d.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[d.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[u,"/mcp"]}),d.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:_,children:m?d.jsx(zr,{className:"size-3.5 text-green-600"}):d.jsx(br,{className:"size-3.5"})})]})]}),d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsxs("span",{children:["Enable"," ",d.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsxs("span",{children:["In"," ",d.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",d.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"3."}),d.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),!c&&d.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[t&&(()=>{const k=t.serverInfo?.title||t.serverInfo?.name||t.name;return d.jsxs(d.Fragment,{children:[d.jsx(ME,{serverConfig:{url:u?`${u}/mcp`:t.url,name:k,headers:t.customHeaders,serverId:t.id},onSuccess:R=>st.success(`Opening in ${R}...`),onError:R=>st.error(`Failed: ${R.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:d.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:d.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:d.jsxs(Oe,{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:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(Ov,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(Po,{className:"size-3"})]})]})}),d.jsx(Cb,{open:g,onOpenChange:v,serverUrl:u?`${u}/mcp`:t.url,serverName:k,serverId:void 0,headers:t.customHeaders,language:"typescript"}),d.jsx(Cb,{open:S,onOpenChange:x,serverUrl:u?`${u}/mcp`:t.url,serverName:k,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),d.jsxs(Nt,{children:[d.jsx(Ct,{children:d.jsx(fF,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),d.jsx(Rt,{children:d.jsx("p",{children:"Toggle theme"})})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsxs(Oe,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[d.jsx(Cpe,{className:"size-4"}),d.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),d.jsx(Rt,{children:d.jsx("p",{children:"Command Palette"})})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",asChild:!0,children:d.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[d.jsx(dF,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden xl:inline",children:"Github"})]})})}),d.jsx(Rt,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(pF,{state:"expanded"})]})]})]})}function sNe({children:e}){const t=Bd(),n=Wo(),{servers:a,addServer:r,removeServer:i,storageLoaded:s}=Am(),c=y.useCallback((P,$,z,G)=>{r(P,{url:P,name:$,proxyConfig:z,transportType:G})},[r]),u=y.useCallback((P,$)=>{console.warn("[Layout] updateConnectionConfig not yet supported in new provider")},[]),{selectedServerId:f,setSelectedServerId:m,activeTab:h,setActiveTab:g,navigateToItem:v,setTunnelUrl:S,tunnelUrl:x,isEmbedded:w,embeddedConfig:E,setEmbeddedMode:_}=cc(),[k,R]=y.useState(!1),[N,I]=y.useState(null),O=TSe();y.useEffect(()=>{const P=new URLSearchParams(n.search),$=P.get("embedded")==="true",z=P.get("embeddedConfig");if($){let G={};if(z)try{G=JSON.parse(z)}catch(K){console.error("Failed to parse embeddedConfig:",K)}_(!0,G)}},[]),y.useEffect(()=>{const $=new URLSearchParams(n.search).get("tunnelUrl");S($)},[n.search,S]),y.useEffect(()=>{const $=new URLSearchParams(n.search).get("tab");$&&["tools","prompts","resources","chat","sampling","elicitation","notifications"].includes($)&&g($)},[n.search,g]),y.useEffect(()=>{const P=G=>{const re=G.detail.requestId;f&&v(f,"sampling",re)},$=G=>{const re=G.detail.requestId;f&&v(f,"elicitation",re)},z=G=>{const re=G.detail.toolName;f&&re?v(f,"tools",re):f&&g("tools")};return window.addEventListener("navigate-to-sampling",P),window.addEventListener("navigate-to-elicitation",$),window.addEventListener("navigate-to-tool-result",z),()=>{window.removeEventListener("navigate-to-sampling",P),window.removeEventListener("navigate-to-elicitation",$),window.removeEventListener("navigate-to-tool-result",z)}},[f,g,v]);const A=y.useRef(null),M=y.useRef(null),j=y.useRef(null),{isAutoConnecting:F}=kSe({connections:a,addConnection:c,removeConnection:i,configLoaded:s,embedded:w}),V=y.useCallback(P=>{$r.getInstance().capture(new qfe({trigger:P})).catch(()=>{}),R(!0)},[]),J=P=>{const $=a.find(fe=>fe.id===P);if(!$||$.state!=="ready"){st.error("Server is not connected and cannot be inspected");return}m(P);const z=new URLSearchParams(n.search),G=z.get("tunnelUrl"),K=z.get("tab"),re=new URLSearchParams;re.set("server",P),G&&re.set("tunnelUrl",G),K&&re.set("tab",K),t(`/?${re.toString()}`)},ee=y.useCallback(P=>{I(P)},[]),ie=y.useCallback(P=>{N&&(P.url!==N?(i(N),c(P.url,P.name,P.proxyConfig,P.transportType)):u(N,{name:P.name,proxyConfig:P.proxyConfig,transportType:P.transportType}),I(null),st.success("Connection settings updated"))},[N,i,c,u]),W=(P,$,z)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:P,itemName:$,serverId:z}),z){const G=a.find(te=>te.id===z);if(console.warn("[Layout] Server lookup:",{serverId:z,serverFound:!!G,serverState:G?.state}),!G||G.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),st.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:z,tab:P,itemName:$}),v(z,P,$);const K=new URLSearchParams(n.search),re=K.get("tunnelUrl"),fe=K.get("tab"),ce=new URLSearchParams;ce.set("server",z),re&&ce.set("tunnelUrl",re),P?ce.set("tab",P):fe&&ce.set("tab",fe);const q=`/?${ce.toString()}`;console.warn("[Layout] Navigating to:",q),t(q)}else console.warn("[Layout] No serverId, just updating tab to:",P),g(P)},Z=a.find(P=>P.id===f),H=Z?Z.tools.map(P=>({...P,_serverId:Z.id})):a.flatMap(P=>P.state==="ready"?P.tools.map($=>({...$,_serverId:P.id,_serverName:P.name})):[]),ae=Z?Z.prompts.map(P=>({...P,_serverId:Z.id})):a.flatMap(P=>P.state==="ready"?P.prompts.map($=>({...$,_serverId:P.id,_serverName:P.name})):[]),ne=Z?Z.resources.map(P=>({...P,_serverId:Z.id})):a.flatMap(P=>P.state==="ready"?P.resources.map($=>({...$,_serverId:P.id,_serverName:P.name})):[]);if(y.useEffect(()=>{const $=new URLSearchParams(n.search).get("server"),z=$?decodeURIComponent($):null;z!==f&&m(z)},[n.search,f,m]),y.useEffect(()=>{const $=new URLSearchParams(n.search).get("server");if(!$)return;const z=decodeURIComponent($),G=a.find(K=>K.id===z);if(!G){const K=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(K)}if(G.state==="failed"){const K=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(K)}},[n.search,t,a]),lZ({onCommandPalette:()=>V("keyboard"),onToolsTab:()=>{Z&&g("tools")},onPromptsTab:()=>{Z&&g("prompts")},onResourcesTab:()=>{Z&&g("resources")},onChatTab:()=>{Z&&g("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{h==="tools"&&A.current?A.current.focusSearch():h==="prompts"&&M.current?M.current.focusSearch():h==="resources"&&j.current&&j.current.focusSearch()},onBlurSearch:()=>{h==="tools"&&A.current?A.current.blurSearch():h==="prompts"&&M.current?M.current.blurSearch():h==="resources"&&j.current&&j.current.blurSearch()}}),F)return d.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx(Yi,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})});const L=w?{backgroundColor:E.backgroundColor||"#f3f3f3",padding:E.padding||"0.5rem"}:{},B=w?"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 d.jsx(oC,{children:d.jsxs("div",{className:B,style:L,children:[d.jsx(oNe,{connections:a,selectedServer:Z,activeTab:h,onServerSelect:J,onTabChange:g,onCommandPaletteOpen:()=>V("button"),onOpenConnectionOptions:ee,embedded:w}),d.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:d.jsx(tNe,{selectedServer:Z,activeTab:h,toolsSearchRef:A,promptsSearchRef:M,resourcesSearchRef:j,children:e})}),d.jsx(eEe,{isOpen:k,onOpenChange:R,tools:H,prompts:ae,resources:ne,savedRequests:O,connections:a,selectedServer:Z,tunnelUrl:x,onNavigate:W,onServerSelect:J}),d.jsx(TW,{connection:N&&a.find(P=>P.id===N)||null,open:N!==null,onOpenChange:P=>{P||I(null)},onConnect:ie})]})})}function lNe(){const[e,t]=y.useState("processing"),[n,a]=y.useState("");return y.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),DN().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(r=>{console.error("[OAuthCallback] Authorization failed:",r),t("error"),a(r instanceof Error?r.message:String(r))})},[]),e==="processing"?d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx(Fs,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"max-w-md p-6",children:[d.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),d.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"max-w-md p-6",children:[d.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var cNe=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,f=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(S=>{let x=S==="class",w=x&&i?r.map(E=>i[E]||E):r;x?(u.classList.remove(...w),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(S,v)}),h(v)}function h(v){c&&f.includes(v)&&(u.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(a)m(a);else try{let v=localStorage.getItem(t)||n,S=s&&v==="system"?g():v;m(S)}catch{}},uNe=y.createContext(void 0),dNe={setTheme:e=>{},themes:[]},fNe=()=>{var e;return(e=y.useContext(uNe))!=null?e:dNe};y.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:a,enableColorScheme:r,defaultTheme:i,value:s,themes:c,nonce:u,scriptProps:f})=>{let m=JSON.stringify([n,t,i,e,c,s,a,r]).slice(1,-1);return y.createElement("script",{...f,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${cNe.toString()})(${m})`}})});function pNe({...e}){const{theme:t="system"}=fNe();return d.jsx(Dge,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function mNe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true",n=y.useMemo(()=>t?void 0:new rse("mcp-inspector-connections"),[t]);return d.jsx(Mve,{children:d.jsx(_9,{storageProvider:n,enableRpcLogging:!0,onServerAdded:(a,r)=>{console.log("[Inspector] Server added:",a,r.state)},onServerRemoved:a=>{console.log("[Inspector] Server removed:",a)},onServerStateChange:(a,r)=>{console.log("[Inspector] Server state changed:",a,r)},onSamplingRequest:(a,r,i,s,c)=>{const u=st(d.jsx(ZTe,{requestId:a.id,serverName:i,onViewDetails:()=>{const f=new CustomEvent("navigate-to-sampling",{detail:{requestId:a.id}});window.dispatchEvent(f),st.dismiss(u)},onApprove:f=>{s(a.id,f),st.success("Sampling request approved"),st.dismiss(u)},onDeny:()=>{c(a.id,"User denied from toast"),st.dismiss(u)}}),{duration:1/0})},onElicitationRequest:(a,r,i,s,c)=>{const u=a.request.mode||"form",f=a.request.message,m=u==="url"&&"url"in a.request?a.request.url:void 0,h=st(d.jsx(qTe,{requestId:a.id,serverName:i,mode:u,message:f,url:m,onViewDetails:()=>{const g=new CustomEvent("navigate-to-elicitation",{detail:{requestId:a.id}});window.dispatchEvent(g),st.dismiss(h)},onOpenUrl:u==="url"&&m?()=>{window.open(m,"_blank"),st.dismiss(h)}:void 0,onCancel:()=>{c(a.id,"User cancelled from toast"),st.dismiss(h)}}),{duration:1/0})},children:d.jsxs(_Se,{children:[d.jsx(Xhe,{basename:"/inspector",children:d.jsxs(Che,{children:[d.jsx(e_,{path:"/oauth/callback",element:d.jsx(lNe,{})}),d.jsx(e_,{path:"/",element:d.jsx(sNe,{children:d.jsx(ESe,{})})})]})}),d.jsx(pNe,{position:"top-center"})]})})})}const yF=new URLSearchParams(window.location.search);if(yF.has("code")||yF.has("error"))try{DN()}catch(e){console.error("[inspector] OAuth callback error:",e)}const wF=document.getElementById("root");wF?dse.createRoot(wF).render(d.jsx(mNe,{})):console.error("[inspector] Root element not found");const hNe=Object.freeze(Object.defineProperty({__proto__:null,clearRpcLogs:Sv,getAllRpcLogs:$N,getRpcLogs:k9,subscribeToRpcLogs:MN,wrapTransportForLogging:T9},Symbol.toStringTag,{value:"Module"}));export{HB as $,bi as A,Bae as B,cz as C,cE as D,ni as E,t5 as F,s6 as G,Goe as H,ZF as I,Ob as J,XF as K,e5 as L,Foe as M,BB as N,jl as O,cv as P,$t as Q,X as R,C6 as S,Pi as T,$F as U,ZJ as V,$b as W,LJ as X,Woe as Y,Qne as Z,ke as _,ia as a,$J as a0,DN as a1,YJ as a2,Rd as b,iy as c,Boe as d,wk as e,vNe as f,bNe as g,Hoe as h,ud as i,XT as j,Wne as k,$e as l,Ib as m,lv as n,np as o,i3 as p,Dne as q,y as r,Dp as s,cu as t,cd as u,Ey as v,dd as w,iH as x,lE as y,eN as z};
1753
+ `),Ze.document.close())}},[S]),Ln=y.useCallback(()=>{K?(ye.current&&ye.current.expand(),Te.current&&Te.current.expand(),re(!1)):(ye.current&&ye.current.collapse(),Te.current&&Te.current.collapse(),re(!0))},[K]),pt=y.useCallback(()=>{s&&(ie(""),J(!0))},[s]),Zn=y.useCallback(()=>{if(!s)return;const He={id:`${Date.now()}-${Math.random()}`,name:ee.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};nt([...j,He]),$r.getInstance().capture(new Xfe({toolName:s.name,serverId:r})).catch(()=>{}),J(!1),ie("")},[s,ee,g,j,nt,r]),sn=y.useCallback(He=>{nt(j.filter(Fe=>Fe.id!==He)),u?.id===He&&f(null)},[j,nt,u]);return P?d.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[z!=="list"&&d.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[d.jsx(Oe,{variant:"ghost",size:"sm",onClick:()=>{z==="response"?G("detail"):(c(null),G("list"))},className:"p-0 h-8 w-8",children:d.jsx(Xy,{className:"h-4 w-4"})}),d.jsxs("div",{className:"flex items-center text-sm font-medium",children:[d.jsx("button",{onClick:()=>{c(null),G("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),z==="detail"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("button",{onClick:()=>{G("response")},className:z==="detail"?"text-foreground hover:underline":z==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),z==="response"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),d.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),d.jsx("div",{className:"flex-1 relative overflow-hidden",children:d.jsxs(g0,{initial:!1,mode:"popLayout",children:[z==="list"&&d.jsxs(xa.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:[d.jsx(cF,{activeTab:A,isSearchExpanded:H,searchQuery:I,filteredToolsCount:Ue.length,savedRequestsCount:j.length,onSearchExpand:()=>ae(!0),onSearchChange:O,onSearchBlur:xe,onTabSwitch:()=>M(A==="tools"?"saved":"tools"),searchInputRef:B}),A==="tools"?d.jsx(lF,{tools:Ue,selectedTool:s,onToolSelect:pe,focusedIndex:ne}):d.jsx(nF,{savedRequests:j,selectedRequest:u,onLoadRequest:oe,onDeleteRequest:sn,focusedIndex:ne})]},"list"),z==="detail"&&d.jsx(xa.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:d.jsx(iF,{selectedTool:s,toolArgs:g,isExecuting:w,isConnected:i,onArgChange:Ee,onExecute:je,onSave:pt})},"detail"),z==="response"&&d.jsx(xa.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:d.jsx(sF,{results:ot,copiedResult:_,previewMode:W,serverId:r,readResource:a,onCopy:We,onDelete:Ye,onFullscreen:kt,onTogglePreview:()=>Z(!W)})},"response")]})}),d.jsx(rF,{isOpen:V,requestName:ee,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ie,onSave:Zn,onCancel:()=>J(!1)})]}):d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(On,{ref:ye,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:d.jsxs(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[d.jsx(On,{defaultSize:75,minSize:30,children:d.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[d.jsx(cF,{activeTab:A,isSearchExpanded:H,searchQuery:I,filteredToolsCount:Ue.length,savedRequestsCount:j.length,onSearchExpand:()=>ae(!0),onSearchChange:O,onSearchBlur:xe,onTabSwitch:()=>M(A==="tools"?"saved":"tools"),searchInputRef:B}),A==="tools"?d.jsx(lF,{tools:Ue,selectedTool:s,onToolSelect:pe,focusedIndex:ne}):d.jsx(nF,{savedRequests:j,selectedRequest:u,onLoadRequest:oe,onDeleteRequest:sn,focusedIndex:ne})]})}),d.jsx(wi,{withHandle:!0}),d.jsxs(On,{ref:Ie,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,style:{minHeight:45},onCollapse:()=>{te(!0)},onExpand:()=>{te(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[d.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:He=>{He.preventDefault(),He.stopPropagation(),q?(Ie.current?.resize(25),te(!1)):(Ie.current?.resize(5),te(!0))},children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),fe>0&&d.jsx(vr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:fe}),fe>0&&!q&&d.jsx(Oe,{variant:"ghost",size:"sm",onClick:He=>{He.preventDefault(),He.stopPropagation(),Me.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:d.jsx(zo,{className:"h-3.5 w-3.5"})})]}),d.jsx(Po,{className:`h-4 w-4 text-muted-foreground transition-transform ${q?"":"rotate-180"}`})]}),d.jsx("div",{className:`flex-1 overflow-hidden min-h-0 ${q?"hidden":""}`,children:d.jsx(zD,{serverIds:[r],onCountChange:ce,onClearRef:Me})})]})]})}),d.jsx(wi,{withHandle:!0}),d.jsx(On,{defaultSize:67,children:d.jsxs(sa,{direction:"vertical",children:[d.jsx(On,{ref:Te,defaultSize:40,collapsible:!0,children:d.jsx(iF,{selectedTool:s,toolArgs:g,isExecuting:w,isConnected:i,onArgChange:Ee,onExecute:je,onSave:pt,onCancel:()=>{R&&R.abort()}})}),d.jsx(wi,{withHandle:!0}),d.jsx(On,{ref:Ge,defaultSize:60,children:d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(sF,{results:ot,copiedResult:_,previewMode:W,serverId:r,readResource:a,onCopy:We,onDelete:Ye,onFullscreen:kt,onTogglePreview:()=>Z(!W),onMaximize:Ln,isMaximized:K})})})]})}),d.jsx(rF,{isOpen:V,requestName:ee,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ie,onSave:Zn,onCancel:()=>J(!1)})]})}gq.displayName="ToolsTab";function HTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Nn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>i(f.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),d.jsx(vr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(zd,{className:"h-4 w-4"})})}),d.jsxs(Rt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(oh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(zo,{className:"h-4 w-4"})})}),d.jsx(Rt,{side:"bottom",children:"Reject all"})]})})]})}function VTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Pd,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.params?.messages?.length||0,f=s.request.params?.maxTokens;return d.jsx(Qs,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,d.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const m=r(s.timestamp),h=[];u>0&&h.push(`${u} message${u>1?"s":""}`),f&&h.push(`max ${f} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function GTe({llmConfig:e}){const t=y.useRef(null);return{generateResponse:y.useCallback(async({request:a})=>{if(!e)throw new Error("LLM config is not available");const r=a.params||{},i=r.maxTokens,s=r.temperature;r.modelPreferences;const c=r.messages||[];if(console.log("[useSamplingLLM] Request structure:",{hasParams:!!r,messagesCount:c.length,messages:c,params:r}),c.length===0)throw new Error("No messages found in sampling request");const u=[],{HumanMessage:f,AIMessage:m}=await ia(async()=>{const{HumanMessage:S,AIMessage:x}=await import("./index-DrmcYZGT.js").then(w=>w.bI);return{HumanMessage:S,AIMessage:x}},[]);for(const S of c){if(!S||!S.role){console.warn("Skipping invalid message:",S);continue}const x=Array.isArray(S.content)?S.content[0]:S.content;if(!x){console.warn("Skipping message with no content:",S);continue}x.type==="text"&&x.text?S.role==="user"?u.push(new f(x.text)):S.role==="assistant"&&u.push(new m(x.text)):console.warn("Skipping message with unsupported content type:",x)}if(u.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 S;const x={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(x.maxTokens=i),s!==void 0?x.temperature=s:e.temperature!==void 0&&(x.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:w}=await ia(async()=>{const{ChatOpenAI:E}=await import("./index-Meiz2XrK.js");return{ChatOpenAI:E}},__vite__mapDeps([0,1,2,3,4,5]));S=new w(x)}else if(e.provider==="anthropic"){const{ChatAnthropic:w}=await ia(async()=>{const{ChatAnthropic:E}=await import("./index-BghX1ooe.js");return{ChatAnthropic:E}},__vite__mapDeps([6,2,1,5]));S=new w(x)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:w}=await ia(async()=>{const{ChatGoogleGenerativeAI:E}=await import("./index-hiNxmj9U.js");return{ChatGoogleGenerativeAI:E}},__vite__mapDeps([7,2,1,4]));S=new w(x)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:S,provider:e.provider,model:e.model,apiKey:e.apiKey}}const h=await t.current.instance.invoke(u);return{role:"assistant",content:{type:"text",text:h.content||h.text||""},model:e.model,stopReason:"endTurn"}},[e]),isAvailable:e!==null}}function WTe({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:f,llmConfig:m}){const[h,g]=y.useState("manual"),[v,S]=y.useState("stub-model"),[x,w]=y.useState("endTurn"),[E,_]=y.useState("assistant"),[k,R]=y.useState("text"),[N,I]=y.useState("positive"),[O,A]=y.useState(""),[M,j]=y.useState("image/png"),[F,V]=y.useState(!1),[J,ee]=y.useState(null),{generateResponse:ie,isAvailable:W}=GTe({llmConfig:m});y.useEffect(()=>{e&&(S("stub-model"),w("endTurn"),_("assistant"),R("text"),I("positive"),A(""),j("image/png"),ee(null))},[e?.id]);const Z=async()=>{if(!(!e||!W)){V(!0),ee(null);try{const L=await ie({request:e.request});S(L.model||m?.model||"stub-model"),w(L.stopReason||"endTurn"),_(L.role||"assistant");const B=Array.isArray(L.content)?L.content[0]:L.content;B.type==="text"?(R("text"),I(B.text||"")):B.type==="image"&&(R("image"),A(B.data||""),j(B.mimeType||"image/png"))}catch(L){const B=L instanceof Error?L.message:"Failed to generate response";ee(B),st.error("LLM Generation Failed",{description:B})}finally{V(!1)}}},H=y.useMemo(()=>{const L={model:v,stopReason:x,role:E,content:{type:k}};return k==="text"?L.content.text=N:k==="image"&&(L.content.data=O,L.content.mimeType=M),L},[v,x,E,k,N,O,M]),ae=()=>{if(!e)return;const L=_N.safeParse(H);if(!L.success){st.error("Invalid response",{description:`Validation failed: ${L.error.message}`});return}t(e.id,L.data),a(),ia(()=>Promise.resolve().then(()=>Rd),void 0).then(B=>{const P=st(B.createElement("div",{className:"space-y-3"},B.createElement("div",null,B.createElement("strong",null,"Sampling Response Sent"),B.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),B.createElement("div",{className:"flex gap-2"},B.createElement("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90",onClick:()=>{const $=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent($),st.dismiss(P)}},"View Tool Result"))),{duration:5e3})})},ne=()=>{e&&(n(e.id,"User rejected sampling request"),a())};return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),d.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?d.jsx(zr,{className:"h-4 w-4 text-green-600"}):d.jsx(br,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Copy request"})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(zm,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Download request"})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(uC,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Fullscreen"})]}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(Qi,{className:"h-4 w-4"})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),d.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:d.jsx(Qn,{data:e.request})})]}),d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(tn,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),d.jsxs(Ao,{value:h,onValueChange:L=>g(L),children:[d.jsx(Oo,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:d.jsx(Io,{})}),d.jsxs(Do,{children:[d.jsx(Kr,{value:"manual",children:"Manual"}),d.jsx(Kr,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&d.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[W?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(Oe,{onClick:Z,disabled:F,size:"sm",className:"flex items-center gap-2",children:F?d.jsxs(d.Fragment,{children:[d.jsx(Fs,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):d.jsxs(d.Fragment,{children:[d.jsx(_me,{className:"h-4 w-4"}),"Generate with LLM"]})}),d.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):d.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),J&&d.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:J})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`model-${e.id}`,children:"Model"}),d.jsx(Nn,{id:`model-${e.id}`,value:v,onChange:L=>S(L.target.value),placeholder:"stub-model",disabled:h==="llm"&&F})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),d.jsx(Nn,{id:`stopReason-${e.id}`,value:x,onChange:L=>w(L.target.value),placeholder:"endTurn",disabled:h==="llm"&&F})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`role-${e.id}`,children:"Role"}),d.jsxs(Ao,{value:E,onValueChange:L=>_(L),disabled:h==="llm"&&F,children:[d.jsx(Oo,{id:`role-${e.id}`,children:d.jsx(Io,{})}),d.jsxs(Do,{children:[d.jsx(Kr,{value:"assistant",children:"assistant"}),d.jsx(Kr,{value:"user",children:"user"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),d.jsxs(Ao,{value:k,onValueChange:L=>R(L),disabled:h==="llm"&&F,children:[d.jsx(Oo,{id:`contentType-${e.id}`,children:d.jsx(Io,{})}),d.jsxs(Do,{children:[d.jsx(Kr,{value:"text",children:"text"}),d.jsx(Kr,{value:"image",children:"image"})]})]})]}),k==="text"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`text-${e.id}`,children:"Text Content"}),d.jsx(Ql,{id:`text-${e.id}`,value:N,onChange:L=>I(L.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&F})]}),k==="image"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),d.jsx(Ql,{id:`imageData-${e.id}`,value:O,onChange:L=>A(L.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&F})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(tn,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),d.jsx(Nn,{id:`mimeType-${e.id}`,value:M,onChange:L=>j(L.target.value),placeholder:"image/png",disabled:h==="llm"&&F})]})]})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Oe,{onClick:ae,className:"flex-1",disabled:h==="llm"&&F,children:"Approve"}),d.jsx(Oe,{onClick:ne,variant:"outline",className:"flex-1",disabled:h==="llm"&&F,children:"Reject"})]})]}):d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}const KTe={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function ZTe({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){return d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Sampling Request Received"}),d.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),n()},children:"View Details"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),a(KTe)},children:"Approve"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:i=>{i.stopPropagation(),r()},children:"Deny"})]})]})}function YTe({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=cc(),{llmConfig:u}=HY({mcpServerUrl:i}),[f,m]=y.useState(null),[h,g]=y.useState(""),[v,S]=y.useState(-1),[x,w]=y.useState(!0),[E,_]=y.useState(!1),[k,R]=y.useState(!0),[N,I]=y.useState(!1),O=y.useRef(null),A=y.useRef(null),M=y.useRef(null),j=y.useRef(!1);y.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:s,pendingRequestsCount:e.length,currentSelectedId:f?.id}),s&&e.length>0){const H=e.find(ae=>ae.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!H,H?.id),H&&(console.log("[SamplingTab] Auto-selecting request:",H.id),c(null),m(H),setTimeout(()=>{const ae=document.getElementById(`sampling-request-${H.id}`);console.log("[SamplingTab] Scrolling to element:",!!ae),ae&&ae.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),y.useEffect(()=>{const H=ae=>{const L=ae.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",L);const B=e.find(P=>P.id===L);B&&(console.log("[SamplingTab] Selecting request from event:",L),m(B),setTimeout(()=>{const P=document.getElementById(`sampling-request-${L}`);P&&P.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",H),()=>window.removeEventListener("navigate-to-sampling",H)},[e]),y.useEffect(()=>{x&&e.length>0&&O.current&&!j.current&&(O.current.scrollTop=0)},[e.length,x]),y.useEffect(()=>{const H=O.current;if(!H)return;const ae=()=>{H.scrollTop>0&&(j.current=!0,w(!1))};return H.addEventListener("scroll",ae),()=>H.removeEventListener("scroll",ae)},[]),y.useEffect(()=>{e.length===0&&(j.current=!1,w(!0))},[e.length]),y.useEffect(()=>{E&&M.current&&M.current.focus()},[E]);const F=y.useCallback(()=>{h.trim()||_(!1)},[h]),V=y.useMemo(()=>{if(!h.trim())return e;const H=h.toLowerCase();return e.filter(ae=>ae.serverName.toLowerCase().includes(H)||JSON.stringify(ae.request||{}).toLowerCase().includes(H))},[e,h]);y.useEffect(()=>{S(-1)},[h]),y.useEffect(()=>{const H=ae=>{const ne=ae.target;if(ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.contentEditable==="true"||ae.metaKey||ae.ctrlKey||ae.altKey)return;const B=V;if(ae.key==="ArrowDown")ae.preventDefault(),S(P=>{const $=P+1;return $>=B.length?0:$});else if(ae.key==="ArrowUp")ae.preventDefault(),S(P=>{const $=P-1;return $<0?B.length-1:$});else if(ae.key==="Enter"&&v>=0){ae.preventDefault();const P=V[v];P&&J(P)}};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[v,V]),y.useEffect(()=>{if(v>=0){const H=`sampling-request-${V[v]?.id}`,ae=document.getElementById(H);ae&&ae.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,V]);const J=y.useCallback(H=>{m(H)},[]),ee=y.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(H=>{n(H.id,"User rejected all requests")}),m(null))},[e,n]),ie=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)),I(!0),setTimeout(()=>I(!1),2e3)}catch(H){console.error("[SamplingTab] Failed to copy request:",H)}},[f]),W=y.useCallback(()=>{if(f)try{const H=new globalThis.Blob([JSON.stringify({id:f.id,serverName:f.serverName,timestamp:f.timestamp,request:f.request},null,2)],{type:"application/json"}),ae=URL.createObjectURL(H),ne=document.createElement("a");ne.href=ae,ne.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(ae)}catch(H){console.error("[SamplingTab] Failed to download request:",H)}},[f]),Z=y.useCallback(async()=>{if(A.current)try{document.fullscreenElement?await document.exitFullscreen():await A.current.requestFullscreen()}catch(H){console.error("[SamplingTab] Failed to toggle fullscreen:",H)}},[]);return r?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(On,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(On,{defaultSize:75,minSize:30,children:[d.jsx(HTe,{isSearchExpanded:E,searchQuery:h,filteredRequestsCount:V.length,requestsCount:e.length,onSearchExpand:()=>_(!0),onSearchChange:g,onSearchBlur:F,onRejectAll:ee,searchInputRef:M}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(VTe,{requests:V,selectedRequest:f,onRequestSelect:J,focusedIndex:v,formatRelativeTime:ay,listRef:O})})]})})}),d.jsx(wi,{}),d.jsx(On,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:A,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(WTe,{request:f,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>R(!k),isCopied:N,onCopy:ie,onDownload:W,onFullscreen:Z,llmConfig:u})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(HG,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function qTe({requestId:e,serverName:t,mode:n,message:a,url:r,onViewDetails:i,onOpenUrl:s,onCancel:c}){return d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{children:[d.jsx("strong",{children:"Elicitation Request Received"}),d.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",a]}),n==="url"&&r&&d.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:r})]}),d.jsxs("div",{className:"flex gap-2 flex-wrap",children:[d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),i()},children:"View Details"}),n==="url"&&s&&d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),s()},children:"Open URL"}),d.jsx("button",{className:"px-3 py-1.5 text-xs font-medium rounded-md hover:bg-accent hover:text-accent-foreground",onClick:u=>{u.stopPropagation(),c()},children:"Cancel"})]})]})}function XTe({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onCancelAll:c,searchInputRef:u}){return d.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[d.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?d.jsx(Nn,{ref:u,placeholder:"Search requests...",value:t,onChange:f=>i(f.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):d.jsxs(d.Fragment,{children:[d.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),d.jsx(vr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:d.jsx(zd,{className:"h-4 w-4"})})}),d.jsxs(Rt,{side:"bottom",className:"flex gap-2",children:["Search",d.jsx(oh,{children:"F"})]})]})]})}),d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:d.jsx(Qi,{className:"h-4 w-4"})})}),d.jsx(Rt,{side:"bottom",children:"Cancel all"})]})})]})}function JTe({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx(Pd,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):d.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.mode||"form",f=u==="form"&&"requestedSchema"in s.request&&s.request.requestedSchema;return d.jsx(Qs,{id:`elicitation-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:d.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,d.jsx(vr,{variant:"outline",className:u==="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:u})]}),description:(()=>{const m=r(s.timestamp),h=[];f&&h.push("with schema"),u==="url"&&h.push("external action");const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function QTe({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:f}){const[m,h]=y.useState({}),[g,v]=y.useState(!1),S=e?.request.mode||"form",x=S==="form",w=S==="url";y.useEffect(()=>{if(e&&x&&"requestedSchema"in e.request){const O=e.request.requestedSchema,A={};if(O?.type==="object"&&O.properties)for(const[M,j]of Object.entries(O.properties)){const F=j;F.default!==void 0?A[M]=F.default:F.type==="boolean"?A[M]=!1:F.type==="number"||F.type==="integer"?A[M]=0:A[M]=""}h(A)}v(!1)},[e?.id,x]);const E=(O,A)=>{h(M=>({...M,[O]:A}))},_=()=>{if(e){if(x){if("requestedSchema"in e.request){const O=e.request.requestedSchema;if(O?.required){const A=O.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(A.length>0){st.error("Missing required fields",{description:`Please fill in: ${A.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else w&&t(e.id,{action:"accept"});a(),ia(()=>Promise.resolve().then(()=>Rd),void 0).then(O=>{const A=st(O.createElement("div",{className:"space-y-3"},O.createElement("div",null,O.createElement("strong",null,"Elicitation Response Sent"),O.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),O.createElement("div",{className:"flex gap-2"},O.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 M=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:null}});window.dispatchEvent(M),st.dismiss(A)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),a())},R=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},N=()=>{e&&w&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},I=y.useMemo(()=>{if(!e||!x||!("requestedSchema"in e.request))return null;const O=e.request.requestedSchema;if(!O||O.type!=="object"||!O.properties)return d.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const A=O.properties,M=O.required||[];return d.jsx("div",{className:"space-y-4",children:Object.entries(A).map(([j,F])=>{const V=F,J=M.includes(j),ee=V.type||"string",ie=V.title||j,W=V.description;return d.jsxs("div",{className:"space-y-2",children:[d.jsxs(tn,{htmlFor:`field-${j}`,children:[ie,J&&d.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),W&&d.jsx("p",{className:"text-xs text-muted-foreground",children:W}),ee==="boolean"?d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(um,{id:`field-${j}`,checked:m[j]||!1,onCheckedChange:Z=>E(j,Z)}),d.jsx(tn,{htmlFor:`field-${j}`,className:"text-sm font-normal cursor-pointer",children:V.title||j})]}):ee==="number"||ee==="integer"?d.jsx(Nn,{id:`field-${j}`,type:"number",value:m[j]||"",onChange:Z=>E(j,ee==="integer"?parseInt(Z.target.value,10):parseFloat(Z.target.value)),placeholder:V.default?.toString()||""}):V.enum?d.jsxs("select",{id:`field-${j}`,value:m[j]||"",onChange:Z=>E(j,Z.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:[d.jsx("option",{value:"",children:"Select..."}),V.enum.map(Z=>d.jsx("option",{value:Z,children:Z},Z))]}):ee==="string"&&(V.format==="textarea"||V.maxLength>100)?d.jsx(Ql,{id:`field-${j}`,value:m[j]||"",onChange:Z=>E(j,Z.target.value),placeholder:V.default||"",rows:4}):d.jsx(Nn,{id:`field-${j}`,type:"text",value:m[j]||"",onChange:Z=>E(j,Z.target.value),placeholder:V.default||""})]},j)})})},[e,m,x]);return e?d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),d.jsx(vr,{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:S}),d.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?d.jsx(zr,{className:"h-4 w-4 text-green-600"}):d.jsx(br,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Copy request"})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:d.jsx(zm,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Download request"})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",onClick:f,className:"h-8 w-8 p-0",children:d.jsx(uC,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:"Fullscreen"})]}),d.jsx(Oe,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:d.jsx(Qi,{className:"h-4 w-4"})})]})]}),d.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),d.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),w&&"url"in e.request&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),d.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[d.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),d.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[d.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),d.jsxs(Oe,{size:"sm",variant:"outline",onClick:N,className:"flex items-center gap-2",children:[d.jsx(XE,{className:"h-4 w-4"}),"Open URL"]})]}),d.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[d.jsx(um,{id:"url-completed",checked:g,onCheckedChange:O=>v(!!O)}),d.jsx(tn,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),x&&d.jsxs("div",{className:"space-y-2",children:[d.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),I]}),x&&"requestedSchema"in e.request&&e.request.requestedSchema&&d.jsxs("details",{className:"space-y-2",children:[d.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),d.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:d.jsx(Qn,{data:e.request.requestedSchema})})]})]}),d.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[d.jsx(Oe,{onClick:_,className:"flex-1",children:"Accept"}),d.jsx(Oe,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),d.jsx(Oe,{onClick:R,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):d.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function eNe({pendingRequests:e=[],onApprove:t,onReject:n,serverId:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=cc(),[c,u]=y.useState(null),[f,m]=y.useState(""),[h,g]=y.useState(-1),[v,S]=y.useState(!0),[x,w]=y.useState(!1),[E,_]=y.useState(!0),[k,R]=y.useState(!1),N=y.useRef(null),I=y.useRef(null),O=y.useRef(null),A=y.useRef(!1);y.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:c?.id}),i&&e.length>0){const W=e.find(Z=>Z.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!W,W?.id),W&&(console.log("[ElicitationTab] Auto-selecting request:",W.id),s(null),u(W),setTimeout(()=>{const Z=document.getElementById(`elicitation-request-${W.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Z),Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,s]),y.useEffect(()=>{const W=Z=>{const ae=Z.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",ae);const ne=e.find(L=>L.id===ae);ne&&(console.log("[ElicitationTab] Selecting request from event:",ae),u(ne),setTimeout(()=>{const L=document.getElementById(`elicitation-request-${ae}`);L&&L.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",W),()=>window.removeEventListener("navigate-to-elicitation",W)},[e]),y.useEffect(()=>{v&&e.length>0&&N.current&&!A.current&&(N.current.scrollTop=0)},[e.length,v]),y.useEffect(()=>{const W=N.current;if(!W)return;const Z=()=>{W.scrollTop>0&&(A.current=!0,S(!1))};return W.addEventListener("scroll",Z),()=>W.removeEventListener("scroll",Z)},[]),y.useEffect(()=>{e.length===0&&(A.current=!1,S(!0))},[e.length]),y.useEffect(()=>{x&&O.current&&O.current.focus()},[x]);const M=y.useCallback(()=>{f.trim()||w(!1)},[f]),j=y.useMemo(()=>{if(!f.trim())return e;const W=f.toLowerCase();return e.filter(Z=>Z.serverName.toLowerCase().includes(W)||Z.request.message.toLowerCase().includes(W)||JSON.stringify(Z.request||{}).toLowerCase().includes(W))},[e,f]);y.useEffect(()=>{g(-1)},[f]),y.useEffect(()=>{const W=Z=>{const H=Z.target;if(H.tagName==="INPUT"||H.tagName==="TEXTAREA"||H.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const ne=j;if(Z.key==="ArrowDown")Z.preventDefault(),g(L=>{const B=L+1;return B>=ne.length?0:B});else if(Z.key==="ArrowUp")Z.preventDefault(),g(L=>{const B=L-1;return B<0?ne.length-1:B});else if(Z.key==="Enter"&&h>=0){Z.preventDefault();const L=j[h];L&&F(L)}};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[h,j]),y.useEffect(()=>{if(h>=0){const W=`elicitation-request-${j[h]?.id}`,Z=document.getElementById(W);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,j]);const F=y.useCallback(W=>{u(W)},[]),V=y.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(W=>{n(W.id,"User cancelled all requests")}),u(null))},[e,n]),J=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(W){console.error("[ElicitationTab] Failed to copy request:",W)}},[c]),ee=y.useCallback(()=>{if(c)try{const W=new globalThis.Blob([JSON.stringify({id:c.id,serverName:c.serverName,timestamp:c.timestamp,request:c.request},null,2)],{type:"application/json"}),Z=URL.createObjectURL(W),H=document.createElement("a");H.href=Z,H.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(H),H.click(),document.body.removeChild(H),URL.revokeObjectURL(Z)}catch(W){console.error("[ElicitationTab] Failed to download request:",W)}},[c]),ie=y.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(W){console.error("[ElicitationTab] Failed to toggle fullscreen:",W)}},[]);return r?d.jsxs(sa,{direction:"horizontal",className:"h-full",children:[d.jsx(On,{defaultSize:40,minSize:30,children:d.jsx(sa,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:d.jsxs(On,{defaultSize:75,minSize:30,children:[d.jsx(XTe,{isSearchExpanded:x,searchQuery:f,filteredRequestsCount:j.length,requestsCount:e.length,onSearchExpand:()=>w(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:V,searchInputRef:O}),d.jsx("div",{className:"flex flex-col h-full",children:d.jsx(JTe,{requests:j,selectedRequest:c,onRequestSelect:F,focusedIndex:h,formatRelativeTime:ay,listRef:N})})]})})}),d.jsx(wi,{}),d.jsx(On,{defaultSize:60,minSize:40,children:d.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:d.jsx(QTe,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:E,onTogglePreview:()=>_(!E),isCopied:k,onCopy:J,onDownload:ee,onFullscreen:ie})})})]}):d.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[d.jsx(ZG,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),d.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function tNe({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?d.jsxs(d.Fragment,{children:[d.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:d.jsx(gq,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:d.jsx(fq,{ref:a,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:d.jsx(mq,{ref:r,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:d.jsx(Yke,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),d.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:d.jsx(YTe,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),d.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:d.jsx(eNe,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),d.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:d.jsx(NTe,{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"&&d.jsx(d.Fragment,{children:i})]}):d.jsx(d.Fragment,{children:i})}function dF({className:e}){return d.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:[d.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"}),d.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const bq=y.createContext(void 0);function vq(){const e=y.use(bq);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const yq=y.createContext(void 0);function nNe(){return y.use(yq)}function uk({ref:e,children:t,defaultValue:n,value:a,onValueChange:r,className:i,collapsed:s,onCollapsedChange:c,...u}){const[f,m]=y.useState(n||""),h=a!==void 0,g=s!==void 0,[v,S]=y.useState(!1),x=y.useCallback(k=>{h||m(k),r?.(k)},[h,r]),w=h?a:f,E=g?s:v,_=y.useCallback(k=>{g||S(k),c?.(k)},[g,c]);return d.jsx(bq,{value:{activeValue:w,handleValueChange:x,collapsed:E,handleCollapsedChange:_},children:d.jsx("div",{ref:e,className:Le("flex flex-col gap-2",i),...u,children:t})})}uk.displayName="Tabs";function dk({ref:e,children:t,className:n,variant:a="default",collapsible:r=!1,...i}){const{activeValue:s,collapsed:c,handleCollapsedChange:u}=vq(),[f,m]=y.useState({width:0,left:0}),h=y.useRef(null),g=y.useRef(null),v=y.useRef(null),S=y.useCallback(()=>{const E=h.current;if(!E)return;const _=E.querySelector("div:first-child");if(!_)return;const k=_.querySelector(`button[data-tab-value="${s}"]`);if(k&&s){const R=_.getBoundingClientRect(),N=k.getBoundingClientRect();m({width:N.width,left:N.left-R.left})}else m({width:0,left:0})},[s]),x=y.useCallback(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(S,16)},[S]);y.useEffect(()=>{const E=setTimeout(S,10);return()=>clearTimeout(E)},[S,c]),y.useEffect(()=>{const E=h.current;if(!E)return;g.current=new ResizeObserver(()=>{x()}),g.current.observe(E);const _=E.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 E=()=>{x()};return window.addEventListener("resize",E),()=>window.removeEventListener("resize",E)},[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]),d.jsx(yq,{value:{variant:a,collapsed:c,handleCollapsedChange:u},children:d.jsx("div",{ref:h,className:Le("relative flex items-center bg-none gap-1",a==="default"&&"p-1 rounded-full border border-zinc-300 dark:border-zinc-600",a==="underline"&&"border-b border-zinc-200 dark:border-zinc-700",n),...i,children:d.jsxs("div",{role:"tablist",className:"flex-1 flex items-center relative",children:[t,d.jsx("span",{ref:w,className:Le("absolute transition-all duration-500 ease-in-out z-0",a==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%)] top-0 border border-zinc-300 dark:border-zinc-600",a==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white")})]})})})}dk.displayName="TabsList";const rNe=({children:e,title:t,collapsed:n})=>!t||!n?e:d.jsx(oC,{children:d.jsxs(Nt,{children:[d.jsx(Ct,{children:e}),d.jsx(Rt,{children:t})]})}),fk=y.forwardRef(({children:e,value:t,className:n,disabled:a,icon:r,title:i,...s},c)=>{const{activeValue:u,handleValueChange:f,collapsed:m}=vq(),g=nNe()?.variant||"default",v=u===t,S=m&&i?i:void 0;return d.jsx(rNe,{title:i,collapsed:m,children:d.jsxs("button",{ref:c,disabled:a,onClick:()=>f(t),"data-tab-value":t,"data-tab-active":v,role:"tab","aria-selected":v?"true":"false",title:S,className:Le("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",g==="default"&&"py-2.5",g==="default"&&"rounded-md px-4",g==="underline"&&"px-6 py-3 border-b-2 border-transparent",v&&"text-foreground",!v&&"text-muted-foreground hover:text-foreground",n),...s,children:[r&&d.jsx(r,{className:Le("h-4 w-4 transition-all duration-500 ease-in-out",!m&&"mr-2",m&&"mr-0!")}),d.jsx("span",{className:Le("transition-all duration-500 ease-in-out overflow-hidden",m?"w-0 opacity-0":"w-auto opacity-100"),children:e})]})})});fk.displayName="TabsTrigger";function fF({className:e}){const{theme:t,setTheme:n}=m0(),a=y.useRef(null),[r,i]=y.useState(!1);y.useEffect(()=>{i(!0)},[]);const s=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?d.jsx(pU,{className:"size-4"}):t==="light"?d.jsx(Rme,{className:"size-5"}):d.jsx(cme,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",f=async()=>{if(!a.current)return;const m=s();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{Dd.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:S}=a.current.getBoundingClientRect(),x=h+S/2,w=g+v/2,E=window.innerWidth-g,_=window.innerHeight-h,k=Math.hypot(Math.max(g,E),Math.max(h,_));document.documentElement.animate({clipPath:[`circle(0px at ${w}px ${x}px)`,`circle(${k}px at ${w}px ${x}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?d.jsx("button",{ref:a,onClick:f,className:Le(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):d.jsx("button",{ref:a,className:Le(e),"aria-label":"Toggle theme",children:d.jsx(pU,{className:"size-4"})})}function pF({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[a,r]=y.useState(!1),i=.2,s=.7,c=.6,u=4,f=i+s+c,m=0,h=i/f,g=(i+s)/f,v=1;return d.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:Le("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[d.jsx("div",{className:"relative",children:d.jsxs(xa.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:Le("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[d.jsxs(xa.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:u,strokeLinecap:"round",strokeLinejoin:"round",children:[d.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"}),d.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),d.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),d.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx(aNe,{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}),d.jsx(mF,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f}),d.jsx(mF,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:f})]})]})}),t==="expanded"&&d.jsxs("div",{className:"font-ubuntu flex-col items-start -space-y-1 mr-3 hidden xl:flex",children:[d.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),d.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function aNe({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return d.jsx(xa.path,{d:e,variants:{rest:{pathLength:0,opacity:0},hover:{pathLength:[0,0,1,1],opacity:[0,0,1,1],transition:{duration:n,times:[a,r,i,s],ease:"easeInOut"}}}})}function mF({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return d.jsx(xa.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:r,times:[i,s,c,u],ease:"easeInOut"}}}})}function Cb({open:e,onOpenChange:t,serverUrl:n,serverName:a,serverId:r,headers:i,language:s}){const{prismStyle:c}=TO(),[u,f]=y.useState(!1),m=s==="typescript"?TF(n,a,r,i):NF(n,a,r,i),h=async()=>{await navigator.clipboard.writeText(m),f(!0),setTimeout(()=>f(!1),2e3)},g=s==="typescript"?"TypeScript":"Python",v=s==="typescript"?"npm install mcp-use":"pip install mcp-use";return d.jsx(Ll,{open:e,onOpenChange:t,children:d.jsxs($l,{className:"max-w-[90vw] max-h-[90vh] overflow-hidden flex flex-col",children:[d.jsxs(Ml,{children:[d.jsxs(Pl,{children:["Add to ",g," SDK"]}),d.jsxs(O7,{children:["Copy the following code to integrate this server into your"," ",g," application using the mcp-use SDK."]})]}),d.jsxs("div",{className:"space-y-4 overflow-y-auto flex-1 min-h-0",children:[d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Instructions"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsxs("span",{children:["Install the mcp-use package:"," ",d.jsx("code",{className:"text-foreground",children:v})]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsxs("span",{children:["Copy the following code into your ",g," project:"]})]})]})]}),d.jsxs("div",{className:"relative w-full overflow-x-auto overflow-y-auto max-h-[60vh]",children:[d.jsx("div",{className:"absolute top-2 right-2 z-10",children:d.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2 bg-background hover:bg-accent border border-border",onClick:h,children:u?d.jsx(zr,{className:"size-3.5 text-green-600"}):d.jsx(br,{className:"size-3.5"})})}),d.jsx(Xp,{language:s,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 wq({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:f}=m0(),m=f==="dark"?"#000000":"#ffffff",h=f==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=i||h;return d.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":r,"--speed":a,"--cut":n,"--bg":v},className:Le("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",s),ref:e,...u,children:[d.jsx("div",{className:Le("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:d.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:d.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,d.jsx("div",{className:Le("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]")}),d.jsx("div",{className:Le("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}wq.displayName="ShimmerButton";function hF({status:e}){const t=i=>{switch(i){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:i}}},{color:n,ringColor:a,tooltip:r}=t(e);return d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),d.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),d.jsx(Rt,{children:d.jsx("p",{children:r})})]})}function gF({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=Bd(),[s,c]=y.useState(!1),[u,f]=y.useState(null),m=h=>{const g=e.find(v=>v.id===h);if(!g||g.state!=="ready"){st.error("Server is not connected and cannot be inspected");return}n(h)};return r?d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("div",{className:"relative",children:d.jsxs(WE,{children:[d.jsx(KE,{asChild:!0,children:d.jsxs(Oe,{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?d.jsx(yu,{server:t,size:"md"}):d.jsx(KG,{className:"h-5 w-5"}),d.jsx(Po,{className:"h-4 w-4"})]})}),d.jsxs(Iv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(ZE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),d.jsx(sp,{}),e.length===0?d.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=>d.jsxs(Ui,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[d.jsx(yu,{server:h,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:h.name}),d.jsx(hF,{status:h.state})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Oe,{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:d.jsx(vp,{className:"h-3 w-3"})}),d.jsx(Oe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),a(h.id)},children:d.jsx(Tu,{className:"h-3 w-3"})})]})]},h.id)),d.jsx(sp,{}),d.jsx(Ui,{onClick:()=>i("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})}),d.jsx(g_,{open:s,onOpenChange:c,connection:u})]}):d.jsx("div",{className:"flex items-center gap-2",children:d.jsxs("div",{className:"relative",children:[d.jsxs(WE,{children:[d.jsx(KE,{asChild:!0,children:d.jsxs(wq,{className:Le("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&&d.jsx(yu,{server:t,size:"md",className:"mr-2"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.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&&d.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.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"})}),d.jsx(Rt,{children:d.jsx("p",{className:"max-w-xs",children:t.error})})]}):d.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&&d.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center gap-1",children:[d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.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:d.jsx(vp,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:d.jsx("p",{children:"View server info"})})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx("button",{type:"button",onClick:()=>{a(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:d.jsx(Tu,{className:"h-4 w-4"})})}),d.jsx(Rt,{children:d.jsx("p",{children:"Edit connection settings"})})]})]}),d.jsxs(Iv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[d.jsx(ZE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),d.jsx(sp,{}),e.length===0?d.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=>d.jsxs(Ui,{onClick:()=>m(h.id),className:"flex items-center gap-3",children:[d.jsx(yu,{server:h,size:"sm"}),d.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[d.jsx("div",{className:"font-medium",children:h.serverInfo?.title||h.serverInfo?.name||h.name}),d.jsx(hF,{status:h.state})]}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx(Oe,{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:d.jsx(vp,{className:"h-3 w-3"})}),d.jsx(Oe,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:g=>{g.stopPropagation(),a(h.id)},children:d.jsx(Tu,{className:"h-3 w-3"})})]})]},h.id)),d.jsx(sp,{}),d.jsx(Ui,{onClick:()=>i("/"),children:d.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]}),d.jsx(g_,{open:s,onOpenChange:c,connection:u})]})})}const bF=[{id:"tools",label:"Tools",icon:Zl},{id:"prompts",label:"Prompts",icon:Wp},{id:"resources",label:"Resources",icon:Gpe},{id:"sampling",label:"Sampling",icon:HG},{id:"elicitation",label:"Elicitation",icon:ZG},{id:"notifications",label:"Notifications",icon:sC},{id:"chat",label:"Chat",icon:ame}];function vF(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 iNe({collapsed:e,onToggle:t}){return d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx("button",{onClick:t,className:Le("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?d.jsx(FG,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"}):d.jsx(Xy,{className:"h-4 w-4 transition-transform duration-500 ease-in-out"})})}),d.jsx(Rt,{children:d.jsx("p",{children:e?"Expand tabs":"Collapse tabs"})})]})}function oNe({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s,embedded:c=!1}){const{tunnelUrl:u}=cc(),f=t&&u,[m,h]=y.useState(!1),[g,v]=y.useState(!1),[S,x]=y.useState(!1),[w,E]=y.useState(!0),_=async()=>{if(u)try{await navigator.clipboard.writeText(`${u}/mcp`),h(!0),st.success("Tunnel URL copied to clipboard"),setTimeout(()=>h(!1),2e3)}catch{st.error("Failed to copy URL")}};return d.jsxs("header",{className:"w-full mx-auto",children:[d.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[d.jsxs("div",{className:"flex items-center justify-between w-full",children:[!c&&d.jsx("div",{className:"flex-1 flex justify-start",children:d.jsx(gF,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),!c&&d.jsx("div",{className:"flex-shrink-0 flex justify-center",children:d.jsx("div",{className:"scale-150",children:d.jsx(pF,{state:"collapsed"})})}),!c&&d.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[t&&(()=>{const k=t.serverInfo?.title||t.serverInfo?.name||t.name;return d.jsxs(d.Fragment,{children:[d.jsx(ME,{serverConfig:{url:u?`${u}/mcp`:t.url,name:k,headers:t.customHeaders,serverId:t.id},onSuccess:R=>st.success(`Opening in ${R}...`),onError:R=>st.error(`Failed: ${R.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:d.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:d.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:d.jsxs(Oe,{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:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(Ov,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(Po,{className:"size-3"})]})]})}),d.jsx(Cb,{open:g,onOpenChange:v,serverUrl:u?`${u}/mcp`:t.url,serverName:k,serverId:void 0,headers:t.customHeaders,language:"typescript"}),d.jsx(Cb,{open:S,onOpenChange:x,serverUrl:u?`${u}/mcp`:t.url,serverName:k,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",asChild:!0,children:d.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:d.jsx(dF,{className:"h-4 w-4"})})})}),d.jsx(Rt,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(fF,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&d.jsx("div",{className:"w-full",children:d.jsx(uk,{value:n,onValueChange:k=>r(k),collapsed:w,onCollapsedChange:E,children:d.jsx(dk,{className:"w-full justify-center",children:bF.map(k=>{const R=vF(k.id,t);return d.jsxs(fk,{value:k.id,icon:k.icon,className:Le("[&>svg]:mr-0 flex-1 flex-row gap-2 relative",w&&"pl-2"),children:[R>0&&d.jsx("span",{className:Le(n===k.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}),d.jsx("span",{className:"sr-only",children:k.label})]},k.id)})})})})]}),d.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[d.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[!c&&d.jsx(gF,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(uk,{value:n,onValueChange:k=>r(k),collapsed:w,onCollapsedChange:E,children:d.jsx(dk,{className:"overflow-x-auto",collapsible:!0,children:bF.map(k=>{const R=vF(k.id,t),N=R>0?`${k.label} (${R})`:k.label;return d.jsx(fk,{value:k.id,icon:k.icon,className:Le("[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",w&&"pl-4"),title:N,children:d.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[k.label,R>0&&d.jsx("span",{className:Le(n===k.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})]})})})})}),d.jsx(iNe,{collapsed:w,onToggle:()=>E(!w)})]}),f&&d.jsxs(jZ,{children:[d.jsx(LZ,{asChild:!0,children:d.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:[d.jsx(Kp,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),d.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),d.jsx(lD,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{children:[d.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[d.jsx(Kp,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),d.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[d.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[u,"/mcp"]}),d.jsx(Oe,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:_,children:m?d.jsx(zr,{className:"size-3.5 text-green-600"}):d.jsx(br,{className:"size-3.5"})})]})]}),d.jsxs("div",{children:[d.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),d.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"1."}),d.jsxs("span",{children:["Enable"," ",d.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"2."}),d.jsxs("span",{children:["In"," ",d.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",d.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),d.jsxs("li",{className:"flex gap-2",children:[d.jsx("span",{className:"font-semibold text-foreground",children:"3."}),d.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),!c&&d.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[t&&(()=>{const k=t.serverInfo?.title||t.serverInfo?.name||t.name;return d.jsxs(d.Fragment,{children:[d.jsx(ME,{serverConfig:{url:u?`${u}/mcp`:t.url,name:k,headers:t.customHeaders,serverId:t.id},onSuccess:R=>st.success(`Opening in ${R}...`),onError:R=>st.error(`Failed: ${R.message}`),additionalItems:[{id:"ts-sdk",label:"TypeScript SDK",icon:d.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:d.jsx("img",{src:"https://cdn.simpleicons.org/python",alt:"Python",className:"h-4 w-4"}),onClick:()=>x(!0)}],trigger:d.jsxs(Oe,{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:[d.jsxs("span",{className:"xl:hidden hidden sm:flex items-center gap-1",children:[d.jsx(Ov,{className:"size-3"}),"Client"]}),d.jsxs("span",{className:"hidden xl:flex items-center gap-1",children:["Add to Client",d.jsx(Po,{className:"size-3"})]})]})}),d.jsx(Cb,{open:g,onOpenChange:v,serverUrl:u?`${u}/mcp`:t.url,serverName:k,serverId:void 0,headers:t.customHeaders,language:"typescript"}),d.jsx(Cb,{open:S,onOpenChange:x,serverUrl:u?`${u}/mcp`:t.url,serverName:k,serverId:void 0,headers:t.customHeaders,language:"python"})]})})(),d.jsxs(Nt,{children:[d.jsx(Ct,{children:d.jsx(fF,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),d.jsx(Rt,{children:d.jsx("p",{children:"Toggle theme"})})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsxs(Oe,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[d.jsx(Cpe,{className:"size-4"}),d.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),d.jsx(Rt,{children:d.jsx("p",{children:"Command Palette"})})]}),d.jsxs(Nt,{children:[d.jsx(Ct,{asChild:!0,children:d.jsx(Oe,{variant:"ghost",size:"sm",asChild:!0,children:d.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[d.jsx(dF,{className:"h-4 w-4"}),d.jsx("span",{className:"hidden xl:inline",children:"Github"})]})})}),d.jsx(Rt,{children:d.jsx("p",{children:"Give us a star ⭐"})})]}),d.jsx(pF,{state:"expanded"})]})]})]})}function sNe({children:e}){const t=Bd(),n=Wo(),{servers:a,addServer:r,removeServer:i,storageLoaded:s}=Am(),c=y.useCallback((P,$,z,G)=>{r(P,{url:P,name:$,proxyConfig:z,transportType:G})},[r]),u=y.useCallback((P,$)=>{console.warn("[Layout] updateConnectionConfig not yet supported in new provider")},[]),{selectedServerId:f,setSelectedServerId:m,activeTab:h,setActiveTab:g,navigateToItem:v,setTunnelUrl:S,tunnelUrl:x,isEmbedded:w,embeddedConfig:E,setEmbeddedMode:_}=cc(),[k,R]=y.useState(!1),[N,I]=y.useState(null),O=TSe();y.useEffect(()=>{const P=new URLSearchParams(n.search),$=P.get("embedded")==="true",z=P.get("embeddedConfig");if($){let G={};if(z)try{G=JSON.parse(z)}catch(K){console.error("Failed to parse embeddedConfig:",K)}_(!0,G)}},[]),y.useEffect(()=>{const $=new URLSearchParams(n.search).get("tunnelUrl");S($)},[n.search,S]),y.useEffect(()=>{const $=new URLSearchParams(n.search).get("tab");$&&["tools","prompts","resources","chat","sampling","elicitation","notifications"].includes($)&&g($)},[n.search,g]),y.useEffect(()=>{const P=G=>{const re=G.detail.requestId;f&&v(f,"sampling",re)},$=G=>{const re=G.detail.requestId;f&&v(f,"elicitation",re)},z=G=>{const re=G.detail.toolName;f&&re?v(f,"tools",re):f&&g("tools")};return window.addEventListener("navigate-to-sampling",P),window.addEventListener("navigate-to-elicitation",$),window.addEventListener("navigate-to-tool-result",z),()=>{window.removeEventListener("navigate-to-sampling",P),window.removeEventListener("navigate-to-elicitation",$),window.removeEventListener("navigate-to-tool-result",z)}},[f,g,v]);const A=y.useRef(null),M=y.useRef(null),j=y.useRef(null),{isAutoConnecting:F}=kSe({connections:a,addConnection:c,removeConnection:i,configLoaded:s,embedded:w}),V=y.useCallback(P=>{$r.getInstance().capture(new qfe({trigger:P})).catch(()=>{}),R(!0)},[]),J=P=>{const $=a.find(fe=>fe.id===P);if(!$||$.state!=="ready"){st.error("Server is not connected and cannot be inspected");return}m(P);const z=new URLSearchParams(n.search),G=z.get("tunnelUrl"),K=z.get("tab"),re=new URLSearchParams;re.set("server",P),G&&re.set("tunnelUrl",G),K&&re.set("tab",K),t(`/?${re.toString()}`)},ee=y.useCallback(P=>{I(P)},[]),ie=y.useCallback(P=>{N&&(P.url!==N?(i(N),c(P.url,P.name,P.proxyConfig,P.transportType)):u(N,{name:P.name,proxyConfig:P.proxyConfig,transportType:P.transportType}),I(null),st.success("Connection settings updated"))},[N,i,c,u]),W=(P,$,z)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:P,itemName:$,serverId:z}),z){const G=a.find(te=>te.id===z);if(console.warn("[Layout] Server lookup:",{serverId:z,serverFound:!!G,serverState:G?.state}),!G||G.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),st.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:z,tab:P,itemName:$}),v(z,P,$);const K=new URLSearchParams(n.search),re=K.get("tunnelUrl"),fe=K.get("tab"),ce=new URLSearchParams;ce.set("server",z),re&&ce.set("tunnelUrl",re),P?ce.set("tab",P):fe&&ce.set("tab",fe);const q=`/?${ce.toString()}`;console.warn("[Layout] Navigating to:",q),t(q)}else console.warn("[Layout] No serverId, just updating tab to:",P),g(P)},Z=a.find(P=>P.id===f),H=Z?Z.tools.map(P=>({...P,_serverId:Z.id})):a.flatMap(P=>P.state==="ready"?P.tools.map($=>({...$,_serverId:P.id,_serverName:P.name})):[]),ae=Z?Z.prompts.map(P=>({...P,_serverId:Z.id})):a.flatMap(P=>P.state==="ready"?P.prompts.map($=>({...$,_serverId:P.id,_serverName:P.name})):[]),ne=Z?Z.resources.map(P=>({...P,_serverId:Z.id})):a.flatMap(P=>P.state==="ready"?P.resources.map($=>({...$,_serverId:P.id,_serverName:P.name})):[]);if(y.useEffect(()=>{const $=new URLSearchParams(n.search).get("server"),z=$?decodeURIComponent($):null;z!==f&&m(z)},[n.search,f,m]),y.useEffect(()=>{const $=new URLSearchParams(n.search).get("server");if(!$)return;const z=decodeURIComponent($),G=a.find(K=>K.id===z);if(!G){const K=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(K)}if(G.state==="failed"){const K=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(K)}},[n.search,t,a]),lZ({onCommandPalette:()=>V("keyboard"),onToolsTab:()=>{Z&&g("tools")},onPromptsTab:()=>{Z&&g("prompts")},onResourcesTab:()=>{Z&&g("resources")},onChatTab:()=>{Z&&g("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{h==="tools"&&A.current?A.current.focusSearch():h==="prompts"&&M.current?M.current.focusSearch():h==="resources"&&j.current&&j.current.focusSearch()},onBlurSearch:()=>{h==="tools"&&A.current?A.current.blurSearch():h==="prompts"&&M.current?M.current.blurSearch():h==="resources"&&j.current&&j.current.blurSearch()}}),F)return d.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx(Yi,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})});const L=w?{backgroundColor:E.backgroundColor||"#f3f3f3",padding:E.padding||"0.5rem"}:{},B=w?"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 d.jsx(oC,{children:d.jsxs("div",{className:B,style:L,children:[d.jsx(oNe,{connections:a,selectedServer:Z,activeTab:h,onServerSelect:J,onTabChange:g,onCommandPaletteOpen:()=>V("button"),onOpenConnectionOptions:ee,embedded:w}),d.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:d.jsx(tNe,{selectedServer:Z,activeTab:h,toolsSearchRef:A,promptsSearchRef:M,resourcesSearchRef:j,children:e})}),d.jsx(eEe,{isOpen:k,onOpenChange:R,tools:H,prompts:ae,resources:ne,savedRequests:O,connections:a,selectedServer:Z,tunnelUrl:x,onNavigate:W,onServerSelect:J}),d.jsx(TW,{connection:N&&a.find(P=>P.id===N)||null,open:N!==null,onOpenChange:P=>{P||I(null)},onConnect:ie})]})})}function lNe(){const[e,t]=y.useState("processing"),[n,a]=y.useState("");return y.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),DN().then(()=>{console.log("[OAuthCallback] Authorization successful"),t("success")}).catch(r=>{console.error("[OAuthCallback] Authorization failed:",r),t("error"),a(r instanceof Error?r.message:String(r))})},[]),e==="processing"?d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"flex flex-col items-center gap-4",children:[d.jsx(Fs,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"max-w-md p-6",children:[d.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),d.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):d.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:d.jsxs("div",{className:"max-w-md p-6",children:[d.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),d.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var cNe=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,f=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(S=>{let x=S==="class",w=x&&i?r.map(E=>i[E]||E):r;x?(u.classList.remove(...w),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(S,v)}),h(v)}function h(v){c&&f.includes(v)&&(u.style.colorScheme=v)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(a)m(a);else try{let v=localStorage.getItem(t)||n,S=s&&v==="system"?g():v;m(S)}catch{}},uNe=y.createContext(void 0),dNe={setTheme:e=>{},themes:[]},fNe=()=>{var e;return(e=y.useContext(uNe))!=null?e:dNe};y.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:a,enableColorScheme:r,defaultTheme:i,value:s,themes:c,nonce:u,scriptProps:f})=>{let m=JSON.stringify([n,t,i,e,c,s,a,r]).slice(1,-1);return y.createElement("script",{...f,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${cNe.toString()})(${m})`}})});function pNe({...e}){const{theme:t="system"}=fNe();return d.jsx(Dge,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function mNe(){const t=new URLSearchParams(window.location.search).get("embedded")==="true",n=y.useMemo(()=>t?void 0:new rse("mcp-inspector-connections"),[t]);return d.jsx(Mve,{children:d.jsx(_9,{storageProvider:n,enableRpcLogging:!0,onServerAdded:(a,r)=>{console.log("[Inspector] Server added:",a,r.state)},onServerRemoved:a=>{console.log("[Inspector] Server removed:",a)},onServerStateChange:(a,r)=>{console.log("[Inspector] Server state changed:",a,r)},onSamplingRequest:(a,r,i,s,c)=>{const u=st(d.jsx(ZTe,{requestId:a.id,serverName:i,onViewDetails:()=>{const f=new CustomEvent("navigate-to-sampling",{detail:{requestId:a.id}});window.dispatchEvent(f),st.dismiss(u)},onApprove:f=>{s(a.id,f),st.success("Sampling request approved"),st.dismiss(u)},onDeny:()=>{c(a.id,"User denied from toast"),st.dismiss(u)}}),{duration:1/0})},onElicitationRequest:(a,r,i,s,c)=>{const u=a.request.mode||"form",f=a.request.message,m=u==="url"&&"url"in a.request?a.request.url:void 0,h=st(d.jsx(qTe,{requestId:a.id,serverName:i,mode:u,message:f,url:m,onViewDetails:()=>{const g=new CustomEvent("navigate-to-elicitation",{detail:{requestId:a.id}});window.dispatchEvent(g),st.dismiss(h)},onOpenUrl:u==="url"&&m?()=>{window.open(m,"_blank"),st.dismiss(h)}:void 0,onCancel:()=>{c(a.id,"User cancelled from toast"),st.dismiss(h)}}),{duration:1/0})},children:d.jsxs(_Se,{children:[d.jsx(Xhe,{basename:"/inspector",children:d.jsxs(Che,{children:[d.jsx(e_,{path:"/oauth/callback",element:d.jsx(lNe,{})}),d.jsx(e_,{path:"/",element:d.jsx(sNe,{children:d.jsx(ESe,{})})})]})}),d.jsx(pNe,{position:"top-center"})]})})})}const yF=new URLSearchParams(window.location.search);if(yF.has("code")||yF.has("error"))try{DN()}catch(e){console.error("[inspector] OAuth callback error:",e)}const wF=document.getElementById("root");wF?dse.createRoot(wF).render(d.jsx(mNe,{})):console.error("[inspector] Root element not found");const hNe=Object.freeze(Object.defineProperty({__proto__:null,clearRpcLogs:Sv,getAllRpcLogs:$N,getRpcLogs:k9,subscribeToRpcLogs:MN,wrapTransportForLogging:T9},Symbol.toStringTag,{value:"Module"}));export{HB as $,bi as A,Bae as B,cz as C,cE as D,ni as E,t5 as F,s6 as G,Goe as H,ZF as I,Ob as J,XF as K,e5 as L,Foe as M,BB as N,jl as O,cv as P,$t as Q,X as R,C6 as S,Pi as T,$F as U,ZJ as V,$b as W,LJ as X,Woe as Y,Qne as Z,ke as _,ia as a,$J as a0,DN as a1,YJ as a2,Rd as b,iy as c,Boe as d,wk as e,vNe as f,bNe as g,Hoe as h,ud as i,XT as j,Wne as k,$e as l,Ib as m,lv as n,np as o,i3 as p,Dne as q,y as r,Dp as s,cu as t,cd as u,Ey as v,dd as w,iH as x,lE as y,eN as z};