@mcp-use/inspector 0.12.4 → 0.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{browser-BXiX12HB.js → browser-BzPxdp9T.js} +3 -3
- package/dist/client/assets/{display-A5IEINAP-DDBGWlE8.js → display-A5IEINAP-BX11cXGe.js} +2 -2
- package/dist/client/assets/{embeddings-BQZ_4S4e.js → embeddings-Azb3VHue.js} +1 -1
- package/dist/client/assets/{index-n6TPfFwj.js → index-BFcdg9p1.js} +1 -1
- package/dist/client/assets/{index-azxbEkS4.js → index-BZHKq4Gu.js} +6 -6
- package/dist/client/assets/{index-CRN2s3We.js → index-CYBG3mWU.js} +1 -1
- package/dist/client/assets/{index-B9yMwUUM.js → index-CbvsEzXT.js} +1 -1
- package/dist/client/assets/{index-C98SBxLG.js → index-DMdheUGh.js} +1 -1
- package/dist/client/assets/{index-Dcx9kAyu.js → index-Dh_Vxoku.js} +1 -1
- package/dist/client/assets/{index-xIW0QfEK.js → index-O0gjGlMB.js} +1 -1
- package/dist/client/assets/{index-DHrW1lhp.js → index-VGF5GoM6.js} +1 -1
- package/dist/client/assets/{index-Dq07y2HU.js → index-dr09MWBF.js} +1 -1
- package/dist/client/assets/{winston-DtEZGSVd.js → winston-Yd0Tb9GZ.js} +1 -1
- package/dist/client/index.html +2 -2
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/winston-
|
|
2
|
-
var Vq=Object.defineProperty;var Gq=(e,t,n)=>t in e?Vq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Nf=(e,t,n)=>Gq(e,typeof t!="symbol"?t+"":t,n);function Wq(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 Wp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function tTe(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 gx={exports:{}},Cf={};var F$;function Kq(){if(F$)return Cf;F$=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 Cf.Fragment=t,Cf.jsx=n,Cf.jsxs=n,Cf}var B$;function Zq(){return B$||(B$=1,gx.exports=Kq()),gx.exports}var f=Zq();const Yq="modulepreload",qq=function(e){return"/inspector/"+e},H$={},Qn=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){let u=function(d){return Promise.all(d.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(d=>{if(d=qq(d),d in H$)return;H$[d]=!0;const m=d.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":Yq,m||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,w)=>{g.addEventListener("load",v),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${d}`)))})}))}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 Xq=Object.defineProperty,Pe=(e,t)=>Xq(e,"name",{value:t,configurable:!0}),Es=(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')}),Gc={};async function F2(){if(typeof process<"u")try{const e=await Qn(()=>import("./__vite-browser-external-D7Ct-6yo.js").then(n=>n._),[]),t=await Qn(()=>import("./path-C2bN6h38.js").then(n=>n.p),[]);return{fs:e.default,path:t.default}}catch{return{fs:null,path:null}}return{fs:null,path:null}}Pe(F2,"getNodeModules");var Aa=null;function B2(){if(typeof Es<"u")try{Aa=Es("winston")}catch{}}Pe(B2,"loadWinstonSync");async function H2(){return Aa||(Aa=await Qn(()=>import("./winston-DtEZGSVd.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),Aa}Pe(H2,"getWinston");var PS="mcp-use";function Ob(){try{return typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")||typeof globalThis.EdgeRuntime<"u"||typeof globalThis.Deno<"u"?!1:typeof process<"u"&&!0&&typeof __dirname<"u"}catch{return!1}}Pe(Ob,"isNodeJSEnvironment");var Eu,Jq=(Eu=class{_level;name;constructor(t=PS,n="info"){this.name=t,this._level=n}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],a=n.indexOf(this._level);return n.indexOf(t)<=a}formatMessage(t,n){return`${new Date().toLocaleTimeString("en-US",{hour12:!1})} [${this.name}] ${t}: ${n}`}error(t){this.shouldLog("error")&&console.error(this.formatMessage("error",t))}warn(t){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t))}info(t){this.shouldLog("info")&&console.info(this.formatMessage("info",t))}debug(t){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t))}http(t){this.shouldLog("http")&&console.log(this.formatMessage("http",t))}verbose(t){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t))}silly(t){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t))}get level(){return this._level}set level(t){this._level=t}},Pe(Eu,"SimpleConsoleLogger"),Eu);function sb(e){switch((typeof process<"u"&&Gc?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}Pe(sb,"resolveLevel");var So,V2=(So=class{static get(t=PS){if(!Ob()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&Gc?.DEBUG||void 0;this.simpleInstances[t]=new Jq(t,sb(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!Aa)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:a}=Aa,{combine:r,timestamp:i,label:s,colorize:c,splat:u}=a;this.instances[t]=n({level:sb(Gc.DEBUG),format:r(c(),u(),s({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[]})}return this.instances[t]}static getFormatter(){if(!Aa)throw new Error("Winston not loaded");const{format:t}=Aa,{printf:n}=t,a=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s}: ${c}`),r=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s.toUpperCase()}: ${c}`),i=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s.toUpperCase()}: ${c}`);switch(this.currentFormat){case"minimal":return a;case"detailed":return r;case"emoji":return i;default:return a}}static async configure(t={}){const{level:n,console:a=!0,file:r,format:i="minimal"}=t,s=typeof process<"u"&&Gc?.DEBUG||void 0,c=n??sb(s);if(this.currentFormat=i,!Ob()){Object.values(this.simpleInstances).forEach(y=>{y.level=c});return}if(await H2(),!Aa)throw new Error("Failed to load winston");const u=this.get();u.level=c;const d=u;if(d.clear(),a&&d.add(new Aa.transports.Console),r){const{fs:y,path:_}=await F2();if(y&&_){const E=_.dirname(_.resolve(r));y.existsSync(E)||y.mkdirSync(E,{recursive:!0}),d.add(new Aa.transports.File({filename:r}))}}const{format:m}=Aa,{combine:h,timestamp:g,label:v,colorize:w,splat:S}=m;Object.values(this.instances).forEach(y=>{y&&"format"in y&&(y.level=c,y.format=h(w(),S(),v({label:PS}),g({format:"HH:mm:ss"}),this.getFormatter()))})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.simpleInstances).forEach(a=>{a.level=n}),Object.values(this.instances).forEach(a=>{a&&(a.level=n)}),typeof process<"u"&&Gc&&(Gc.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},Pe(So,"Logger"),Nf(So,"instances",{}),Nf(So,"simpleInstances",{}),Nf(So,"currentFormat","minimal"),So);Ob()&&(B2(),Aa&&V2.configure());var we=V2.get(),lb={},G2=typeof globalThis.Deno<"u";function Qq(e){return G2?globalThis.Deno.env.get(e):lb[e]}Pe(Qq,"getEnv");function eX(){return G2?globalThis.Deno.cwd():process.cwd()}Pe(eX,"getCwd");function tu(){return globalThis.crypto.randomUUID()}Pe(tu,"generateUUID");var tX="1.10.4";function Db(){return tX}Pe(Db,"getPackageVersion");var _u,Ti=(_u=class{},Pe(_u,"BaseTelemetryEvent"),_u),ku,nX=(ku=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}}},Pe(ku,"MCPAgentExecutionEvent"),ku);function W2(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"),d=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:d.length>0?d:null,mcpAppsResourcesNumber:d.length}}Pe(W2,"createServerRunEventData");var Tu,rX=(Tu=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}}},Pe(Tu,"ServerRunEvent"),Tu),Nu,aX=(Nu=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}}},Pe(Nu,"ServerInitializeEvent"),Nu),Cu,iX=(Cu=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}}},Pe(Cu,"ServerToolCallEvent"),Cu),Ru,oX=(Ru=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}}},Pe(Ru,"ServerResourceCallEvent"),Ru),Au,sX=(Au=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}}},Pe(Au,"ServerPromptCallEvent"),Au),Iu,lX=(Iu=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}}},Pe(Iu,"ServerContextEvent"),Iu),Ou,cX=(Ou=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}}},Pe(Ou,"MCPClientInitEvent"),Ou),Du,uX=(Du=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}}},Pe(Du,"ConnectorInitEvent"),Du),ju,dX=(ju=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}}},Pe(ju,"ClientAddServerEvent"),ju),Lu,fX=(Lu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},Pe(Lu,"ClientRemoveServerEvent"),Lu);function K2(e){return e._llm_type||e.constructor.name.toLowerCase()}Pe(K2,"getModelProvider");function Z2(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}Pe(Z2,"getModelName");function pX(e){return[K2(e),Z2(e)]}Pe(pX,"extractModelInfo");var V$="mcp_use_user_id";function Y2(){try{return typeof globalThis.Bun<"u"?"bun":typeof globalThis.Deno<"u"?"deno":typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")?"cloudflare-workers":typeof globalThis.EdgeRuntime<"u"?"edge":typeof window<"u"&&typeof document<"u"?"browser":typeof process<"u"&&typeof process.versions?.node<"u"?"node":"unknown"}catch{return"unknown"}}Pe(Y2,"detectRuntimeEnvironment");function q2(e){switch(e){case"node":case"bun":return"filesystem";case"browser":try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only";case"deno":return"session-only";default:return"session-only"}}Pe(q2,"getStorageCapability");var bx=null;function X2(){return bx===null&&(bx=Y2()),bx}Pe(X2,"getRuntimeEnvironment");var $u,mX=($u=class{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(n){we.debug(`Failed to send Scarf event: ${n}`)}}},Pe($u,"ScarfEventLogger"),$u),pi,J2=(pi=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";SCARF_GATEWAY_URL="https://mcpuse.gateway.scarf.sh/events-ts";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogNodeClient=null;_posthogBrowserClient=null;_posthogLoading=null;_scarfClient=null;_runtimeEnvironment;_storageCapability;_source;_userIdPath=null;_versionDownloadPath=null;constructor(){this._runtimeEnvironment=X2(),this._storageCapability=q2(this._runtimeEnvironment),this._source=typeof process<"u"&&lb?.MCP_USE_TELEMETRY_SOURCE||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";if(t)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,we.debug("Telemetry disabled via environment/localStorage");else if(!n)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,we.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`);else{we.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."),this._posthogLoading=this._initPostHog();try{this._scarfClient=new mX(this.SCARF_GATEWAY_URL,3e3)}catch(a){we.warn(`Failed to initialize Scarf telemetry: ${a}`),this._scarfClient=null}}}_checkTelemetryDisabled(){return typeof process<"u"&&lb?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase()==="false"||typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHog(){this._runtimeEnvironment==="browser"?await this._initPostHogBrowser():await this._initPostHogNode()}async _initPostHogBrowser(){try{const t=await Qn(()=>import("./module-DXhXtM9n.js"),[]),n=t.default||t.posthog;if(!n||typeof n.init!="function")throw new Error("posthog-js module did not export expected interface");n.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:Pe(()=>{we.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=n}catch(t){we.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}async _initPostHogNode(){try{const{PostHog:t}=await Qn(async()=>{const{PostHog:r}=await import("./posthog-node-CuYhrq1Q.js");return{PostHog:r}},[]),n=["cloudflare-workers","edge","deno"].includes(this._runtimeEnvironment),a={host:this.HOST,disableGeoip:!1};n&&(a.flushAt=1,a.flushInterval=0),this._posthogNodeClient=new t(this.PROJECT_API_KEY,a),we.debug("PostHog Node.js client initialized")}catch(t){we.warn(`Failed to initialize PostHog Node.js telemetry: ${t}`),this._posthogNodeClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return pi.instance||(pi.instance=new pi),pi.instance}setSource(t){this._source=t,we.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogNodeClient!==null||this._posthogBrowserClient!==null||this._scarfClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"filesystem":this._currUserId=this._getUserIdFromFilesystem();break;case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:this._currUserId=`session-${tu()}`,we.debug(`Using session-based user ID (${this._runtimeEnvironment} environment)`);break}this._storageCapability==="filesystem"&&this._currUserId&&this._trackPackageDownloadInternal(this._currUserId,{triggered_by:"user_id_property"}).catch(t=>we.debug(`Failed to track package download: ${t}`))}catch(t){we.debug(`Failed to get/create user ID: ${t}`),this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromFilesystem(){const t=Es("fs"),n=Es("os"),a=Es("path");if(this._userIdPath||(this._userIdPath=a.join(this._getCacheHome(n,a),"mcp_use_3","telemetry_user_id")),!t.existsSync(this._userIdPath)){we.debug(`Creating user ID path: ${this._userIdPath}`),t.mkdirSync(a.dirname(this._userIdPath),{recursive:!0});const i=tu();return t.writeFileSync(this._userIdPath,i),we.debug(`User ID path created: ${this._userIdPath}`),i}return t.readFileSync(this._userIdPath,"utf-8").trim()}_getUserIdFromLocalStorage(){try{let t=localStorage.getItem(V$);return t||(t=tu(),localStorage.setItem(V$,t),we.debug("Created new browser user ID")),t}catch(t){return we.debug(`localStorage access failed: ${t}`),`session-${tu()}`}}_getCacheHome(t,n){const a=lb.XDG_CACHE_HOME;if(a&&n.isAbsolute(a))return a;const r=t.homedir();return n.join(r,".cache")}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogNodeClient&&!this._posthogBrowserClient&&!this._scarfClient)return;const n={...t.properties};if(n.mcp_use_version=Db(),n.language="typescript",n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogNodeClient)try{we.debug(`CAPTURE: PostHog Node Event ${t.name}`),this._posthogNodeClient.capture({distinctId:this.userId,event:t.name,properties:n})}catch(a){we.debug(`Failed to track PostHog Node event ${t.name}: ${a}`)}if(this._posthogBrowserClient)try{we.debug(`CAPTURE: PostHog Browser Event ${t.name}`),this._posthogBrowserClient.capture(t.name,{...n,distinct_id:this.userId})}catch(a){we.debug(`Failed to track PostHog Browser event ${t.name}: ${a}`)}if(this._scarfClient)try{const a={...n,user_id:this.userId,event:t.name};await this._scarfClient.logEvent(a)}catch(a){we.debug(`Failed to track Scarf event ${t.name}: ${a}`)}}async trackPackageDownload(t){return this._trackPackageDownloadInternal(this.userId,t)}async _trackPackageDownloadInternal(t,n){if(this._scarfClient&&this._storageCapability==="filesystem")try{const a=Es("fs"),r=Es("path"),i=Es("os");this._versionDownloadPath||(this._versionDownloadPath=r.join(this._getCacheHome(i,r),"mcp_use","download_version"));const s=Db();let c=!1,u=!1;if(!a.existsSync(this._versionDownloadPath))c=!0,u=!0,a.mkdirSync(r.dirname(this._versionDownloadPath),{recursive:!0}),a.writeFileSync(this._versionDownloadPath,s);else{const d=a.readFileSync(this._versionDownloadPath,"utf-8").trim();s>d&&(c=!0,u=!1,a.writeFileSync(this._versionDownloadPath,s))}if(c){we.debug(`Tracking package download event with properties: ${JSON.stringify(n)}`);const d={...n||{}};d.mcp_use_version=s,d.user_id=t,d.event="package_download",d.first_download=u,d.language="typescript",d.source=this._source,d.runtime=this._runtimeEnvironment,await this._scarfClient.logEvent(d)}}catch(a){we.debug(`Failed to track Scarf package_download event: ${a}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new nX(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const a=W2(t,n),r=new rX(a);await this.capture(r)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new aX(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new iX(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new oX(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new sX(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new lX(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new cX(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new uX(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const a=new dX({serverName:t,serverConfig:n});await this.capture(a)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new fX({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){we.debug(`Failed to identify user: ${a}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){we.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){if(this._posthogNodeClient)try{this._posthogNodeClient.flush(),we.debug("PostHog client telemetry queue flushed")}catch(t){we.debug(`Failed to flush PostHog client: ${t}`)}}shutdown(){if(this._posthogNodeClient)try{this._posthogNodeClient.shutdown(),we.debug("PostHog client shutdown successfully")}catch(t){we.debug(`Error shutting down PostHog client: ${t}`)}}},Pe(pi,"Telemetry"),Nf(pi,"instance",null),pi),Mi=J2;function hX(e){Mi.getInstance().setSource(e)}Pe(hX,"setTelemetrySource");const Q2=Object.freeze({status:"aborted"});function me(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 d=s.prototype,m=Object.keys(d);for(let h=0;h<m.length;h++){const g=m[h];g in c||(c[g]=d[g].bind(c))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(c){var u;const d=n?.Parent?new i:this;a(d,c),(u=d._zod).deferred??(u.deferred=[]);for(const m of d._zod.deferred)m();return d}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 eF=Symbol("zod_brand");class Rl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Uv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const jb={};function ea(e){return e&&Object.assign(jb,e),jb}function gX(e){return e}function bX(e){return e}function vX(e){}function yX(e){throw new Error}function wX(e){}function F_(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 Ue(e,t="|"){return e.map(n=>ut(n)).join(t)}function Lb(e,t){return typeof t=="bigint"?t.toString():t}function Kp(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Kl(e){return e==null}function zv(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function tF(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 G$=Symbol("evaluating");function Ht(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==G$)return a===void 0&&(a=G$,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function xX(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function zs(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function zo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function SX(e){return zo(e._zod.def)}function EX(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function _X(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 kX(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 US(e){return JSON.stringify(e)}function nF(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const B_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ku(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const rF=Kp(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function jl(e){if(Ku(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ku(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Fv(e){return jl(e)?{...e}:Array.isArray(e)?[...e]:e}function TX(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const NX=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}`)}},$b=new Set(["string","number","symbol"]),aF=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Oo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ei(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 CX(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 ut(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function iF(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const oF={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]},sF={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function lF(e,t){const n=e._zod.def,a=zo(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 zs(this,"shape",r),r},checks:[]});return ei(e,a)}function cF(e,t){const n=e._zod.def,a=zo(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 zs(this,"shape",r),r},checks:[]});return ei(e,a)}function uF(e,t){if(!jl(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=zo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return zs(this,"shape",i),i},checks:[]});return ei(e,r)}function dF(e,t){if(!jl(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 zs(this,"shape",a),a},checks:e._zod.def.checks};return ei(e,n)}function fF(e,t){const n=zo(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return zs(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ei(e,n)}function pF(e,t,n){const a=zo(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 zs(this,"shape",i),i},checks:[]});return ei(t,a)}function mF(e,t,n){const a=zo(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 zs(this,"shape",i),i},checks:[]});return ei(t,a)}function El(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 mi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function Pf(e){return typeof e=="string"?e:e?.message}function yi(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=Pf(e.inst?._zod.def?.error?.(e))??Pf(t?.error?.(e))??Pf(n.customError?.(e))??Pf(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function Bv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Hv(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Zu(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function RX(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function hF(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 gF(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function AX(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return hF(t+n)}function IX(e){return gF(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function OX(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 DX(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class jX{constructor(...t){}}const bF=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:sF,Class:jX,NUMBER_FORMAT_RANGES:oF,aborted:El,allowsEval:rF,assert:wX,assertEqual:gX,assertIs:vX,assertNever:yX,assertNotEqual:bX,assignProp:zs,base64ToUint8Array:hF,base64urlToUint8Array:AX,cached:Kp,captureStackTrace:B_,cleanEnum:RX,cleanRegex:zv,clone:ei,cloneDef:SX,createTransparentProxy:CX,defineLazy:Ht,esc:US,escapeRegex:Oo,extend:uF,finalizeIssue:yi,floatSafeRemainder:tF,getElementAtPath:EX,getEnumValues:F_,getLengthableOrigin:Hv,getParsedType:NX,getSizableOrigin:Bv,hexToUint8Array:OX,isObject:Ku,isPlainObject:jl,issue:Zu,joinValues:Ue,jsonStringifyReplacer:Lb,merge:fF,mergeDefs:zo,normalizeParams:Ae,nullish:Kl,numKeys:TX,objectClone:xX,omit:cF,optionalKeys:iF,partial:pF,pick:lF,prefixIssues:mi,primitiveTypes:aF,promiseAllObject:_X,propertyKeyTypes:$b,randomString:kX,required:mF,safeExtend:dF,shallowClone:Fv,slugify:nF,stringifyPrimitive:ut,uint8ArrayToBase64:gF,uint8ArrayToBase64url:IX,uint8ArrayToHex:DX,unwrapMessage:Pf},Symbol.toStringTag,{value:"Module"})),vF=(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,Lb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},H_=me("$ZodError",vF),La=me("$ZodError",vF,{Parent:Error});function V_(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 G_(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 yF(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(d=>a({issues:d},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 d=[...i,...u.path];if(d.length===0){n.errors.push(t(u));continue}let m=n,h=0;for(;h<d.length;){const g=d[h],v=h===d.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 wF(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 xF(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 ${wF(a.path)}`);return t.join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/winston-Yd0Tb9GZ.js","assets/util-t-trnxQI.js","assets/__vite-browser-external-D7Ct-6yo.js","assets/index-DRz5BQNA.js","assets/path-C2bN6h38.js","assets/index-DMdheUGh.js","assets/index-CYBG3mWU.js","assets/index-Dh_Vxoku.js","assets/index-VGF5GoM6.js","assets/embeddings-Azb3VHue.js","assets/index-O0gjGlMB.js","assets/index-BFcdg9p1.js","assets/browser-BzPxdp9T.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Vq=Object.defineProperty;var Gq=(e,t,n)=>t in e?Vq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Nf=(e,t,n)=>Gq(e,typeof t!="symbol"?t+"":t,n);function Wq(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 Wp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function tTe(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 gx={exports:{}},Cf={};var F$;function Kq(){if(F$)return Cf;F$=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 Cf.Fragment=t,Cf.jsx=n,Cf.jsxs=n,Cf}var B$;function Zq(){return B$||(B$=1,gx.exports=Kq()),gx.exports}var f=Zq();const Yq="modulepreload",qq=function(e){return"/inspector/"+e},H$={},Qn=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){let u=function(d){return Promise.all(d.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(d=>{if(d=qq(d),d in H$)return;H$[d]=!0;const m=d.endsWith(".css"),h=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${h}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":Yq,m||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),m)return new Promise((v,w)=>{g.addEventListener("load",v),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${d}`)))})}))}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 Xq=Object.defineProperty,Pe=(e,t)=>Xq(e,"name",{value:t,configurable:!0}),Es=(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')}),Gc={};async function F2(){if(typeof process<"u")try{const e=await Qn(()=>import("./__vite-browser-external-D7Ct-6yo.js").then(n=>n._),[]),t=await Qn(()=>import("./path-C2bN6h38.js").then(n=>n.p),[]);return{fs:e.default,path:t.default}}catch{return{fs:null,path:null}}return{fs:null,path:null}}Pe(F2,"getNodeModules");var Aa=null;function B2(){if(typeof Es<"u")try{Aa=Es("winston")}catch{}}Pe(B2,"loadWinstonSync");async function H2(){return Aa||(Aa=await Qn(()=>import("./winston-Yd0Tb9GZ.js").then(e=>e.w),__vite__mapDeps([0,1,2,3,4]))),Aa}Pe(H2,"getWinston");var PS="mcp-use";function Ob(){try{return typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")||typeof globalThis.EdgeRuntime<"u"||typeof globalThis.Deno<"u"?!1:typeof process<"u"&&!0&&typeof __dirname<"u"}catch{return!1}}Pe(Ob,"isNodeJSEnvironment");var Eu,Jq=(Eu=class{_level;name;constructor(t=PS,n="info"){this.name=t,this._level=n}shouldLog(t){const n=["error","warn","info","http","verbose","debug","silly"],a=n.indexOf(this._level);return n.indexOf(t)<=a}formatMessage(t,n){return`${new Date().toLocaleTimeString("en-US",{hour12:!1})} [${this.name}] ${t}: ${n}`}error(t){this.shouldLog("error")&&console.error(this.formatMessage("error",t))}warn(t){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t))}info(t){this.shouldLog("info")&&console.info(this.formatMessage("info",t))}debug(t){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t))}http(t){this.shouldLog("http")&&console.log(this.formatMessage("http",t))}verbose(t){this.shouldLog("verbose")&&console.log(this.formatMessage("verbose",t))}silly(t){this.shouldLog("silly")&&console.log(this.formatMessage("silly",t))}get level(){return this._level}set level(t){this._level=t}},Pe(Eu,"SimpleConsoleLogger"),Eu);function sb(e){switch((typeof process<"u"&&Gc?e:void 0)?.trim()){case"2":return"debug";case"1":return"info";default:return"info"}}Pe(sb,"resolveLevel");var So,V2=(So=class{static get(t=PS){if(!Ob()){if(!this.simpleInstances[t]){const n=typeof process<"u"&&Gc?.DEBUG||void 0;this.simpleInstances[t]=new Jq(t,sb(n))}return this.simpleInstances[t]}if(!this.instances[t]){if(!Aa)throw new Error("Winston not loaded - call Logger.configure() first");const{createLogger:n,format:a}=Aa,{combine:r,timestamp:i,label:s,colorize:c,splat:u}=a;this.instances[t]=n({level:sb(Gc.DEBUG),format:r(c(),u(),s({label:t}),i({format:"HH:mm:ss"}),this.getFormatter()),transports:[]})}return this.instances[t]}static getFormatter(){if(!Aa)throw new Error("Winston not loaded");const{format:t}=Aa,{printf:n}=t,a=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s}: ${c}`),r=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s.toUpperCase()}: ${c}`),i=n(({level:s,message:c,label:u,timestamp:d})=>`${d} [${u}] ${s.toUpperCase()}: ${c}`);switch(this.currentFormat){case"minimal":return a;case"detailed":return r;case"emoji":return i;default:return a}}static async configure(t={}){const{level:n,console:a=!0,file:r,format:i="minimal"}=t,s=typeof process<"u"&&Gc?.DEBUG||void 0,c=n??sb(s);if(this.currentFormat=i,!Ob()){Object.values(this.simpleInstances).forEach(y=>{y.level=c});return}if(await H2(),!Aa)throw new Error("Failed to load winston");const u=this.get();u.level=c;const d=u;if(d.clear(),a&&d.add(new Aa.transports.Console),r){const{fs:y,path:_}=await F2();if(y&&_){const E=_.dirname(_.resolve(r));y.existsSync(E)||y.mkdirSync(E,{recursive:!0}),d.add(new Aa.transports.File({filename:r}))}}const{format:m}=Aa,{combine:h,timestamp:g,label:v,colorize:w,splat:S}=m;Object.values(this.instances).forEach(y=>{y&&"format"in y&&(y.level=c,y.format=h(w(),S(),v({label:PS}),g({format:"HH:mm:ss"}),this.getFormatter()))})}static setDebug(t){let n;t===2||t===!0?n="debug":n="info",Object.values(this.simpleInstances).forEach(a=>{a.level=n}),Object.values(this.instances).forEach(a=>{a&&(a.level=n)}),typeof process<"u"&&Gc&&(Gc.DEBUG=t?t===!0?"2":String(t):"0")}static setFormat(t){this.currentFormat=t,this.configure({format:t})}},Pe(So,"Logger"),Nf(So,"instances",{}),Nf(So,"simpleInstances",{}),Nf(So,"currentFormat","minimal"),So);Ob()&&(B2(),Aa&&V2.configure());var we=V2.get(),lb={},G2=typeof globalThis.Deno<"u";function Qq(e){return G2?globalThis.Deno.env.get(e):lb[e]}Pe(Qq,"getEnv");function eX(){return G2?globalThis.Deno.cwd():process.cwd()}Pe(eX,"getCwd");function tu(){return globalThis.crypto.randomUUID()}Pe(tu,"generateUUID");var tX="1.10.5";function Db(){return tX}Pe(Db,"getPackageVersion");var _u,Ti=(_u=class{},Pe(_u,"BaseTelemetryEvent"),_u),ku,nX=(ku=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}}},Pe(ku,"MCPAgentExecutionEvent"),ku);function W2(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"),d=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:d.length>0?d:null,mcpAppsResourcesNumber:d.length}}Pe(W2,"createServerRunEventData");var Tu,rX=(Tu=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}}},Pe(Tu,"ServerRunEvent"),Tu),Nu,aX=(Nu=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}}},Pe(Nu,"ServerInitializeEvent"),Nu),Cu,iX=(Cu=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}}},Pe(Cu,"ServerToolCallEvent"),Cu),Ru,oX=(Ru=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}}},Pe(Ru,"ServerResourceCallEvent"),Ru),Au,sX=(Au=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}}},Pe(Au,"ServerPromptCallEvent"),Au),Iu,lX=(Iu=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}}},Pe(Iu,"ServerContextEvent"),Iu),Ou,cX=(Ou=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}}},Pe(Ou,"MCPClientInitEvent"),Ou),Du,uX=(Du=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}}},Pe(Du,"ConnectorInitEvent"),Du),ju,dX=(ju=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}}},Pe(ju,"ClientAddServerEvent"),ju),Lu,fX=(Lu=class extends Ti{constructor(t){super(),this.data=t}get name(){return"client_remove_server"}get properties(){return{server_name:this.data.serverName}}},Pe(Lu,"ClientRemoveServerEvent"),Lu);function K2(e){return e._llm_type||e.constructor.name.toLowerCase()}Pe(K2,"getModelProvider");function Z2(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}Pe(Z2,"getModelName");function pX(e){return[K2(e),Z2(e)]}Pe(pX,"extractModelInfo");var V$="mcp_use_user_id";function Y2(){try{return typeof globalThis.Bun<"u"?"bun":typeof globalThis.Deno<"u"?"deno":typeof navigator<"u"&&navigator.userAgent?.includes("Cloudflare-Workers")?"cloudflare-workers":typeof globalThis.EdgeRuntime<"u"?"edge":typeof window<"u"&&typeof document<"u"?"browser":typeof process<"u"&&typeof process.versions?.node<"u"?"node":"unknown"}catch{return"unknown"}}Pe(Y2,"detectRuntimeEnvironment");function q2(e){switch(e){case"node":case"bun":return"filesystem";case"browser":try{if(typeof localStorage<"u")return localStorage.setItem("__mcp_use_test__","1"),localStorage.removeItem("__mcp_use_test__"),"localStorage"}catch{}return"session-only";case"deno":return"session-only";default:return"session-only"}}Pe(q2,"getStorageCapability");var bx=null;function X2(){return bx===null&&(bx=Y2()),bx}Pe(X2,"getRuntimeEnvironment");var $u,mX=($u=class{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(n){we.debug(`Failed to send Scarf event: ${n}`)}}},Pe($u,"ScarfEventLogger"),$u),pi,J2=(pi=class{PROJECT_API_KEY="phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";HOST="https://eu.i.posthog.com";SCARF_GATEWAY_URL="https://mcpuse.gateway.scarf.sh/events-ts";UNKNOWN_USER_ID="UNKNOWN_USER_ID";_currUserId=null;_posthogNodeClient=null;_posthogBrowserClient=null;_posthogLoading=null;_scarfClient=null;_runtimeEnvironment;_storageCapability;_source;_userIdPath=null;_versionDownloadPath=null;constructor(){this._runtimeEnvironment=X2(),this._storageCapability=q2(this._runtimeEnvironment),this._source=typeof process<"u"&&lb?.MCP_USE_TELEMETRY_SOURCE||this._runtimeEnvironment;const t=this._checkTelemetryDisabled(),n=this._runtimeEnvironment!=="unknown";if(t)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,we.debug("Telemetry disabled via environment/localStorage");else if(!n)this._posthogNodeClient=null,this._posthogBrowserClient=null,this._scarfClient=null,we.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`);else{we.info("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."),this._posthogLoading=this._initPostHog();try{this._scarfClient=new mX(this.SCARF_GATEWAY_URL,3e3)}catch(a){we.warn(`Failed to initialize Scarf telemetry: ${a}`),this._scarfClient=null}}}_checkTelemetryDisabled(){return typeof process<"u"&&lb?.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase()==="false"||typeof localStorage<"u"&&localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY")==="false"}async _initPostHog(){this._runtimeEnvironment==="browser"?await this._initPostHogBrowser():await this._initPostHogNode()}async _initPostHogBrowser(){try{const t=await Qn(()=>import("./module-DXhXtM9n.js"),[]),n=t.default||t.posthog;if(!n||typeof n.init!="function")throw new Error("posthog-js module did not export expected interface");n.init(this.PROJECT_API_KEY,{api_host:this.HOST,persistence:"localStorage",autocapture:!1,capture_pageview:!1,disable_session_recording:!0,loaded:Pe(()=>{we.debug("PostHog browser client initialized")},"loaded")}),this._posthogBrowserClient=n}catch(t){we.warn(`Failed to initialize PostHog browser telemetry: ${t}`),this._posthogBrowserClient=null}}async _initPostHogNode(){try{const{PostHog:t}=await Qn(async()=>{const{PostHog:r}=await import("./posthog-node-CuYhrq1Q.js");return{PostHog:r}},[]),n=["cloudflare-workers","edge","deno"].includes(this._runtimeEnvironment),a={host:this.HOST,disableGeoip:!1};n&&(a.flushAt=1,a.flushInterval=0),this._posthogNodeClient=new t(this.PROJECT_API_KEY,a),we.debug("PostHog Node.js client initialized")}catch(t){we.warn(`Failed to initialize PostHog Node.js telemetry: ${t}`),this._posthogNodeClient=null}}get runtimeEnvironment(){return this._runtimeEnvironment}get storageCapability(){return this._storageCapability}static getInstance(){return pi.instance||(pi.instance=new pi),pi.instance}setSource(t){this._source=t,we.debug(`Telemetry source set to: ${t}`)}getSource(){return this._source}get isEnabled(){return this._posthogNodeClient!==null||this._posthogBrowserClient!==null||this._scarfClient!==null}get userId(){if(this._currUserId)return this._currUserId;try{switch(this._storageCapability){case"filesystem":this._currUserId=this._getUserIdFromFilesystem();break;case"localStorage":this._currUserId=this._getUserIdFromLocalStorage();break;case"session-only":default:this._currUserId=`session-${tu()}`,we.debug(`Using session-based user ID (${this._runtimeEnvironment} environment)`);break}this._storageCapability==="filesystem"&&this._currUserId&&this._trackPackageDownloadInternal(this._currUserId,{triggered_by:"user_id_property"}).catch(t=>we.debug(`Failed to track package download: ${t}`))}catch(t){we.debug(`Failed to get/create user ID: ${t}`),this._currUserId=this.UNKNOWN_USER_ID}return this._currUserId}_getUserIdFromFilesystem(){const t=Es("fs"),n=Es("os"),a=Es("path");if(this._userIdPath||(this._userIdPath=a.join(this._getCacheHome(n,a),"mcp_use_3","telemetry_user_id")),!t.existsSync(this._userIdPath)){we.debug(`Creating user ID path: ${this._userIdPath}`),t.mkdirSync(a.dirname(this._userIdPath),{recursive:!0});const i=tu();return t.writeFileSync(this._userIdPath,i),we.debug(`User ID path created: ${this._userIdPath}`),i}return t.readFileSync(this._userIdPath,"utf-8").trim()}_getUserIdFromLocalStorage(){try{let t=localStorage.getItem(V$);return t||(t=tu(),localStorage.setItem(V$,t),we.debug("Created new browser user ID")),t}catch(t){return we.debug(`localStorage access failed: ${t}`),`session-${tu()}`}}_getCacheHome(t,n){const a=lb.XDG_CACHE_HOME;if(a&&n.isAbsolute(a))return a;const r=t.homedir();return n.join(r,".cache")}async capture(t){if(this._posthogLoading&&await this._posthogLoading,!this._posthogNodeClient&&!this._posthogBrowserClient&&!this._scarfClient)return;const n={...t.properties};if(n.mcp_use_version=Db(),n.language="typescript",n.source=this._source,n.runtime=this._runtimeEnvironment,this._posthogNodeClient)try{we.debug(`CAPTURE: PostHog Node Event ${t.name}`),this._posthogNodeClient.capture({distinctId:this.userId,event:t.name,properties:n})}catch(a){we.debug(`Failed to track PostHog Node event ${t.name}: ${a}`)}if(this._posthogBrowserClient)try{we.debug(`CAPTURE: PostHog Browser Event ${t.name}`),this._posthogBrowserClient.capture(t.name,{...n,distinct_id:this.userId})}catch(a){we.debug(`Failed to track PostHog Browser event ${t.name}: ${a}`)}if(this._scarfClient)try{const a={...n,user_id:this.userId,event:t.name};await this._scarfClient.logEvent(a)}catch(a){we.debug(`Failed to track Scarf event ${t.name}: ${a}`)}}async trackPackageDownload(t){return this._trackPackageDownloadInternal(this.userId,t)}async _trackPackageDownloadInternal(t,n){if(this._scarfClient&&this._storageCapability==="filesystem")try{const a=Es("fs"),r=Es("path"),i=Es("os");this._versionDownloadPath||(this._versionDownloadPath=r.join(this._getCacheHome(i,r),"mcp_use","download_version"));const s=Db();let c=!1,u=!1;if(!a.existsSync(this._versionDownloadPath))c=!0,u=!0,a.mkdirSync(r.dirname(this._versionDownloadPath),{recursive:!0}),a.writeFileSync(this._versionDownloadPath,s);else{const d=a.readFileSync(this._versionDownloadPath,"utf-8").trim();s>d&&(c=!0,u=!1,a.writeFileSync(this._versionDownloadPath,s))}if(c){we.debug(`Tracking package download event with properties: ${JSON.stringify(n)}`);const d={...n||{}};d.mcp_use_version=s,d.user_id=t,d.event="package_download",d.first_download=u,d.language="typescript",d.source=this._source,d.runtime=this._runtimeEnvironment,await this._scarfClient.logEvent(d)}}catch(a){we.debug(`Failed to track Scarf package_download event: ${a}`)}}async trackAgentExecution(t){if(!this.isEnabled)return;const n=new nX(t);await this.capture(n)}async trackServerRunFromServer(t,n){if(!this.isEnabled)return;const a=W2(t,n),r=new rX(a);await this.capture(r)}async trackServerInitialize(t){if(!this.isEnabled)return;const n=new aX(t);await this.capture(n)}async trackServerToolCall(t){if(!this.isEnabled)return;const n=new iX(t);await this.capture(n)}async trackServerResourceCall(t){if(!this.isEnabled)return;const n=new oX(t);await this.capture(n)}async trackServerPromptCall(t){if(!this.isEnabled)return;const n=new sX(t);await this.capture(n)}async trackServerContext(t){if(!this.isEnabled)return;const n=new lX(t);await this.capture(n)}async trackMCPClientInit(t){if(!this.isEnabled)return;const n=new cX(t);await this.capture(n)}async trackConnectorInit(t){if(!this.isEnabled)return;const n=new uX(t);await this.capture(n)}async trackClientAddServer(t,n){if(!this.isEnabled)return;const a=new dX({serverName:t,serverConfig:n});await this.capture(a)}async trackClientRemoveServer(t){if(!this.isEnabled)return;const n=new fX({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){we.debug(`Failed to identify user: ${a}`)}}reset(){if(this._posthogBrowserClient)try{this._posthogBrowserClient.reset()}catch(t){we.debug(`Failed to reset user: ${t}`)}this._currUserId=null}flush(){if(this._posthogNodeClient)try{this._posthogNodeClient.flush(),we.debug("PostHog client telemetry queue flushed")}catch(t){we.debug(`Failed to flush PostHog client: ${t}`)}}shutdown(){if(this._posthogNodeClient)try{this._posthogNodeClient.shutdown(),we.debug("PostHog client shutdown successfully")}catch(t){we.debug(`Error shutting down PostHog client: ${t}`)}}},Pe(pi,"Telemetry"),Nf(pi,"instance",null),pi),Mi=J2;function hX(e){Mi.getInstance().setSource(e)}Pe(hX,"setTelemetrySource");const Q2=Object.freeze({status:"aborted"});function me(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 d=s.prototype,m=Object.keys(d);for(let h=0;h<m.length;h++){const g=m[h];g in c||(c[g]=d[g].bind(c))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(c){var u;const d=n?.Parent?new i:this;a(d,c),(u=d._zod).deferred??(u.deferred=[]);for(const m of d._zod.deferred)m();return d}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 eF=Symbol("zod_brand");class Rl extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Uv extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const jb={};function ea(e){return e&&Object.assign(jb,e),jb}function gX(e){return e}function bX(e){return e}function vX(e){}function yX(e){throw new Error}function wX(e){}function F_(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 Ue(e,t="|"){return e.map(n=>ut(n)).join(t)}function Lb(e,t){return typeof t=="bigint"?t.toString():t}function Kp(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Kl(e){return e==null}function zv(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function tF(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 G$=Symbol("evaluating");function Ht(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==G$)return a===void 0&&(a=G$,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function xX(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function zs(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function zo(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function SX(e){return zo(e._zod.def)}function EX(e,t){return t?t.reduce((n,a)=>n?.[a],e):e}function _X(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 kX(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 US(e){return JSON.stringify(e)}function nF(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const B_="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ku(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const rF=Kp(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function jl(e){if(Ku(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ku(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Fv(e){return jl(e)?{...e}:Array.isArray(e)?[...e]:e}function TX(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const NX=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}`)}},$b=new Set(["string","number","symbol"]),aF=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Oo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ei(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 CX(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 ut(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function iF(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const oF={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]},sF={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function lF(e,t){const n=e._zod.def,a=zo(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 zs(this,"shape",r),r},checks:[]});return ei(e,a)}function cF(e,t){const n=e._zod.def,a=zo(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 zs(this,"shape",r),r},checks:[]});return ei(e,a)}function uF(e,t){if(!jl(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=zo(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return zs(this,"shape",i),i},checks:[]});return ei(e,r)}function dF(e,t){if(!jl(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 zs(this,"shape",a),a},checks:e._zod.def.checks};return ei(e,n)}function fF(e,t){const n=zo(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return zs(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return ei(e,n)}function pF(e,t,n){const a=zo(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 zs(this,"shape",i),i},checks:[]});return ei(t,a)}function mF(e,t,n){const a=zo(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 zs(this,"shape",i),i},checks:[]});return ei(t,a)}function El(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 mi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function Pf(e){return typeof e=="string"?e:e?.message}function yi(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const r=Pf(e.inst?._zod.def?.error?.(e))??Pf(t?.error?.(e))??Pf(n.customError?.(e))??Pf(n.localeError?.(e))??"Invalid input";a.message=r}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function Bv(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Hv(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Zu(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}function RX(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function hF(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 gF(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function AX(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return hF(t+n)}function IX(e){return gF(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function OX(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 DX(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class jX{constructor(...t){}}const bF=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:sF,Class:jX,NUMBER_FORMAT_RANGES:oF,aborted:El,allowsEval:rF,assert:wX,assertEqual:gX,assertIs:vX,assertNever:yX,assertNotEqual:bX,assignProp:zs,base64ToUint8Array:hF,base64urlToUint8Array:AX,cached:Kp,captureStackTrace:B_,cleanEnum:RX,cleanRegex:zv,clone:ei,cloneDef:SX,createTransparentProxy:CX,defineLazy:Ht,esc:US,escapeRegex:Oo,extend:uF,finalizeIssue:yi,floatSafeRemainder:tF,getElementAtPath:EX,getEnumValues:F_,getLengthableOrigin:Hv,getParsedType:NX,getSizableOrigin:Bv,hexToUint8Array:OX,isObject:Ku,isPlainObject:jl,issue:Zu,joinValues:Ue,jsonStringifyReplacer:Lb,merge:fF,mergeDefs:zo,normalizeParams:Ae,nullish:Kl,numKeys:TX,objectClone:xX,omit:cF,optionalKeys:iF,partial:pF,pick:lF,prefixIssues:mi,primitiveTypes:aF,promiseAllObject:_X,propertyKeyTypes:$b,randomString:kX,required:mF,safeExtend:dF,shallowClone:Fv,slugify:nF,stringifyPrimitive:ut,uint8ArrayToBase64:gF,uint8ArrayToBase64url:IX,uint8ArrayToHex:DX,unwrapMessage:Pf},Symbol.toStringTag,{value:"Module"})),vF=(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,Lb,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},H_=me("$ZodError",vF),La=me("$ZodError",vF,{Parent:Error});function V_(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 G_(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 yF(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(d=>a({issues:d},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 d=[...i,...u.path];if(d.length===0){n.errors.push(t(u));continue}let m=n,h=0;for(;h<d.length;){const g=d[h],v=h===d.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 wF(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 xF(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 ${wF(a.path)}`);return t.join(`
|
|
3
3
|
`)}const Zp=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 Rl;if(s.issues.length){const c=new(r?.Err??e)(s.issues.map(u=>yi(u,i,ea())));throw B_(c,r?.callee),c}return s.value},zS=Zp(La),Yp=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=>yi(u,i,ea())));throw B_(c,r?.callee),c}return s.value},FS=Yp(La),qp=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 Rl;return i.issues.length?{success:!1,error:new(e??H_)(i.issues.map(s=>yi(s,r,ea())))}:{success:!0,data:i.value}},W_=qp(La),Xp=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=>yi(s,r,ea())))}:{success:!0,data:i.value}},SF=Xp(La),K_=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Zp(e)(t,n,r)},LX=K_(La),Z_=e=>(t,n,a)=>Zp(e)(t,n,a),$X=Z_(La),Y_=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Yp(e)(t,n,r)},MX=Y_(La),q_=e=>async(t,n,a)=>Yp(e)(t,n,a),PX=q_(La),X_=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return qp(e)(t,n,r)},UX=X_(La),J_=e=>(t,n,a)=>qp(e)(t,n,a),zX=J_(La),Q_=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Xp(e)(t,n,r)},FX=Q_(La),ek=e=>async(t,n,a)=>Xp(e)(t,n,a),BX=ek(La),EF=/^[cC][^\s-]{8,}$/,_F=/^[0-9a-z]+$/,kF=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,TF=/^[0-9a-vA-V]{20}$/,NF=/^[A-Za-z0-9]{27}$/,CF=/^[a-zA-Z0-9_-]{21}$/,RF=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,HX=/^[-+]?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)?)??$/,AF=/^([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})$/,Yu=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)$/,VX=Yu(4),GX=Yu(6),WX=Yu(7),IF=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,KX=/^[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])?)*$/,ZX=/^(([^<>()\[\]\\.,;:\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,}))$/,OF=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,YX=OF,qX=/^[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])?)*$/,XX="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function DF(){return new RegExp(XX,"u")}const jF=/^(?:(?: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])$/,LF=/^(([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}|:))$/,$F=e=>{const t=Oo(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},MF=/^((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])$/,PF=/^(([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])$/,UF=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tk=/^[A-Za-z0-9_-]*$/,zF=/^(?=.{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])?)*\.?$/,FF=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,BF=/^\+(?:[0-9]){6,14}[0-9]$/,HF="(?:(?:\\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])))",VF=new RegExp(`^${HF}$`);function GF(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 WF(e){return new RegExp(`^${GF(e)}$`)}function KF(e){const t=GF({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(`^${HF}T(?:${a})$`)}const ZF=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},YF=/^-?\d+n?$/,qF=/^-?\d+$/,XF=/^-?\d+(?:\.\d+)?/,JF=/^(?:true|false)$/i,QF=/^null$/i,e3=/^undefined$/i,t3=/^[^A-Z]*$/,n3=/^[^a-z]*$/,r3=/^[0-9a-fA-F]*$/;function Jp(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Qp(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const JX=/^[0-9a-fA-F]{32}$/,QX=Jp(22,"=="),eJ=Qp(22),tJ=/^[0-9a-fA-F]{40}$/,nJ=Jp(27,"="),rJ=Qp(27),aJ=/^[0-9a-fA-F]{64}$/,iJ=Jp(43,"="),oJ=Qp(43),sJ=/^[0-9a-fA-F]{96}$/,lJ=Jp(64,""),cJ=Qp(64),uJ=/^[0-9a-fA-F]{128}$/,dJ=Jp(86,"=="),fJ=Qp(86),nk=Object.freeze(Object.defineProperty({__proto__:null,base64:UF,base64url:tk,bigint:YF,boolean:JF,browserEmail:qX,cidrv4:MF,cidrv6:PF,cuid:EF,cuid2:_F,date:VF,datetime:KF,domain:FF,duration:RF,e164:BF,email:IF,emoji:DF,extendedDuration:HX,guid:AF,hex:r3,hostname:zF,html5Email:KX,idnEmail:YX,integer:qF,ipv4:jF,ipv6:LF,ksuid:NF,lowercase:t3,mac:$F,md5_base64:QX,md5_base64url:eJ,md5_hex:JX,nanoid:CF,null:QF,number:XF,rfc5322Email:ZX,sha1_base64:nJ,sha1_base64url:rJ,sha1_hex:tJ,sha256_base64:iJ,sha256_base64url:oJ,sha256_hex:aJ,sha384_base64:lJ,sha384_base64url:cJ,sha384_hex:sJ,sha512_base64:dJ,sha512_base64url:fJ,sha512_hex:uJ,string:ZF,time:WF,ulid:kF,undefined:e3,unicodeEmail:OF,uppercase:n3,uuid:Yu,uuid4:VX,uuid6:GX,uuid7:WX,xid:TF},Symbol.toStringTag,{value:"Module"})),Un=me("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),a3={number:"number",bigint:"bigint",object:"date"},rk=me("$ZodCheckLessThan",(e,t)=>{Un.init(e,t);const n=a3[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})}}),ak=me("$ZodCheckGreaterThan",(e,t)=>{Un.init(e,t);const n=a3[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})}}),i3=me("$ZodCheckMultipleOf",(e,t)=>{Un.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):tF(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})}}),o3=me("$ZodCheckNumberFormat",(e,t)=>{Un.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[r,i]=oF[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=qF)}),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})}}),s3=me("$ZodCheckBigIntFormat",(e,t)=>{Un.init(e,t);const[n,a]=sF[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})}}),l3=me("$ZodCheckMaxSize",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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:Bv(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),c3=me("$ZodCheckMinSize",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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:Bv(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),u3=me("$ZodCheckSizeEquals",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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:Bv(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})}}),d3=me("$ZodCheckMaxLength",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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=Hv(r);a.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),f3=me("$ZodCheckMinLength",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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=Hv(r);a.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),p3=me("$ZodCheckLengthEquals",(e,t)=>{var n;Un.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Kl(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=Hv(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})}}),em=me("$ZodCheckStringFormat",(e,t)=>{var n,a;Un.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=()=>{})}),m3=me("$ZodCheckRegex",(e,t)=>{em.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})}}),h3=me("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=t3),em.init(e,t)}),g3=me("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=n3),em.init(e,t)}),b3=me("$ZodCheckIncludes",(e,t)=>{Un.init(e,t);const n=Oo(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})}}),v3=me("$ZodCheckStartsWith",(e,t)=>{Un.init(e,t);const n=new RegExp(`^${Oo(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})}}),y3=me("$ZodCheckEndsWith",(e,t)=>{Un.init(e,t);const n=new RegExp(`.*${Oo(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 W$(e,t,n){e.issues.length&&t.issues.push(...mi(n,e.issues))}const w3=me("$ZodCheckProperty",(e,t)=>{Un.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=>W$(r,n,t.property));W$(a,n,t.property)}}),x3=me("$ZodCheckMimeType",(e,t)=>{Un.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})}}),S3=me("$ZodCheckOverwrite",(e,t)=>{Un.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class E3{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(`
|
|
4
4
|
`).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(`
|
|
5
5
|
`))}}const _3={major:4,minor:1,patch:13},bt=me("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=_3;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 d=El(s),m;for(const h of c){if(h._zod.def.when){if(!h._zod.def.when(s))continue}else if(d)continue;const g=s.issues.length,v=h._zod.check(s);if(v instanceof Promise&&u?.async===!1)throw new Rl;if(m||v instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await v,s.issues.length!==g&&(d||(d=El(s,g)))});else{if(s.issues.length===g)continue;d||(d=El(s,g))}}return m?m.then(()=>s):s},i=(s,c,u)=>{if(El(s))return s.aborted=!0,s;const d=r(c,a,u);if(d instanceof Promise){if(u.async===!1)throw new Rl;return d.then(m=>e._zod.parse(m,u))}return e._zod.parse(d,u)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){const d=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(m=>i(m,s,c)):i(d,s,c)}const u=e._zod.parse(s,c);if(u instanceof Promise){if(c.async===!1)throw new Rl;return u.then(d=>r(d,a,c))}return r(u,a,c)}}e["~standard"]={validate:r=>{try{const i=W_(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return SF(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}}),tm=me("$ZodString",(e,t)=>{bt.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ZF(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}}),Tn=me("$ZodStringFormat",(e,t)=>{em.init(e,t),tm.init(e,t)}),k3=me("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=AF),Tn.init(e,t)}),T3=me("$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=Yu(a))}else t.pattern??(t.pattern=Yu());Tn.init(e,t)}),N3=me("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=IF),Tn.init(e,t)}),C3=me("$ZodURL",(e,t)=>{Tn.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})}}}),R3=me("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=DF()),Tn.init(e,t)}),A3=me("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=CF),Tn.init(e,t)}),I3=me("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=EF),Tn.init(e,t)}),O3=me("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=_F),Tn.init(e,t)}),D3=me("$ZodULID",(e,t)=>{t.pattern??(t.pattern=kF),Tn.init(e,t)}),j3=me("$ZodXID",(e,t)=>{t.pattern??(t.pattern=TF),Tn.init(e,t)}),L3=me("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=NF),Tn.init(e,t)}),$3=me("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=KF(t)),Tn.init(e,t)}),M3=me("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=VF),Tn.init(e,t)}),P3=me("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=WF(t)),Tn.init(e,t)}),U3=me("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=RF),Tn.init(e,t)}),z3=me("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=jF),Tn.init(e,t),e._zod.bag.format="ipv4"}),F3=me("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=LF),Tn.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})}}}),B3=me("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=$F(t.delimiter)),Tn.init(e,t),e._zod.bag.format="mac"}),H3=me("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=MF),Tn.init(e,t)}),V3=me("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=PF),Tn.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 ik(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const G3=me("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=UF),Tn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ik(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function W3(e){if(!tk.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ik(n)}const K3=me("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=tk),Tn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{W3(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Z3=me("$ZodE164",(e,t)=>{t.pattern??(t.pattern=BF),Tn.init(e,t)});function Y3(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 q3=me("$ZodJWT",(e,t)=>{Tn.init(e,t),e._zod.check=n=>{Y3(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),X3=me("$ZodCustomStringFormat",(e,t)=>{Tn.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})}}),ok=me("$ZodNumber",(e,t)=>{bt.init(e,t),e._zod.pattern=e._zod.bag.pattern??XF,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}}),J3=me("$ZodNumberFormat",(e,t)=>{o3.init(e,t),ok.init(e,t)}),sk=me("$ZodBoolean",(e,t)=>{bt.init(e,t),e._zod.pattern=JF,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}}),lk=me("$ZodBigInt",(e,t)=>{bt.init(e,t),e._zod.pattern=YF,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}}),Q3=me("$ZodBigIntFormat",(e,t)=>{s3.init(e,t),lk.init(e,t)}),eB=me("$ZodSymbol",(e,t)=>{bt.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}}),tB=me("$ZodUndefined",(e,t)=>{bt.init(e,t),e._zod.pattern=e3,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}}),nB=me("$ZodNull",(e,t)=>{bt.init(e,t),e._zod.pattern=QF,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}}),rB=me("$ZodAny",(e,t)=>{bt.init(e,t),e._zod.parse=n=>n}),aB=me("$ZodUnknown",(e,t)=>{bt.init(e,t),e._zod.parse=n=>n}),iB=me("$ZodNever",(e,t)=>{bt.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),oB=me("$ZodVoid",(e,t)=>{bt.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}}),sB=me("$ZodDate",(e,t)=>{bt.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 K$(e,t,n){e.issues.length&&t.issues.push(...mi(n,e.issues)),t.value[n]=e.value}const lB=me("$ZodArray",(e,t)=>{bt.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(d=>K$(d,n,s))):K$(u,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function Mb(e,t,n,a){e.issues.length&&t.issues.push(...mi(n,e.issues)),e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function cB(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=iF(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function uB(e,t,n,a,r,i){const s=[],c=r.keySet,u=r.catchall._zod,d=u.def.type;for(const m in t){if(c.has(m))continue;if(d==="never"){s.push(m);continue}const h=u.run({value:t[m],issues:[]},a);h instanceof Promise?e.push(h.then(g=>Mb(g,n,m,t))):Mb(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 dB=me("$ZodObject",(e,t)=>{if(bt.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=Kp(()=>cB(t));Ht(e._zod,"propValues",()=>{const c=t.shape,u={};for(const d in c){const m=c[d]._zod;if(m.values){u[d]??(u[d]=new Set);for(const h of m.values)u[d].add(h)}}return u});const r=Ku,i=t.catchall;let s;e._zod.parse=(c,u)=>{s??(s=a.value);const d=c.value;if(!r(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const m=[],h=s.shape;for(const g of s.keys){const w=h[g]._zod.run({value:d[g],issues:[]},u);w instanceof Promise?m.push(w.then(S=>Mb(S,c,g,d))):Mb(w,c,g,d)}return i?uB(m,d,c,u,a.value,e):m.length?Promise.all(m).then(()=>c):c}}),fB=me("$ZodObjectJIT",(e,t)=>{dB.init(e,t);const n=e._zod.parse,a=Kp(()=>cB(t)),r=g=>{const v=new E3(["shape","payload","ctx"]),w=a.value,S=k=>{const C=US(k);return`shape[${C}]._zod.run({ value: input[${C}], issues: [] }, ctx)`};v.write("const input = payload.value;");const y=Object.create(null);let _=0;for(const k of w.keys)y[k]=`key_${_++}`;v.write("const newResult = {};");for(const k of w.keys){const C=y[k],R=US(k);v.write(`const ${C} = ${S(k)};`),v.write(`
|
|
@@ -32,7 +32,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
32
32
|
`;break;case"id":c=y.includes("\0")?void 0:y;break;case"retry":/^\d+$/.test(y)?a(parseInt(y,10)):n(new IP(`Invalid \`retry\` value: "${y}"`,{type:"invalid-retry",value:y,line:_}));break;default:n(new IP(`Unknown field "${S.length>20?`${S.slice(0,20)}…`:S}"`,{type:"unknown-field",field:S,value:y,line:_}));break}}function v(){u.length>0&&t({id:c,event:d||void 0,data:u.endsWith(`
|
|
33
33
|
`)?u.slice(0,-1):u}),c=void 0,u="",d=""}function w(S={}){i&&S.consume&&h(i),s=!0,c=void 0,u="",d="",i=""}return{feed:m,reset:w}}function mie(e){const t=[];let n="",a=0;for(;a<e.length;){const r=e.indexOf("\r",a),i=e.indexOf(`
|
|
34
34
|
`,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]===`
|
|
35
|
-
`&&a++}}return[t,n]}class hie extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let r;super({start(i){r=MH({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 gie={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class yl extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class bie{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=EH(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(a=n?.reconnectionOptions)!==null&&a!==void 0?a:gie}async _authThenStart(){var t;if(!this._authProvider)throw new Ya("No auth provider");let n;try{n=await ko(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 Ya;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=Kb((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 yl(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 w=t.pipeThrough(new TextDecoderStream).pipeThrough(new hie({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:E}=await w.read();if(E)break;if(_.id&&(s=_.id,c=!0,r?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const k=cb.parse(JSON.parse(_.data));zf(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(w){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${w}`)),(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(_){(v=this.onerror)===null||v===void 0||v.call(this,new Error(`Failed to reconnect: ${_ instanceof Error?_.message:String(_)}`))}}})()}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 Ya("No auth provider");if(await ko(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya("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,d;try{const{resumptionToken:m,onresumptiontoken:h}=n||{};if(m){this._startOrAuthSse({resumptionToken:m,replayMessageId:KS(t)?t.id:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.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},w=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,v),S=w.headers.get("mcp-session-id");if(S&&(this._sessionId=S),!w.ok){const k=await w.text().catch(()=>null);if(w.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new yl(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:C,scope:R}=xp(w);if(this._resourceMetadataUrl=C,this._scope=R,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya;return this._hasCompletedAuthFlow=!0,this.send(t)}if(w.status===403&&this._authProvider){const{resourceMetadataUrl:C,scope:R,error:I}=xp(w);if(I==="insufficient_scope"){const A=w.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===A)throw new yl(403,"Server returned 403 after trying upscoping");if(R&&(this._scope=R),C&&(this._resourceMetadataUrl=C),this._lastUpscopingHeader=A??void 0,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Ya;return this.send(t)}}throw new yl(w.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,w.status===202){await((i=w.body)===null||i===void 0?void 0:i.cancel()),lne(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const _=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,E=w.headers.get("content-type");if(_)if(E?.includes("text/event-stream"))this._handleSseStream(w.body,{onresumptiontoken:h},!1);else if(E?.includes("application/json")){const k=await w.json(),C=Array.isArray(k)?k.map(R=>cb.parse(R)):[cb.parse(k)];for(const R of C)(s=this.onmessage)===null||s===void 0||s.call(this,R)}else throw await((c=w.body)===null||c===void 0?void 0:c.cancel()),new yl(-1,`Unexpected content type: ${E}`);else await((u=w.body)===null||u===void 0?void 0:u.cancel())}catch(m){throw(d=this.onerror)===null||d===void 0||d.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 yl(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 OP 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(DP(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(DP(this),n)}}function vie(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function oE(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(oE).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${oE(e.cause)}`:e.message:`${e}`}function DP(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var PH=e=>{throw TypeError(e)},qT=(e,t,n)=>t.has(e)||PH("Cannot "+n),Bt=(e,t,n)=>(qT(e,t,"read from private field"),n?n.call(e):t.get(e)),ur=(e,t,n)=>t.has(e)?PH("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),$n=(e,t,n,a)=>(qT(e,t,"write to private field"),t.set(e,n),n),wo=(e,t,n)=>(qT(e,t,"access private method"),n),ma,xl,Wc,db,Jb,Jf,ru,Qf,Ts,Kc,mu,Zc,Ff,ci,sE,lE,cE,jP,uE,dE,Bf,fE,pE;class fb extends EventTarget{constructor(t,n){var a,r;super(),ur(this,ci),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,ur(this,ma),ur(this,xl),ur(this,Wc),ur(this,db),ur(this,Jb),ur(this,Jf),ur(this,ru),ur(this,Qf,null),ur(this,Ts),ur(this,Kc),ur(this,mu,null),ur(this,Zc,null),ur(this,Ff,null),ur(this,lE,async i=>{var s;Bt(this,Kc).reset();const{body:c,redirected:u,status:d,headers:m}=i;if(d===204){wo(this,ci,Bf).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?$n(this,Wc,new URL(i.url)):$n(this,Wc,void 0),d!==200){wo(this,ci,Bf).call(this,`Non-200 status code (${d})`,d);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){wo(this,ci,Bf).call(this,'Invalid content type, expected "text/event-stream"',d);return}if(Bt(this,ma)===this.CLOSED)return;$n(this,ma,this.OPEN);const h=new Event("open");if((s=Bt(this,Ff))==null||s.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){wo(this,ci,Bf).call(this,"Invalid response body, expected a web ReadableStream",d),this.close();return}const g=new TextDecoder,v=c.getReader();let w=!0;do{const{done:S,value:y}=await v.read();y&&Bt(this,Kc).feed(g.decode(y,{stream:!S})),S&&(w=!1,Bt(this,Kc).reset(),wo(this,ci,fE).call(this))}while(w)}),ur(this,cE,i=>{$n(this,Ts,void 0),!(i.name==="AbortError"||i.type==="aborted")&&wo(this,ci,fE).call(this,oE(i))}),ur(this,uE,i=>{typeof i.id=="string"&&$n(this,Qf,i.id);const s=new MessageEvent(i.event||"message",{data:i.data,origin:Bt(this,Wc)?Bt(this,Wc).origin:Bt(this,xl).origin,lastEventId:i.id||""});Bt(this,Zc)&&(!i.event||i.event==="message")&&Bt(this,Zc).call(this,s),this.dispatchEvent(s)}),ur(this,dE,i=>{$n(this,Jf,i)}),ur(this,pE,()=>{$n(this,ru,void 0),Bt(this,ma)===this.CONNECTING&&wo(this,ci,sE).call(this)});try{if(t instanceof URL)$n(this,xl,t);else if(typeof t=="string")$n(this,xl,new URL(t,yie()));else throw new Error("Invalid URL")}catch{throw vie("An invalid or illegal string was specified")}$n(this,Kc,MH({onEvent:Bt(this,uE),onRetry:Bt(this,dE)})),$n(this,ma,this.CONNECTING),$n(this,Jf,3e3),$n(this,Jb,(a=n?.fetch)!=null?a:globalThis.fetch),$n(this,db,(r=n?.withCredentials)!=null?r:!1),wo(this,ci,sE).call(this)}get readyState(){return Bt(this,ma)}get url(){return Bt(this,xl).href}get withCredentials(){return Bt(this,db)}get onerror(){return Bt(this,mu)}set onerror(t){$n(this,mu,t)}get onmessage(){return Bt(this,Zc)}set onmessage(t){$n(this,Zc,t)}get onopen(){return Bt(this,Ff)}set onopen(t){$n(this,Ff,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(){Bt(this,ru)&&clearTimeout(Bt(this,ru)),Bt(this,ma)!==this.CLOSED&&(Bt(this,Ts)&&Bt(this,Ts).abort(),$n(this,ma,this.CLOSED),$n(this,Ts,void 0))}}ma=new WeakMap,xl=new WeakMap,Wc=new WeakMap,db=new WeakMap,Jb=new WeakMap,Jf=new WeakMap,ru=new WeakMap,Qf=new WeakMap,Ts=new WeakMap,Kc=new WeakMap,mu=new WeakMap,Zc=new WeakMap,Ff=new WeakMap,ci=new WeakSet,sE=function(){$n(this,ma,this.CONNECTING),$n(this,Ts,new AbortController),Bt(this,Jb)(Bt(this,xl),wo(this,ci,jP).call(this)).then(Bt(this,lE)).catch(Bt(this,cE))},lE=new WeakMap,cE=new WeakMap,jP=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Bt(this,Qf)?{"Last-Event-ID":Bt(this,Qf)}:void 0},cache:"no-store",signal:(e=Bt(this,Ts))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},uE=new WeakMap,dE=new WeakMap,Bf=function(e,t){var n;Bt(this,ma)!==this.CLOSED&&$n(this,ma,this.CLOSED);const a=new OP("error",{code:t,message:e});(n=Bt(this,mu))==null||n.call(this,a),this.dispatchEvent(a)},fE=function(e,t){var n;if(Bt(this,ma)===this.CLOSED)return;$n(this,ma,this.CONNECTING);const a=new OP("error",{code:t,message:e});(n=Bt(this,mu))==null||n.call(this,a),this.dispatchEvent(a),$n(this,ru,setTimeout(Bt(this,pE),Bt(this,Jf)))},pE=new WeakMap,fb.CONNECTING=0,fb.OPEN=1,fb.CLOSED=2;function yie(){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 wie extends Error{constructor(t,n,a){super(`SSE error: ${n}`),this.code=t,this.event=a}}class xie{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=EH(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new Ya("No auth provider");let n;try{n=await ko(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 Ya;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=Kb((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 fb(this._url.href,{...this._eventSourceInit,fetch:async(c,u)=>{const d=await this._commonHeaders();d.set("Accept","text/event-stream");const m=await r(c,{...u,headers:d});if(m.status===401&&m.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=xp(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 d=new wie(c.code,c.message,c);s(d),(u=this.onerror)===null||u===void 0||u.call(this,d)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",c=>{var u;const d=c;try{if(this._endpoint=new URL(d.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,d;const m=c;let h;try{h=cb.parse(JSON.parse(m.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(d=this.onmessage)===null||d===void 0||d.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 Ya("No auth provider");if(await ko(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya("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 d=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:m,scope:h}=xp(u);if(this._resourceMetadataUrl=m,this._scope=h,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${d}`)}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 Lx,LP;function Sie(){return LP||(LP=1,Lx=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}),Lx}var Eie=Sie();const $P=Wp(Eie);var Pu,_ie=(Pu=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}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)}},Pe(Pu,"MCPSession"),Pu),Uu,UH=(Uu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),we.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){we.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?we.debug(`${this.constructor.name} task aborted successfully`):we.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,we.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(){we.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),we.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,we.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){we.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=Pe(()=>{a.removeEventListener("abort",r),t()},"onAbort");a.addEventListener("abort",r)})}},Pe(Uu,"ConnectionManager"),Uu),zu,kie=(zu=class extends UH{url;opts;_transport=null;constructor(t,n){super(),this.url=typeof t=="string"?new URL(t):t,this.opts=n}async establishConnection(){return this._transport=new xie(this.url,this.opts),we.debug(`${this.constructor.name} connected successfully`),this._transport}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){we.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},Pe(zu,"SseConnectionManager"),zu),Fu,MP=(Fu=class extends pH{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;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.timeout=n.timeout??3e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1}async connect(){if(this.connected){we.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){we.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}we.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{we.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),we.info("✅ Successfully connected via streamable HTTP")}catch(n){let a="Unknown error",r=!1;if(n instanceof yl){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",we.warn(`⚠️ ${a}`)):i.code===404||i.code===405?(a=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,we.debug(a)):(a=`Server returned ${i.code}: ${i.message}`,we.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",we.warn(`⚠️ ${a}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(a="Server doesn't support streamable HTTP (405/404)",we.debug(a)):(a=`Streamable HTTP failed: ${n.message}`,we.debug(a))}if(r){we.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}we.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if(we.error("Failed to connect with both transports:"),we.error(` Streamable HTTP: ${a}`),we.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 bie(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:{}}}:{}}};we.debug("Creating Client with capabilities:",JSON.stringify(r.capabilities,null,2)),this.client=new NP(this.clientInfo,r),this.setupRootsHandler(),we.debug("Roots handler registered before connect");try{await this.client.connect(a,{timeout:Math.min(this.timeout,3e3)});const i=n.sessionId;i?we.debug(`Session ID obtained: ${i}`):we.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:Pe(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){we.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(),we.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 kie(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:{}}}:{}}};we.debug("Creating Client with capabilities (SSE):",JSON.stringify(a.capabilities,null,2)),this.client=new NP(this.clientInfo,a),this.setupRootsHandler(),we.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),we.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}},Pe(Fu,"HttpConnector"),Fu),Bu,Tie=(Bu=class extends UH{url;headers;_ws=null;constructor(t,n={}){super(),this.url=t,this.headers=n}async establishConnection(){return we.debug(`Connecting to WebSocket: ${this.url}`),new Promise((t,n)=>{const a=new $P(this.url,{headers:this.headers});this._ws=a;const r=Pe(()=>{s(),we.debug("WebSocket connected successfully"),t(a)},"onOpen"),i=Pe(c=>{s(),we.error(`Failed to connect to WebSocket: ${c}`),n(c)},"onError"),s=Pe(()=>{a.off("open",r),a.off("error",i)},"cleanup");a.on("open",r),a.on("error",i)})}async closeConnection(t){return we.debug("Closing WebSocket connection"),new Promise(n=>{const a=Pe(()=>{t.off("close",a),this._ws=null,n()},"onClose");if(t.readyState===$P.CLOSED){a();return}t.on("close",a);try{t.close()}catch(r){we.warn(`Error closing WebSocket connection: ${r}`),a()}})}},Pe(Bu,"WebSocketConnectionManager"),Bu),Hu,Nie=(Hu=class extends pH{url;headers;connectionManager=null;ws=null;receiverTask=null;pending=new Map;toolsCache=null;constructor(t,n={}){super(),this.url=t,this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`)}async connect(){if(this.connected){we.debug("Already connected to MCP implementation");return}we.debug(`Connecting via WebSocket: ${this.url}`);try{this.connectionManager=new Tie(this.url,this.headers),this.ws=await this.connectionManager.start(),this.receiverTask=this.receiveLoop(),this.connected=!0,we.debug("WebSocket connected successfully")}catch(t){throw we.error(`Failed to connect: ${t}`),await this.cleanupResources(),t}}async disconnect(){if(!this.connected){we.debug("Not connected to MCP implementation");return}we.debug("Disconnecting …"),await this.cleanupResources(),this.connected=!1}sendRequest(t,n=null){if(!this.ws)throw new Error("WebSocket is not connected");const a=tu(),r=JSON.stringify({id:a,method:t,params:n??{}});return new Promise((i,s)=>{this.pending.set(a,{resolve:i,reject:s}),this.ws.send(r,c=>{c&&(this.pending.delete(a),s(c))})})}async receiveLoop(){if(!this.ws)return;const t=this.ws,n=Pe(a=>{let r;try{r=JSON.parse(a.data??a)}catch(s){we.warn("Received non‑JSON frame",s);return}const i=r.id;if(i&&this.pending.has(i)){const{resolve:s,reject:c}=this.pending.get(i);this.pending.delete(i),"result"in r?s(r.result):"error"in r&&c(r.error)}else r.method&&!r.id?(we.debug("Received notification",r.method,r.params),this.handleNotification(r)):we.debug("Received unsolicited message",r)},"onMessage");return t.addEventListener?t.addEventListener("message",n):t.on("message",n),new Promise(a=>{const r=Pe(()=>{t.removeEventListener?t.removeEventListener("message",n):t.off("message",n),this.rejectAll(new Error("WebSocket closed")),a()},"onClose");t.addEventListener?t.addEventListener("close",r):t.on("close",r)})}rejectAll(t){for(const{reject:n}of this.pending.values())n(t);this.pending.clear()}async handleNotification(t){switch(t.method){case"notifications/tools/list_changed":await this.refreshToolsCache();break;case"notifications/resources/list_changed":await this.onResourcesListChanged();break;case"notifications/prompts/list_changed":await this.onPromptsListChanged();break}for(const n of this.notificationHandlers)try{await n({method:t.method,params:t.params})}catch(a){we.error("Error in notification handler:",a)}}async refreshToolsCache(){try{we.debug("[Auto] Refreshing tools cache due to list_changed notification");const t=await this.listTools();this.toolsCache=t.map(n=>n),we.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(t){we.warn("[Auto] Failed to refresh tools cache:",t)}}async initialize(){we.debug("Initializing MCP session over WebSocket");const t=await this.sendRequest("initialize"),n=await this.listTools();return this.toolsCache=n.map(a=>a),we.debug(`Initialized with ${this.toolsCache.length} tools`),t}async listTools(){return(await this.sendRequest("tools/list")).tools??[]}async callTool(t,n){return await this.sendRequest("tools/call",{name:t,arguments:n})}async listResources(){const t=await this.sendRequest("resources/list");return{resources:Array.isArray(t)?t:[]}}async readResource(t){return await this.sendRequest("resources/read",{uri:t})}async request(t,n=null){return await this.sendRequest(t,n)}get tools(){if(!this.toolsCache)throw new Error("MCP client is not initialized");return this.toolsCache}async cleanupResources(){this.receiverTask&&await this.receiverTask.catch(()=>{}),this.receiverTask=null,this.rejectAll(new Error("WebSocket disconnected")),this.connectionManager&&(await this.connectionManager.stop(),this.connectionManager=null,this.ws=null),this.toolsCache=null}get publicIdentifier(){return{type:"websocket",url:this.url}}},Pe(Hu,"WebSocketConnector"),Hu),Vu,Cie=(Vu=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,Mi.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Mi.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&&we.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 _ie(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&&we.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}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){we.warn(`No session exists for server ${t}, nothing to close`);return}try{we.debug(`Closing session for server ${t}`),await n.disconnect()}catch(a){we.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{we.debug(`Closing session for server ${a}`),await this.closeSession(a)}catch(r){const i=`Failed to close session for server '${a}': ${r}`;we.error(i),n.push(i)}n.length?we.error(`Encountered ${n.length} errors while closing sessions`):we.debug("All sessions closed successfully")}},Pe(Vu,"BaseMCPClient"),Vu),Dl,Rie=(Dl=class extends Cie{static getPackageVersion(){return Db()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Mi.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>we.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new Dl(t)}createConnectorFromConfig(t){const{url:n,transport:a,headers:r,authToken:i,authProvider:s,wrapTransport:c,clientOptions:u,samplingCallback:d,elicitationCallback:m}=t;if(!n)throw new Error("Server URL is required");const h={headers:r,authToken:i,authProvider:s,wrapTransport:c,clientOptions:u,samplingCallback:d,elicitationCallback:m};return u?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(u,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),a==="websocket"||n.startsWith("ws://")||n.startsWith("wss://")?new Nie(n,h):a==="http"||n.startsWith("http://")||n.startsWith("https://")?new MP(n,h):new MP(n,h)}},Pe(Dl,"BrowserMCPClient"),Dl);function au(e){const t=Pe(()=>{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(zH).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}Pe(au,"sanitizeUrl");function zH([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}Pe(zH,"sanitizeParam");var Gu,pb=(Gu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;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.callbackUrl=au(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 au(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}}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=au(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?au(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}`}},Pe(Gu,"BrowserOAuthClientProvider"),Gu);async function XT(){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 d=localStorage.getItem(u);if(!d)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{c=JSON.parse(d)}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 pb(m,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await ko(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 S=window.location.pathname.split("/").filter(Boolean),y=S.length>0&&S[S.length-1]==="callback"?"/"+S.slice(0,-2).join("/"):"/";window.location.href=y||"/"}else throw console.warn(`${i} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(d){console.error(`${i} Error during OAuth callback handling:`,d);const m=d instanceof Error?d.message:String(d);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 w=document.createElement("p");w.textContent="You can close this window or ";const S=document.createElement("a");if(S.href="#",S.textContent="click here to close",S.onclick=y=>(y.preventDefault(),window.close(),!1),w.appendChild(S),w.appendChild(document.createTextNode(".")),h.appendChild(w),d instanceof Error&&d.stack){const y=document.createElement("pre");y.style.fontSize="0.8em",y.style.color="#555",y.style.marginTop="20px",y.style.whiteSpace="pre-wrap",y.textContent=d.stack,h.appendChild(y)}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")))}}Pe(XT,"onMcpAuthorization");var $x={exports:{}},gt={};var PP;function Aie(){if(PP)return gt;PP=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"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,y={};function _(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||w}_.prototype.isReactComponent={},_.prototype.setState=function(j,V){if(typeof j!="object"&&typeof j!="function"&&j!=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,j,V,"setState")},_.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function E(){}E.prototype=_.prototype;function k(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||w}var C=k.prototype=new E;C.constructor=k,S(C,_.prototype),C.isPureReactComponent=!0;var R=Array.isArray;function I(){}var A={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function M(j,V,z){var L=z.ref;return{$$typeof:e,type:j,key:V,ref:L!==void 0?L:null,props:z}}function U(j,V){return M(j.type,V,j.props)}function H(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function K(j){var V={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(z){return V[z]})}var Q=/\/+/g;function te(j,V){return typeof j=="object"&&j!==null&&j.key!=null?K(""+j.key):V.toString(36)}function ae(j){switch(j.status){case"fulfilled":return j.value;case"rejected":throw j.reason;default:switch(typeof j.status=="string"?j.then(I,I):(j.status="pending",j.then(function(V){j.status==="pending"&&(j.status="fulfilled",j.value=V)},function(V){j.status==="pending"&&(j.status="rejected",j.reason=V)})),j.status){case"fulfilled":return j.value;case"rejected":throw j.reason}}throw j}function B(j,V,z,L,$){var F=typeof j;(F==="undefined"||F==="boolean")&&(j=null);var W=!1;if(j===null)W=!0;else switch(F){case"bigint":case"string":case"number":W=!0;break;case"object":switch(j.$$typeof){case e:case t:W=!0;break;case m:return W=j._init,B(W(j._payload),V,z,L,$)}}if(W)return $=$(j),W=L===""?"."+te(j,0):L,R($)?(z="",W!=null&&(z=W.replace(Q,"$&/")+"/"),B($,V,z,"",function(le){return le})):$!=null&&(H($)&&($=U($,z+($.key==null||j&&j.key===$.key?"":(""+$.key).replace(Q,"$&/")+"/")+W)),V.push($)),1;W=0;var X=L===""?".":L+":";if(R(j))for(var ie=0;ie<j.length;ie++)L=j[ie],F=X+te(L,ie),W+=B(L,V,z,F,$);else if(ie=v(j),typeof ie=="function")for(j=ie.call(j),ie=0;!(L=j.next()).done;)L=L.value,F=X+te(L,ie++),W+=B(L,V,z,F,$);else if(F==="object"){if(typeof j.then=="function")return B(ae(j),V,z,L,$);throw V=String(j),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return W}function Z(j,V,z){if(j==null)return j;var L=[],$=0;return B(j,L,"","",function(F){return V.call(z,F,$++)}),L}function G(j){if(j._status===-1){var V=j._result;V=V(),V.then(function(z){(j._status===0||j._status===-1)&&(j._status=1,j._result=z)},function(z){(j._status===0||j._status===-1)&&(j._status=2,j._result=z)}),j._status===-1&&(j._status=0,j._result=V)}if(j._status===1)return j._result.default;throw j._result}var re=typeof reportError=="function"?reportError:function(j){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof j=="object"&&j!==null&&typeof j.message=="string"?String(j.message):String(j),error:j});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",j);return}console.error(j)},ne={map:Z,forEach:function(j,V,z){Z(j,function(){V.apply(this,arguments)},z)},count:function(j){var V=0;return Z(j,function(){V++}),V},toArray:function(j){return Z(j,function(V){return V})||[]},only:function(j){if(!H(j))throw Error("React.Children.only expected to receive a single React element child.");return j}};return gt.Activity=h,gt.Children=ne,gt.Component=_,gt.Fragment=n,gt.Profiler=r,gt.PureComponent=k,gt.StrictMode=a,gt.Suspense=u,gt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,gt.__COMPILER_RUNTIME={__proto__:null,c:function(j){return A.H.useMemoCache(j)}},gt.cache=function(j){return function(){return j.apply(null,arguments)}},gt.cacheSignal=function(){return null},gt.cloneElement=function(j,V,z){if(j==null)throw Error("The argument must be a React element, but you passed "+j+".");var L=S({},j.props),$=j.key;if(V!=null)for(F in V.key!==void 0&&($=""+V.key),V)!O.call(V,F)||F==="key"||F==="__self"||F==="__source"||F==="ref"&&V.ref===void 0||(L[F]=V[F]);var F=arguments.length-2;if(F===1)L.children=z;else if(1<F){for(var W=Array(F),X=0;X<F;X++)W[X]=arguments[X+2];L.children=W}return M(j.type,$,L)},gt.createContext=function(j){return j={$$typeof:s,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null},j.Provider=j,j.Consumer={$$typeof:i,_context:j},j},gt.createElement=function(j,V,z){var L,$={},F=null;if(V!=null)for(L in V.key!==void 0&&(F=""+V.key),V)O.call(V,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&($[L]=V[L]);var W=arguments.length-2;if(W===1)$.children=z;else if(1<W){for(var X=Array(W),ie=0;ie<W;ie++)X[ie]=arguments[ie+2];$.children=X}if(j&&j.defaultProps)for(L in W=j.defaultProps,W)$[L]===void 0&&($[L]=W[L]);return M(j,F,$)},gt.createRef=function(){return{current:null}},gt.forwardRef=function(j){return{$$typeof:c,render:j}},gt.isValidElement=H,gt.lazy=function(j){return{$$typeof:m,_payload:{_status:-1,_result:j},_init:G}},gt.memo=function(j,V){return{$$typeof:d,type:j,compare:V===void 0?null:V}},gt.startTransition=function(j){var V=A.T,z={};A.T=z;try{var L=j(),$=A.S;$!==null&&$(z,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(I,re)}catch(F){re(F)}finally{V!==null&&z.types!==null&&(V.types=z.types),A.T=V}},gt.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},gt.use=function(j){return A.H.use(j)},gt.useActionState=function(j,V,z){return A.H.useActionState(j,V,z)},gt.useCallback=function(j,V){return A.H.useCallback(j,V)},gt.useContext=function(j){return A.H.useContext(j)},gt.useDebugValue=function(){},gt.useDeferredValue=function(j,V){return A.H.useDeferredValue(j,V)},gt.useEffect=function(j,V){return A.H.useEffect(j,V)},gt.useEffectEvent=function(j){return A.H.useEffectEvent(j)},gt.useId=function(){return A.H.useId()},gt.useImperativeHandle=function(j,V,z){return A.H.useImperativeHandle(j,V,z)},gt.useInsertionEffect=function(j,V){return A.H.useInsertionEffect(j,V)},gt.useLayoutEffect=function(j,V){return A.H.useLayoutEffect(j,V)},gt.useMemo=function(j,V){return A.H.useMemo(j,V)},gt.useOptimistic=function(j,V){return A.H.useOptimistic(j,V)},gt.useReducer=function(j,V,z){return A.H.useReducer(j,V,z)},gt.useRef=function(j){return A.H.useRef(j)},gt.useState=function(j){return A.H.useState(j)},gt.useSyncExternalStore=function(j,V,z){return A.H.useSyncExternalStore(j,V,z)},gt.useTransition=function(){return A.H.useTransition()},gt.version="19.2.0",gt}var UP;function JT(){return UP||(UP=1,$x.exports=Aie()),$x.exports}var x=JT();const ue=Wp(x),pd=Wq({__proto__:null,default:ue},[x]);function mE(e,t){if(!e)throw new Error(t)}Pe(mE,"assert");var Iie=3e3,Oie=5e3;function QT(e){const{url:t,enabled:n=!0,clientName:a,clientUri:r,callbackUrl:i=typeof window<"u"?au(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:s="mcp:auth",clientConfig:c={},customHeaders:u={},debug:d=!1,autoRetry:m=!1,autoReconnect:h=Iie,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:w=!1,onPopupWindow:S,timeout:y=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:C,onElicitation:R}=e,[I,A]=x.useState("discovering"),[O,M]=x.useState([]),[U,H]=x.useState([]),[K,Q]=x.useState([]),[te,ae]=x.useState([]),[B,Z]=x.useState(),[G,re]=x.useState(),[ne,j]=x.useState(void 0),[V,z]=x.useState([]),[L,$]=x.useState(void 0),F=x.useRef(null),W=x.useRef(null),X=x.useRef(!1),ie=x.useRef(!0),le=x.useRef(0),J=x.useRef(null),q=x.useRef(I),se=x.useRef(h),he=x.useRef(null);x.useEffect(()=>{q.current=I,se.current=h},[I,h]);const ce=x.useCallback((je,Fe,...pt)=>{const Qe=pt.length>0?`${Fe} ${pt.map(Tt=>JSON.stringify(Tt)).join(" ")}`:Fe;console[je](`[useMcp] ${Qe}`),ie.current&&z(Tt=>[...Tt.slice(-100),{level:je,message:Qe,timestamp:Date.now()}])},[]),Te=x.useCallback(async(je=!1)=>{if(je||ce("info","Disconnecting..."),X.current=!1,J.current&&clearTimeout(J.current),J.current=null,F.current)try{await F.current.closeSession("inspector-server")}catch(Fe){je||ce("warn","Error closing session:",Fe)}F.current=null,ie.current&&!je&&(A("discovering"),M([]),H([]),Q([]),ae([]),j(void 0),$(void 0))},[ce]),He=x.useCallback((je,Fe)=>{if(ce("error",je,Fe??""),ie.current){A("failed"),j(je);const pt=W.current?.getLastAttemptedAuthUrl();pt&&($(pt),ce("info","Manual authentication URL may be available.",pt))}X.current=!1,t&&Mi.getInstance().trackUseMcpConnection({url:t,transportType:g,success:!1,errorType:Fe?.name||"UnknownError",hasOAuth:!!W.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{})},[ce,t,g,C,R]),Ee=x.useCallback(async()=>{if(!n||!t){ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(X.current){ce("debug","Connection attempt already in progress.");return}if(!ie.current){ce("debug","Connect called after unmount, aborting.");return}X.current=!0,le.current+=1,j(void 0),$(void 0),he.current=null,A("discovering"),ce("info",`Connecting attempt #${le.current} to ${t}...`),W.current||(W.current=new pb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ce("debug","BrowserOAuthClientProvider initialized in connect.")),F.current||(F.current=new Rie,ce("debug","BrowserMCPClient initialized in connect."));const je=Pe(async(pt,Qe=!1)=>{ce("info",`Attempting connection with transport: ${pt}`);try{const Tt="inspector-server",nt={url:t,transport:pt==="sse"?"http":pt};if(u&&Object.keys(u).length>0&&(nt.headers=u),W.current){const wt=await W.current.tokens();wt?.access_token&&(nt.headers={...nt.headers,Authorization:`Bearer ${wt.access_token}`})}F.current.addServer(Tt,{...nt,authProvider:W.current,clientOptions:c,samplingCallback:C,elicitationCallback:R,wrapTransport:E?wt=>(console.log("[useMcp] Applying transport wrapper for server:",Tt,"url:",t),E(wt,t)):void 0});const Ie=await F.current.createSession(Tt,!1);k&&Ie.on("notification",k),await Ie.initialize(),ce("info","✅ Successfully connected to MCP server"),ce("info","Server info:",Ie.connector.serverInfo),ce("info","Server capabilities:",Ie.connector.serverCapabilities),console.log("[useMcp] Server info:",Ie.connector.serverInfo),console.log("[useMcp] Server capabilities:",Ie.connector.serverCapabilities),A("ready"),he.current=pt,Mi.getInstance().trackUseMcpConnection({url:t,transportType:pt,success:!0,hasOAuth:!!W.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{}),M(Ie.connector.tools||[]);const $e=await Ie.connector.listAllResources();H($e.resources||[]);const Ve=await Ie.connector.listPrompts();ae(Ve.prompts||[]);const at=Ie.connector.serverInfo,dt=Ie.connector.serverCapabilities;return at&&(console.log("[useMcp] Server info:",at),Z(at)),dt&&(console.log("[useMcp] Server capabilities:",dt),re(dt)),"success"}catch(Tt){const nt=Tt,Ie=nt?.message||String(Tt);if(nt.code===401||Ie.includes("401")||Ie.includes("Unauthorized")){if(W.current){ce("info","Authentication required. OAuth provider available.");try{const{auth:$e}=await Qn(async()=>{const{auth:at}=await Promise.resolve().then(()=>AP);return{auth:at}},void 0),Ve=new URL(t).origin;$e(W.current,{serverUrl:Ve}).catch(()=>{}),setTimeout(()=>{if(ie.current){const at=W.current?.getLastAttemptedAuthUrl();at?($(at),ce("info","Manual authentication URL available:",at)):ce("warn","Could not generate authentication URL")}},100)}catch($e){ce("warn","Error generating auth URL:",$e)}return ie.current&&A("pending_auth"),X.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(He("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(He("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return He(Ie,nt instanceof Error?nt:new Error(String(nt))),"failed"}},"tryConnectWithTransport");let Fe="failed";if(g==="sse")ce("debug","Using SSE-only transport mode"),Fe=await je("sse");else if(g==="http")ce("debug","Using HTTP-only transport mode"),Fe=await je("http");else{ce("debug","Using auto transport mode (HTTP with SSE fallback)");const pt=await je("http");pt==="fallback"&&ie.current&&q.current!=="authenticating"?(ce("info","HTTP failed, attempting SSE fallback..."),Fe=await je("sse")):Fe=pt}(Fe==="success"||Fe==="failed"||Fe==="auth_redirect")&&(X.current=!1),ce("debug",`Connection sequence finished with status: ${Fe}`)},[ce,He,Te,t,s,a,r,i,c.name,c.version,u,g,v,w,S,n,y,_]),ke=x.useCallback(async(je,Fe,pt)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot call tool "${je}".`);ce("info",`Calling tool: ${je}`,Fe);const Qe=Date.now();try{const nt=F.current.getSession("inspector-server");if(!nt)throw new Error("No active session found");const Ie=await nt.connector.callTool(je,Fe||{},pt);return ce("info",`Tool "${je}" call successful:`,Ie),Mi.getInstance().trackUseMcpToolCall({toolName:je,success:!0,executionTimeMs:Date.now()-Qe}).catch(()=>{}),Ie}catch(Tt){throw ce("error",`Tool "${je}" call failed:`,Tt),Mi.getInstance().trackUseMcpToolCall({toolName:je,success:!1,errorType:Tt instanceof Error?Tt.name:"UnknownError",executionTimeMs:Date.now()-Qe}).catch(()=>{}),Tt}},[I]),ze=x.useCallback(()=>{q.current==="failed"?(ce("info","Retry requested..."),Ee()):ce("warn",`Retry called but state is not 'failed' (state: ${q.current}). Ignoring.`)},[ce,Ee]),fe=x.useCallback(async()=>{ce("info","Manual authentication requested...");const je=q.current;if(je==="failed")ce("info","Attempting to reconnect and authenticate via retry..."),ze();else if(je==="pending_auth"){ce("info","Proceeding with authentication from pending state...");try{mE(W.current,"Auth Provider not available for manual auth"),mE(t,"Server URL is required for authentication"),ce("info","Clearing all OAuth state and initiating fresh flow...");const Fe=`${s}:${W.current.serverUrlHash}`;Object.keys(localStorage).forEach(nt=>{nt.startsWith(Fe)&&(ce("debug",`Removing stale OAuth key: ${nt}`),localStorage.removeItem(nt)),nt.startsWith(`${s}:state_`)&&(ce("debug",`Removing orphaned state: ${nt}`),localStorage.removeItem(nt))}),A("authenticating");const pt=new pb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:w,onPopupWindow:S});W.current=pt,ce("info","Triggering fresh OAuth authorization...");const{auth:Qe}=await Qn(async()=>{const{auth:nt}=await Promise.resolve().then(()=>AP);return{auth:nt}},void 0),Tt=new URL(t).origin;Qe(pt,{serverUrl:Tt}).catch(nt=>{ce("info","OAuth flow initiated:",nt instanceof Error?nt.message:"Redirecting...")})}catch(Fe){if(!ie.current)return;A("pending_auth"),ce("error",`Manual authentication failed: ${Fe instanceof Error?Fe.message:String(Fe)}`)}}else if(je==="authenticating"){ce("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Fe=W.current?.getLastAttemptedAuthUrl();Fe&&!L&&($(Fe),ce("info","Manual authentication URL retrieved:",Fe))}else ce("info",`Client not in a state requiring manual authentication trigger (state: ${je}). If needed, try disconnecting and reconnecting.`)},[ce,ze,L,t,w,S,s,a,r,i]),Oe=x.useCallback(()=>{if(W.current){const je=W.current.clearStorage();ce("info",`Cleared ${je} item(s) from localStorage for ${t}.`),$(void 0),Te()}else ce("warn","Auth provider not initialized, cannot clear storage.")},[t,ce,Te]),Be=x.useCallback(async()=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot list resources.`);ce("info","Listing resources");try{const Fe=F.current.getSession("inspector-server");if(!Fe)throw new Error("No active session found");const pt=await Fe.connector.listAllResources();H(pt.resources||[]),ce("info","Resources listed successfully")}catch(je){throw ce("error","List resources failed:",je),je}},[I]),Se=x.useCallback(async je=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot read resource.`);ce("info",`Reading resource: ${je}`);try{const pt=F.current.getSession("inspector-server");if(!pt)throw new Error("No active session found");const Qe=await pt.connector.readResource(je);return ce("info","Resource read successful:",Qe),Mi.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!0}).catch(()=>{}),Qe}catch(Fe){throw ce("error","Resource read failed:",Fe),Mi.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!1,errorType:Fe instanceof Error?Fe.name:"UnknownError"}).catch(()=>{}),Fe}},[I]),tt=x.useCallback(async()=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot list prompts.`);ce("info","Listing prompts");try{const Fe=F.current.getSession("inspector-server");if(!Fe)throw new Error("No active session found");const pt=await Fe.connector.listPrompts();ae(pt.prompts||[]),ce("info","Prompts listed successfully")}catch(je){throw ce("error","List prompts failed:",je),je}},[I]),it=x.useCallback(async(je,Fe)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot get prompt.`);ce("info",`Getting prompt: ${je}`,Fe);try{const Qe=F.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const Tt=await Qe.connector.getPrompt(je,Fe||{});return ce("info",`Prompt "${je}" retrieved successfully:`,Tt),Tt}catch(pt){throw ce("error",`Prompt "${je}" retrieval failed:`,pt),pt}},[I]),ht=x.useRef(Ee),Rt=x.useRef(He);return x.useEffect(()=>{ht.current=Ee,Rt.current=He}),x.useEffect(()=>{const je=Pe(Fe=>{Fe.origin===window.location.origin&&Fe.data?.type==="mcp_auth_callback"&&(ce("info","Received auth callback message.",Fe.data),J.current&&clearTimeout(J.current),J.current=null,Fe.data.success?(ce("info","Authentication successful via popup. Reconnecting client..."),X.current&&ce("debug","Connection attempt already in progress, resetting flag to allow reconnection."),X.current=!1,setTimeout(()=>{ie.current&&(ce("debug","Initiating reconnection after successful auth callback."),ht.current())},100)):Rt.current(`Authentication failed in callback: ${Fe.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",je),ce("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",je),ce("debug","Auth callback message listener removed."),J.current&&clearTimeout(J.current)}},[ce]),x.useEffect(()=>(ie.current=!0,!n||!t?(ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),A("discovering"),()=>{ie.current=!1}):(ce("debug","useMcp mounted, initiating connection."),le.current=0,(!W.current||W.current.serverUrl!==t)&&(W.current=new pb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ce("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),Ee(),()=>{ie.current=!1,ce("debug","useMcp unmounting, disconnecting."),Te(!0)})),[t,n,s,i,a,r,c.name,c.version,w]),x.useEffect(()=>{let je=null;if(I==="failed"&&m&&le.current>0){const Fe=typeof m=="number"?m:Oie;ce("info",`Connection failed, auto-retrying in ${Fe}ms...`),je=setTimeout(()=>{ie.current&&q.current==="failed"&&ze()},Fe)}return()=>{je&&clearTimeout(je)}},[I,m,ze,ce]),{state:I,tools:O,resources:U,resourceTemplates:K,prompts:te,serverInfo:B,capabilities:G,error:ne,log:V,authUrl:L,client:F.current,callTool:ke,readResource:Se,listResources:Be,listPrompts:tt,getPrompt:it,retry:ze,disconnect:Te,authenticate:fe,clearStorage:Oe}}Pe(QT,"useMcp");var Wu,Die=(Wu=class extends ue.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?ue.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"},ue.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),ue.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},Pe(Wu,"ErrorBoundary"),Wu),ep="openai:set_globals";function li(e){return x.useSyncExternalStore(t=>{const n=Pe(a=>{a.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(ep,n),()=>{typeof window<"u"&&window.removeEventListener(ep,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}Pe(li,"useOpenAiGlobal");function md(e){const[t,n]=x.useState(()=>typeof window<"u"&&!!window.openai);x.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const O=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},100),M=Pe(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(ep,M);const U=setTimeout(()=>{clearInterval(O),typeof window<"u"&&window.removeEventListener(ep,M)},5e3);return()=>{clearInterval(O),clearTimeout(U),typeof window<"u"&&window.removeEventListener(ep,M)}},[]);const a=x.useMemo(()=>t?"openai":"mcp-ui",[t]),r=typeof window<"u"?window.location.search:"",i=x.useMemo(()=>{const O=new URLSearchParams(r);return O.has("mcpUseParams")?JSON.parse(O.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[r]),s=a==="openai"?li("toolInput"):i.toolInput,c=a==="openai"?li("toolOutput"):i.toolOutput,u=li("toolResponseMetadata"),d=li("widgetState"),m=li("theme"),h=li("displayMode"),g=li("safeArea"),v=li("maxHeight"),w=li("userAgent"),S=li("locale"),y=x.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,E]=x.useState(null);x.useEffect(()=>{d!==void 0&&E(d)},[d]);const k=x.useCallback(async(O,M)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(O,M)},[]),C=x.useCallback(async O=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:O})},[]),R=x.useCallback(O=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:O})},[]),I=x.useCallback(async O=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:O})},[]),A=x.useCallback(async O=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const U=typeof O=="function"?O(d!==void 0?d:_):O;return E(U),window.openai.setWidgetState(U)},[d,_]);return{props:s||e||{},output:c??null,metadata:u??null,state:_,setState:A,theme:m||"light",displayMode:h||"inline",safeArea:g||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:v||600,userAgent:w||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:S||"en",mcp_url:y,callTool:k,sendFollowUpMessage:C,openExternal:R,requestDisplayMode:I,isAvailable:t}}Pe(md,"useWidget");function jie(e){const{props:t}=md(e);return t}Pe(jie,"useWidgetProps");function Lie(){const{theme:e}=md();return e}Pe(Lie,"useWidgetTheme");function $ie(e){const{state:t,setState:n}=md();return x.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Pe($ie,"useWidgetState");var zP=Pe(({children:e})=>{const{theme:t,isAvailable:n}=md();console.log("theme",t);const[a,r]=x.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");x.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),c=Pe(u=>{r(u.matches?"dark":"light")},"handleChange");return s.addEventListener("change",c),()=>s.removeEventListener("change",c)},[]);const i=n?t:a;return x.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),ue.createElement(ue.Fragment,null,e)},"ThemeProvider");function FH({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:d,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:w,userAgent:S,locale:y,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:C,requestDisplayMode:R,setState:I}=md(),[A,O]=x.useState(!1),[M,U]=x.useState(!1),H=x.useRef(null),K=x.useRef(null),[Q,te]=x.useState([]),[ae,B]=x.useState(""),[Z,G]=x.useState("get-my-city"),[re,ne]=x.useState("{}"),[j,V]=x.useState("Test follow-up message"),[z,L]=x.useState("https://docs.mcp-use.com"),$=g==="fullscreen"&&_,F=g==="pip"&&_,W=typeof window<"u"&&window.location.pathname.includes("/inspector/api/dev-widget/");x.useEffect(()=>{const Se=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const tt=Object.keys(window.openai);te(tt)}catch{te([])}else te([])},100);return()=>{clearTimeout(Se)}},[]);const X=h==="dark",ie=Pe(()=>{const Se=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",A?"opacity-100":"opacity-0",A?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...Se,"top-4","left-4"];case"top-center":return[...Se,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...Se,"top-4","right-4"];case"center-left":return[...Se,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...Se,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...Se,"bottom-4","left-4"];case"bottom-center":return[...Se,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...Se,"bottom-4","right-4"];default:return[...Se,"top-4","right-4"]}},"getPositionClasses"),le=Pe(()=>{const tt=v?.insets?.top?Math.max(16,v.insets.top+8):16,it=v?.insets?.right?Math.max(16,v.insets.right+8):16,ht=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Rt=v?.insets?.left?Math.max(16,v.insets.left+8):16,je={};switch(n){case"top-left":je.top=`${tt}px`,je.left=`${Rt}px`;break;case"top-center":je.top=`${tt}px`;break;case"top-right":je.top=`${tt}px`,je.right=`${it}px`;break;case"center-left":je.left=`${Rt}px`;break;case"center-right":je.right=`${it}px`;break;case"bottom-left":je.bottom=`${ht}px`,je.left=`${Rt}px`;break;case"bottom-center":je.bottom=`${ht}px`;break;case"bottom-right":je.bottom=`${ht}px`,je.right=`${it}px`;break;default:je.top=`${tt}px`,je.right=`${it}px`;break}return je},"getPositionOffsetStyles");x.useEffect(()=>{if(!a)return;const Se=Pe(()=>O(!0),"handleMouseEnter"),tt=Pe(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",Se),a.addEventListener("mouseleave",tt),()=>{a.removeEventListener("mouseenter",Se),a.removeEventListener("mouseleave",tt)}},[a]),x.useEffect(()=>{if(!M)return;const Se=Pe(tt=>{K.current&&!K.current.contains(tt.target)&&U(!1)},"handleClickOutside");return document.addEventListener("mousedown",Se),()=>{document.removeEventListener("mousedown",Se)}},[M]),x.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const J=Pe(()=>{U(!M)},"handleToggleOverlay"),q=Pe(async()=>{try{B("Calling tool...");const Se=re.trim()?JSON.parse(re):{},tt=await E(Z,Se);B(`Success: ${JSON.stringify(tt,null,2)}`)}catch(Se){B(`Error: ${Se.message}`)}},"handleCallTool"),se=Pe(async()=>{try{B("Sending follow-up message..."),await k(j),B("Follow-up message sent successfully")}catch(Se){B(`Error: ${Se.message}`)}},"handleSendFollowUpMessage"),he=Pe(()=>{try{C(z),B(`Opened external link: ${z}`)}catch(Se){B(`Error: ${Se.message}`)}},"handleOpenExternal"),ce=Pe(async Se=>{try{B(`Requesting display mode: ${Se}...`);const tt=await R(Se);B(`Display mode granted: ${tt.mode}`)}catch(tt){B(`Error: ${tt.message}`)}},"handleRequestDisplayMode"),Te=Pe(async()=>{try{const Se=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};B("Setting state..."),await I(Se),B(`State updated: ${JSON.stringify(Se,null,2)}`)}catch(Se){B(`Error: ${Se.message}`)}},"handleSetState"),He=Pe(async()=>{try{await R("fullscreen")}catch(Se){console.error("Failed to go fullscreen:",Se)}},"handleFullscreen"),Ee=Pe(async()=>{try{await R("pip")}catch(Se){console.error("Failed to go pip:",Se)}},"handlePip"),ke=Pe(()=>{const Se=["absolute","px-2","py-1","bg-black/90","text-white","rounded","text-xs","whitespace-nowrap","pointer-events-none","transition-opacity","duration-200","ease-in-out"];switch(n){case"top-right":return[...Se,"top-full","right-0","mt-2"];case"top-left":return[...Se,"top-full","left-0","mt-2"];case"top-center":return[...Se,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...Se,"bottom-full","right-0","mb-2"];case"bottom-left":return[...Se,"bottom-full","left-0","mb-2"];case"bottom-center":return[...Se,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...Se,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...Se,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...Se,"top-full","right-0","mt-2"]}},"getTooltipClasses"),ze=Pe(({onClick:Se,label:tt,children:it})=>{const[ht,Rt]=x.useState(!1),je=ke();return ue.createElement("button",{className:`p-2 ${X?"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 ${X?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Rt(!0),onMouseLeave:()=>Rt(!1),onClick:Se,"aria-label":tt},ue.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"},it),r&&ue.createElement("span",{className:`${je.join(" ")} ${ht?"opacity-100":"opacity-0"}`},tt))},"IconButton"),fe=Pe(Se=>{if(Se===null)return"null";if(Se===void 0)return"undefined";if(typeof Se=="object")try{return JSON.stringify(Se,null,2)}catch{return String(Se)}return String(Se)},"formatValue"),Oe=Pe(Se=>Se?`${Se.device?.type||"unknown"}`:"N/A","formatUserAgent"),Be=Pe(Se=>{if(!Se?.insets)return"N/A";const{top:tt,bottom:it,left:ht,right:Rt}=Se.insets;return`T:${tt} B:${it} L:${ht} R:${Rt}`},"formatSafeArea");return ue.createElement(ue.Fragment,null,ue.createElement("div",{ref:H,className:`${t} relative h-fit`,onMouseEnter:()=>!a&&O(!0),onMouseLeave:()=>!a&&O(!1)},ue.createElement("div",{className:ie().join(" "),style:le()},!W&&ue.createElement(ue.Fragment,null,!$&&!F&&ue.createElement(ue.Fragment,null,(s===!0||s==="fullscreen")&&ue.createElement(ze,{onClick:He,label:"Fullscreen"},ue.createElement("path",{d:"M15 3h6v6"}),ue.createElement("path",{d:"m21 3-7 7"}),ue.createElement("path",{d:"m3 21 7-7"}),ue.createElement("path",{d:"M9 21H3v-6"})),(s===!0||s==="pip")&&ue.createElement(ze,{onClick:Ee,label:"Picture in Picture"},ue.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),ue.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&ue.createElement(ze,{onClick:J,label:"Debug Info"},ue.createElement("path",{d:"M12 20v-9"}),ue.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),ue.createElement("path",{d:"M14.12 3.88 16 2"}),ue.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),ue.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),ue.createElement("path",{d:"M22 13h-4"}),ue.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),ue.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),ue.createElement("path",{d:"M6 13H2"}),ue.createElement("path",{d:"m8 2 1.88 1.88"}),ue.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),M&&i&&ue.createElement("div",{ref:K,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:Se=>{Se.target===K.current&&U(!1)}},ue.createElement("button",{onClick:()=>U(!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"},"×"),ue.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},ue.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),ue.createElement("table",{className:"w-full border-collapse border-spacing-0"},ue.createElement("tbody",null,ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(c))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(u))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(d))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(m))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),ue.createElement("td",{className:"p-2"},h)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),ue.createElement("td",{className:"p-2"},g)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),ue.createElement("td",{className:"p-2"},y)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),ue.createElement("td",{className:"p-2"},w,"px")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),ue.createElement("td",{className:"p-2"},Oe(S))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),ue.createElement("td",{className:"p-2"},Be(v))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),ue.createElement("td",{className:"p-2"},_?"Yes":"No")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),ue.createElement("td",{className:"p-2"},Q.length>0?Q.join(", "):"N/A")))),ue.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),ue.createElement("div",{className:"flex flex-col gap-3"},ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:Z,onChange:Se=>G(Se.target.value),placeholder:"Tool name",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]"}),ue.createElement("input",{type:"text",value:re,onChange:Se=>ne(Se.target.value),placeholder:'{"key": "value"}',className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:q,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:j,onChange:Se=>V(Se.target.value),placeholder:"Follow-up message",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.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")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:z,onChange:Se=>L(Se.target.value),placeholder:"External URL",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:he,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),ue.createElement("button",{onClick:()=>ce("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"),ue.createElement("button",{onClick:()=>ce("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"),ue.createElement("button",{onClick:()=>ce("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")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.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)")),ae&&ue.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"},ue.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ae,ue.createElement("button",{onClick:()=>B(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}Pe(FH,"WidgetControls");function BH(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Pe(BH,"getBasename");var Mie=150,Pie=5;function Uie({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=BH(),i=x.useRef(null),s=x.useRef(0),c=x.useRef(null),u=x.useRef(!1),[d,m]=x.useState(null),[h,g]=x.useState(null),[v,w]=x.useState(!0);x.useEffect(()=>{let E=!0;return(async()=>{try{const k=await Qn(()=>import("./index-Dq07y2HU.js"),[]);E&&(m(()=>k.BrowserRouter),w(!1))}catch{E&&(g(new Error(`❌ react-router-dom not installed!
|
|
35
|
+
`&&a++}}return[t,n]}class hie extends TransformStream{constructor({onError:t,onRetry:n,onComment:a}={}){let r;super({start(i){r=MH({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 gie={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class yl extends Error{constructor(t,n){super(`Streamable HTTP error: ${n}`),this.code=t}}class bie{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=EH(n?.fetch,n?.requestInit),this._sessionId=n?.sessionId,this._reconnectionOptions=(a=n?.reconnectionOptions)!==null&&a!==void 0?a:gie}async _authThenStart(){var t;if(!this._authProvider)throw new Ya("No auth provider");let n;try{n=await ko(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 Ya;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=Kb((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 yl(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 w=t.pipeThrough(new TextDecoderStream).pipeThrough(new hie({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:E}=await w.read();if(E)break;if(_.id&&(s=_.id,c=!0,r?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const k=cb.parse(JSON.parse(_.data));zf(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(w){if((g=this.onerror)===null||g===void 0||g.call(this,new Error(`SSE stream disconnected: ${w}`)),(a||c)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:i},0)}catch(_){(v=this.onerror)===null||v===void 0||v.call(this,new Error(`Failed to reconnect: ${_ instanceof Error?_.message:String(_)}`))}}})()}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 Ya("No auth provider");if(await ko(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya("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,d;try{const{resumptionToken:m,onresumptiontoken:h}=n||{};if(m){this._startOrAuthSse({resumptionToken:m,replayMessageId:KS(t)?t.id:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.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},w=await((r=this._fetch)!==null&&r!==void 0?r:fetch)(this._url,v),S=w.headers.get("mcp-session-id");if(S&&(this._sessionId=S),!w.ok){const k=await w.text().catch(()=>null);if(w.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new yl(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:C,scope:R}=xp(w);if(this._resourceMetadataUrl=C,this._scope=R,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya;return this._hasCompletedAuthFlow=!0,this.send(t)}if(w.status===403&&this._authProvider){const{resourceMetadataUrl:C,scope:R,error:I}=xp(w);if(I==="insufficient_scope"){const A=w.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===A)throw new yl(403,"Server returned 403 after trying upscoping");if(R&&(this._scope=R),C&&(this._resourceMetadataUrl=C),this._lastUpscopingHeader=A??void 0,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Ya;return this.send(t)}}throw new yl(w.status,`Error POSTing to endpoint: ${k}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,w.status===202){await((i=w.body)===null||i===void 0?void 0:i.cancel()),lne(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(k=>{var C;return(C=this.onerror)===null||C===void 0?void 0:C.call(this,k)});return}const _=(Array.isArray(t)?t:[t]).filter(k=>"method"in k&&"id"in k&&k.id!==void 0).length>0,E=w.headers.get("content-type");if(_)if(E?.includes("text/event-stream"))this._handleSseStream(w.body,{onresumptiontoken:h},!1);else if(E?.includes("application/json")){const k=await w.json(),C=Array.isArray(k)?k.map(R=>cb.parse(R)):[cb.parse(k)];for(const R of C)(s=this.onmessage)===null||s===void 0||s.call(this,R)}else throw await((c=w.body)===null||c===void 0?void 0:c.cancel()),new yl(-1,`Unexpected content type: ${E}`);else await((u=w.body)===null||u===void 0?void 0:u.cancel())}catch(m){throw(d=this.onerror)===null||d===void 0||d.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 yl(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 OP 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(DP(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(DP(this),n)}}function vie(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function oE(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(oE).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${oE(e.cause)}`:e.message:`${e}`}function DP(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var PH=e=>{throw TypeError(e)},qT=(e,t,n)=>t.has(e)||PH("Cannot "+n),Bt=(e,t,n)=>(qT(e,t,"read from private field"),n?n.call(e):t.get(e)),ur=(e,t,n)=>t.has(e)?PH("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),$n=(e,t,n,a)=>(qT(e,t,"write to private field"),t.set(e,n),n),wo=(e,t,n)=>(qT(e,t,"access private method"),n),ma,xl,Wc,db,Jb,Jf,ru,Qf,Ts,Kc,mu,Zc,Ff,ci,sE,lE,cE,jP,uE,dE,Bf,fE,pE;class fb extends EventTarget{constructor(t,n){var a,r;super(),ur(this,ci),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,ur(this,ma),ur(this,xl),ur(this,Wc),ur(this,db),ur(this,Jb),ur(this,Jf),ur(this,ru),ur(this,Qf,null),ur(this,Ts),ur(this,Kc),ur(this,mu,null),ur(this,Zc,null),ur(this,Ff,null),ur(this,lE,async i=>{var s;Bt(this,Kc).reset();const{body:c,redirected:u,status:d,headers:m}=i;if(d===204){wo(this,ci,Bf).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(u?$n(this,Wc,new URL(i.url)):$n(this,Wc,void 0),d!==200){wo(this,ci,Bf).call(this,`Non-200 status code (${d})`,d);return}if(!(m.get("content-type")||"").startsWith("text/event-stream")){wo(this,ci,Bf).call(this,'Invalid content type, expected "text/event-stream"',d);return}if(Bt(this,ma)===this.CLOSED)return;$n(this,ma,this.OPEN);const h=new Event("open");if((s=Bt(this,Ff))==null||s.call(this,h),this.dispatchEvent(h),typeof c!="object"||!c||!("getReader"in c)){wo(this,ci,Bf).call(this,"Invalid response body, expected a web ReadableStream",d),this.close();return}const g=new TextDecoder,v=c.getReader();let w=!0;do{const{done:S,value:y}=await v.read();y&&Bt(this,Kc).feed(g.decode(y,{stream:!S})),S&&(w=!1,Bt(this,Kc).reset(),wo(this,ci,fE).call(this))}while(w)}),ur(this,cE,i=>{$n(this,Ts,void 0),!(i.name==="AbortError"||i.type==="aborted")&&wo(this,ci,fE).call(this,oE(i))}),ur(this,uE,i=>{typeof i.id=="string"&&$n(this,Qf,i.id);const s=new MessageEvent(i.event||"message",{data:i.data,origin:Bt(this,Wc)?Bt(this,Wc).origin:Bt(this,xl).origin,lastEventId:i.id||""});Bt(this,Zc)&&(!i.event||i.event==="message")&&Bt(this,Zc).call(this,s),this.dispatchEvent(s)}),ur(this,dE,i=>{$n(this,Jf,i)}),ur(this,pE,()=>{$n(this,ru,void 0),Bt(this,ma)===this.CONNECTING&&wo(this,ci,sE).call(this)});try{if(t instanceof URL)$n(this,xl,t);else if(typeof t=="string")$n(this,xl,new URL(t,yie()));else throw new Error("Invalid URL")}catch{throw vie("An invalid or illegal string was specified")}$n(this,Kc,MH({onEvent:Bt(this,uE),onRetry:Bt(this,dE)})),$n(this,ma,this.CONNECTING),$n(this,Jf,3e3),$n(this,Jb,(a=n?.fetch)!=null?a:globalThis.fetch),$n(this,db,(r=n?.withCredentials)!=null?r:!1),wo(this,ci,sE).call(this)}get readyState(){return Bt(this,ma)}get url(){return Bt(this,xl).href}get withCredentials(){return Bt(this,db)}get onerror(){return Bt(this,mu)}set onerror(t){$n(this,mu,t)}get onmessage(){return Bt(this,Zc)}set onmessage(t){$n(this,Zc,t)}get onopen(){return Bt(this,Ff)}set onopen(t){$n(this,Ff,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(){Bt(this,ru)&&clearTimeout(Bt(this,ru)),Bt(this,ma)!==this.CLOSED&&(Bt(this,Ts)&&Bt(this,Ts).abort(),$n(this,ma,this.CLOSED),$n(this,Ts,void 0))}}ma=new WeakMap,xl=new WeakMap,Wc=new WeakMap,db=new WeakMap,Jb=new WeakMap,Jf=new WeakMap,ru=new WeakMap,Qf=new WeakMap,Ts=new WeakMap,Kc=new WeakMap,mu=new WeakMap,Zc=new WeakMap,Ff=new WeakMap,ci=new WeakSet,sE=function(){$n(this,ma,this.CONNECTING),$n(this,Ts,new AbortController),Bt(this,Jb)(Bt(this,xl),wo(this,ci,jP).call(this)).then(Bt(this,lE)).catch(Bt(this,cE))},lE=new WeakMap,cE=new WeakMap,jP=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Bt(this,Qf)?{"Last-Event-ID":Bt(this,Qf)}:void 0},cache:"no-store",signal:(e=Bt(this,Ts))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},uE=new WeakMap,dE=new WeakMap,Bf=function(e,t){var n;Bt(this,ma)!==this.CLOSED&&$n(this,ma,this.CLOSED);const a=new OP("error",{code:t,message:e});(n=Bt(this,mu))==null||n.call(this,a),this.dispatchEvent(a)},fE=function(e,t){var n;if(Bt(this,ma)===this.CLOSED)return;$n(this,ma,this.CONNECTING);const a=new OP("error",{code:t,message:e});(n=Bt(this,mu))==null||n.call(this,a),this.dispatchEvent(a),$n(this,ru,setTimeout(Bt(this,pE),Bt(this,Jf)))},pE=new WeakMap,fb.CONNECTING=0,fb.OPEN=1,fb.CLOSED=2;function yie(){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 wie extends Error{constructor(t,n,a){super(`SSE error: ${n}`),this.code=t,this.event=a}}class xie{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=EH(n?.fetch,n?.requestInit)}async _authThenStart(){var t;if(!this._authProvider)throw new Ya("No auth provider");let n;try{n=await ko(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 Ya;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=Kb((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 fb(this._url.href,{...this._eventSourceInit,fetch:async(c,u)=>{const d=await this._commonHeaders();d.set("Accept","text/event-stream");const m=await r(c,{...u,headers:d});if(m.status===401&&m.headers.has("www-authenticate")){const{resourceMetadataUrl:h,scope:g}=xp(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 d=new wie(c.code,c.message,c);s(d),(u=this.onerror)===null||u===void 0||u.call(this,d)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",c=>{var u;const d=c;try{if(this._endpoint=new URL(d.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,d;const m=c;let h;try{h=cb.parse(JSON.parse(m.data))}catch(g){(u=this.onerror)===null||u===void 0||u.call(this,g);return}(d=this.onmessage)===null||d===void 0||d.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 Ya("No auth provider");if(await ko(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya("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 d=await u.text().catch(()=>null);if(u.status===401&&this._authProvider){const{resourceMetadataUrl:m,scope:h}=xp(u);if(this._resourceMetadataUrl=m,this._scope=h,await ko(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Ya;return this.send(t)}throw new Error(`Error POSTing to endpoint (HTTP ${u.status}): ${d}`)}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 Lx,LP;function Sie(){return LP||(LP=1,Lx=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}),Lx}var Eie=Sie();const $P=Wp(Eie);var Pu,_ie=(Pu=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}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)}},Pe(Pu,"MCPSession"),Pu),Uu,UH=(Uu=class{_readyPromise;_readyResolver;_donePromise;_doneResolver;_exception=null;_connection=null;_task=null;_abortController=null;constructor(){this.reset()}async start(){if(this.reset(),we.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){we.debug(`Cancelling ${this.constructor.name} task`),this._abortController.abort();try{await this._task}catch(t){t instanceof Error&&t.name==="AbortError"?we.debug(`${this.constructor.name} task aborted successfully`):we.warn(`Error stopping ${this.constructor.name} task: ${t}`)}}await this._donePromise,we.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(){we.debug(`Running ${this.constructor.name} task`);try{this._connection=await this.establishConnection(),we.debug(`${this.constructor.name} connected successfully`),this._readyResolver(),await this.waitForAbort()}catch(t){this._exception=t,we.error(`Error in ${this.constructor.name} task: ${t}`),this._readyResolver()}finally{if(this._connection!==null){try{await this.closeConnection(this._connection)}catch(t){we.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=Pe(()=>{a.removeEventListener("abort",r),t()},"onAbort");a.addEventListener("abort",r)})}},Pe(Uu,"ConnectionManager"),Uu),zu,kie=(zu=class extends UH{url;opts;_transport=null;constructor(t,n){super(),this.url=typeof t=="string"?new URL(t):t,this.opts=n}async establishConnection(){return this._transport=new xie(this.url,this.opts),we.debug(`${this.constructor.name} connected successfully`),this._transport}async closeConnection(t){if(this._transport)try{await this._transport.close()}catch(n){we.warn(`Error closing SSE transport: ${n}`)}finally{this._transport=null}}},Pe(zu,"SseConnectionManager"),zu),Fu,MP=(Fu=class extends pH{baseUrl;headers;timeout;sseReadTimeout;clientInfo;preferSse;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.timeout=n.timeout??3e4,this.sseReadTimeout=n.sseReadTimeout??3e5,this.clientInfo=n.clientInfo??{name:"http-connector",version:"1.0.0"},this.preferSse=n.preferSse??!1}async connect(){if(this.connected){we.debug("Already connected to MCP implementation");return}const t=this.baseUrl;if(this.preferSse){we.debug(`Connecting to MCP implementation via HTTP/SSE: ${t}`),await this.connectWithSse(t);return}we.debug(`Connecting to MCP implementation via HTTP: ${t}`);try{we.info("🔄 Attempting streamable HTTP transport..."),await this.connectWithStreamableHttp(t),we.info("✅ Successfully connected via streamable HTTP")}catch(n){let a="Unknown error",r=!1;if(n instanceof yl){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",we.warn(`⚠️ ${a}`)):i.code===404||i.code===405?(a=`Server returned ${i.code} - server likely doesn't support streamable HTTP`,we.debug(a)):(a=`Server returned ${i.code}: ${i.message}`,we.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",we.warn(`⚠️ ${a}`)):i.includes("405 Method Not Allowed")||i.includes("404 Not Found")?(a="Server doesn't support streamable HTTP (405/404)",we.debug(a)):(a=`Streamable HTTP failed: ${n.message}`,we.debug(a))}if(r){we.info("Authentication required - skipping SSE fallback"),await this.cleanupResources();const i=new Error("Authentication required");throw i.code=401,i}we.info("🔄 Falling back to SSE transport...");try{await this.connectWithSse(t)}catch(i){if(we.error("Failed to connect with both transports:"),we.error(` Streamable HTTP: ${a}`),we.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 bie(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:{}}}:{}}};we.debug("Creating Client with capabilities:",JSON.stringify(r.capabilities,null,2)),this.client=new NP(this.clientInfo,r),this.setupRootsHandler(),we.debug("Roots handler registered before connect");try{await this.client.connect(a,{timeout:Math.min(this.timeout,3e3)});const i=n.sessionId;i?we.debug(`Session ID obtained: ${i}`):we.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:Pe(async()=>{if(this.streamableTransport)try{await this.streamableTransport.terminateSession(),await this.streamableTransport.close()}catch(i){we.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(),we.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 kie(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:{}}}:{}}};we.debug("Creating Client with capabilities (SSE):",JSON.stringify(a.capabilities,null,2)),this.client=new NP(this.clientInfo,a),this.setupRootsHandler(),we.debug("Roots handler registered before connect (SSE)"),await this.client.connect(n),this.connected=!0,this.transportType="sse",this.setupNotificationHandler(),this.setupSamplingHandler(),this.setupElicitationHandler(),we.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}},Pe(Fu,"HttpConnector"),Fu),Bu,Tie=(Bu=class extends UH{url;headers;_ws=null;constructor(t,n={}){super(),this.url=t,this.headers=n}async establishConnection(){return we.debug(`Connecting to WebSocket: ${this.url}`),new Promise((t,n)=>{const a=new $P(this.url,{headers:this.headers});this._ws=a;const r=Pe(()=>{s(),we.debug("WebSocket connected successfully"),t(a)},"onOpen"),i=Pe(c=>{s(),we.error(`Failed to connect to WebSocket: ${c}`),n(c)},"onError"),s=Pe(()=>{a.off("open",r),a.off("error",i)},"cleanup");a.on("open",r),a.on("error",i)})}async closeConnection(t){return we.debug("Closing WebSocket connection"),new Promise(n=>{const a=Pe(()=>{t.off("close",a),this._ws=null,n()},"onClose");if(t.readyState===$P.CLOSED){a();return}t.on("close",a);try{t.close()}catch(r){we.warn(`Error closing WebSocket connection: ${r}`),a()}})}},Pe(Bu,"WebSocketConnectionManager"),Bu),Hu,Nie=(Hu=class extends pH{url;headers;connectionManager=null;ws=null;receiverTask=null;pending=new Map;toolsCache=null;constructor(t,n={}){super(),this.url=t,this.headers={...n.headers??{}},n.authToken&&(this.headers.Authorization=`Bearer ${n.authToken}`)}async connect(){if(this.connected){we.debug("Already connected to MCP implementation");return}we.debug(`Connecting via WebSocket: ${this.url}`);try{this.connectionManager=new Tie(this.url,this.headers),this.ws=await this.connectionManager.start(),this.receiverTask=this.receiveLoop(),this.connected=!0,we.debug("WebSocket connected successfully")}catch(t){throw we.error(`Failed to connect: ${t}`),await this.cleanupResources(),t}}async disconnect(){if(!this.connected){we.debug("Not connected to MCP implementation");return}we.debug("Disconnecting …"),await this.cleanupResources(),this.connected=!1}sendRequest(t,n=null){if(!this.ws)throw new Error("WebSocket is not connected");const a=tu(),r=JSON.stringify({id:a,method:t,params:n??{}});return new Promise((i,s)=>{this.pending.set(a,{resolve:i,reject:s}),this.ws.send(r,c=>{c&&(this.pending.delete(a),s(c))})})}async receiveLoop(){if(!this.ws)return;const t=this.ws,n=Pe(a=>{let r;try{r=JSON.parse(a.data??a)}catch(s){we.warn("Received non‑JSON frame",s);return}const i=r.id;if(i&&this.pending.has(i)){const{resolve:s,reject:c}=this.pending.get(i);this.pending.delete(i),"result"in r?s(r.result):"error"in r&&c(r.error)}else r.method&&!r.id?(we.debug("Received notification",r.method,r.params),this.handleNotification(r)):we.debug("Received unsolicited message",r)},"onMessage");return t.addEventListener?t.addEventListener("message",n):t.on("message",n),new Promise(a=>{const r=Pe(()=>{t.removeEventListener?t.removeEventListener("message",n):t.off("message",n),this.rejectAll(new Error("WebSocket closed")),a()},"onClose");t.addEventListener?t.addEventListener("close",r):t.on("close",r)})}rejectAll(t){for(const{reject:n}of this.pending.values())n(t);this.pending.clear()}async handleNotification(t){switch(t.method){case"notifications/tools/list_changed":await this.refreshToolsCache();break;case"notifications/resources/list_changed":await this.onResourcesListChanged();break;case"notifications/prompts/list_changed":await this.onPromptsListChanged();break}for(const n of this.notificationHandlers)try{await n({method:t.method,params:t.params})}catch(a){we.error("Error in notification handler:",a)}}async refreshToolsCache(){try{we.debug("[Auto] Refreshing tools cache due to list_changed notification");const t=await this.listTools();this.toolsCache=t.map(n=>n),we.debug(`[Auto] Refreshed tools cache: ${this.toolsCache.length} tools`)}catch(t){we.warn("[Auto] Failed to refresh tools cache:",t)}}async initialize(){we.debug("Initializing MCP session over WebSocket");const t=await this.sendRequest("initialize"),n=await this.listTools();return this.toolsCache=n.map(a=>a),we.debug(`Initialized with ${this.toolsCache.length} tools`),t}async listTools(){return(await this.sendRequest("tools/list")).tools??[]}async callTool(t,n){return await this.sendRequest("tools/call",{name:t,arguments:n})}async listResources(){const t=await this.sendRequest("resources/list");return{resources:Array.isArray(t)?t:[]}}async readResource(t){return await this.sendRequest("resources/read",{uri:t})}async request(t,n=null){return await this.sendRequest(t,n)}get tools(){if(!this.toolsCache)throw new Error("MCP client is not initialized");return this.toolsCache}async cleanupResources(){this.receiverTask&&await this.receiverTask.catch(()=>{}),this.receiverTask=null,this.rejectAll(new Error("WebSocket disconnected")),this.connectionManager&&(await this.connectionManager.stop(),this.connectionManager=null,this.ws=null),this.toolsCache=null}get publicIdentifier(){return{type:"websocket",url:this.url}}},Pe(Hu,"WebSocketConnector"),Hu),Vu,Cie=(Vu=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,Mi.getInstance().trackClientAddServer(t,n)}removeServer(t){this.config.mcpServers?.[t]&&(delete this.config.mcpServers[t],this.activeSessions=this.activeSessions.filter(n=>n!==t),Mi.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&&we.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 _ie(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&&we.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}getAllActiveSessions(){return Object.fromEntries(this.activeSessions.map(t=>[t,this.sessions[t]]))}async closeSession(t){const n=this.sessions[t];if(!n){we.warn(`No session exists for server ${t}, nothing to close`);return}try{we.debug(`Closing session for server ${t}`),await n.disconnect()}catch(a){we.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{we.debug(`Closing session for server ${a}`),await this.closeSession(a)}catch(r){const i=`Failed to close session for server '${a}': ${r}`;we.error(i),n.push(i)}n.length?we.error(`Encountered ${n.length} errors while closing sessions`):we.debug("All sessions closed successfully")}},Pe(Vu,"BaseMCPClient"),Vu),Dl,Rie=(Dl=class extends Cie{static getPackageVersion(){return Db()}constructor(t){super(t),this._trackClientInit()}_trackClientInit(){const t=Object.keys(this.config.mcpServers??{});Mi.getInstance().trackMCPClientInit({codeMode:!1,sandbox:!1,allCallbacks:!1,verify:!1,servers:t,numServers:t.length,isBrowser:!0}).catch(n=>we.debug(`Failed to track BrowserMCPClient init: ${n}`))}static fromDict(t){return new Dl(t)}createConnectorFromConfig(t){const{url:n,transport:a,headers:r,authToken:i,authProvider:s,wrapTransport:c,clientOptions:u,samplingCallback:d,elicitationCallback:m}=t;if(!n)throw new Error("Server URL is required");const h={headers:r,authToken:i,authProvider:s,wrapTransport:c,clientOptions:u,samplingCallback:d,elicitationCallback:m};return u?console.log("[BrowserMCPClient] Passing clientOptions to connector:",JSON.stringify(u,null,2)):console.warn("[BrowserMCPClient] No clientOptions provided to connector!"),a==="websocket"||n.startsWith("ws://")||n.startsWith("wss://")?new Nie(n,h):a==="http"||n.startsWith("http://")||n.startsWith("https://")?new MP(n,h):new MP(n,h)}},Pe(Dl,"BrowserMCPClient"),Dl);function au(e){const t=Pe(()=>{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(zH).join("&"),n.hash=n.hash.slice(0,1)+encodeURIComponent(n.hash.slice(1)),n.href}Pe(au,"sanitizeUrl");function zH([e,t]){return`${encodeURIComponent(e)}${t.length>0?`=${encodeURIComponent(t)}`:""}`}Pe(zH,"sanitizeParam");var Gu,pb=(Gu=class{serverUrl;storageKeyPrefix;serverUrlHash;clientName;clientUri;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.callbackUrl=au(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 au(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}}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=au(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?au(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}`}},Pe(Gu,"BrowserOAuthClientProvider"),Gu);async function XT(){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 d=localStorage.getItem(u);if(!d)throw new Error(`Invalid or expired state parameter "${n}". No matching state found in storage.`);try{c=JSON.parse(d)}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 pb(m,h),console.log(`${i} Calling SDK auth() to exchange code...`);const g=new URL(m).origin,v=await ko(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 S=window.location.pathname.split("/").filter(Boolean),y=S.length>0&&S[S.length-1]==="callback"?"/"+S.slice(0,-2).join("/"):"/";window.location.href=y||"/"}else throw console.warn(`${i} SDK auth() returned unexpected status: ${v}`),new Error(`Unexpected result from authentication library: ${v}`)}catch(d){console.error(`${i} Error during OAuth callback handling:`,d);const m=d instanceof Error?d.message:String(d);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 w=document.createElement("p");w.textContent="You can close this window or ";const S=document.createElement("a");if(S.href="#",S.textContent="click here to close",S.onclick=y=>(y.preventDefault(),window.close(),!1),w.appendChild(S),w.appendChild(document.createTextNode(".")),h.appendChild(w),d instanceof Error&&d.stack){const y=document.createElement("pre");y.style.fontSize="0.8em",y.style.color="#555",y.style.marginTop="20px",y.style.whiteSpace="pre-wrap",y.textContent=d.stack,h.appendChild(y)}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")))}}Pe(XT,"onMcpAuthorization");var $x={exports:{}},gt={};var PP;function Aie(){if(PP)return gt;PP=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"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),h=Symbol.for("react.activity"),g=Symbol.iterator;function v(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,y={};function _(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||w}_.prototype.isReactComponent={},_.prototype.setState=function(j,V){if(typeof j!="object"&&typeof j!="function"&&j!=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,j,V,"setState")},_.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function E(){}E.prototype=_.prototype;function k(j,V,z){this.props=j,this.context=V,this.refs=y,this.updater=z||w}var C=k.prototype=new E;C.constructor=k,S(C,_.prototype),C.isPureReactComponent=!0;var R=Array.isArray;function I(){}var A={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function M(j,V,z){var L=z.ref;return{$$typeof:e,type:j,key:V,ref:L!==void 0?L:null,props:z}}function U(j,V){return M(j.type,V,j.props)}function H(j){return typeof j=="object"&&j!==null&&j.$$typeof===e}function K(j){var V={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(z){return V[z]})}var Q=/\/+/g;function te(j,V){return typeof j=="object"&&j!==null&&j.key!=null?K(""+j.key):V.toString(36)}function ae(j){switch(j.status){case"fulfilled":return j.value;case"rejected":throw j.reason;default:switch(typeof j.status=="string"?j.then(I,I):(j.status="pending",j.then(function(V){j.status==="pending"&&(j.status="fulfilled",j.value=V)},function(V){j.status==="pending"&&(j.status="rejected",j.reason=V)})),j.status){case"fulfilled":return j.value;case"rejected":throw j.reason}}throw j}function B(j,V,z,L,$){var F=typeof j;(F==="undefined"||F==="boolean")&&(j=null);var W=!1;if(j===null)W=!0;else switch(F){case"bigint":case"string":case"number":W=!0;break;case"object":switch(j.$$typeof){case e:case t:W=!0;break;case m:return W=j._init,B(W(j._payload),V,z,L,$)}}if(W)return $=$(j),W=L===""?"."+te(j,0):L,R($)?(z="",W!=null&&(z=W.replace(Q,"$&/")+"/"),B($,V,z,"",function(le){return le})):$!=null&&(H($)&&($=U($,z+($.key==null||j&&j.key===$.key?"":(""+$.key).replace(Q,"$&/")+"/")+W)),V.push($)),1;W=0;var X=L===""?".":L+":";if(R(j))for(var ie=0;ie<j.length;ie++)L=j[ie],F=X+te(L,ie),W+=B(L,V,z,F,$);else if(ie=v(j),typeof ie=="function")for(j=ie.call(j),ie=0;!(L=j.next()).done;)L=L.value,F=X+te(L,ie++),W+=B(L,V,z,F,$);else if(F==="object"){if(typeof j.then=="function")return B(ae(j),V,z,L,$);throw V=String(j),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return W}function Z(j,V,z){if(j==null)return j;var L=[],$=0;return B(j,L,"","",function(F){return V.call(z,F,$++)}),L}function G(j){if(j._status===-1){var V=j._result;V=V(),V.then(function(z){(j._status===0||j._status===-1)&&(j._status=1,j._result=z)},function(z){(j._status===0||j._status===-1)&&(j._status=2,j._result=z)}),j._status===-1&&(j._status=0,j._result=V)}if(j._status===1)return j._result.default;throw j._result}var re=typeof reportError=="function"?reportError:function(j){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof j=="object"&&j!==null&&typeof j.message=="string"?String(j.message):String(j),error:j});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",j);return}console.error(j)},ne={map:Z,forEach:function(j,V,z){Z(j,function(){V.apply(this,arguments)},z)},count:function(j){var V=0;return Z(j,function(){V++}),V},toArray:function(j){return Z(j,function(V){return V})||[]},only:function(j){if(!H(j))throw Error("React.Children.only expected to receive a single React element child.");return j}};return gt.Activity=h,gt.Children=ne,gt.Component=_,gt.Fragment=n,gt.Profiler=r,gt.PureComponent=k,gt.StrictMode=a,gt.Suspense=u,gt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=A,gt.__COMPILER_RUNTIME={__proto__:null,c:function(j){return A.H.useMemoCache(j)}},gt.cache=function(j){return function(){return j.apply(null,arguments)}},gt.cacheSignal=function(){return null},gt.cloneElement=function(j,V,z){if(j==null)throw Error("The argument must be a React element, but you passed "+j+".");var L=S({},j.props),$=j.key;if(V!=null)for(F in V.key!==void 0&&($=""+V.key),V)!O.call(V,F)||F==="key"||F==="__self"||F==="__source"||F==="ref"&&V.ref===void 0||(L[F]=V[F]);var F=arguments.length-2;if(F===1)L.children=z;else if(1<F){for(var W=Array(F),X=0;X<F;X++)W[X]=arguments[X+2];L.children=W}return M(j.type,$,L)},gt.createContext=function(j){return j={$$typeof:s,_currentValue:j,_currentValue2:j,_threadCount:0,Provider:null,Consumer:null},j.Provider=j,j.Consumer={$$typeof:i,_context:j},j},gt.createElement=function(j,V,z){var L,$={},F=null;if(V!=null)for(L in V.key!==void 0&&(F=""+V.key),V)O.call(V,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&($[L]=V[L]);var W=arguments.length-2;if(W===1)$.children=z;else if(1<W){for(var X=Array(W),ie=0;ie<W;ie++)X[ie]=arguments[ie+2];$.children=X}if(j&&j.defaultProps)for(L in W=j.defaultProps,W)$[L]===void 0&&($[L]=W[L]);return M(j,F,$)},gt.createRef=function(){return{current:null}},gt.forwardRef=function(j){return{$$typeof:c,render:j}},gt.isValidElement=H,gt.lazy=function(j){return{$$typeof:m,_payload:{_status:-1,_result:j},_init:G}},gt.memo=function(j,V){return{$$typeof:d,type:j,compare:V===void 0?null:V}},gt.startTransition=function(j){var V=A.T,z={};A.T=z;try{var L=j(),$=A.S;$!==null&&$(z,L),typeof L=="object"&&L!==null&&typeof L.then=="function"&&L.then(I,re)}catch(F){re(F)}finally{V!==null&&z.types!==null&&(V.types=z.types),A.T=V}},gt.unstable_useCacheRefresh=function(){return A.H.useCacheRefresh()},gt.use=function(j){return A.H.use(j)},gt.useActionState=function(j,V,z){return A.H.useActionState(j,V,z)},gt.useCallback=function(j,V){return A.H.useCallback(j,V)},gt.useContext=function(j){return A.H.useContext(j)},gt.useDebugValue=function(){},gt.useDeferredValue=function(j,V){return A.H.useDeferredValue(j,V)},gt.useEffect=function(j,V){return A.H.useEffect(j,V)},gt.useEffectEvent=function(j){return A.H.useEffectEvent(j)},gt.useId=function(){return A.H.useId()},gt.useImperativeHandle=function(j,V,z){return A.H.useImperativeHandle(j,V,z)},gt.useInsertionEffect=function(j,V){return A.H.useInsertionEffect(j,V)},gt.useLayoutEffect=function(j,V){return A.H.useLayoutEffect(j,V)},gt.useMemo=function(j,V){return A.H.useMemo(j,V)},gt.useOptimistic=function(j,V){return A.H.useOptimistic(j,V)},gt.useReducer=function(j,V,z){return A.H.useReducer(j,V,z)},gt.useRef=function(j){return A.H.useRef(j)},gt.useState=function(j){return A.H.useState(j)},gt.useSyncExternalStore=function(j,V,z){return A.H.useSyncExternalStore(j,V,z)},gt.useTransition=function(){return A.H.useTransition()},gt.version="19.2.0",gt}var UP;function JT(){return UP||(UP=1,$x.exports=Aie()),$x.exports}var x=JT();const ue=Wp(x),pd=Wq({__proto__:null,default:ue},[x]);function mE(e,t){if(!e)throw new Error(t)}Pe(mE,"assert");var Iie=3e3,Oie=5e3;function QT(e){const{url:t,enabled:n=!0,clientName:a,clientUri:r,callbackUrl:i=typeof window<"u"?au(new URL("/oauth/callback",window.location.origin).toString()):"/oauth/callback",storageKeyPrefix:s="mcp:auth",clientConfig:c={},customHeaders:u={},debug:d=!1,autoRetry:m=!1,autoReconnect:h=Iie,transportType:g="auto",preventAutoAuth:v=!1,useRedirectFlow:w=!1,onPopupWindow:S,timeout:y=3e4,sseReadTimeout:_=3e5,wrapTransport:E,onNotification:k,samplingCallback:C,onElicitation:R}=e,[I,A]=x.useState("discovering"),[O,M]=x.useState([]),[U,H]=x.useState([]),[K,Q]=x.useState([]),[te,ae]=x.useState([]),[B,Z]=x.useState(),[G,re]=x.useState(),[ne,j]=x.useState(void 0),[V,z]=x.useState([]),[L,$]=x.useState(void 0),F=x.useRef(null),W=x.useRef(null),X=x.useRef(!1),ie=x.useRef(!0),le=x.useRef(0),J=x.useRef(null),q=x.useRef(I),se=x.useRef(h),he=x.useRef(null);x.useEffect(()=>{q.current=I,se.current=h},[I,h]);const ce=x.useCallback((je,Fe,...pt)=>{const Qe=pt.length>0?`${Fe} ${pt.map(Tt=>JSON.stringify(Tt)).join(" ")}`:Fe;console[je](`[useMcp] ${Qe}`),ie.current&&z(Tt=>[...Tt.slice(-100),{level:je,message:Qe,timestamp:Date.now()}])},[]),Te=x.useCallback(async(je=!1)=>{if(je||ce("info","Disconnecting..."),X.current=!1,J.current&&clearTimeout(J.current),J.current=null,F.current)try{await F.current.closeSession("inspector-server")}catch(Fe){je||ce("warn","Error closing session:",Fe)}F.current=null,ie.current&&!je&&(A("discovering"),M([]),H([]),Q([]),ae([]),j(void 0),$(void 0))},[ce]),He=x.useCallback((je,Fe)=>{if(ce("error",je,Fe??""),ie.current){A("failed"),j(je);const pt=W.current?.getLastAttemptedAuthUrl();pt&&($(pt),ce("info","Manual authentication URL may be available.",pt))}X.current=!1,t&&Mi.getInstance().trackUseMcpConnection({url:t,transportType:g,success:!1,errorType:Fe?.name||"UnknownError",hasOAuth:!!W.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{})},[ce,t,g,C,R]),Ee=x.useCallback(async()=>{if(!n||!t){ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag.");return}if(X.current){ce("debug","Connection attempt already in progress.");return}if(!ie.current){ce("debug","Connect called after unmount, aborting.");return}X.current=!0,le.current+=1,j(void 0),$(void 0),he.current=null,A("discovering"),ce("info",`Connecting attempt #${le.current} to ${t}...`),W.current||(W.current=new pb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ce("debug","BrowserOAuthClientProvider initialized in connect.")),F.current||(F.current=new Rie,ce("debug","BrowserMCPClient initialized in connect."));const je=Pe(async(pt,Qe=!1)=>{ce("info",`Attempting connection with transport: ${pt}`);try{const Tt="inspector-server",nt={url:t,transport:pt==="sse"?"http":pt};if(u&&Object.keys(u).length>0&&(nt.headers=u),W.current){const wt=await W.current.tokens();wt?.access_token&&(nt.headers={...nt.headers,Authorization:`Bearer ${wt.access_token}`})}F.current.addServer(Tt,{...nt,authProvider:W.current,clientOptions:c,samplingCallback:C,elicitationCallback:R,wrapTransport:E?wt=>(console.log("[useMcp] Applying transport wrapper for server:",Tt,"url:",t),E(wt,t)):void 0});const Ie=await F.current.createSession(Tt,!1);k&&Ie.on("notification",k),await Ie.initialize(),ce("info","✅ Successfully connected to MCP server"),ce("info","Server info:",Ie.connector.serverInfo),ce("info","Server capabilities:",Ie.connector.serverCapabilities),console.log("[useMcp] Server info:",Ie.connector.serverInfo),console.log("[useMcp] Server capabilities:",Ie.connector.serverCapabilities),A("ready"),he.current=pt,Mi.getInstance().trackUseMcpConnection({url:t,transportType:pt,success:!0,hasOAuth:!!W.current,hasSampling:!!C,hasElicitation:!!R}).catch(()=>{}),M(Ie.connector.tools||[]);const $e=await Ie.connector.listAllResources();H($e.resources||[]);const Ve=await Ie.connector.listPrompts();ae(Ve.prompts||[]);const at=Ie.connector.serverInfo,dt=Ie.connector.serverCapabilities;return at&&(console.log("[useMcp] Server info:",at),Z(at)),dt&&(console.log("[useMcp] Server capabilities:",dt),re(dt)),"success"}catch(Tt){const nt=Tt,Ie=nt?.message||String(Tt);if(nt.code===401||Ie.includes("401")||Ie.includes("Unauthorized")){if(W.current){ce("info","Authentication required. OAuth provider available.");try{const{auth:$e}=await Qn(async()=>{const{auth:at}=await Promise.resolve().then(()=>AP);return{auth:at}},void 0),Ve=new URL(t).origin;$e(W.current,{serverUrl:Ve}).catch(()=>{}),setTimeout(()=>{if(ie.current){const at=W.current?.getLastAttemptedAuthUrl();at?($(at),ce("info","Manual authentication URL available:",at)):ce("warn","Could not generate authentication URL")}},100)}catch($e){ce("warn","Error generating auth URL:",$e)}return ie.current&&A("pending_auth"),X.current=!1,"auth_redirect"}return u&&Object.keys(u).length>0?(He("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."),"failed"):(He("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."),"failed")}return He(Ie,nt instanceof Error?nt:new Error(String(nt))),"failed"}},"tryConnectWithTransport");let Fe="failed";if(g==="sse")ce("debug","Using SSE-only transport mode"),Fe=await je("sse");else if(g==="http")ce("debug","Using HTTP-only transport mode"),Fe=await je("http");else{ce("debug","Using auto transport mode (HTTP with SSE fallback)");const pt=await je("http");pt==="fallback"&&ie.current&&q.current!=="authenticating"?(ce("info","HTTP failed, attempting SSE fallback..."),Fe=await je("sse")):Fe=pt}(Fe==="success"||Fe==="failed"||Fe==="auth_redirect")&&(X.current=!1),ce("debug",`Connection sequence finished with status: ${Fe}`)},[ce,He,Te,t,s,a,r,i,c.name,c.version,u,g,v,w,S,n,y,_]),ke=x.useCallback(async(je,Fe,pt)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot call tool "${je}".`);ce("info",`Calling tool: ${je}`,Fe);const Qe=Date.now();try{const nt=F.current.getSession("inspector-server");if(!nt)throw new Error("No active session found");const Ie=await nt.connector.callTool(je,Fe||{},pt);return ce("info",`Tool "${je}" call successful:`,Ie),Mi.getInstance().trackUseMcpToolCall({toolName:je,success:!0,executionTimeMs:Date.now()-Qe}).catch(()=>{}),Ie}catch(Tt){throw ce("error",`Tool "${je}" call failed:`,Tt),Mi.getInstance().trackUseMcpToolCall({toolName:je,success:!1,errorType:Tt instanceof Error?Tt.name:"UnknownError",executionTimeMs:Date.now()-Qe}).catch(()=>{}),Tt}},[I]),ze=x.useCallback(()=>{q.current==="failed"?(ce("info","Retry requested..."),Ee()):ce("warn",`Retry called but state is not 'failed' (state: ${q.current}). Ignoring.`)},[ce,Ee]),fe=x.useCallback(async()=>{ce("info","Manual authentication requested...");const je=q.current;if(je==="failed")ce("info","Attempting to reconnect and authenticate via retry..."),ze();else if(je==="pending_auth"){ce("info","Proceeding with authentication from pending state...");try{mE(W.current,"Auth Provider not available for manual auth"),mE(t,"Server URL is required for authentication"),ce("info","Clearing all OAuth state and initiating fresh flow...");const Fe=`${s}:${W.current.serverUrlHash}`;Object.keys(localStorage).forEach(nt=>{nt.startsWith(Fe)&&(ce("debug",`Removing stale OAuth key: ${nt}`),localStorage.removeItem(nt)),nt.startsWith(`${s}:state_`)&&(ce("debug",`Removing orphaned state: ${nt}`),localStorage.removeItem(nt))}),A("authenticating");const pt=new pb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:!1,useRedirectFlow:w,onPopupWindow:S});W.current=pt,ce("info","Triggering fresh OAuth authorization...");const{auth:Qe}=await Qn(async()=>{const{auth:nt}=await Promise.resolve().then(()=>AP);return{auth:nt}},void 0),Tt=new URL(t).origin;Qe(pt,{serverUrl:Tt}).catch(nt=>{ce("info","OAuth flow initiated:",nt instanceof Error?nt.message:"Redirecting...")})}catch(Fe){if(!ie.current)return;A("pending_auth"),ce("error",`Manual authentication failed: ${Fe instanceof Error?Fe.message:String(Fe)}`)}}else if(je==="authenticating"){ce("warn","Already attempting authentication. Check for blocked popups or wait for timeout.");const Fe=W.current?.getLastAttemptedAuthUrl();Fe&&!L&&($(Fe),ce("info","Manual authentication URL retrieved:",Fe))}else ce("info",`Client not in a state requiring manual authentication trigger (state: ${je}). If needed, try disconnecting and reconnecting.`)},[ce,ze,L,t,w,S,s,a,r,i]),Oe=x.useCallback(()=>{if(W.current){const je=W.current.clearStorage();ce("info",`Cleared ${je} item(s) from localStorage for ${t}.`),$(void 0),Te()}else ce("warn","Auth provider not initialized, cannot clear storage.")},[t,ce,Te]),Be=x.useCallback(async()=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot list resources.`);ce("info","Listing resources");try{const Fe=F.current.getSession("inspector-server");if(!Fe)throw new Error("No active session found");const pt=await Fe.connector.listAllResources();H(pt.resources||[]),ce("info","Resources listed successfully")}catch(je){throw ce("error","List resources failed:",je),je}},[I]),Se=x.useCallback(async je=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot read resource.`);ce("info",`Reading resource: ${je}`);try{const pt=F.current.getSession("inspector-server");if(!pt)throw new Error("No active session found");const Qe=await pt.connector.readResource(je);return ce("info","Resource read successful:",Qe),Mi.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!0}).catch(()=>{}),Qe}catch(Fe){throw ce("error","Resource read failed:",Fe),Mi.getInstance().trackUseMcpResourceRead({resourceUri:je,success:!1,errorType:Fe instanceof Error?Fe.name:"UnknownError"}).catch(()=>{}),Fe}},[I]),tt=x.useCallback(async()=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot list prompts.`);ce("info","Listing prompts");try{const Fe=F.current.getSession("inspector-server");if(!Fe)throw new Error("No active session found");const pt=await Fe.connector.listPrompts();ae(pt.prompts||[]),ce("info","Prompts listed successfully")}catch(je){throw ce("error","List prompts failed:",je),je}},[I]),it=x.useCallback(async(je,Fe)=>{if(q.current!=="ready"||!F.current)throw new Error(`MCP client is not ready (current state: ${I}). Cannot get prompt.`);ce("info",`Getting prompt: ${je}`,Fe);try{const Qe=F.current.getSession("inspector-server");if(!Qe)throw new Error("No active session found");const Tt=await Qe.connector.getPrompt(je,Fe||{});return ce("info",`Prompt "${je}" retrieved successfully:`,Tt),Tt}catch(pt){throw ce("error",`Prompt "${je}" retrieval failed:`,pt),pt}},[I]),ht=x.useRef(Ee),Rt=x.useRef(He);return x.useEffect(()=>{ht.current=Ee,Rt.current=He}),x.useEffect(()=>{const je=Pe(Fe=>{Fe.origin===window.location.origin&&Fe.data?.type==="mcp_auth_callback"&&(ce("info","Received auth callback message.",Fe.data),J.current&&clearTimeout(J.current),J.current=null,Fe.data.success?(ce("info","Authentication successful via popup. Reconnecting client..."),X.current&&ce("debug","Connection attempt already in progress, resetting flag to allow reconnection."),X.current=!1,setTimeout(()=>{ie.current&&(ce("debug","Initiating reconnection after successful auth callback."),ht.current())},100)):Rt.current(`Authentication failed in callback: ${Fe.data.error||"Unknown reason."}`))},"messageHandler");return window.addEventListener("message",je),ce("debug","Auth callback message listener added."),()=>{window.removeEventListener("message",je),ce("debug","Auth callback message listener removed."),J.current&&clearTimeout(J.current)}},[ce]),x.useEffect(()=>(ie.current=!0,!n||!t?(ce("debug",n?"No server URL provided, skipping connection.":"Connection disabled via enabled flag."),A("discovering"),()=>{ie.current=!1}):(ce("debug","useMcp mounted, initiating connection."),le.current=0,(!W.current||W.current.serverUrl!==t)&&(W.current=new pb(t,{storageKeyPrefix:s,clientName:a,clientUri:r,callbackUrl:i,preventAutoAuth:v,useRedirectFlow:w,onPopupWindow:S}),ce("debug","BrowserOAuthClientProvider initialized/updated on mount/option change.")),Ee(),()=>{ie.current=!1,ce("debug","useMcp unmounting, disconnecting."),Te(!0)})),[t,n,s,i,a,r,c.name,c.version,w]),x.useEffect(()=>{let je=null;if(I==="failed"&&m&&le.current>0){const Fe=typeof m=="number"?m:Oie;ce("info",`Connection failed, auto-retrying in ${Fe}ms...`),je=setTimeout(()=>{ie.current&&q.current==="failed"&&ze()},Fe)}return()=>{je&&clearTimeout(je)}},[I,m,ze,ce]),{state:I,tools:O,resources:U,resourceTemplates:K,prompts:te,serverInfo:B,capabilities:G,error:ne,log:V,authUrl:L,client:F.current,callTool:ke,readResource:Se,listResources:Be,listPrompts:tt,getPrompt:it,retry:ze,disconnect:Te,authenticate:fe,clearStorage:Oe}}Pe(QT,"useMcp");var Wu,Die=(Wu=class extends ue.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?ue.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"},ue.createElement("h3",{className:"font-bold mb-2"},"Widget Error"),ue.createElement("pre",{className:"text-sm whitespace-pre-wrap"},this.state.error?.message)):this.props.children}},Pe(Wu,"ErrorBoundary"),Wu),ep="openai:set_globals";function li(e){return x.useSyncExternalStore(t=>{const n=Pe(a=>{a.detail.globals[e]!==void 0&&t()},"handleSetGlobal");return typeof window<"u"&&window.addEventListener(ep,n),()=>{typeof window<"u"&&window.removeEventListener(ep,n)}},()=>typeof window<"u"&&window.openai?window.openai[e]:void 0)}Pe(li,"useOpenAiGlobal");function md(e){const[t,n]=x.useState(()=>typeof window<"u"&&!!window.openai);x.useEffect(()=>{if(typeof window<"u"&&window.openai){n(!0);return}const O=setInterval(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},100),M=Pe(()=>{typeof window<"u"&&window.openai&&(n(!0),clearInterval(O))},"handleSetGlobals");typeof window<"u"&&window.addEventListener(ep,M);const U=setTimeout(()=>{clearInterval(O),typeof window<"u"&&window.removeEventListener(ep,M)},5e3);return()=>{clearInterval(O),clearTimeout(U),typeof window<"u"&&window.removeEventListener(ep,M)}},[]);const a=x.useMemo(()=>t?"openai":"mcp-ui",[t]),r=typeof window<"u"?window.location.search:"",i=x.useMemo(()=>{const O=new URLSearchParams(r);return O.has("mcpUseParams")?JSON.parse(O.get("mcpUseParams")):{toolInput:{},toolOutput:{},toolId:""}},[r]),s=a==="openai"?li("toolInput"):i.toolInput,c=a==="openai"?li("toolOutput"):i.toolOutput,u=li("toolResponseMetadata"),d=li("widgetState"),m=li("theme"),h=li("displayMode"),g=li("safeArea"),v=li("maxHeight"),w=li("userAgent"),S=li("locale"),y=x.useMemo(()=>typeof window<"u"&&window.__mcpPublicUrl?window.__mcpPublicUrl.replace(/\/mcp-use\/public$/,""):"",[]),[_,E]=x.useState(null);x.useEffect(()=>{d!==void 0&&E(d)},[d]);const k=x.useCallback(async(O,M)=>{if(!window.openai?.callTool)throw new Error("window.openai.callTool is not available");return window.openai.callTool(O,M)},[]),C=x.useCallback(async O=>{if(!window.openai?.sendFollowUpMessage)throw new Error("window.openai.sendFollowUpMessage is not available");return window.openai.sendFollowUpMessage({prompt:O})},[]),R=x.useCallback(O=>{if(!window.openai?.openExternal)throw new Error("window.openai.openExternal is not available");window.openai.openExternal({href:O})},[]),I=x.useCallback(async O=>{if(!window.openai?.requestDisplayMode)throw new Error("window.openai.requestDisplayMode is not available");return window.openai.requestDisplayMode({mode:O})},[]),A=x.useCallback(async O=>{if(!window.openai?.setWidgetState)throw new Error("window.openai.setWidgetState is not available");const U=typeof O=="function"?O(d!==void 0?d:_):O;return E(U),window.openai.setWidgetState(U)},[d,_]);return{props:s||e||{},output:c??null,metadata:u??null,state:_,setState:A,theme:m||"light",displayMode:h||"inline",safeArea:g||{insets:{top:0,bottom:0,left:0,right:0}},maxHeight:v||600,userAgent:w||{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:S||"en",mcp_url:y,callTool:k,sendFollowUpMessage:C,openExternal:R,requestDisplayMode:I,isAvailable:t}}Pe(md,"useWidget");function jie(e){const{props:t}=md(e);return t}Pe(jie,"useWidgetProps");function Lie(){const{theme:e}=md();return e}Pe(Lie,"useWidgetTheme");function $ie(e){const{state:t,setState:n}=md();return x.useEffect(()=>{t===null&&e!==void 0&&window.openai?.setWidgetState&&n(e)},[]),[t,n]}Pe($ie,"useWidgetState");var zP=Pe(({children:e})=>{const{theme:t,isAvailable:n}=md();console.log("theme",t);const[a,r]=x.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");x.useEffect(()=>{if(typeof window>"u")return;const s=window.matchMedia("(prefers-color-scheme: dark)"),c=Pe(u=>{r(u.matches?"dark":"light")},"handleChange");return s.addEventListener("change",c),()=>s.removeEventListener("change",c)},[]);const i=n?t:a;return x.useLayoutEffect(()=>{typeof document>"u"||(i==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark"))},[i]),ue.createElement(ue.Fragment,null,e)},"ThemeProvider");function FH({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:d,state:m,theme:h,displayMode:g,safeArea:v,maxHeight:w,userAgent:S,locale:y,isAvailable:_,callTool:E,sendFollowUpMessage:k,openExternal:C,requestDisplayMode:R,setState:I}=md(),[A,O]=x.useState(!1),[M,U]=x.useState(!1),H=x.useRef(null),K=x.useRef(null),[Q,te]=x.useState([]),[ae,B]=x.useState(""),[Z,G]=x.useState("get-my-city"),[re,ne]=x.useState("{}"),[j,V]=x.useState("Test follow-up message"),[z,L]=x.useState("https://docs.mcp-use.com"),$=g==="fullscreen"&&_,F=g==="pip"&&_,W=typeof window<"u"&&window.location.pathname.includes("/inspector/api/dev-widget/");x.useEffect(()=>{const Se=setTimeout(()=>{if(typeof window<"u"&&window.openai)try{const tt=Object.keys(window.openai);te(tt)}catch{te([])}else te([])},100);return()=>{clearTimeout(Se)}},[]);const X=h==="dark",ie=Pe(()=>{const Se=["absolute","z-[1000]","flex","gap-2","transition-opacity","duration-200","ease-in-out",A?"opacity-100":"opacity-0",A?"pointer-events-auto":"pointer-events-none"];switch(n){case"top-left":return[...Se,"top-4","left-4"];case"top-center":return[...Se,"top-4","left-1/2","-translate-x-1/2"];case"top-right":return[...Se,"top-4","right-4"];case"center-left":return[...Se,"top-1/2","left-4","-translate-y-1/2"];case"center-right":return[...Se,"top-1/2","right-4","-translate-y-1/2"];case"bottom-left":return[...Se,"bottom-4","left-4"];case"bottom-center":return[...Se,"bottom-4","left-1/2","-translate-x-1/2"];case"bottom-right":return[...Se,"bottom-4","right-4"];default:return[...Se,"top-4","right-4"]}},"getPositionClasses"),le=Pe(()=>{const tt=v?.insets?.top?Math.max(16,v.insets.top+8):16,it=v?.insets?.right?Math.max(16,v.insets.right+8):16,ht=v?.insets?.bottom?Math.max(16,v.insets.bottom+8):16,Rt=v?.insets?.left?Math.max(16,v.insets.left+8):16,je={};switch(n){case"top-left":je.top=`${tt}px`,je.left=`${Rt}px`;break;case"top-center":je.top=`${tt}px`;break;case"top-right":je.top=`${tt}px`,je.right=`${it}px`;break;case"center-left":je.left=`${Rt}px`;break;case"center-right":je.right=`${it}px`;break;case"bottom-left":je.bottom=`${ht}px`,je.left=`${Rt}px`;break;case"bottom-center":je.bottom=`${ht}px`;break;case"bottom-right":je.bottom=`${ht}px`,je.right=`${it}px`;break;default:je.top=`${tt}px`,je.right=`${it}px`;break}return je},"getPositionOffsetStyles");x.useEffect(()=>{if(!a)return;const Se=Pe(()=>O(!0),"handleMouseEnter"),tt=Pe(()=>O(!1),"handleMouseLeave");return a.addEventListener("mouseenter",Se),a.addEventListener("mouseleave",tt),()=>{a.removeEventListener("mouseenter",Se),a.removeEventListener("mouseleave",tt)}},[a]),x.useEffect(()=>{if(!M)return;const Se=Pe(tt=>{K.current&&!K.current.contains(tt.target)&&U(!1)},"handleClickOutside");return document.addEventListener("mousedown",Se),()=>{document.removeEventListener("mousedown",Se)}},[M]),x.useEffect(()=>(M?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[M]);const J=Pe(()=>{U(!M)},"handleToggleOverlay"),q=Pe(async()=>{try{B("Calling tool...");const Se=re.trim()?JSON.parse(re):{},tt=await E(Z,Se);B(`Success: ${JSON.stringify(tt,null,2)}`)}catch(Se){B(`Error: ${Se.message}`)}},"handleCallTool"),se=Pe(async()=>{try{B("Sending follow-up message..."),await k(j),B("Follow-up message sent successfully")}catch(Se){B(`Error: ${Se.message}`)}},"handleSendFollowUpMessage"),he=Pe(()=>{try{C(z),B(`Opened external link: ${z}`)}catch(Se){B(`Error: ${Se.message}`)}},"handleOpenExternal"),ce=Pe(async Se=>{try{B(`Requesting display mode: ${Se}...`);const tt=await R(Se);B(`Display mode granted: ${tt.mode}`)}catch(tt){B(`Error: ${tt.message}`)}},"handleRequestDisplayMode"),Te=Pe(async()=>{try{const Se=m?{...m,debugTimestamp:new Date().toISOString()}:{debugTimestamp:new Date().toISOString()};B("Setting state..."),await I(Se),B(`State updated: ${JSON.stringify(Se,null,2)}`)}catch(Se){B(`Error: ${Se.message}`)}},"handleSetState"),He=Pe(async()=>{try{await R("fullscreen")}catch(Se){console.error("Failed to go fullscreen:",Se)}},"handleFullscreen"),Ee=Pe(async()=>{try{await R("pip")}catch(Se){console.error("Failed to go pip:",Se)}},"handlePip"),ke=Pe(()=>{const Se=["absolute","px-2","py-1","bg-black/90","text-white","rounded","text-xs","whitespace-nowrap","pointer-events-none","transition-opacity","duration-200","ease-in-out"];switch(n){case"top-right":return[...Se,"top-full","right-0","mt-2"];case"top-left":return[...Se,"top-full","left-0","mt-2"];case"top-center":return[...Se,"top-full","left-1/2","-translate-x-1/2","mt-2"];case"bottom-right":return[...Se,"bottom-full","right-0","mb-2"];case"bottom-left":return[...Se,"bottom-full","left-0","mb-2"];case"bottom-center":return[...Se,"bottom-full","left-1/2","-translate-x-1/2","mb-2"];case"center-left":return[...Se,"left-full","top-1/2","-translate-y-1/2","ml-2"];case"center-right":return[...Se,"right-full","top-1/2","-translate-y-1/2","mr-2"];default:return[...Se,"top-full","right-0","mt-2"]}},"getTooltipClasses"),ze=Pe(({onClick:Se,label:tt,children:it})=>{const[ht,Rt]=x.useState(!1),je=ke();return ue.createElement("button",{className:`p-2 ${X?"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 ${X?"shadow-[0_2px_8px_rgba(0,0,0,0.3)]":"shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,onMouseEnter:()=>Rt(!0),onMouseLeave:()=>Rt(!1),onClick:Se,"aria-label":tt},ue.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"},it),r&&ue.createElement("span",{className:`${je.join(" ")} ${ht?"opacity-100":"opacity-0"}`},tt))},"IconButton"),fe=Pe(Se=>{if(Se===null)return"null";if(Se===void 0)return"undefined";if(typeof Se=="object")try{return JSON.stringify(Se,null,2)}catch{return String(Se)}return String(Se)},"formatValue"),Oe=Pe(Se=>Se?`${Se.device?.type||"unknown"}`:"N/A","formatUserAgent"),Be=Pe(Se=>{if(!Se?.insets)return"N/A";const{top:tt,bottom:it,left:ht,right:Rt}=Se.insets;return`T:${tt} B:${it} L:${ht} R:${Rt}`},"formatSafeArea");return ue.createElement(ue.Fragment,null,ue.createElement("div",{ref:H,className:`${t} relative h-fit`,onMouseEnter:()=>!a&&O(!0),onMouseLeave:()=>!a&&O(!1)},ue.createElement("div",{className:ie().join(" "),style:le()},!W&&ue.createElement(ue.Fragment,null,!$&&!F&&ue.createElement(ue.Fragment,null,(s===!0||s==="fullscreen")&&ue.createElement(ze,{onClick:He,label:"Fullscreen"},ue.createElement("path",{d:"M15 3h6v6"}),ue.createElement("path",{d:"m21 3-7 7"}),ue.createElement("path",{d:"m3 21 7-7"}),ue.createElement("path",{d:"M9 21H3v-6"})),(s===!0||s==="pip")&&ue.createElement(ze,{onClick:Ee,label:"Picture in Picture"},ue.createElement("path",{d:"M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4"}),ue.createElement("rect",{width:"10",height:"7",x:"12",y:"13",rx:"2"}))),i&&ue.createElement(ze,{onClick:J,label:"Debug Info"},ue.createElement("path",{d:"M12 20v-9"}),ue.createElement("path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z"}),ue.createElement("path",{d:"M14.12 3.88 16 2"}),ue.createElement("path",{d:"M21 21a4 4 0 0 0-3.81-4"}),ue.createElement("path",{d:"M21 5a4 4 0 0 1-3.55 3.97"}),ue.createElement("path",{d:"M22 13h-4"}),ue.createElement("path",{d:"M3 21a4 4 0 0 1 3.81-4"}),ue.createElement("path",{d:"M3 5a4 4 0 0 0 3.55 3.97"}),ue.createElement("path",{d:"M6 13H2"}),ue.createElement("path",{d:"m8 2 1.88 1.88"}),ue.createElement("path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13"})))),e),M&&i&&ue.createElement("div",{ref:K,className:"fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",onClick:Se=>{Se.target===K.current&&U(!1)}},ue.createElement("button",{onClick:()=>U(!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"},"×"),ue.createElement("div",{className:"max-w-[1200px] mx-auto pt-10"},ue.createElement("h1",{className:"text-lg font-bold mb-4 border-b border-gray-700 pb-2"},"Debug Info"),ue.createElement("table",{className:"w-full border-collapse border-spacing-0"},ue.createElement("tbody",null,ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Props"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(c))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Output"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(u))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Metadata"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(d))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"State"),ue.createElement("td",{className:"p-2 whitespace-pre-wrap break-all"},fe(m))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Theme"),ue.createElement("td",{className:"p-2"},h)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Display Mode"),ue.createElement("td",{className:"p-2"},g)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Locale"),ue.createElement("td",{className:"p-2"},y)),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Max Height"),ue.createElement("td",{className:"p-2"},w,"px")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"User Agent"),ue.createElement("td",{className:"p-2"},Oe(S))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"Safe Area"),ue.createElement("td",{className:"p-2"},Be(v))),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"API Available"),ue.createElement("td",{className:"p-2"},_?"Yes":"No")),ue.createElement("tr",{className:"border-b border-gray-700"},ue.createElement("td",{className:"p-2 font-bold w-[200px] align-top"},"window.openai Keys"),ue.createElement("td",{className:"p-2"},Q.length>0?Q.join(", "):"N/A")))),ue.createElement("h2",{className:"text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2"},"Actions"),ue.createElement("div",{className:"flex flex-col gap-3"},ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:Z,onChange:Se=>G(Se.target.value),placeholder:"Tool name",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]"}),ue.createElement("input",{type:"text",value:re,onChange:Se=>ne(Se.target.value),placeholder:'{"key": "value"}',className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:q,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Call Tool")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:j,onChange:Se=>V(Se.target.value),placeholder:"Follow-up message",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.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")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("input",{type:"text",value:z,onChange:Se=>L(Se.target.value),placeholder:"External URL",className:"py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"}),ue.createElement("button",{onClick:he,className:"py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"},"Open Link")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.createElement("span",{className:"w-[150px] text-xs"},"Display Mode:"),ue.createElement("button",{onClick:()=>ce("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"),ue.createElement("button",{onClick:()=>ce("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"),ue.createElement("button",{onClick:()=>ce("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")),ue.createElement("div",{className:"flex gap-2 items-center"},ue.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)")),ae&&ue.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"},ue.createElement("div",{className:"font-bold mb-1 text-gray-400"},"Result:"),ae,ue.createElement("button",{onClick:()=>B(""),className:"mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"},"Clear"))))))}Pe(FH,"WidgetControls");function BH(){if(typeof window>"u")return"/";const t=window.location.pathname.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);return t?t[1]:"/"}Pe(BH,"getBasename");var Mie=150,Pie=5;function Uie({children:e,debugger:t=!1,viewControls:n=!1,autoSize:a=!1}){const r=BH(),i=x.useRef(null),s=x.useRef(0),c=x.useRef(null),u=x.useRef(!1),[d,m]=x.useState(null),[h,g]=x.useState(null),[v,w]=x.useState(!0);x.useEffect(()=>{let E=!0;return(async()=>{try{const k=await Qn(()=>import("./index-dr09MWBF.js"),[]);E&&(m(()=>k.BrowserRouter),w(!1))}catch{E&&(g(new Error(`❌ react-router-dom not installed!
|
|
36
36
|
|
|
37
37
|
To use MCP widgets with McpUseProvider, you need to install:
|
|
38
38
|
|
|
@@ -90,7 +90,7 @@ Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}
|
|
|
90
90
|
`)},TU=function(){var e=parseInt(document.body.getAttribute(gu)||"0",10);return isFinite(e)?e:0},Wue=function(){x.useEffect(function(){return document.body.setAttribute(gu,(TU()+1).toString()),function(){var e=TU()-1;e<=0?document.body.removeAttribute(gu):document.body.setAttribute(gu,e.toString())}},[])},Kue=function(e){var t=e.noRelative,n=e.noImportant,a=e.gapMode,r=a===void 0?"margin":a;Wue();var i=x.useMemo(function(){return Hue(r)},[r]);return x.createElement(Vue,{styles:Gue(i,!t,r,n?"":"!important")})},_E=!1;if(typeof window<"u")try{var Vg=Object.defineProperty({},"passive",{get:function(){return _E=!0,!0}});window.addEventListener("test",Vg,Vg),window.removeEventListener("test",Vg,Vg)}catch{_E=!1}var Fc=_E?{passive:!1}:!1,Zue=function(e){return e.tagName==="TEXTAREA"},c9=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Zue(e)&&n[t]==="visible")},Yue=function(e){return c9(e,"overflowY")},que=function(e){return c9(e,"overflowX")},NU=function(e,t){var n=t.ownerDocument,a=t;do{typeof ShadowRoot<"u"&&a instanceof ShadowRoot&&(a=a.host);var r=u9(e,a);if(r){var i=d9(e,a),s=i[1],c=i[2];if(s>c)return!0}a=a.parentNode}while(a&&a!==n.body);return!1},Xue=function(e){var t=e.scrollTop,n=e.scrollHeight,a=e.clientHeight;return[t,n,a]},Jue=function(e){var t=e.scrollLeft,n=e.scrollWidth,a=e.clientWidth;return[t,n,a]},u9=function(e,t){return e==="v"?Yue(t):que(t)},d9=function(e,t){return e==="v"?Xue(t):Jue(t)},Que=function(e,t){return e==="h"&&t==="rtl"?-1:1},ede=function(e,t,n,a,r){var i=Que(e,window.getComputedStyle(t).direction),s=i*a,c=n.target,u=t.contains(c),d=!1,m=s>0,h=0,g=0;do{if(!c)break;var v=d9(e,c),w=v[0],S=v[1],y=v[2],_=S-y-i*w;(w||_)&&u9(e,c)&&(h+=_,g+=w);var E=c.parentNode;c=E&&E.nodeType===Node.DOCUMENT_FRAGMENT_NODE?E.host:E}while(!u&&c!==document.body||u&&(t.contains(c)||t===c));return(m&&Math.abs(h)<1||!m&&Math.abs(g)<1)&&(d=!0),d},Gg=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},CU=function(e){return[e.deltaX,e.deltaY]},RU=function(e){return e&&"current"in e?e.current:e},tde=function(e,t){return e[0]===t[0]&&e[1]===t[1]},nde=function(e){return`
|
|
91
91
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
92
92
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
93
|
-
`)},rde=0,Bc=[];function ade(e){var t=x.useRef([]),n=x.useRef([0,0]),a=x.useRef(),r=x.useState(rde++)[0],i=x.useState(l9)[0],s=x.useRef(e);x.useEffect(function(){s.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var S=kue([e.lockRef.current],(e.shards||[]).map(RU),!0).filter(Boolean);return S.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),S.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=x.useCallback(function(S,y){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!s.current.allowPinchZoom;var _=Gg(S),E=n.current,k="deltaX"in S?S.deltaX:E[0]-_[0],C="deltaY"in S?S.deltaY:E[1]-_[1],R,I=S.target,A=Math.abs(k)>Math.abs(C)?"h":"v";if("touches"in S&&A==="h"&&I.type==="range")return!1;var O=NU(A,I);if(!O)return!0;if(O?R=A:(R=A==="v"?"h":"v",O=NU(A,I)),!O)return!1;if(!a.current&&"changedTouches"in S&&(k||C)&&(a.current=R),!R)return!0;var M=a.current||R;return ede(M,y,S,M==="h"?k:C)},[]),u=x.useCallback(function(S){var y=S;if(!(!Bc.length||Bc[Bc.length-1]!==i)){var _="deltaY"in y?CU(y):Gg(y),E=t.current.filter(function(R){return R.name===y.type&&(R.target===y.target||y.target===R.shadowParent)&&tde(R.delta,_)})[0];if(E&&E.should){y.cancelable&&y.preventDefault();return}if(!E){var k=(s.current.shards||[]).map(RU).filter(Boolean).filter(function(R){return R.contains(y.target)}),C=k.length>0?c(y,k[0]):!s.current.noIsolation;C&&y.cancelable&&y.preventDefault()}}},[]),d=x.useCallback(function(S,y,_,E){var k={name:S,delta:y,target:_,should:E,shadowParent:ide(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(C){return C!==k})},1)},[]),m=x.useCallback(function(S){n.current=Gg(S),a.current=void 0},[]),h=x.useCallback(function(S){d(S.type,CU(S),S.target,c(S,e.lockRef.current))},[]),g=x.useCallback(function(S){d(S.type,Gg(S),S.target,c(S,e.lockRef.current))},[]);x.useEffect(function(){return Bc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Fc),document.addEventListener("touchmove",u,Fc),document.addEventListener("touchstart",m,Fc),function(){Bc=Bc.filter(function(S){return S!==i}),document.removeEventListener("wheel",u,Fc),document.removeEventListener("touchmove",u,Fc),document.removeEventListener("touchstart",m,Fc)}},[]);var v=e.removeScrollBar,w=e.inert;return x.createElement(x.Fragment,null,w?x.createElement(i,{styles:nde(r)}):null,v?x.createElement(Kue,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ide(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ode=jue(s9,ade);var gm=x.forwardRef(function(e,t){return x.createElement(Sy,Pi({},e,{ref:t,sideCar:ode}))});gm.classNames=Sy.classNames;var kE=["Enter"," "],sde=["ArrowDown","PageUp","Home"],f9=["ArrowUp","PageDown","End"],lde=[...sde,...f9],cde={ltr:[...kE,"ArrowRight"],rtl:[...kE,"ArrowLeft"]},ude={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bm="Menu",[kp,dde,fde]=oN(bm),[Yl,p9]=Ci(bm,[fde,Hs,QV]),Ey=Hs(),m9=QV(),[pde,ql]=Yl(bm),[mde,vm]=Yl(bm),h9=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=Ey(t),[u,d]=x.useState(null),m=x.useRef(!1),h=Gi(i),g=sN(r);return x.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),f.jsx(vy,{...c,children:f.jsx(pde,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:f.jsx(mde,{scope:t,onClose:x.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};h9.displayName=bm;var hde="MenuAnchor",bN=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Ey(n);return f.jsx(mm,{...r,...a,ref:t})});bN.displayName=hde;var vN="MenuPortal",[gde,g9]=Yl(vN,{forceMount:void 0}),b9=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=ql(vN,t);return f.jsx(gde,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(_d,{asChild:!0,container:r,children:a})})})};b9.displayName=vN;var Ja="MenuContent",[bde,yN]=Yl(Ja),v9=x.forwardRef((e,t)=>{const n=g9(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ql(Ja,e.__scopeMenu),s=vm(Ja,e.__scopeMenu);return f.jsx(kp.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(kp.Slot,{scope:e.__scopeMenu,children:s.modal?f.jsx(vde,{...r,ref:t}):f.jsx(yde,{...r,ref:t})})})})}),vde=x.forwardRef((e,t)=>{const n=ql(Ja,e.__scopeMenu),a=x.useRef(null),r=Qt(t,a);return x.useEffect(()=>{const i=a.current;if(i)return xy(i)},[]),f.jsx(wN,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ge(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),yde=x.forwardRef((e,t)=>{const n=ql(Ja,e.__scopeMenu);return f.jsx(wN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),wde=Ml("MenuContent.ScrollLock"),wN=x.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:w,...S}=e,y=ql(Ja,n),_=vm(Ja,n),E=Ey(n),k=m9(n),C=dde(n),[R,I]=x.useState(null),A=x.useRef(null),O=Qt(t,A,y.onContentChange),M=x.useRef(0),U=x.useRef(""),H=x.useRef(0),K=x.useRef(null),Q=x.useRef("right"),te=x.useRef(0),ae=w?gm:x.Fragment,B=w?{as:wde,allowPinchZoom:!0}:void 0,Z=re=>{const ne=U.current+re,j=C().filter(W=>!W.disabled),V=document.activeElement,z=j.find(W=>W.ref.current===V)?.textValue,L=j.map(W=>W.textValue),$=Ode(L,ne,z),F=j.find(W=>W.textValue===$)?.ref.current;(function W(X){U.current=X,window.clearTimeout(M.current),X!==""&&(M.current=window.setTimeout(()=>W(""),1e3))})(ne),F&&setTimeout(()=>F.focus())};x.useEffect(()=>()=>window.clearTimeout(M.current),[]),py();const G=x.useCallback(re=>Q.current===K.current?.side&&jde(re,K.current?.area),[]);return f.jsx(bde,{scope:n,searchRef:U,onItemEnter:x.useCallback(re=>{G(re)&&re.preventDefault()},[G]),onItemLeave:x.useCallback(re=>{G(re)||(A.current?.focus(),I(null))},[G]),onTriggerLeave:x.useCallback(re=>{G(re)&&re.preventDefault()},[G]),pointerGraceTimerRef:H,onPointerGraceIntentChange:x.useCallback(re=>{K.current=re},[]),children:f.jsx(ae,{...B,children:f.jsx(fm,{asChild:!0,trapped:r,onMountAutoFocus:Ge(i,re=>{re.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:f.jsx(xd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:f.jsx(wue,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:R,onCurrentTabStopIdChange:I,onEntryFocus:Ge(u,re=>{_.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(yy,{role:"menu","aria-orientation":"vertical","data-state":j9(y.open),"data-radix-menu-content":"",dir:_.dir,...E,...S,ref:O,style:{outline:"none",...S.style},onKeyDown:Ge(S.onKeyDown,re=>{const j=re.target.closest("[data-radix-menu-content]")===re.currentTarget,V=re.ctrlKey||re.altKey||re.metaKey,z=re.key.length===1;j&&(re.key==="Tab"&&re.preventDefault(),!V&&z&&Z(re.key));const L=A.current;if(re.target!==L||!lde.includes(re.key))return;re.preventDefault();const F=C().filter(W=>!W.disabled).map(W=>W.ref.current);f9.includes(re.key)&&F.reverse(),Ade(F)}),onBlur:Ge(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(M.current),U.current="")}),onPointerMove:Ge(e.onPointerMove,Tp(re=>{const ne=re.target,j=te.current!==re.clientX;if(re.currentTarget.contains(ne)&&j){const V=re.clientX>te.current?"right":"left";Q.current=V,te.current=re.clientX}}))})})})})})})});v9.displayName=Ja;var xde="MenuGroup",xN=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"group",...a,ref:t})});xN.displayName=xde;var Sde="MenuLabel",y9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{...a,ref:t})});y9.displayName=Sde;var ov="MenuItem",AU="menu.itemSelect",_y=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=x.useRef(null),s=vm(ov,e.__scopeMenu),c=yN(ov,e.__scopeMenu),u=Qt(t,i),d=x.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(AU,{bubbles:!0,cancelable:!0});h.addEventListener(AU,v=>a?.(v),{once:!0}),NV(h,g),g.defaultPrevented?d.current=!1:s.onClose()}};return f.jsx(w9,{...r,ref:u,disabled:n,onClick:Ge(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:Ge(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:Ge(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||kE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});_y.displayName=ov;var w9=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=yN(ov,n),c=m9(n),u=x.useRef(null),d=Qt(t,u),[m,h]=x.useState(!1),[g,v]=x.useState("");return x.useEffect(()=>{const w=u.current;w&&v((w.textContent??"").trim())},[i.children]),f.jsx(kp.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:f.jsx(xue,{asChild:!0,...c,focusable:!a,children:f.jsx(Et.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:d,onPointerMove:Ge(e.onPointerMove,Tp(w=>{a?s.onItemLeave(w):(s.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ge(e.onPointerLeave,Tp(w=>s.onItemLeave(w))),onFocus:Ge(e.onFocus,()=>h(!0)),onBlur:Ge(e.onBlur,()=>h(!1))})})})}),Ede="MenuCheckboxItem",x9=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return f.jsx(T9,{scope:e.__scopeMenu,checked:n,children:f.jsx(_y,{role:"menuitemcheckbox","aria-checked":sv(n)?"mixed":n,...r,ref:t,"data-state":EN(n),onSelect:Ge(r.onSelect,()=>a?.(sv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});x9.displayName=Ede;var S9="MenuRadioGroup",[_de,kde]=Yl(S9,{value:void 0,onValueChange:()=>{}}),E9=x.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Gi(a);return f.jsx(_de,{scope:e.__scopeMenu,value:n,onValueChange:i,children:f.jsx(xN,{...r,ref:t})})});E9.displayName=S9;var _9="MenuRadioItem",k9=x.forwardRef((e,t)=>{const{value:n,...a}=e,r=kde(_9,e.__scopeMenu),i=n===r.value;return f.jsx(T9,{scope:e.__scopeMenu,checked:i,children:f.jsx(_y,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":EN(i),onSelect:Ge(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});k9.displayName=_9;var SN="MenuItemIndicator",[T9,Tde]=Yl(SN,{checked:!1}),N9=x.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=Tde(SN,n);return f.jsx(Ma,{present:a||sv(i.checked)||i.checked===!0,children:f.jsx(Et.span,{...r,ref:t,"data-state":EN(i.checked)})})});N9.displayName=SN;var Nde="MenuSeparator",C9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});C9.displayName=Nde;var Cde="MenuArrow",R9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Ey(n);return f.jsx(wy,{...r,...a,ref:t})});R9.displayName=Cde;var Rde="MenuSub",[nTe,A9]=Yl(Rde),Hf="MenuSubTrigger",I9=x.forwardRef((e,t)=>{const n=ql(Hf,e.__scopeMenu),a=vm(Hf,e.__scopeMenu),r=A9(Hf,e.__scopeMenu),i=yN(Hf,e.__scopeMenu),s=x.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=i,d={__scopeMenu:e.__scopeMenu},m=x.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return x.useEffect(()=>m,[m]),x.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),u(null)}},[c,u]),f.jsx(bN,{asChild:!0,...d,children:f.jsx(w9,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":j9(n.open),...e,ref:Vi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ge(e.onPointerMove,Tp(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:Ge(e.onPointerLeave,Tp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,w=v==="right",S=w?-5:5,y=g[w?"left":"right"],_=g[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+S,y:h.clientY},{x:y,y:g.top},{x:_,y:g.top},{x:_,y:g.bottom},{x:y,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:Ge(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||cde[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});I9.displayName=Hf;var O9="MenuSubContent",D9=x.forwardRef((e,t)=>{const n=g9(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ql(Ja,e.__scopeMenu),s=vm(Ja,e.__scopeMenu),c=A9(O9,e.__scopeMenu),u=x.useRef(null),d=Qt(t,u);return f.jsx(kp.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(kp.Slot,{scope:e.__scopeMenu,children:f.jsx(wN,{id:c.contentId,"aria-labelledby":c.triggerId,...r,ref:d,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:Ge(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ge(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ge(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=ude[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});D9.displayName=O9;function j9(e){return e?"open":"closed"}function sv(e){return e==="indeterminate"}function EN(e){return sv(e)?"indeterminate":e?"checked":"unchecked"}function Ade(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ide(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function Ode(e,t,n){const r=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Ide(e,Math.max(i,0));r.length===1&&(s=s.filter(d=>d!==n));const u=s.find(d=>d.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function Dde(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],d=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-d)*(a-m)/(g-m)+d&&(r=!r)}return r}function jde(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Dde(n,t)}function Tp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Lde=h9,$de=bN,Mde=b9,Pde=v9,Ude=xN,zde=y9,Fde=_y,Bde=x9,Hde=E9,Vde=k9,Gde=N9,Wde=C9,Kde=R9,Zde=I9,Yde=D9,ky="DropdownMenu",[qde]=Ci(ky,[p9]),ra=p9(),[Xde,L9]=qde(ky),$9=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ra(t),d=x.useRef(null),[m,h]=jo({prop:r,defaultProp:i??!1,onChange:s,caller:ky});return f.jsx(Xde,{scope:t,triggerId:Dr(),triggerRef:d,contentId:Dr(),open:m,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),modal:c,children:f.jsx(Lde,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};$9.displayName=ky;var M9="DropdownMenuTrigger",P9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=L9(M9,n),s=ra(n);return f.jsx($de,{asChild:!0,...s,children:f.jsx(Et.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:Vi(t,i.triggerRef),onPointerDown:Ge(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ge(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});P9.displayName=M9;var Jde="DropdownMenuPortal",U9=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ra(t);return f.jsx(Mde,{...a,...n})};U9.displayName=Jde;var z9="DropdownMenuContent",F9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=L9(z9,n),i=ra(n),s=x.useRef(!1);return f.jsx(Pde,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ge(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ge(e.onInteractOutside,c=>{const u=c.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,m=u.button===2||d;(!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)"}})});F9.displayName=z9;var Qde="DropdownMenuGroup",efe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Ude,{...r,...a,ref:t})});efe.displayName=Qde;var tfe="DropdownMenuLabel",B9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(zde,{...r,...a,ref:t})});B9.displayName=tfe;var nfe="DropdownMenuItem",H9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Fde,{...r,...a,ref:t})});H9.displayName=nfe;var rfe="DropdownMenuCheckboxItem",V9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Bde,{...r,...a,ref:t})});V9.displayName=rfe;var afe="DropdownMenuRadioGroup",ife=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Hde,{...r,...a,ref:t})});ife.displayName=afe;var ofe="DropdownMenuRadioItem",G9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Vde,{...r,...a,ref:t})});G9.displayName=ofe;var sfe="DropdownMenuItemIndicator",lfe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Gde,{...r,...a,ref:t})});lfe.displayName=sfe;var cfe="DropdownMenuSeparator",W9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Wde,{...r,...a,ref:t})});W9.displayName=cfe;var ufe="DropdownMenuArrow",dfe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Kde,{...r,...a,ref:t})});dfe.displayName=ufe;var ffe="DropdownMenuSubTrigger",K9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Zde,{...r,...a,ref:t})});K9.displayName=ffe;var pfe="DropdownMenuSubContent",Z9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Yde,{...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)"}})});Z9.displayName=pfe;var mfe=$9,hfe=P9,gfe=U9,Y9=F9,q9=B9,X9=H9,bfe=V9,vfe=G9,J9=W9,yfe=K9,wfe=Z9;const TE=mfe,NE=hfe;yfe.displayName;wfe.displayName;function lv({ref:e,className:t,sideOffset:n=4,...a}){return f.jsx(gfe,{children:f.jsx(Y9,{ref:e,sideOffset:n,className:De("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})})}lv.displayName=Y9.displayName;function To({ref:e,className:t,inset:n,...a}){return f.jsx(X9,{ref:e,className:De("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...a})}To.displayName=X9.displayName;bfe.displayName;vfe.displayName;function CE({ref:e,className:t,inset:n,...a}){return f.jsx(q9,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}CE.displayName=q9.displayName;function Vf({ref:e,className:t,...n}){return f.jsx(J9,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}Vf.displayName=J9.displayName;var xfe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ho=xfe.reduce((e,t)=>{const n=cV(`Primitive.${t}`),a=x.forwardRef((r,i)=>{const{asChild:s,...c}=r,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),Sfe="Label",Q9=x.forwardRef((e,t)=>f.jsx(Ho.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Q9.displayName=Sfe;var Efe=Q9;function Kt({className:e,...t}){return f.jsx(Efe,{"data-slot":"label",className:De("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function kd({message:e,className:t="",vertical:n,noBorder:a}){return f.jsx("div",{className:De(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:f.jsxs("p",{className:De("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[f.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:f.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:f.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[f.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"}),f.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),f.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function e8({className:e,color:t,children:n,grayscaled:a=!1}){const r=x.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=x.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=x.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=x.useMemo(()=>t||`oklch(${Math.min(i,1)} ${r} ${s})`,[s,r,i]),u=x.useMemo(()=>`oklch(${Math.min(i*2,1)} ${r} ${s})`,[s,r,i,t]),d=x.useMemo(()=>Math.floor(Math.random()*360),[s]),m=x.useMemo(()=>"1000%",[]);return f.jsx("section",{className:De("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:f.jsxs("div",{className:"isolate relative w-full h-full",children:[f.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${d}deg, ${c}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${m})`}}),n&&f.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function _N(e){const t=x.useRef({value:e,previous:e});return x.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ty="Switch",[_fe]=Ci(Ty),[kfe,Tfe]=_fe(Ty),t8=x.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:d,form:m,...h}=e,[g,v]=x.useState(null),w=Qt(t,k=>v(k)),S=x.useRef(!1),y=g?m||!!g.closest("form"):!0,[_,E]=jo({prop:r,defaultProp:i??!1,onChange:d,caller:Ty});return f.jsxs(kfe,{scope:n,checked:_,disabled:c,children:[f.jsx(Et.button,{type:"button",role:"switch","aria-checked":_,"aria-required":s,"data-state":i8(_),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:w,onClick:Ge(e.onClick,k=>{E(C=>!C),y&&(S.current=k.isPropagationStopped(),S.current||k.stopPropagation())})}),y&&f.jsx(a8,{control:g,bubbles:!S.current,name:a,value:u,checked:_,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});t8.displayName=Ty;var n8="SwitchThumb",r8=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=Tfe(n8,n);return f.jsx(Et.span,{"data-state":i8(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});r8.displayName=n8;var Nfe="SwitchBubbleInput",a8=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=x.useRef(null),c=Qt(s,i),u=_N(n),d=mN(t);return x.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const w=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(w)}},[u,n,a]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...r,tabIndex:-1,ref:c,style:{...r.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});a8.displayName=Nfe;function i8(e){return e?"checked":"unchecked"}var o8=t8,Cfe=r8;function Ny({ref:e,className:t,...n}){return f.jsx(o8,{className:De("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:f.jsx(Cfe,{className:De("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})}Ny.displayName=o8.displayName;var s8=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"}),Rfe="VisuallyHidden",l8=x.forwardRef((e,t)=>f.jsx(Et.span,{...e,ref:t,style:{...s8,...e.style}}));l8.displayName=Rfe;var Afe=l8,[Cy]=Ci("Tooltip",[Hs]),Ry=Hs(),c8="TooltipProvider",Ife=700,RE="tooltip.open",[Ofe,kN]=Cy(c8),u8=e=>{const{__scopeTooltip:t,delayDuration:n=Ife,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=e,s=x.useRef(!0),c=x.useRef(!1),u=x.useRef(0);return x.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),f.jsx(Ofe,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:x.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:x.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,a)},[a]),isPointerInTransitRef:c,onPointerInTransitChange:x.useCallback(d=>{c.current=d},[]),disableHoverableContent:r,children:i})};u8.displayName=c8;var Np="Tooltip",[Dfe,ym]=Cy(Np),d8=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=kN(Np,e.__scopeTooltip),d=Ry(t),[m,h]=x.useState(null),g=Dr(),v=x.useRef(0),w=s??u.disableHoverableContent,S=c??u.delayDuration,y=x.useRef(!1),[_,E]=jo({prop:a,defaultProp:r??!1,onChange:A=>{A?(u.onOpen(),document.dispatchEvent(new CustomEvent(RE))):u.onClose(),i?.(A)},caller:Np}),k=x.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),C=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y.current=!1,E(!0)},[E]),R=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,E(!1)},[E]),I=x.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{y.current=!0,E(!0),v.current=0},S)},[S,E]);return x.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),f.jsx(vy,{...d,children:f.jsx(Dfe,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:x.useCallback(()=>{u.isOpenDelayedRef.current?I():C()},[u.isOpenDelayedRef,I,C]),onTriggerLeave:x.useCallback(()=>{w?R():(window.clearTimeout(v.current),v.current=0)},[R,w]),onOpen:C,onClose:R,disableHoverableContent:w,children:n})})};d8.displayName=Np;var AE="TooltipTrigger",f8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=ym(AE,n),i=kN(AE,n),s=Ry(n),c=x.useRef(null),u=Qt(t,c,r.onTriggerChange),d=x.useRef(!1),m=x.useRef(!1),h=x.useCallback(()=>d.current=!1,[]);return x.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),f.jsx(mm,{asChild:!0,...s,children:f.jsx(Et.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ge(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ge(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ge(e.onPointerDown,()=>{r.open&&r.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ge(e.onFocus,()=>{d.current||r.onOpen()}),onBlur:Ge(e.onBlur,r.onClose),onClick:Ge(e.onClick,r.onClose)})})});f8.displayName=AE;var TN="TooltipPortal",[jfe,Lfe]=Cy(TN,{forceMount:void 0}),p8=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=ym(TN,t);return f.jsx(jfe,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(_d,{asChild:!0,container:r,children:a})})})};p8.displayName=TN;var td="TooltipContent",m8=x.forwardRef((e,t)=>{const n=Lfe(td,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=ym(td,e.__scopeTooltip);return f.jsx(Ma,{present:a||s.open,children:s.disableHoverableContent?f.jsx(h8,{side:r,...i,ref:t}):f.jsx($fe,{side:r,...i,ref:t})})}),$fe=x.forwardRef((e,t)=>{const n=ym(td,e.__scopeTooltip),a=kN(td,e.__scopeTooltip),r=x.useRef(null),i=Qt(t,r),[s,c]=x.useState(null),{trigger:u,onClose:d}=n,m=r.current,{onPointerInTransitChange:h}=a,g=x.useCallback(()=>{c(null),h(!1)},[h]),v=x.useCallback((w,S)=>{const y=w.currentTarget,_={x:w.clientX,y:w.clientY},E=zfe(_,y.getBoundingClientRect()),k=Ffe(_,E),C=Bfe(S.getBoundingClientRect()),R=Vfe([...k,...C]);c(R),h(!0)},[h]);return x.useEffect(()=>()=>g(),[g]),x.useEffect(()=>{if(u&&m){const w=y=>v(y,m),S=y=>v(y,u);return u.addEventListener("pointerleave",w),m.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",w),m.removeEventListener("pointerleave",S)}}},[u,m,v,g]),x.useEffect(()=>{if(s){const w=S=>{const y=S.target,_={x:S.clientX,y:S.clientY},E=u?.contains(y)||m?.contains(y),k=!Hfe(_,s);E?g():k&&(g(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,m,s,d,g]),f.jsx(h8,{...e,ref:i})}),[Mfe,Pfe]=Cy(Np,{isInside:!1}),Ufe=yle("TooltipContent"),h8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=ym(td,n),d=Ry(n),{onClose:m}=u;return x.useEffect(()=>(document.addEventListener(RE,m),()=>document.removeEventListener(RE,m)),[m]),x.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]),f.jsx(xd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:f.jsxs(yy,{"data-state":u.stateAttribute,...d,...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:[f.jsx(Ufe,{children:a}),f.jsx(Mfe,{scope:n,isInside:!0,children:f.jsx(Afe,{id:u.contentId,role:"tooltip",children:r||a})})]})})});m8.displayName=td;var g8="TooltipArrow",b8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Ry(n);return Pfe(g8,n).isInside?null:f.jsx(wy,{...r,...a,ref:t})});b8.displayName=g8;function zfe(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 Ffe(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 Bfe(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 Hfe(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],d=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-d)*(a-m)/(g-m)+d&&(r=!r)}return r}function Vfe(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),Gfe(t)}function Gfe(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 Wfe=u8,Kfe=d8,Zfe=f8,Yfe=p8,qfe=m8,Xfe=b8;function v8({delayDuration:e=0,...t}){return f.jsx(Wfe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Dt({...e}){return f.jsx(v8,{children:f.jsx(Kfe,{"data-slot":"tooltip",...e})})}function jt({...e}){return f.jsx(Zfe,{"data-slot":"tooltip-trigger",...e})}function Lt({className:e,sideOffset:t=0,children:n,...a}){return f.jsx(Yfe,{children:f.jsxs(qfe,{"data-slot":"tooltip-content",sideOffset:t,className:De("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...a,children:[n,f.jsx(Xfe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class Jfe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class IU{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 OU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class DU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class jU{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 Qfe{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 epe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class tpe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class npe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function tS(){try{return"0.12.4"}catch{return"0.0.0"}}var rpe={};function nS(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class LU{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 bs(e){return`mcp_inspector_telemetry_${e}`}class yr{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=nS(),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 LU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new LU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(bs("disabled"))==="true"||typeof process<"u"&&rpe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(bs("source")):null}static getInstance(){return yr.instance||(yr.instance=new yr),yr.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(bs("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!nS())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(bs("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(bs("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(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&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:tS(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=tS(),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&&nS())try{const n=tS();let a=!1,r=!1;const i=localStorage.getItem(bs("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(bs("download_version"),n)):(a=!0,r=!0,localStorage.setItem(bs("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 Jfe(t);await this.capture(n)}}const ape={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function ipe({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Sampling Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),f.jsxs("div",{className:"flex gap-2",children:[f.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"}),f.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(ape)},children:"Approve"}),f.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 ope({requestId:e,serverName:t,mode:n,message:a,url:r,onViewDetails:i,onOpenUrl:s,onCancel:c}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Elicitation Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",a]}),n==="url"&&r&&f.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:r})]}),f.jsxs("div",{className:"flex gap-2 flex-wrap",children:[f.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&&f.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"}),f.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"})]})]})}const Wg=()=>{},Kg=()=>{},Zg=()=>{},Yg=()=>{},y8=x.createContext(null);function NN(){const e=x.use(y8);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function spe({url:e,name:t,proxyConfig:n,transportType:a,connectionId:r,onUpdate:i,onRemove:s}){const c=typeof window<"u"?new URL("/inspector/oauth/callback",window.location.origin).toString():"/inspector/oauth/callback";let u=e,d={};if(n?.proxyAddress){const L=new URL(n.proxyAddress),$=new URL(e);u=`${L.origin}${L.pathname}${$.pathname}${$.search}`,d["X-Target-URL"]=e}n?.customHeaders&&(d={...d,...n.customHeaders});const[m,h]=x.useState([]),g=x.useRef(0),[v,w]=x.useState([]),S=x.useRef(0),y=x.useMemo(()=>m.map(L=>({id:L.id,request:L.request,timestamp:L.timestamp,serverName:L.serverName})),[m]),_=x.useMemo(()=>v.map(L=>({id:L.id,request:L.request,timestamp:L.timestamp,serverName:L.serverName})),[v]),E=x.useRef(null),[k,C]=x.useState(!1),R=x.useRef(!1);x.useEffect(()=>{typeof window<"u"&&!R.current&&(R.current=!0,Qn(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(L=>{E.current=L.wrapTransportForLogging,C(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(L=>{console.error("[McpContext] Failed to load transport wrapper:",L)}))},[]);const I=x.useMemo(()=>{if(!(!k||!E.current))return(L,$)=>{const F=r;return console.log("[McpContext] Applying transport wrapper, serverId:",F,"from connector:",$),E.current(L,F)}},[k,r]),A=`mcp-inspector-notifications-${r}`,O=500,[M,U]=x.useState([]);x.useEffect(()=>{try{const L=localStorage.getItem(A);if(L){const $=JSON.parse(L);Array.isArray($)&&U($)}}catch(L){console.error("Failed to load notifications from localStorage:",L)}},[A]),x.useEffect(()=>{try{localStorage.setItem(A,JSON.stringify(M))}catch(L){console.error("Failed to save notifications to localStorage:",L)}},[M,A]);const H=x.useCallback(L=>{U($=>$.map(F=>F.id===L?{...F,read:!0}:F))},[]),K=x.useCallback(()=>{U(L=>L.map($=>({...$,read:!0})))},[]),Q=x.useCallback(()=>{U([])},[]),te=x.useCallback(L=>{U($=>{const F=[L,...$];return F.length>O?F.slice(0,O):F})},[]),ae=x.useCallback((L,$)=>{h(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),B=x.useCallback((L,$)=>{h(F=>{const W=F.find(X=>X.id===L);return W?(W.reject(new Error($||"User rejected sampling request")),F.filter(X=>X.id!==L)):F})},[]),Z=x.useCallback((L,$)=>{w(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),G=x.useCallback((L,$)=>{w(F=>{const W=F.find(X=>X.id===L);return W?(W.reject(new Error($||"User rejected elicitation request")),F.filter(X=>X.id!==L)):F})},[]),re=x.useCallback(async L=>new Promise(($,F)=>{const W=`sampling-${g.current++}`,X={id:W,request:{params:L},timestamp:Date.now(),serverName:t,resolve:$,reject:F};h(ie=>[...ie,X]),typeof window<"u"&&Qn(async()=>{const{toast:ie}=await Promise.resolve().then(()=>BU);return{toast:ie}},void 0).then(({toast:ie})=>{const le=ie(f.jsx(ipe,{requestId:W,serverName:t,onViewDetails:()=>{const J=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:W}});window.dispatchEvent(J),ie.dismiss(le)},onApprove:J=>{h(q=>{const se=q.find(he=>he.id===W);return se?(se.resolve(J),ie.success("Sampling request approved"),q.filter(he=>he.id!==W)):q}),ie.dismiss(le)},onDeny:()=>{h(J=>{const q=J.find(se=>se.id===W);return q?(q.reject(new Error("User denied sampling request from toast")),ie.error("Sampling request denied"),J.filter(se=>se.id!==W)):J}),ie.dismiss(le)}}),{duration:5e3})})}),[t]),ne=x.useCallback(async L=>new Promise(($,F)=>{const W=`elicitation-${S.current++}`,X={id:W,request:L,timestamp:Date.now(),serverName:t,resolve:$,reject:F};w(ie=>[...ie,X]),typeof window<"u"&&Qn(async()=>{const{toast:ie}=await Promise.resolve().then(()=>BU);return{toast:ie}},void 0).then(({toast:ie})=>{const le=ie(f.jsx(ope,{requestId:W,serverName:t,mode:L.mode||"form",message:L.message,url:L.mode==="url"?L.url:void 0,onViewDetails:()=>{const J=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:W}});window.dispatchEvent(J),ie.dismiss(le)},onOpenUrl:L.mode==="url"?()=>{window.open(L.url,"_blank"),ie.dismiss(le)}:void 0,onCancel:()=>{w(J=>{const q=J.find(se=>se.id===W);return q?(q.reject(new Error("User cancelled elicitation request from toast")),ie.error("Elicitation request cancelled"),J.filter(se=>se.id!==W)):J}),ie.dismiss(le)}}),{duration:5e3})})}),[t]),j=QT({url:u,callbackUrl:c,customHeaders:Object.keys(d).length>0?d:void 0,transportType:a||"http",preventAutoAuth:!0,useRedirectFlow:!0,enabled:k,wrapTransport:I,onNotification:L=>{te({id:globalThis.crypto.randomUUID(),method:L.method,params:L.params,timestamp:Date.now(),read:!1})},samplingCallback:re,onElicitation:ne}),V=x.useRef(i),z=x.useRef(null);return x.useEffect(()=>{V.current=i},[i]),x.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{j.state==="ready"&&j.serverInfo&&console.log("[McpContext] Server info available:",j.serverInfo);const L=M.filter(W=>!W.read).length,$={id:r,url:e,name:j.serverInfo?.name||t,state:j.state,tools:j.tools,resources:j.resources,prompts:j.prompts,error:j.error??null,authUrl:j.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:j.serverInfo,capabilities:j.capabilities,notifications:M,unreadNotificationCount:L,markNotificationRead:H,markAllNotificationsRead:K,clearNotifications:Q,pendingSamplingRequests:y,approveSampling:ae,rejectSampling:B,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:j.callTool,readResource:j.readResource,listPrompts:j.listPrompts,getPrompt:j.getPrompt,authenticate:j.authenticate,retry:j.retry,clearStorage:j.clearStorage,disconnect:j.disconnect,client:j.client},F=z.current;(!F||F.state!==$.state||F.error!==$.error||F.authUrl!==$.authUrl||F.name!==$.name||F.tools.length!==$.tools.length||F.resources.length!==$.resources.length||F.prompts.length!==$.prompts.length||F.serverInfo!==$.serverInfo||F.capabilities!==$.capabilities||F.notifications.length!==$.notifications.length||F.unreadNotificationCount!==$.unreadNotificationCount||F.pendingSamplingRequests.length!==$.pendingSamplingRequests.length||F.pendingElicitationRequests.length!==$.pendingElicitationRequests.length||!F.client)&&(z.current=$,V.current($))});else{const L=M.filter(W=>!W.read).length,$={id:r,url:e,name:j.serverInfo?.name||t,state:j.state,tools:j.tools,resources:j.resources,prompts:j.prompts,error:j.error??null,authUrl:j.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:j.serverInfo,capabilities:j.capabilities,notifications:M,unreadNotificationCount:L,markNotificationRead:H,markAllNotificationsRead:K,clearNotifications:Q,pendingSamplingRequests:y,approveSampling:ae,rejectSampling:B,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:j.callTool,readResource:j.readResource,listPrompts:j.listPrompts,getPrompt:j.getPrompt,authenticate:j.authenticate,retry:j.retry,clearStorage:j.clearStorage,disconnect:j.disconnect,client:j.client},F=z.current;(!F||F.state!==$.state||F.error!==$.error||F.authUrl!==$.authUrl||F.name!==$.name||F.tools.length!==$.tools.length||F.resources.length!==$.resources.length||F.prompts.length!==$.prompts.length||F.serverInfo!==$.serverInfo||F.capabilities!==$.capabilities||F.notifications.length!==$.notifications.length||F.unreadNotificationCount!==$.unreadNotificationCount||F.pendingSamplingRequests.length!==$.pendingSamplingRequests.length||F.pendingElicitationRequests.length!==$.pendingElicitationRequests.length||!F.client)&&(z.current=$,V.current($))}},[e,t,a,n,d,r,j.state,j.tools,j.resources,j.prompts,j.error,j.authUrl,j.serverInfo,j.capabilities,j.client,M,H,K,Q,j.callTool,j.readResource,j.listPrompts,j.getPrompt,j.authenticate,j.retry,j.clearStorage,m,ae,B,_,Z,G]),null}function lpe({children:e}){const[t,n]=x.useState([]),[a,r]=x.useState(!1),[i,s]=x.useState(!0),[c,u]=x.useState([]);x.useEffect(()=>{try{const y=localStorage.getItem("mcp-inspector-connections");if(y){const E=JSON.parse(y);Array.isArray(E)&&(u(E),n(E.map(k=>({id:k.id||k.url,url:k.url,name:k.name||"MCP Server",state:"discovering",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k.proxyConfig?.customHeaders,transportType:k.transportType,proxyConfig:k.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Wg,rejectSampling:Kg,pendingElicitationRequests:[],approveElicitation:Zg,rejectElicitation:Yg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&s(_==="true")}catch(y){console.error("Failed to load connections from localStorage:",y)}finally{r(!0)}},[]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-connections",JSON.stringify(c))},[c,a]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-auto-connect",String(i))},[i,a]);const d=x.useCallback((y,_,E,k)=>{const C=c.find(A=>A.url===y),R=t.find(A=>A.url===y);if(C&&R){if(JSON.stringify(C.proxyConfig)!==JSON.stringify(E)&&E){u(O=>O.filter(M=>M.url!==y)),n(O=>O.filter(M=>M.url!==y)),setTimeout(()=>{const O={id:y,url:y,name:_||C.name||"MCP Server",proxyConfig:E,transportType:k||C.transportType};u(M=>[...M,O]),n(M=>[...M,{id:y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||C.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Wg,rejectSampling:Kg,pendingElicitationRequests:[],approveElicitation:Zg,rejectElicitation:Yg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!R){(E||k)&&u(A=>A.map(O=>O.url===y?{...O,proxyConfig:E||O.proxyConfig,transportType:k||O.transportType,name:_||O.name}:O)),n(A=>[...A,{id:C.id||y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||C.proxyConfig?.customHeaders,transportType:k||C.transportType,proxyConfig:E||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Wg,rejectSampling:Kg,pendingElicitationRequests:[],approveElicitation:Zg,rejectElicitation:Yg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const I={id:y,url:y,name:_||"MCP Server",proxyConfig:E,transportType:k};u(A=>[...A,I]),n(A=>[...A,{id:y,url:y,name:_||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Wg,rejectSampling:Kg,pendingElicitationRequests:[],approveElicitation:Zg,rejectElicitation:Yg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[c,t]),m=x.useCallback(y=>{const _=t.find(k=>k.id===y);_&&(console.log(`[McpContext] Cleaning up connection: ${y}`),_.disconnect&&(console.log(`[McpContext] Disconnecting from server: ${y}`),_.disconnect()),_.clearStorage&&(console.log(`[McpContext] Clearing OAuth storage for connection: ${y}`),_.clearStorage())),u(k=>k.filter(C=>C.id!==y)),n(k=>k.filter(C=>C.id!==y));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const C=JSON.parse(E).filter(R=>(R.id||R.url)!==y);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(k){console.error("Failed to update localStorage on remove:",k)}yr.getInstance().capture(new epe({serverId:y}))},[t]),h=x.useCallback((y,_)=>{u(E=>E.map(k=>k.id===y||k.url===y?{...k,..._}:k)),n(E=>E.map(k=>k.id===y?{...k,..._}:k))},[]),g=x.useCallback(y=>{n(_=>{const E=_.findIndex(R=>R.id===y.id);if(E===-1)return _;const k=_[E];if(k.state===y.state&&k.tools===y.tools&&k.resources===y.resources&&k.prompts===y.prompts&&k.error===y.error&&k.serverInfo===y.serverInfo&&k.client===y.client&&k.notifications===y.notifications&&k.unreadNotificationCount===y.unreadNotificationCount&&k.pendingSamplingRequests.length===y.pendingSamplingRequests.length&&k.pendingElicitationRequests.length===y.pendingElicitationRequests.length)return _;const C=[..._];return C[E]=y,C})},[]),v=x.useCallback(y=>{console.log("Connect requested for:",y)},[]),w=x.useCallback(y=>{console.log("Disconnect requested for:",y)},[]),S=x.useMemo(()=>({connections:t,addConnection:d,removeConnection:m,updateConnectionConfig:h,autoConnect:i,setAutoConnect:s,connectServer:v,disconnectServer:w,configLoaded:a}),[t,d,m,h,i,v,w,a]);return f.jsxs(y8.Provider,{value:S,children:[e,a&&i&&c.map(y=>{const _=`${y.id||y.url}-${y.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",y.proxyConfig),f.jsx(spe,{url:y.url,name:y.name,proxyConfig:y.proxyConfig,transportType:y.transportType,connectionId:y.id||y.url,onUpdate:g,onRemove:()=>m(y.id||y.url)},_)})]})}const cpe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),upe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),$U=e=>{const t=upe(e);return t.charAt(0).toUpperCase()+t.slice(1)},w8=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),dpe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var fpe={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 ppe=x.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...c},u)=>x.createElement("svg",{ref:u,...fpe,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:w8("lucide",r),...!i&&!dpe(c)&&{"aria-hidden":"true"},...c},[...s.map(([d,m])=>x.createElement(d,m)),...Array.isArray(i)?i:[i]]));const Xe=(e,t)=>{const n=x.forwardRef(({className:a,...r},i)=>x.createElement(ppe,{ref:i,iconNode:t,className:w8(`lucide-${cpe($U(e))}`,`lucide-${e}`,a),...r}));return n.displayName=$U(e),n};const mpe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],hpe=Xe("arrow-down-to-line",mpe);const gpe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],bpe=Xe("arrow-up-from-line",gpe);const vpe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ype=Xe("arrow-up",vpe);const wpe=[["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"}]],CN=Xe("bell",wpe);const xpe=[["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"}]],x8=Xe("brush",xpe);const Spe=[["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"}]],Epe=Xe("bug",Spe);const _pe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ta=Xe("check",_pe);const kpe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Xl=Xe("chevron-down",kpe);const Tpe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Npe=Xe("chevron-right",Tpe);const Cpe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],RN=Xe("chevron-left",Cpe);const Rpe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ape=Xe("chevron-up",Rpe);const Ipe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Ope=Xe("chevrons-up-down",Ipe);const Dpe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],MU=Xe("circle-minus",Dpe);const jpe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],nd=Xe("clock",jpe);const Lpe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],AN=Xe("code",Lpe);const $pe=[["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"}]],Mpe=Xe("cog",$pe);const Ppe=[["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"}]],Upe=Xe("command",Ppe);const zpe=[["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"}]],jr=Xe("copy",zpe);const Fpe=[["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"}]],Ay=Xe("database",Fpe);const Bpe=[["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"}]],wm=Xe("download",Bpe);const Hpe=[["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"}]],Vpe=Xe("ellipsis-vertical",Hpe);const Gpe=[["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"}]],IE=Xe("external-link",Gpe);const Wpe=[["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"}]],S8=Xe("eye-off",Wpe);const Kpe=[["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"}]],OE=Xe("eye",Kpe);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"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Ype=Xe("file-code",Zpe);const qpe=[["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"}]],Xpe=Xe("file-image",qpe);const Jpe=[["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"}]],IN=Xe("file-text",Jpe);const Qpe=[["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"}]],eme=Xe("file",Qpe);const tme=[["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"}]],nme=Xe("folder-open",tme);const rme=[["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"}]],ame=Xe("globe",rme);const ime=[["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"}]],ome=Xe("grip-vertical",ime);const sme=[["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"}]],E8=Xe("hash",sme);const lme=[["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"}]],cv=Xe("history",lme);const cme=[["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"}]],_8=Xe("key",cme);const ume=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ls=Xe("loader-circle",ume);const dme=[["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"}]],ON=Xe("maximize-2",dme);const fme=[["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"}]],DN=Xe("maximize",fme);const pme=[["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"}]],mme=Xe("message-circle",pme);const hme=[["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"}]],Cp=Xe("message-square",hme);const gme=[["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"}]],bme=Xe("minimize",gme);const vme=[["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=Xe("monitor",vme);const yme=[["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"}]],wme=Xe("moon",yme);const xme=[["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"}]],Sme=Xe("picture-in-picture",xme);const Eme=[["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"}]],k8=Xe("play",Eme);const _me=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],T8=Xe("plus",_me);const kme=[["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"}]],UU=Xe("rotate-ccw",kme);const Tme=[["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"}]],jN=Xe("save",Tme);const Nme=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Td=Xe("search",Nme);const Cme=[["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"}]],Rme=Xe("send",Cme);const Ame=[["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"}]],Ime=Xe("server",Ame);const Ome=[["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"}]],bu=Xe("settings",Ome);const Dme=[["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"}]],jme=Xe("shield",Dme);const Lme=[["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=Xe("sparkles",Lme);const Mme=[["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"}]],N8=Xe("square-check-big",Mme);const Pme=[["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"}]],Ume=Xe("square-pen",Pme);const zme=[["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"}]],Fme=Xe("sun-dim",zme);const Bme=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],rS=Xe("terminal",Bme);const Hme=[["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"}]],$s=Xe("trash-2",Hme);const Vme=[["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"}]],Gme=Xe("trash",Vme);const Wme=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Ul=Xe("wrench",Wme);const Kme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Yi=Xe("x",Kme);const Zme=[["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"}]],Rp=Xe("zap",Zme);function Yme(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 qme=e=>{switch(e){case"success":return Qme;case"info":return the;case"warning":return ehe;case"error":return nhe;default:return null}},Xme=Array(12).fill(0),Jme=({visible:e,className:t})=>ue.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},Xme.map((n,a)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),Qme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.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"})),ehe=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ue.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"})),the=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.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"})),nhe=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.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"})),rhe=ue.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"},ue.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ue.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ahe=()=>{const[e,t]=ue.useState(document.hidden);return ue.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let DE=1;class ihe{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:DE++,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 d=>{if(s=["resolve",d],ue.isValidElement(d))i=!1,this.create({id:a,type:"default",message:d});else if(she(d)&&!d.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(d instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...w})}}).catch(async d=>{if(s=["reject",d],n.error!==void 0){i=!1;const m=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,v=typeof m=="object"&&!ue.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((d,m)=>c.then(()=>s[0]==="reject"?m(s[1]):d(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||DE++;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 pa=new ihe,ohe=(e,t)=>{const n=t?.id||DE++;return pa.addToast({title:e,...t,id:n}),n},she=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",lhe=ohe,che=()=>pa.toasts,uhe=()=>pa.getActiveToasts(),Jt=Object.assign(lhe,{success:pa.success,info:pa.info,warning:pa.warning,error:pa.error,custom:pa.custom,message:pa.message,promise:pa.promise,dismiss:pa.dismiss,loading:pa.loading},{getHistory:che,getToasts:uhe});Yme("[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 qg(e){return e.label!==void 0}const dhe=3,fhe="24px",phe="16px",zU=4e3,mhe=356,hhe=14,ghe=45,bhe=200;function $i(...e){return e.filter(Boolean).join(" ")}function vhe(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const yhe=e=>{var t,n,a,r,i,s,c,u,d;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:w,visibleToasts:S,heights:y,index:_,toasts:E,expanded:k,removeToast:C,defaultRichColors:R,closeButton:I,style:A,cancelButtonStyle:O,actionButtonStyle:M,className:U="",descriptionClassName:H="",duration:K,position:Q,gap:te,expandByDefault:ae,classNames:B,icons:Z,closeButtonAriaLabel:G="Close toast"}=e,[re,ne]=ue.useState(null),[j,V]=ue.useState(null),[z,L]=ue.useState(!1),[$,F]=ue.useState(!1),[W,X]=ue.useState(!1),[ie,le]=ue.useState(!1),[J,q]=ue.useState(!1),[se,he]=ue.useState(0),[ce,Te]=ue.useState(0),He=ue.useRef(h.duration||K||zU),Ee=ue.useRef(null),ke=ue.useRef(null),ze=_===0,fe=_+1<=S,Oe=h.type,Be=h.dismissible!==!1,Se=h.className||"",tt=h.descriptionClassName||"",it=ue.useMemo(()=>y.findIndex(Ye=>Ye.toastId===h.id)||0,[y,h.id]),ht=ue.useMemo(()=>{var Ye;return(Ye=h.closeButton)!=null?Ye:I},[h.closeButton,I]),Rt=ue.useMemo(()=>h.duration||K||zU,[h.duration,K]),je=ue.useRef(0),Fe=ue.useRef(0),pt=ue.useRef(0),Qe=ue.useRef(null),[Tt,nt]=Q.split("-"),Ie=ue.useMemo(()=>y.reduce((Ye,vt,Mt)=>Mt>=it?Ye:Ye+vt.height,0),[y,it]),$e=ahe(),Ve=h.invert||m,at=Oe==="loading";Fe.current=ue.useMemo(()=>it*te+Ie,[it,Ie]),ue.useEffect(()=>{He.current=Rt},[Rt]),ue.useEffect(()=>{L(!0)},[]),ue.useEffect(()=>{const Ye=ke.current;if(Ye){const vt=Ye.getBoundingClientRect().height;return Te(vt),w(Mt=>[{toastId:h.id,height:vt,position:h.position},...Mt]),()=>w(Mt=>Mt.filter(Pt=>Pt.toastId!==h.id))}},[w,h.id]),ue.useLayoutEffect(()=>{if(!z)return;const Ye=ke.current,vt=Ye.style.height;Ye.style.height="auto";const Mt=Ye.getBoundingClientRect().height;Ye.style.height=vt,Te(Mt),w(Pt=>Pt.find(fn=>fn.toastId===h.id)?Pt.map(fn=>fn.toastId===h.id?{...fn,height:Mt}:fn):[{toastId:h.id,height:Mt,position:h.position},...Pt])},[z,h.title,h.description,w,h.id,h.jsx,h.action,h.cancel]);const dt=ue.useCallback(()=>{F(!0),he(Fe.current),w(Ye=>Ye.filter(vt=>vt.toastId!==h.id)),setTimeout(()=>{C(h)},bhe)},[h,C,w,Fe]);ue.useEffect(()=>{if(h.promise&&Oe==="loading"||h.duration===1/0||h.type==="loading")return;let Ye;return k||v||$e?(()=>{if(pt.current<je.current){const Pt=new Date().getTime()-je.current;He.current=He.current-Pt}pt.current=new Date().getTime()})():(()=>{He.current!==1/0&&(je.current=new Date().getTime(),Ye=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),dt()},He.current))})(),()=>clearTimeout(Ye)},[k,v,h,Oe,$e,dt]),ue.useEffect(()=>{h.delete&&(dt(),h.onDismiss==null||h.onDismiss.call(h,h))},[dt,h.delete]);function wt(){var Ye;if(Z?.loading){var vt;return ue.createElement("div",{className:$i(B?.loader,h==null||(vt=h.classNames)==null?void 0:vt.loader,"sonner-loader"),"data-visible":Oe==="loading"},Z.loading)}return ue.createElement(Jme,{className:$i(B?.loader,h==null||(Ye=h.classNames)==null?void 0:Ye.loader),visible:Oe==="loading"})}const xt=h.icon||Z?.[Oe]||qme(Oe);var dn,hn;return ue.createElement("li",{tabIndex:0,ref:ke,className:$i(U,Se,B?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,B?.default,B?.[Oe],h==null||(n=h.classNames)==null?void 0:n[Oe]),"data-sonner-toast":"","data-rich-colors":(dn=h.richColors)!=null?dn:R,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":z,"data-promise":!!h.promise,"data-swiped":J,"data-removed":$,"data-visible":fe,"data-y-position":Tt,"data-x-position":nt,"data-index":_,"data-front":ze,"data-swiping":W,"data-dismissible":Be,"data-type":Oe,"data-invert":Ve,"data-swipe-out":ie,"data-swipe-direction":j,"data-expanded":!!(k||ae&&z),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${$?se:Fe.current}px`,"--initial-height":ae?"auto":`${ce}px`,...A,...h.style},onDragEnd:()=>{X(!1),ne(null),Qe.current=null},onPointerDown:Ye=>{Ye.button!==2&&(at||!Be||(Ee.current=new Date,he(Fe.current),Ye.target.setPointerCapture(Ye.pointerId),Ye.target.tagName!=="BUTTON"&&(X(!0),Qe.current={x:Ye.clientX,y:Ye.clientY})))},onPointerUp:()=>{var Ye,vt,Mt;if(ie||!Be)return;Qe.current=null;const Pt=Number(((Ye=ke.current)==null?void 0:Ye.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),fr=Number(((vt=ke.current)==null?void 0:vt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),fn=new Date().getTime()-((Mt=Ee.current)==null?void 0:Mt.getTime()),Kn=re==="x"?Pt:fr,Zn=Math.abs(Kn)/fn;if(Math.abs(Kn)>=ghe||Zn>.11){he(Fe.current),h.onDismiss==null||h.onDismiss.call(h,h),V(re==="x"?Pt>0?"right":"left":fr>0?"down":"up"),dt(),le(!0);return}else{var wn,pn;(wn=ke.current)==null||wn.style.setProperty("--swipe-amount-x","0px"),(pn=ke.current)==null||pn.style.setProperty("--swipe-amount-y","0px")}q(!1),X(!1),ne(null)},onPointerMove:Ye=>{var vt,Mt,Pt;if(!Qe.current||!Be||((vt=window.getSelection())==null?void 0:vt.toString().length)>0)return;const fn=Ye.clientY-Qe.current.y,Kn=Ye.clientX-Qe.current.x;var Zn;const wn=(Zn=e.swipeDirections)!=null?Zn:vhe(Q);!re&&(Math.abs(Kn)>1||Math.abs(fn)>1)&&ne(Math.abs(Kn)>Math.abs(fn)?"x":"y");let pn={x:0,y:0};const aa=en=>1/(1.5+Math.abs(en)/20);if(re==="y"){if(wn.includes("top")||wn.includes("bottom"))if(wn.includes("top")&&fn<0||wn.includes("bottom")&&fn>0)pn.y=fn;else{const en=fn*aa(fn);pn.y=Math.abs(en)<Math.abs(fn)?en:fn}}else if(re==="x"&&(wn.includes("left")||wn.includes("right")))if(wn.includes("left")&&Kn<0||wn.includes("right")&&Kn>0)pn.x=Kn;else{const en=Kn*aa(Kn);pn.x=Math.abs(en)<Math.abs(Kn)?en:Kn}(Math.abs(pn.x)>0||Math.abs(pn.y)>0)&&q(!0),(Mt=ke.current)==null||Mt.style.setProperty("--swipe-amount-x",`${pn.x}px`),(Pt=ke.current)==null||Pt.style.setProperty("--swipe-amount-y",`${pn.y}px`)}},ht&&!h.jsx&&Oe!=="loading"?ue.createElement("button",{"aria-label":G,"data-disabled":at,"data-close-button":!0,onClick:at||!Be?()=>{}:()=>{dt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:$i(B?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(hn=Z?.close)!=null?hn:rhe):null,(Oe||h.icon||h.promise)&&h.icon!==null&&(Z?.[Oe]!==null||h.icon)?ue.createElement("div",{"data-icon":"",className:$i(B?.icon,h==null||(r=h.classNames)==null?void 0:r.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||wt():null,h.type!=="loading"?xt:null):null,ue.createElement("div",{"data-content":"",className:$i(B?.content,h==null||(i=h.classNames)==null?void 0:i.content)},ue.createElement("div",{"data-title":"",className:$i(B?.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?ue.createElement("div",{"data-description":"",className:$i(H,tt,B?.description,h==null||(c=h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),ue.isValidElement(h.cancel)?h.cancel:h.cancel&&qg(h.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ye=>{qg(h.cancel)&&Be&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ye),dt())},className:$i(B?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,ue.isValidElement(h.action)?h.action:h.action&&qg(h.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:Ye=>{qg(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ye),!Ye.defaultPrevented&&dt())},className:$i(B?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function FU(){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 whe(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?phe:fhe;function u(d){["top","right","bottom","left"].forEach(m=>{n[`${s}-${m}`]=typeof d=="number"?`${d}px`:d})}typeof a=="number"||typeof a=="string"?u(a):typeof a=="object"?["top","right","bottom","left"].forEach(d=>{a[d]===void 0?n[`${s}-${d}`]=c:n[`${s}-${d}`]=typeof a[d]=="number"?`${a[d]}px`:a[d]}):u(c)}),n}const C8=ue.forwardRef(function(t,n){const{id:a,invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:c,closeButton:u,className:d,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:w,style:S,visibleToasts:y=dhe,toastOptions:_,dir:E=FU(),gap:k=hhe,icons:C,containerAriaLabel:R="Notifications"}=t,[I,A]=ue.useState([]),O=ue.useMemo(()=>a?I.filter(z=>z.toasterId===a):I.filter(z=>!z.toasterId),[I,a]),M=ue.useMemo(()=>Array.from(new Set([i].concat(O.filter(z=>z.position).map(z=>z.position)))),[O,i]),[U,H]=ue.useState([]),[K,Q]=ue.useState(!1),[te,ae]=ue.useState(!1),[B,Z]=ue.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),G=ue.useRef(null),re=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),ne=ue.useRef(null),j=ue.useRef(!1),V=ue.useCallback(z=>{A(L=>{var $;return($=L.find(F=>F.id===z.id))!=null&&$.delete||pa.dismiss(z.id),L.filter(({id:F})=>F!==z.id)})},[]);return ue.useEffect(()=>pa.subscribe(z=>{if(z.dismiss){requestAnimationFrame(()=>{A(L=>L.map($=>$.id===z.id?{...$,delete:!0}:$))});return}setTimeout(()=>{sV.flushSync(()=>{A(L=>{const $=L.findIndex(F=>F.id===z.id);return $!==-1?[...L.slice(0,$),{...L[$],...z},...L.slice($+1)]:[z,...L]})})})}),[I]),ue.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 z=window.matchMedia("(prefers-color-scheme: dark)");try{z.addEventListener("change",({matches:L})=>{Z(L?"dark":"light")})}catch{z.addListener(({matches:$})=>{try{Z($?"dark":"light")}catch(F){console.error(F)}})}},[g]),ue.useEffect(()=>{I.length<=1&&Q(!1)},[I]),ue.useEffect(()=>{const z=L=>{var $;if(s.every(X=>L[X]||L.code===X)){var W;Q(!0),(W=G.current)==null||W.focus()}L.code==="Escape"&&(document.activeElement===G.current||($=G.current)!=null&&$.contains(document.activeElement))&&Q(!1)};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[s]),ue.useEffect(()=>{if(G.current)return()=>{ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null,j.current=!1)}},[G.current]),ue.createElement("section",{ref:n,"aria-label":`${R} ${re}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((z,L)=>{var $;const[F,W]=z.split("-");return O.length?ue.createElement("ol",{key:z,dir:E==="auto"?FU():E,tabIndex:-1,ref:G,className:d,"data-sonner-toaster":!0,"data-sonner-theme":B,"data-y-position":F,"data-x-position":W,style:{"--front-toast-height":`${(($=U[0])==null?void 0:$.height)||0}px`,"--width":`${mhe}px`,"--gap":`${k}px`,...S,...whe(m,h)},onBlur:X=>{j.current&&!X.currentTarget.contains(X.relatedTarget)&&(j.current=!1,ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||j.current||(j.current=!0,ne.current=X.relatedTarget)},onMouseEnter:()=>Q(!0),onMouseMove:()=>Q(!0),onMouseLeave:()=>{te||Q(!1)},onDragEnd:()=>Q(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||ae(!0)},onPointerUp:()=>ae(!1)},O.filter(X=>!X.position&&L===0||X.position===z).map((X,ie)=>{var le,J;return ue.createElement(yhe,{key:X.id,icons:C,index:ie,toast:X,defaultRichColors:v,duration:(le=_?.duration)!=null?le:w,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:r,visibleToasts:y,closeButton:(J=_?.closeButton)!=null?J:u,interacting:te,position:z,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:V,toasts:O.filter(q=>q.position==X.position),heights:U.filter(q=>q.position==X.position),setHeights:H,expandByDefault:c,gap:k,expanded:K,swipeDirections:t.swipeDirections})})):null}))}),BU=Object.freeze(Object.defineProperty({__proto__:null,Toaster:C8,toast:Jt},Symbol.toStringTag,{value:"Module"}));var Iy="Dialog",[R8]=Ci(Iy),[xhe,Ri]=R8(Iy),A8=e=>{const{__scopeDialog:t,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:s=!0}=e,c=x.useRef(null),u=x.useRef(null),[d,m]=jo({prop:a,defaultProp:r??!1,onChange:i,caller:Iy});return f.jsx(xhe,{scope:t,triggerRef:c,contentRef:u,contentId:Dr(),titleId:Dr(),descriptionId:Dr(),open:d,onOpenChange:m,onOpenToggle:x.useCallback(()=>m(h=>!h),[m]),modal:s,children:n})};A8.displayName=Iy;var I8="DialogTrigger",O8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(I8,n),i=Qt(t,r.triggerRef);return f.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":MN(r.open),...a,ref:i,onClick:Ge(e.onClick,r.onOpenToggle)})});O8.displayName=I8;var LN="DialogPortal",[She,D8]=R8(LN,{forceMount:void 0}),j8=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Ri(LN,t);return f.jsx(She,{scope:t,forceMount:n,children:x.Children.map(a,s=>f.jsx(Ma,{present:n||i.open,children:f.jsx(_d,{asChild:!0,container:r,children:s})}))})};j8.displayName=LN;var uv="DialogOverlay",L8=x.forwardRef((e,t)=>{const n=D8(uv,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ri(uv,e.__scopeDialog);return i.modal?f.jsx(Ma,{present:a||i.open,children:f.jsx(_he,{...r,ref:t})}):null});L8.displayName=uv;var Ehe=Ml("DialogOverlay.RemoveScroll"),_he=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(uv,n);return f.jsx(gm,{as:Ehe,allowPinchZoom:!0,shards:[r.contentRef],children:f.jsx(Et.div,{"data-state":MN(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),zl="DialogContent",$8=x.forwardRef((e,t)=>{const n=D8(zl,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ri(zl,e.__scopeDialog);return f.jsx(Ma,{present:a||i.open,children:i.modal?f.jsx(khe,{...r,ref:t}):f.jsx(The,{...r,ref:t})})});$8.displayName=zl;var khe=x.forwardRef((e,t)=>{const n=Ri(zl,e.__scopeDialog),a=x.useRef(null),r=Qt(t,n.contentRef,a);return x.useEffect(()=>{const i=a.current;if(i)return xy(i)},[]),f.jsx(M8,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ge(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ge(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:Ge(e.onFocusOutside,i=>i.preventDefault())})}),The=x.forwardRef((e,t)=>{const n=Ri(zl,e.__scopeDialog),a=x.useRef(!1),r=x.useRef(!1);return f.jsx(M8,{...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()}})}),M8=x.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=e,c=Ri(zl,n),u=x.useRef(null),d=Qt(t,u);return py(),f.jsxs(f.Fragment,{children:[f.jsx(fm,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:f.jsx(xd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":MN(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(Nhe,{titleId:c.titleId}),f.jsx(Rhe,{contentRef:u,descriptionId:c.descriptionId})]})]})}),$N="DialogTitle",P8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri($N,n);return f.jsx(Et.h2,{id:r.titleId,...a,ref:t})});P8.displayName=$N;var U8="DialogDescription",z8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(U8,n);return f.jsx(Et.p,{id:r.descriptionId,...a,ref:t})});z8.displayName=U8;var F8="DialogClose",B8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(F8,n);return f.jsx(Et.button,{type:"button",...a,ref:t,onClick:Ge(e.onClick,()=>r.onOpenChange(!1))})});B8.displayName=F8;function MN(e){return e?"open":"closed"}var H8="DialogTitleWarning",[rTe,V8]=ple(H8,{contentName:zl,titleName:$N,docsSlug:"dialog"}),Nhe=({titleId:e})=>{const t=V8(H8),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
93
|
+
`)},rde=0,Bc=[];function ade(e){var t=x.useRef([]),n=x.useRef([0,0]),a=x.useRef(),r=x.useState(rde++)[0],i=x.useState(l9)[0],s=x.useRef(e);x.useEffect(function(){s.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var S=kue([e.lockRef.current],(e.shards||[]).map(RU),!0).filter(Boolean);return S.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),S.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=x.useCallback(function(S,y){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!s.current.allowPinchZoom;var _=Gg(S),E=n.current,k="deltaX"in S?S.deltaX:E[0]-_[0],C="deltaY"in S?S.deltaY:E[1]-_[1],R,I=S.target,A=Math.abs(k)>Math.abs(C)?"h":"v";if("touches"in S&&A==="h"&&I.type==="range")return!1;var O=NU(A,I);if(!O)return!0;if(O?R=A:(R=A==="v"?"h":"v",O=NU(A,I)),!O)return!1;if(!a.current&&"changedTouches"in S&&(k||C)&&(a.current=R),!R)return!0;var M=a.current||R;return ede(M,y,S,M==="h"?k:C)},[]),u=x.useCallback(function(S){var y=S;if(!(!Bc.length||Bc[Bc.length-1]!==i)){var _="deltaY"in y?CU(y):Gg(y),E=t.current.filter(function(R){return R.name===y.type&&(R.target===y.target||y.target===R.shadowParent)&&tde(R.delta,_)})[0];if(E&&E.should){y.cancelable&&y.preventDefault();return}if(!E){var k=(s.current.shards||[]).map(RU).filter(Boolean).filter(function(R){return R.contains(y.target)}),C=k.length>0?c(y,k[0]):!s.current.noIsolation;C&&y.cancelable&&y.preventDefault()}}},[]),d=x.useCallback(function(S,y,_,E){var k={name:S,delta:y,target:_,should:E,shadowParent:ide(_)};t.current.push(k),setTimeout(function(){t.current=t.current.filter(function(C){return C!==k})},1)},[]),m=x.useCallback(function(S){n.current=Gg(S),a.current=void 0},[]),h=x.useCallback(function(S){d(S.type,CU(S),S.target,c(S,e.lockRef.current))},[]),g=x.useCallback(function(S){d(S.type,Gg(S),S.target,c(S,e.lockRef.current))},[]);x.useEffect(function(){return Bc.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:g}),document.addEventListener("wheel",u,Fc),document.addEventListener("touchmove",u,Fc),document.addEventListener("touchstart",m,Fc),function(){Bc=Bc.filter(function(S){return S!==i}),document.removeEventListener("wheel",u,Fc),document.removeEventListener("touchmove",u,Fc),document.removeEventListener("touchstart",m,Fc)}},[]);var v=e.removeScrollBar,w=e.inert;return x.createElement(x.Fragment,null,w?x.createElement(i,{styles:nde(r)}):null,v?x.createElement(Kue,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function ide(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ode=jue(s9,ade);var gm=x.forwardRef(function(e,t){return x.createElement(Sy,Pi({},e,{ref:t,sideCar:ode}))});gm.classNames=Sy.classNames;var kE=["Enter"," "],sde=["ArrowDown","PageUp","Home"],f9=["ArrowUp","PageDown","End"],lde=[...sde,...f9],cde={ltr:[...kE,"ArrowRight"],rtl:[...kE,"ArrowLeft"]},ude={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bm="Menu",[kp,dde,fde]=oN(bm),[Yl,p9]=Ci(bm,[fde,Hs,QV]),Ey=Hs(),m9=QV(),[pde,ql]=Yl(bm),[mde,vm]=Yl(bm),h9=e=>{const{__scopeMenu:t,open:n=!1,children:a,dir:r,onOpenChange:i,modal:s=!0}=e,c=Ey(t),[u,d]=x.useState(null),m=x.useRef(!1),h=Gi(i),g=sN(r);return x.useEffect(()=>{const v=()=>{m.current=!0,document.addEventListener("pointerdown",w,{capture:!0,once:!0}),document.addEventListener("pointermove",w,{capture:!0,once:!0})},w=()=>m.current=!1;return document.addEventListener("keydown",v,{capture:!0}),()=>{document.removeEventListener("keydown",v,{capture:!0}),document.removeEventListener("pointerdown",w,{capture:!0}),document.removeEventListener("pointermove",w,{capture:!0})}},[]),f.jsx(vy,{...c,children:f.jsx(pde,{scope:t,open:n,onOpenChange:h,content:u,onContentChange:d,children:f.jsx(mde,{scope:t,onClose:x.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:s,children:a})})})};h9.displayName=bm;var hde="MenuAnchor",bN=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Ey(n);return f.jsx(mm,{...r,...a,ref:t})});bN.displayName=hde;var vN="MenuPortal",[gde,g9]=Yl(vN,{forceMount:void 0}),b9=e=>{const{__scopeMenu:t,forceMount:n,children:a,container:r}=e,i=ql(vN,t);return f.jsx(gde,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(_d,{asChild:!0,container:r,children:a})})})};b9.displayName=vN;var Ja="MenuContent",[bde,yN]=Yl(Ja),v9=x.forwardRef((e,t)=>{const n=g9(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ql(Ja,e.__scopeMenu),s=vm(Ja,e.__scopeMenu);return f.jsx(kp.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(kp.Slot,{scope:e.__scopeMenu,children:s.modal?f.jsx(vde,{...r,ref:t}):f.jsx(yde,{...r,ref:t})})})})}),vde=x.forwardRef((e,t)=>{const n=ql(Ja,e.__scopeMenu),a=x.useRef(null),r=Qt(t,a);return x.useEffect(()=>{const i=a.current;if(i)return xy(i)},[]),f.jsx(wN,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ge(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),yde=x.forwardRef((e,t)=>{const n=ql(Ja,e.__scopeMenu);return f.jsx(wN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),wde=Ml("MenuContent.ScrollLock"),wN=x.forwardRef((e,t)=>{const{__scopeMenu:n,loop:a=!1,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:c,onEntryFocus:u,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,disableOutsideScroll:w,...S}=e,y=ql(Ja,n),_=vm(Ja,n),E=Ey(n),k=m9(n),C=dde(n),[R,I]=x.useState(null),A=x.useRef(null),O=Qt(t,A,y.onContentChange),M=x.useRef(0),U=x.useRef(""),H=x.useRef(0),K=x.useRef(null),Q=x.useRef("right"),te=x.useRef(0),ae=w?gm:x.Fragment,B=w?{as:wde,allowPinchZoom:!0}:void 0,Z=re=>{const ne=U.current+re,j=C().filter(W=>!W.disabled),V=document.activeElement,z=j.find(W=>W.ref.current===V)?.textValue,L=j.map(W=>W.textValue),$=Ode(L,ne,z),F=j.find(W=>W.textValue===$)?.ref.current;(function W(X){U.current=X,window.clearTimeout(M.current),X!==""&&(M.current=window.setTimeout(()=>W(""),1e3))})(ne),F&&setTimeout(()=>F.focus())};x.useEffect(()=>()=>window.clearTimeout(M.current),[]),py();const G=x.useCallback(re=>Q.current===K.current?.side&&jde(re,K.current?.area),[]);return f.jsx(bde,{scope:n,searchRef:U,onItemEnter:x.useCallback(re=>{G(re)&&re.preventDefault()},[G]),onItemLeave:x.useCallback(re=>{G(re)||(A.current?.focus(),I(null))},[G]),onTriggerLeave:x.useCallback(re=>{G(re)&&re.preventDefault()},[G]),pointerGraceTimerRef:H,onPointerGraceIntentChange:x.useCallback(re=>{K.current=re},[]),children:f.jsx(ae,{...B,children:f.jsx(fm,{asChild:!0,trapped:r,onMountAutoFocus:Ge(i,re=>{re.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:f.jsx(xd,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:d,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:v,children:f.jsx(wue,{asChild:!0,...k,dir:_.dir,orientation:"vertical",loop:a,currentTabStopId:R,onCurrentTabStopIdChange:I,onEntryFocus:Ge(u,re=>{_.isUsingKeyboardRef.current||re.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(yy,{role:"menu","aria-orientation":"vertical","data-state":j9(y.open),"data-radix-menu-content":"",dir:_.dir,...E,...S,ref:O,style:{outline:"none",...S.style},onKeyDown:Ge(S.onKeyDown,re=>{const j=re.target.closest("[data-radix-menu-content]")===re.currentTarget,V=re.ctrlKey||re.altKey||re.metaKey,z=re.key.length===1;j&&(re.key==="Tab"&&re.preventDefault(),!V&&z&&Z(re.key));const L=A.current;if(re.target!==L||!lde.includes(re.key))return;re.preventDefault();const F=C().filter(W=>!W.disabled).map(W=>W.ref.current);f9.includes(re.key)&&F.reverse(),Ade(F)}),onBlur:Ge(e.onBlur,re=>{re.currentTarget.contains(re.target)||(window.clearTimeout(M.current),U.current="")}),onPointerMove:Ge(e.onPointerMove,Tp(re=>{const ne=re.target,j=te.current!==re.clientX;if(re.currentTarget.contains(ne)&&j){const V=re.clientX>te.current?"right":"left";Q.current=V,te.current=re.clientX}}))})})})})})})});v9.displayName=Ja;var xde="MenuGroup",xN=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"group",...a,ref:t})});xN.displayName=xde;var Sde="MenuLabel",y9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{...a,ref:t})});y9.displayName=Sde;var ov="MenuItem",AU="menu.itemSelect",_y=x.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:a,...r}=e,i=x.useRef(null),s=vm(ov,e.__scopeMenu),c=yN(ov,e.__scopeMenu),u=Qt(t,i),d=x.useRef(!1),m=()=>{const h=i.current;if(!n&&h){const g=new CustomEvent(AU,{bubbles:!0,cancelable:!0});h.addEventListener(AU,v=>a?.(v),{once:!0}),NV(h,g),g.defaultPrevented?d.current=!1:s.onClose()}};return f.jsx(w9,{...r,ref:u,disabled:n,onClick:Ge(e.onClick,m),onPointerDown:h=>{e.onPointerDown?.(h),d.current=!0},onPointerUp:Ge(e.onPointerUp,h=>{d.current||h.currentTarget?.click()}),onKeyDown:Ge(e.onKeyDown,h=>{const g=c.searchRef.current!=="";n||g&&h.key===" "||kE.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});_y.displayName=ov;var w9=x.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:a=!1,textValue:r,...i}=e,s=yN(ov,n),c=m9(n),u=x.useRef(null),d=Qt(t,u),[m,h]=x.useState(!1),[g,v]=x.useState("");return x.useEffect(()=>{const w=u.current;w&&v((w.textContent??"").trim())},[i.children]),f.jsx(kp.ItemSlot,{scope:n,disabled:a,textValue:r??g,children:f.jsx(xue,{asChild:!0,...c,focusable:!a,children:f.jsx(Et.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":a||void 0,"data-disabled":a?"":void 0,...i,ref:d,onPointerMove:Ge(e.onPointerMove,Tp(w=>{a?s.onItemLeave(w):(s.onItemEnter(w),w.defaultPrevented||w.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ge(e.onPointerLeave,Tp(w=>s.onItemLeave(w))),onFocus:Ge(e.onFocus,()=>h(!0)),onBlur:Ge(e.onBlur,()=>h(!1))})})})}),Ede="MenuCheckboxItem",x9=x.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:a,...r}=e;return f.jsx(T9,{scope:e.__scopeMenu,checked:n,children:f.jsx(_y,{role:"menuitemcheckbox","aria-checked":sv(n)?"mixed":n,...r,ref:t,"data-state":EN(n),onSelect:Ge(r.onSelect,()=>a?.(sv(n)?!0:!n),{checkForDefaultPrevented:!1})})})});x9.displayName=Ede;var S9="MenuRadioGroup",[_de,kde]=Yl(S9,{value:void 0,onValueChange:()=>{}}),E9=x.forwardRef((e,t)=>{const{value:n,onValueChange:a,...r}=e,i=Gi(a);return f.jsx(_de,{scope:e.__scopeMenu,value:n,onValueChange:i,children:f.jsx(xN,{...r,ref:t})})});E9.displayName=S9;var _9="MenuRadioItem",k9=x.forwardRef((e,t)=>{const{value:n,...a}=e,r=kde(_9,e.__scopeMenu),i=n===r.value;return f.jsx(T9,{scope:e.__scopeMenu,checked:i,children:f.jsx(_y,{role:"menuitemradio","aria-checked":i,...a,ref:t,"data-state":EN(i),onSelect:Ge(a.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});k9.displayName=_9;var SN="MenuItemIndicator",[T9,Tde]=Yl(SN,{checked:!1}),N9=x.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:a,...r}=e,i=Tde(SN,n);return f.jsx(Ma,{present:a||sv(i.checked)||i.checked===!0,children:f.jsx(Et.span,{...r,ref:t,"data-state":EN(i.checked)})})});N9.displayName=SN;var Nde="MenuSeparator",C9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e;return f.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...a,ref:t})});C9.displayName=Nde;var Cde="MenuArrow",R9=x.forwardRef((e,t)=>{const{__scopeMenu:n,...a}=e,r=Ey(n);return f.jsx(wy,{...r,...a,ref:t})});R9.displayName=Cde;var Rde="MenuSub",[nTe,A9]=Yl(Rde),Hf="MenuSubTrigger",I9=x.forwardRef((e,t)=>{const n=ql(Hf,e.__scopeMenu),a=vm(Hf,e.__scopeMenu),r=A9(Hf,e.__scopeMenu),i=yN(Hf,e.__scopeMenu),s=x.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:u}=i,d={__scopeMenu:e.__scopeMenu},m=x.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return x.useEffect(()=>m,[m]),x.useEffect(()=>{const h=c.current;return()=>{window.clearTimeout(h),u(null)}},[c,u]),f.jsx(bN,{asChild:!0,...d,children:f.jsx(w9,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":r.contentId,"data-state":j9(n.open),...e,ref:Vi(t,r.onTriggerChange),onClick:h=>{e.onClick?.(h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ge(e.onPointerMove,Tp(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:Ge(e.onPointerLeave,Tp(h=>{m();const g=n.content?.getBoundingClientRect();if(g){const v=n.content?.dataset.side,w=v==="right",S=w?-5:5,y=g[w?"left":"right"],_=g[w?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+S,y:h.clientY},{x:y,y:g.top},{x:_,y:g.top},{x:_,y:g.bottom},{x:y,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:Ge(e.onKeyDown,h=>{const g=i.searchRef.current!=="";e.disabled||g&&h.key===" "||cde[a.dir].includes(h.key)&&(n.onOpenChange(!0),n.content?.focus(),h.preventDefault())})})})});I9.displayName=Hf;var O9="MenuSubContent",D9=x.forwardRef((e,t)=>{const n=g9(Ja,e.__scopeMenu),{forceMount:a=n.forceMount,...r}=e,i=ql(Ja,e.__scopeMenu),s=vm(Ja,e.__scopeMenu),c=A9(O9,e.__scopeMenu),u=x.useRef(null),d=Qt(t,u);return f.jsx(kp.Provider,{scope:e.__scopeMenu,children:f.jsx(Ma,{present:a||i.open,children:f.jsx(kp.Slot,{scope:e.__scopeMenu,children:f.jsx(wN,{id:c.contentId,"aria-labelledby":c.triggerId,...r,ref:d,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:Ge(e.onFocusOutside,m=>{m.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ge(e.onEscapeKeyDown,m=>{s.onClose(),m.preventDefault()}),onKeyDown:Ge(e.onKeyDown,m=>{const h=m.currentTarget.contains(m.target),g=ude[s.dir].includes(m.key);h&&g&&(i.onOpenChange(!1),c.trigger?.focus(),m.preventDefault())})})})})})});D9.displayName=O9;function j9(e){return e?"open":"closed"}function sv(e){return e==="indeterminate"}function EN(e){return sv(e)?"indeterminate":e?"checked":"unchecked"}function Ade(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ide(e,t){return e.map((n,a)=>e[(t+a)%e.length])}function Ode(e,t,n){const r=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let s=Ide(e,Math.max(i,0));r.length===1&&(s=s.filter(d=>d!==n));const u=s.find(d=>d.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function Dde(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],d=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-d)*(a-m)/(g-m)+d&&(r=!r)}return r}function jde(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Dde(n,t)}function Tp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Lde=h9,$de=bN,Mde=b9,Pde=v9,Ude=xN,zde=y9,Fde=_y,Bde=x9,Hde=E9,Vde=k9,Gde=N9,Wde=C9,Kde=R9,Zde=I9,Yde=D9,ky="DropdownMenu",[qde]=Ci(ky,[p9]),ra=p9(),[Xde,L9]=qde(ky),$9=e=>{const{__scopeDropdownMenu:t,children:n,dir:a,open:r,defaultOpen:i,onOpenChange:s,modal:c=!0}=e,u=ra(t),d=x.useRef(null),[m,h]=jo({prop:r,defaultProp:i??!1,onChange:s,caller:ky});return f.jsx(Xde,{scope:t,triggerId:Dr(),triggerRef:d,contentId:Dr(),open:m,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(g=>!g),[h]),modal:c,children:f.jsx(Lde,{...u,open:m,onOpenChange:h,dir:a,modal:c,children:n})})};$9.displayName=ky;var M9="DropdownMenuTrigger",P9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:a=!1,...r}=e,i=L9(M9,n),s=ra(n);return f.jsx($de,{asChild:!0,...s,children:f.jsx(Et.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:Vi(t,i.triggerRef),onPointerDown:Ge(e.onPointerDown,c=>{!a&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ge(e.onKeyDown,c=>{a||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});P9.displayName=M9;var Jde="DropdownMenuPortal",U9=e=>{const{__scopeDropdownMenu:t,...n}=e,a=ra(t);return f.jsx(Mde,{...a,...n})};U9.displayName=Jde;var z9="DropdownMenuContent",F9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=L9(z9,n),i=ra(n),s=x.useRef(!1);return f.jsx(Pde,{id:r.contentId,"aria-labelledby":r.triggerId,...i,...a,ref:t,onCloseAutoFocus:Ge(e.onCloseAutoFocus,c=>{s.current||r.triggerRef.current?.focus(),s.current=!1,c.preventDefault()}),onInteractOutside:Ge(e.onInteractOutside,c=>{const u=c.detail.originalEvent,d=u.button===0&&u.ctrlKey===!0,m=u.button===2||d;(!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)"}})});F9.displayName=z9;var Qde="DropdownMenuGroup",efe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Ude,{...r,...a,ref:t})});efe.displayName=Qde;var tfe="DropdownMenuLabel",B9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(zde,{...r,...a,ref:t})});B9.displayName=tfe;var nfe="DropdownMenuItem",H9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Fde,{...r,...a,ref:t})});H9.displayName=nfe;var rfe="DropdownMenuCheckboxItem",V9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Bde,{...r,...a,ref:t})});V9.displayName=rfe;var afe="DropdownMenuRadioGroup",ife=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Hde,{...r,...a,ref:t})});ife.displayName=afe;var ofe="DropdownMenuRadioItem",G9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Vde,{...r,...a,ref:t})});G9.displayName=ofe;var sfe="DropdownMenuItemIndicator",lfe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Gde,{...r,...a,ref:t})});lfe.displayName=sfe;var cfe="DropdownMenuSeparator",W9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Wde,{...r,...a,ref:t})});W9.displayName=cfe;var ufe="DropdownMenuArrow",dfe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Kde,{...r,...a,ref:t})});dfe.displayName=ufe;var ffe="DropdownMenuSubTrigger",K9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Zde,{...r,...a,ref:t})});K9.displayName=ffe;var pfe="DropdownMenuSubContent",Z9=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...a}=e,r=ra(n);return f.jsx(Yde,{...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)"}})});Z9.displayName=pfe;var mfe=$9,hfe=P9,gfe=U9,Y9=F9,q9=B9,X9=H9,bfe=V9,vfe=G9,J9=W9,yfe=K9,wfe=Z9;const TE=mfe,NE=hfe;yfe.displayName;wfe.displayName;function lv({ref:e,className:t,sideOffset:n=4,...a}){return f.jsx(gfe,{children:f.jsx(Y9,{ref:e,sideOffset:n,className:De("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})})}lv.displayName=Y9.displayName;function To({ref:e,className:t,inset:n,...a}){return f.jsx(X9,{ref:e,className:De("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",t),...a})}To.displayName=X9.displayName;bfe.displayName;vfe.displayName;function CE({ref:e,className:t,inset:n,...a}){return f.jsx(q9,{ref:e,className:De("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",t),...a})}CE.displayName=q9.displayName;function Vf({ref:e,className:t,...n}){return f.jsx(J9,{ref:e,className:De("-mx-1 my-1 h-px bg-muted",t),...n})}Vf.displayName=J9.displayName;var xfe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ho=xfe.reduce((e,t)=>{const n=cV(`Primitive.${t}`),a=x.forwardRef((r,i)=>{const{asChild:s,...c}=r,u=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(u,{...c,ref:i})});return a.displayName=`Primitive.${t}`,{...e,[t]:a}},{}),Sfe="Label",Q9=x.forwardRef((e,t)=>f.jsx(Ho.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Q9.displayName=Sfe;var Efe=Q9;function Kt({className:e,...t}){return f.jsx(Efe,{"data-slot":"label",className:De("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}function kd({message:e,className:t="",vertical:n,noBorder:a}){return f.jsx("div",{className:De(`mt-2 rounded-md p-6 ${t}`,!a&&"border"),children:f.jsxs("p",{className:De("text-sm text-muted-foreground flex items-center gap-4",n&&"flex-col"),children:[f.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:f.jsx("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:f.jsxs("g",{transform:"translate(5.320900, 5.320900)",fillRule:"nonzero",className:"stroke-black dark:stroke-white",strokeWidth:"4",children:[f.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"}),f.jsx("circle",{cx:"50",cy:"212.0001",r:"52.5"}),f.jsx("circle",{cx:"212.0001",cy:"50",r:"52.5"})]})})}),e]})})}function e8({className:e,color:t,children:n,grayscaled:a=!1}){const r=x.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=x.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=x.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=x.useMemo(()=>t||`oklch(${Math.min(i,1)} ${r} ${s})`,[s,r,i]),u=x.useMemo(()=>`oklch(${Math.min(i*2,1)} ${r} ${s})`,[s,r,i,t]),d=x.useMemo(()=>Math.floor(Math.random()*360),[s]),m=x.useMemo(()=>"1000%",[]);return f.jsx("section",{className:De("relative w-full h-full overflow-hidden",e),style:{background:`${u}`},children:f.jsxs("div",{className:"isolate relative w-full h-full",children:[f.jsx("div",{className:"noise w-full h-full",style:{background:`linear-gradient(${d}deg, ${c}, transparent), url(https://grainy-gradients.vercel.app/noise.svg)`,filter:`contrast(120%) brightness(${m})`}}),n&&f.jsx("div",{className:"relative z-10 w-full h-full",children:n})]})})}function _N(e){const t=x.useRef({value:e,previous:e});return x.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Ty="Switch",[_fe]=Ci(Ty),[kfe,Tfe]=_fe(Ty),t8=x.forwardRef((e,t)=>{const{__scopeSwitch:n,name:a,checked:r,defaultChecked:i,required:s,disabled:c,value:u="on",onCheckedChange:d,form:m,...h}=e,[g,v]=x.useState(null),w=Qt(t,k=>v(k)),S=x.useRef(!1),y=g?m||!!g.closest("form"):!0,[_,E]=jo({prop:r,defaultProp:i??!1,onChange:d,caller:Ty});return f.jsxs(kfe,{scope:n,checked:_,disabled:c,children:[f.jsx(Et.button,{type:"button",role:"switch","aria-checked":_,"aria-required":s,"data-state":i8(_),"data-disabled":c?"":void 0,disabled:c,value:u,...h,ref:w,onClick:Ge(e.onClick,k=>{E(C=>!C),y&&(S.current=k.isPropagationStopped(),S.current||k.stopPropagation())})}),y&&f.jsx(a8,{control:g,bubbles:!S.current,name:a,value:u,checked:_,required:s,disabled:c,form:m,style:{transform:"translateX(-100%)"}})]})});t8.displayName=Ty;var n8="SwitchThumb",r8=x.forwardRef((e,t)=>{const{__scopeSwitch:n,...a}=e,r=Tfe(n8,n);return f.jsx(Et.span,{"data-state":i8(r.checked),"data-disabled":r.disabled?"":void 0,...a,ref:t})});r8.displayName=n8;var Nfe="SwitchBubbleInput",a8=x.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:a=!0,...r},i)=>{const s=x.useRef(null),c=Qt(s,i),u=_N(n),d=mN(t);return x.useEffect(()=>{const m=s.current;if(!m)return;const h=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==n&&v){const w=new Event("click",{bubbles:a});v.call(m,n),m.dispatchEvent(w)}},[u,n,a]),f.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...r,tabIndex:-1,ref:c,style:{...r.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});a8.displayName=Nfe;function i8(e){return e?"checked":"unchecked"}var o8=t8,Cfe=r8;function Ny({ref:e,className:t,...n}){return f.jsx(o8,{className:De("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...n,ref:e,children:f.jsx(Cfe,{className:De("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})})}Ny.displayName=o8.displayName;var s8=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"}),Rfe="VisuallyHidden",l8=x.forwardRef((e,t)=>f.jsx(Et.span,{...e,ref:t,style:{...s8,...e.style}}));l8.displayName=Rfe;var Afe=l8,[Cy]=Ci("Tooltip",[Hs]),Ry=Hs(),c8="TooltipProvider",Ife=700,RE="tooltip.open",[Ofe,kN]=Cy(c8),u8=e=>{const{__scopeTooltip:t,delayDuration:n=Ife,skipDelayDuration:a=300,disableHoverableContent:r=!1,children:i}=e,s=x.useRef(!0),c=x.useRef(!1),u=x.useRef(0);return x.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),f.jsx(Ofe,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:x.useCallback(()=>{window.clearTimeout(u.current),s.current=!1},[]),onClose:x.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>s.current=!0,a)},[a]),isPointerInTransitRef:c,onPointerInTransitChange:x.useCallback(d=>{c.current=d},[]),disableHoverableContent:r,children:i})};u8.displayName=c8;var Np="Tooltip",[Dfe,ym]=Cy(Np),d8=e=>{const{__scopeTooltip:t,children:n,open:a,defaultOpen:r,onOpenChange:i,disableHoverableContent:s,delayDuration:c}=e,u=kN(Np,e.__scopeTooltip),d=Ry(t),[m,h]=x.useState(null),g=Dr(),v=x.useRef(0),w=s??u.disableHoverableContent,S=c??u.delayDuration,y=x.useRef(!1),[_,E]=jo({prop:a,defaultProp:r??!1,onChange:A=>{A?(u.onOpen(),document.dispatchEvent(new CustomEvent(RE))):u.onClose(),i?.(A)},caller:Np}),k=x.useMemo(()=>_?y.current?"delayed-open":"instant-open":"closed",[_]),C=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,y.current=!1,E(!0)},[E]),R=x.useCallback(()=>{window.clearTimeout(v.current),v.current=0,E(!1)},[E]),I=x.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{y.current=!0,E(!0),v.current=0},S)},[S,E]);return x.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),f.jsx(vy,{...d,children:f.jsx(Dfe,{scope:t,contentId:g,open:_,stateAttribute:k,trigger:m,onTriggerChange:h,onTriggerEnter:x.useCallback(()=>{u.isOpenDelayedRef.current?I():C()},[u.isOpenDelayedRef,I,C]),onTriggerLeave:x.useCallback(()=>{w?R():(window.clearTimeout(v.current),v.current=0)},[R,w]),onOpen:C,onClose:R,disableHoverableContent:w,children:n})})};d8.displayName=Np;var AE="TooltipTrigger",f8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=ym(AE,n),i=kN(AE,n),s=Ry(n),c=x.useRef(null),u=Qt(t,c,r.onTriggerChange),d=x.useRef(!1),m=x.useRef(!1),h=x.useCallback(()=>d.current=!1,[]);return x.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),f.jsx(mm,{asChild:!0,...s,children:f.jsx(Et.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...a,ref:u,onPointerMove:Ge(e.onPointerMove,g=>{g.pointerType!=="touch"&&!m.current&&!i.isPointerInTransitRef.current&&(r.onTriggerEnter(),m.current=!0)}),onPointerLeave:Ge(e.onPointerLeave,()=>{r.onTriggerLeave(),m.current=!1}),onPointerDown:Ge(e.onPointerDown,()=>{r.open&&r.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Ge(e.onFocus,()=>{d.current||r.onOpen()}),onBlur:Ge(e.onBlur,r.onClose),onClick:Ge(e.onClick,r.onClose)})})});f8.displayName=AE;var TN="TooltipPortal",[jfe,Lfe]=Cy(TN,{forceMount:void 0}),p8=e=>{const{__scopeTooltip:t,forceMount:n,children:a,container:r}=e,i=ym(TN,t);return f.jsx(jfe,{scope:t,forceMount:n,children:f.jsx(Ma,{present:n||i.open,children:f.jsx(_d,{asChild:!0,container:r,children:a})})})};p8.displayName=TN;var td="TooltipContent",m8=x.forwardRef((e,t)=>{const n=Lfe(td,e.__scopeTooltip),{forceMount:a=n.forceMount,side:r="top",...i}=e,s=ym(td,e.__scopeTooltip);return f.jsx(Ma,{present:a||s.open,children:s.disableHoverableContent?f.jsx(h8,{side:r,...i,ref:t}):f.jsx($fe,{side:r,...i,ref:t})})}),$fe=x.forwardRef((e,t)=>{const n=ym(td,e.__scopeTooltip),a=kN(td,e.__scopeTooltip),r=x.useRef(null),i=Qt(t,r),[s,c]=x.useState(null),{trigger:u,onClose:d}=n,m=r.current,{onPointerInTransitChange:h}=a,g=x.useCallback(()=>{c(null),h(!1)},[h]),v=x.useCallback((w,S)=>{const y=w.currentTarget,_={x:w.clientX,y:w.clientY},E=zfe(_,y.getBoundingClientRect()),k=Ffe(_,E),C=Bfe(S.getBoundingClientRect()),R=Vfe([...k,...C]);c(R),h(!0)},[h]);return x.useEffect(()=>()=>g(),[g]),x.useEffect(()=>{if(u&&m){const w=y=>v(y,m),S=y=>v(y,u);return u.addEventListener("pointerleave",w),m.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",w),m.removeEventListener("pointerleave",S)}}},[u,m,v,g]),x.useEffect(()=>{if(s){const w=S=>{const y=S.target,_={x:S.clientX,y:S.clientY},E=u?.contains(y)||m?.contains(y),k=!Hfe(_,s);E?g():k&&(g(),d())};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)}},[u,m,s,d,g]),f.jsx(h8,{...e,ref:i})}),[Mfe,Pfe]=Cy(Np,{isInside:!1}),Ufe=yle("TooltipContent"),h8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,children:a,"aria-label":r,onEscapeKeyDown:i,onPointerDownOutside:s,...c}=e,u=ym(td,n),d=Ry(n),{onClose:m}=u;return x.useEffect(()=>(document.addEventListener(RE,m),()=>document.removeEventListener(RE,m)),[m]),x.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]),f.jsx(xd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:h=>h.preventDefault(),onDismiss:m,children:f.jsxs(yy,{"data-state":u.stateAttribute,...d,...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:[f.jsx(Ufe,{children:a}),f.jsx(Mfe,{scope:n,isInside:!0,children:f.jsx(Afe,{id:u.contentId,role:"tooltip",children:r||a})})]})})});m8.displayName=td;var g8="TooltipArrow",b8=x.forwardRef((e,t)=>{const{__scopeTooltip:n,...a}=e,r=Ry(n);return Pfe(g8,n).isInside?null:f.jsx(wy,{...r,...a,ref:t})});b8.displayName=g8;function zfe(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 Ffe(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 Bfe(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 Hfe(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],d=c.x,m=c.y,h=u.x,g=u.y;m>a!=g>a&&n<(h-d)*(a-m)/(g-m)+d&&(r=!r)}return r}function Vfe(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),Gfe(t)}function Gfe(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 Wfe=u8,Kfe=d8,Zfe=f8,Yfe=p8,qfe=m8,Xfe=b8;function v8({delayDuration:e=0,...t}){return f.jsx(Wfe,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Dt({...e}){return f.jsx(v8,{children:f.jsx(Kfe,{"data-slot":"tooltip",...e})})}function jt({...e}){return f.jsx(Zfe,{"data-slot":"tooltip-trigger",...e})}function Lt({className:e,sideOffset:t=0,children:n,...a}){return f.jsx(Yfe,{children:f.jsxs(qfe,{"data-slot":"tooltip-content",sideOffset:t,className:De("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...a,children:[n,f.jsx(Xfe,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}class Jfe{name="mcp_inspector_open";properties;constructor(t){this.properties={server_url:t.serverUrl,connection_count:t.connectionCount}}}class IU{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 OU{name="mcp_resource_read";properties;constructor(t){this.properties={resource_uri:t.resourceUri,server_id:t.serverId,success:t.success,error:t.error}}}class DU{name="mcp_prompt_call";properties;constructor(t){this.properties={prompt_name:t.promptName,server_id:t.serverId,success:t.success,error:t.error}}}class jU{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 Qfe{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 epe{name="mcp_server_removed";properties;constructor(t){this.properties={server_id:t.serverId}}}class tpe{name="mcp_command_palette_open";properties;constructor(t){this.properties={trigger:t.trigger}}}class npe{name="mcp_tool_saved";properties;constructor(t){this.properties={tool_name:t.toolName,server_id:t.serverId}}}function tS(){try{return"0.12.5"}catch{return"0.0.0"}}var rpe={};function nS(){try{return typeof window<"u"&&typeof document<"u"}catch{return!1}}class LU{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 bs(e){return`mcp_inspector_telemetry_${e}`}class yr{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=nS(),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 LU(this.POSTHOG_PROXY_URL,3e3)}catch{this._posthogClient=null}try{this._scarfClient=new LU(this.SCARF_PROXY_URL,3e3)}catch{this._scarfClient=null}}}isTelemetryDisabled(){return typeof localStorage<"u"&&localStorage.getItem(bs("disabled"))==="true"||typeof process<"u"&&rpe?.MCP_USE_ANONYMIZED_TELEMETRY==="false"}getStoredSource(){return typeof localStorage<"u"?localStorage.getItem(bs("source")):null}static getInstance(){return yr.instance||(yr.instance=new yr),yr.instance}setSource(t){this._source=t,typeof localStorage<"u"&&localStorage.setItem(bs("source"),t)}getSource(){return this._source}get userId(){if(this._currUserId)return this._currUserId;if(!nS())return this._currUserId=this.UNKNOWN_USER_ID,this._currUserId;try{const t=localStorage.getItem(bs("user_id"));if(t)this._currUserId=t;else{const n=this.generateUserId();localStorage.setItem(bs("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(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=Math.random()*16|0;return(t==="x"?n:n&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:tS(),language:"typescript",source:this._source,package:"inspector"}};await this._posthogClient.logEvent(n)}catch{}if(this._scarfClient)try{const n={};n.mcp_use_version=tS(),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&&nS())try{const n=tS();let a=!1,r=!1;const i=localStorage.getItem(bs("download_version"));if(i?n>i&&(a=!0,r=!1,localStorage.setItem(bs("download_version"),n)):(a=!0,r=!0,localStorage.setItem(bs("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 Jfe(t);await this.capture(n)}}const ape={model:"stub-model",stopReason:"endTurn",role:"assistant",content:{type:"text",text:"positive"}};function ipe({requestId:e,serverName:t,onViewDetails:n,onApprove:a,onDeny:r}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Sampling Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["New request from ",t]})]}),f.jsxs("div",{className:"flex gap-2",children:[f.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"}),f.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(ape)},children:"Approve"}),f.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 ope({requestId:e,serverName:t,mode:n,message:a,url:r,onViewDetails:i,onOpenUrl:s,onCancel:c}){return f.jsxs("div",{className:"space-y-3",children:[f.jsxs("div",{children:[f.jsx("strong",{children:"Elicitation Request Received"}),f.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["From ",t,": ",a]}),n==="url"&&r&&f.jsx("p",{className:"text-xs text-muted-foreground mt-1 font-mono",children:r})]}),f.jsxs("div",{className:"flex gap-2 flex-wrap",children:[f.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&&f.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"}),f.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"})]})]})}const Wg=()=>{},Kg=()=>{},Zg=()=>{},Yg=()=>{},y8=x.createContext(null);function NN(){const e=x.use(y8);if(!e)throw new Error("useMcpContext must be used within a McpProvider");return e}function spe({url:e,name:t,proxyConfig:n,transportType:a,connectionId:r,onUpdate:i,onRemove:s}){const c=typeof window<"u"?new URL("/inspector/oauth/callback",window.location.origin).toString():"/inspector/oauth/callback";let u=e,d={};if(n?.proxyAddress){const L=new URL(n.proxyAddress),$=new URL(e);u=`${L.origin}${L.pathname}${$.pathname}${$.search}`,d["X-Target-URL"]=e}n?.customHeaders&&(d={...d,...n.customHeaders});const[m,h]=x.useState([]),g=x.useRef(0),[v,w]=x.useState([]),S=x.useRef(0),y=x.useMemo(()=>m.map(L=>({id:L.id,request:L.request,timestamp:L.timestamp,serverName:L.serverName})),[m]),_=x.useMemo(()=>v.map(L=>({id:L.id,request:L.request,timestamp:L.timestamp,serverName:L.serverName})),[v]),E=x.useRef(null),[k,C]=x.useState(!1),R=x.useRef(!1);x.useEffect(()=>{typeof window<"u"&&!R.current&&(R.current=!0,Qn(()=>import("./transport-wrapper-browser-BI4dDu3b.js"),[]).then(L=>{E.current=L.wrapTransportForLogging,C(!0),console.log("[McpContext] Transport wrapper loaded")}).catch(L=>{console.error("[McpContext] Failed to load transport wrapper:",L)}))},[]);const I=x.useMemo(()=>{if(!(!k||!E.current))return(L,$)=>{const F=r;return console.log("[McpContext] Applying transport wrapper, serverId:",F,"from connector:",$),E.current(L,F)}},[k,r]),A=`mcp-inspector-notifications-${r}`,O=500,[M,U]=x.useState([]);x.useEffect(()=>{try{const L=localStorage.getItem(A);if(L){const $=JSON.parse(L);Array.isArray($)&&U($)}}catch(L){console.error("Failed to load notifications from localStorage:",L)}},[A]),x.useEffect(()=>{try{localStorage.setItem(A,JSON.stringify(M))}catch(L){console.error("Failed to save notifications to localStorage:",L)}},[M,A]);const H=x.useCallback(L=>{U($=>$.map(F=>F.id===L?{...F,read:!0}:F))},[]),K=x.useCallback(()=>{U(L=>L.map($=>({...$,read:!0})))},[]),Q=x.useCallback(()=>{U([])},[]),te=x.useCallback(L=>{U($=>{const F=[L,...$];return F.length>O?F.slice(0,O):F})},[]),ae=x.useCallback((L,$)=>{h(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),B=x.useCallback((L,$)=>{h(F=>{const W=F.find(X=>X.id===L);return W?(W.reject(new Error($||"User rejected sampling request")),F.filter(X=>X.id!==L)):F})},[]),Z=x.useCallback((L,$)=>{w(F=>{const W=F.find(X=>X.id===L);return W?(W.resolve($),F.filter(X=>X.id!==L)):F})},[]),G=x.useCallback((L,$)=>{w(F=>{const W=F.find(X=>X.id===L);return W?(W.reject(new Error($||"User rejected elicitation request")),F.filter(X=>X.id!==L)):F})},[]),re=x.useCallback(async L=>new Promise(($,F)=>{const W=`sampling-${g.current++}`,X={id:W,request:{params:L},timestamp:Date.now(),serverName:t,resolve:$,reject:F};h(ie=>[...ie,X]),typeof window<"u"&&Qn(async()=>{const{toast:ie}=await Promise.resolve().then(()=>BU);return{toast:ie}},void 0).then(({toast:ie})=>{const le=ie(f.jsx(ipe,{requestId:W,serverName:t,onViewDetails:()=>{const J=new globalThis.CustomEvent("navigate-to-sampling",{detail:{requestId:W}});window.dispatchEvent(J),ie.dismiss(le)},onApprove:J=>{h(q=>{const se=q.find(he=>he.id===W);return se?(se.resolve(J),ie.success("Sampling request approved"),q.filter(he=>he.id!==W)):q}),ie.dismiss(le)},onDeny:()=>{h(J=>{const q=J.find(se=>se.id===W);return q?(q.reject(new Error("User denied sampling request from toast")),ie.error("Sampling request denied"),J.filter(se=>se.id!==W)):J}),ie.dismiss(le)}}),{duration:5e3})})}),[t]),ne=x.useCallback(async L=>new Promise(($,F)=>{const W=`elicitation-${S.current++}`,X={id:W,request:L,timestamp:Date.now(),serverName:t,resolve:$,reject:F};w(ie=>[...ie,X]),typeof window<"u"&&Qn(async()=>{const{toast:ie}=await Promise.resolve().then(()=>BU);return{toast:ie}},void 0).then(({toast:ie})=>{const le=ie(f.jsx(ope,{requestId:W,serverName:t,mode:L.mode||"form",message:L.message,url:L.mode==="url"?L.url:void 0,onViewDetails:()=>{const J=new globalThis.CustomEvent("navigate-to-elicitation",{detail:{requestId:W}});window.dispatchEvent(J),ie.dismiss(le)},onOpenUrl:L.mode==="url"?()=>{window.open(L.url,"_blank"),ie.dismiss(le)}:void 0,onCancel:()=>{w(J=>{const q=J.find(se=>se.id===W);return q?(q.reject(new Error("User cancelled elicitation request from toast")),ie.error("Elicitation request cancelled"),J.filter(se=>se.id!==W)):J}),ie.dismiss(le)}}),{duration:5e3})})}),[t]),j=QT({url:u,callbackUrl:c,customHeaders:Object.keys(d).length>0?d:void 0,transportType:a||"http",preventAutoAuth:!0,useRedirectFlow:!0,enabled:k,wrapTransport:I,onNotification:L=>{te({id:globalThis.crypto.randomUUID(),method:L.method,params:L.params,timestamp:Date.now(),read:!1})},samplingCallback:re,onElicitation:ne}),V=x.useRef(i),z=x.useRef(null);return x.useEffect(()=>{V.current=i},[i]),x.useEffect(()=>{if(typeof queueMicrotask<"u")queueMicrotask(()=>{j.state==="ready"&&j.serverInfo&&console.log("[McpContext] Server info available:",j.serverInfo);const L=M.filter(W=>!W.read).length,$={id:r,url:e,name:j.serverInfo?.name||t,state:j.state,tools:j.tools,resources:j.resources,prompts:j.prompts,error:j.error??null,authUrl:j.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:j.serverInfo,capabilities:j.capabilities,notifications:M,unreadNotificationCount:L,markNotificationRead:H,markAllNotificationsRead:K,clearNotifications:Q,pendingSamplingRequests:y,approveSampling:ae,rejectSampling:B,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:j.callTool,readResource:j.readResource,listPrompts:j.listPrompts,getPrompt:j.getPrompt,authenticate:j.authenticate,retry:j.retry,clearStorage:j.clearStorage,disconnect:j.disconnect,client:j.client},F=z.current;(!F||F.state!==$.state||F.error!==$.error||F.authUrl!==$.authUrl||F.name!==$.name||F.tools.length!==$.tools.length||F.resources.length!==$.resources.length||F.prompts.length!==$.prompts.length||F.serverInfo!==$.serverInfo||F.capabilities!==$.capabilities||F.notifications.length!==$.notifications.length||F.unreadNotificationCount!==$.unreadNotificationCount||F.pendingSamplingRequests.length!==$.pendingSamplingRequests.length||F.pendingElicitationRequests.length!==$.pendingElicitationRequests.length||!F.client)&&(z.current=$,V.current($))});else{const L=M.filter(W=>!W.read).length,$={id:r,url:e,name:j.serverInfo?.name||t,state:j.state,tools:j.tools,resources:j.resources,prompts:j.prompts,error:j.error??null,authUrl:j.authUrl??null,customHeaders:d,transportType:a,proxyConfig:n,serverInfo:j.serverInfo,capabilities:j.capabilities,notifications:M,unreadNotificationCount:L,markNotificationRead:H,markAllNotificationsRead:K,clearNotifications:Q,pendingSamplingRequests:y,approveSampling:ae,rejectSampling:B,pendingElicitationRequests:_,approveElicitation:Z,rejectElicitation:G,callTool:j.callTool,readResource:j.readResource,listPrompts:j.listPrompts,getPrompt:j.getPrompt,authenticate:j.authenticate,retry:j.retry,clearStorage:j.clearStorage,disconnect:j.disconnect,client:j.client},F=z.current;(!F||F.state!==$.state||F.error!==$.error||F.authUrl!==$.authUrl||F.name!==$.name||F.tools.length!==$.tools.length||F.resources.length!==$.resources.length||F.prompts.length!==$.prompts.length||F.serverInfo!==$.serverInfo||F.capabilities!==$.capabilities||F.notifications.length!==$.notifications.length||F.unreadNotificationCount!==$.unreadNotificationCount||F.pendingSamplingRequests.length!==$.pendingSamplingRequests.length||F.pendingElicitationRequests.length!==$.pendingElicitationRequests.length||!F.client)&&(z.current=$,V.current($))}},[e,t,a,n,d,r,j.state,j.tools,j.resources,j.prompts,j.error,j.authUrl,j.serverInfo,j.capabilities,j.client,M,H,K,Q,j.callTool,j.readResource,j.listPrompts,j.getPrompt,j.authenticate,j.retry,j.clearStorage,m,ae,B,_,Z,G]),null}function lpe({children:e}){const[t,n]=x.useState([]),[a,r]=x.useState(!1),[i,s]=x.useState(!0),[c,u]=x.useState([]);x.useEffect(()=>{try{const y=localStorage.getItem("mcp-inspector-connections");if(y){const E=JSON.parse(y);Array.isArray(E)&&(u(E),n(E.map(k=>({id:k.id||k.url,url:k.url,name:k.name||"MCP Server",state:"discovering",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:k.proxyConfig?.customHeaders,transportType:k.transportType,proxyConfig:k.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Wg,rejectSampling:Kg,pendingElicitationRequests:[],approveElicitation:Zg,rejectElicitation:Yg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}))))}const _=localStorage.getItem("mcp-inspector-auto-connect");_!==null&&s(_==="true")}catch(y){console.error("Failed to load connections from localStorage:",y)}finally{r(!0)}},[]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-connections",JSON.stringify(c))},[c,a]),x.useEffect(()=>{a&&localStorage.setItem("mcp-inspector-auto-connect",String(i))},[i,a]);const d=x.useCallback((y,_,E,k)=>{const C=c.find(A=>A.url===y),R=t.find(A=>A.url===y);if(C&&R){if(JSON.stringify(C.proxyConfig)!==JSON.stringify(E)&&E){u(O=>O.filter(M=>M.url!==y)),n(O=>O.filter(M=>M.url!==y)),setTimeout(()=>{const O={id:y,url:y,name:_||C.name||"MCP Server",proxyConfig:E,transportType:k||C.transportType};u(M=>[...M,O]),n(M=>[...M,{id:y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k||C.transportType,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Wg,rejectSampling:Kg,pendingElicitationRequests:[],approveElicitation:Zg,rejectElicitation:Yg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},10);return}return}if(C&&!R){(E||k)&&u(A=>A.map(O=>O.url===y?{...O,proxyConfig:E||O.proxyConfig,transportType:k||O.transportType,name:_||O.name}:O)),n(A=>[...A,{id:C.id||y,url:y,name:_||C.name||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders||C.proxyConfig?.customHeaders,transportType:k||C.transportType,proxyConfig:E||C.proxyConfig,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Wg,rejectSampling:Kg,pendingElicitationRequests:[],approveElicitation:Zg,rejectElicitation:Yg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}]);return}const I={id:y,url:y,name:_||"MCP Server",proxyConfig:E,transportType:k};u(A=>[...A,I]),n(A=>[...A,{id:y,url:y,name:_||"MCP Server",state:"connecting",tools:[],resources:[],prompts:[],error:null,authUrl:null,customHeaders:E?.customHeaders,transportType:k,proxyConfig:E,notifications:[],unreadNotificationCount:0,markNotificationRead:()=>{},markAllNotificationsRead:()=>{},clearNotifications:()=>{},pendingSamplingRequests:[],approveSampling:Wg,rejectSampling:Kg,pendingElicitationRequests:[],approveElicitation:Zg,rejectElicitation:Yg,callTool:async()=>{},readResource:async()=>{},listPrompts:async()=>{},getPrompt:async()=>{},authenticate:()=>{},retry:()=>{},clearStorage:()=>{},disconnect:()=>{},client:null}])},[c,t]),m=x.useCallback(y=>{const _=t.find(k=>k.id===y);_&&(console.log(`[McpContext] Cleaning up connection: ${y}`),_.disconnect&&(console.log(`[McpContext] Disconnecting from server: ${y}`),_.disconnect()),_.clearStorage&&(console.log(`[McpContext] Clearing OAuth storage for connection: ${y}`),_.clearStorage())),u(k=>k.filter(C=>C.id!==y)),n(k=>k.filter(C=>C.id!==y));const E=localStorage.getItem("mcp-inspector-connections");if(E)try{const C=JSON.parse(E).filter(R=>(R.id||R.url)!==y);localStorage.setItem("mcp-inspector-connections",JSON.stringify(C))}catch(k){console.error("Failed to update localStorage on remove:",k)}yr.getInstance().capture(new epe({serverId:y}))},[t]),h=x.useCallback((y,_)=>{u(E=>E.map(k=>k.id===y||k.url===y?{...k,..._}:k)),n(E=>E.map(k=>k.id===y?{...k,..._}:k))},[]),g=x.useCallback(y=>{n(_=>{const E=_.findIndex(R=>R.id===y.id);if(E===-1)return _;const k=_[E];if(k.state===y.state&&k.tools===y.tools&&k.resources===y.resources&&k.prompts===y.prompts&&k.error===y.error&&k.serverInfo===y.serverInfo&&k.client===y.client&&k.notifications===y.notifications&&k.unreadNotificationCount===y.unreadNotificationCount&&k.pendingSamplingRequests.length===y.pendingSamplingRequests.length&&k.pendingElicitationRequests.length===y.pendingElicitationRequests.length)return _;const C=[..._];return C[E]=y,C})},[]),v=x.useCallback(y=>{console.log("Connect requested for:",y)},[]),w=x.useCallback(y=>{console.log("Disconnect requested for:",y)},[]),S=x.useMemo(()=>({connections:t,addConnection:d,removeConnection:m,updateConnectionConfig:h,autoConnect:i,setAutoConnect:s,connectServer:v,disconnectServer:w,configLoaded:a}),[t,d,m,h,i,v,w,a]);return f.jsxs(y8.Provider,{value:S,children:[e,a&&i&&c.map(y=>{const _=`${y.id||y.url}-${y.proxyConfig?.proxyAddress?"proxy":"direct"}`;return console.warn("[McpContext] Rendering McpConnectionWrapper with key:",_,"proxyConfig:",y.proxyConfig),f.jsx(spe,{url:y.url,name:y.name,proxyConfig:y.proxyConfig,transportType:y.transportType,connectionId:y.id||y.url,onUpdate:g,onRemove:()=>m(y.id||y.url)},_)})]})}const cpe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),upe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,a)=>a?a.toUpperCase():n.toLowerCase()),$U=e=>{const t=upe(e);return t.charAt(0).toUpperCase()+t.slice(1)},w8=(...e)=>e.filter((t,n,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===n).join(" ").trim(),dpe=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var fpe={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 ppe=x.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:a,className:r="",children:i,iconNode:s,...c},u)=>x.createElement("svg",{ref:u,...fpe,width:t,height:t,stroke:e,strokeWidth:a?Number(n)*24/Number(t):n,className:w8("lucide",r),...!i&&!dpe(c)&&{"aria-hidden":"true"},...c},[...s.map(([d,m])=>x.createElement(d,m)),...Array.isArray(i)?i:[i]]));const Xe=(e,t)=>{const n=x.forwardRef(({className:a,...r},i)=>x.createElement(ppe,{ref:i,iconNode:t,className:w8(`lucide-${cpe($U(e))}`,`lucide-${e}`,a),...r}));return n.displayName=$U(e),n};const mpe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],hpe=Xe("arrow-down-to-line",mpe);const gpe=[["path",{d:"m18 9-6-6-6 6",key:"kcunyi"}],["path",{d:"M12 3v14",key:"7cf3v8"}],["path",{d:"M5 21h14",key:"11awu3"}]],bpe=Xe("arrow-up-from-line",gpe);const vpe=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ype=Xe("arrow-up",vpe);const wpe=[["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"}]],CN=Xe("bell",wpe);const xpe=[["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"}]],x8=Xe("brush",xpe);const Spe=[["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"}]],Epe=Xe("bug",Spe);const _pe=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ta=Xe("check",_pe);const kpe=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Xl=Xe("chevron-down",kpe);const Tpe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Npe=Xe("chevron-right",Tpe);const Cpe=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],RN=Xe("chevron-left",Cpe);const Rpe=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ape=Xe("chevron-up",Rpe);const Ipe=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Ope=Xe("chevrons-up-down",Ipe);const Dpe=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],MU=Xe("circle-minus",Dpe);const jpe=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],nd=Xe("clock",jpe);const Lpe=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],AN=Xe("code",Lpe);const $pe=[["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"}]],Mpe=Xe("cog",$pe);const Ppe=[["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"}]],Upe=Xe("command",Ppe);const zpe=[["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"}]],jr=Xe("copy",zpe);const Fpe=[["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"}]],Ay=Xe("database",Fpe);const Bpe=[["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"}]],wm=Xe("download",Bpe);const Hpe=[["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"}]],Vpe=Xe("ellipsis-vertical",Hpe);const Gpe=[["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"}]],IE=Xe("external-link",Gpe);const Wpe=[["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"}]],S8=Xe("eye-off",Wpe);const Kpe=[["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"}]],OE=Xe("eye",Kpe);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"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Ype=Xe("file-code",Zpe);const qpe=[["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"}]],Xpe=Xe("file-image",qpe);const Jpe=[["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"}]],IN=Xe("file-text",Jpe);const Qpe=[["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"}]],eme=Xe("file",Qpe);const tme=[["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"}]],nme=Xe("folder-open",tme);const rme=[["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"}]],ame=Xe("globe",rme);const ime=[["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"}]],ome=Xe("grip-vertical",ime);const sme=[["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"}]],E8=Xe("hash",sme);const lme=[["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"}]],cv=Xe("history",lme);const cme=[["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"}]],_8=Xe("key",cme);const ume=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ls=Xe("loader-circle",ume);const dme=[["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"}]],ON=Xe("maximize-2",dme);const fme=[["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"}]],DN=Xe("maximize",fme);const pme=[["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"}]],mme=Xe("message-circle",pme);const hme=[["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"}]],Cp=Xe("message-square",hme);const gme=[["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"}]],bme=Xe("minimize",gme);const vme=[["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=Xe("monitor",vme);const yme=[["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"}]],wme=Xe("moon",yme);const xme=[["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"}]],Sme=Xe("picture-in-picture",xme);const Eme=[["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"}]],k8=Xe("play",Eme);const _me=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],T8=Xe("plus",_me);const kme=[["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"}]],UU=Xe("rotate-ccw",kme);const Tme=[["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"}]],jN=Xe("save",Tme);const Nme=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Td=Xe("search",Nme);const Cme=[["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"}]],Rme=Xe("send",Cme);const Ame=[["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"}]],Ime=Xe("server",Ame);const Ome=[["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"}]],bu=Xe("settings",Ome);const Dme=[["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"}]],jme=Xe("shield",Dme);const Lme=[["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=Xe("sparkles",Lme);const Mme=[["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"}]],N8=Xe("square-check-big",Mme);const Pme=[["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"}]],Ume=Xe("square-pen",Pme);const zme=[["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"}]],Fme=Xe("sun-dim",zme);const Bme=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],rS=Xe("terminal",Bme);const Hme=[["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"}]],$s=Xe("trash-2",Hme);const Vme=[["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"}]],Gme=Xe("trash",Vme);const Wme=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Ul=Xe("wrench",Wme);const Kme=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Yi=Xe("x",Kme);const Zme=[["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"}]],Rp=Xe("zap",Zme);function Yme(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 qme=e=>{switch(e){case"success":return Qme;case"info":return the;case"warning":return ehe;case"error":return nhe;default:return null}},Xme=Array(12).fill(0),Jme=({visible:e,className:t})=>ue.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},Xme.map((n,a)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),Qme=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.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"})),ehe=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ue.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"})),the=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.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"})),nhe=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.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"})),rhe=ue.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"},ue.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ue.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ahe=()=>{const[e,t]=ue.useState(document.hidden);return ue.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let DE=1;class ihe{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:DE++,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 d=>{if(s=["resolve",d],ue.isValidElement(d))i=!1,this.create({id:a,type:"default",message:d});else if(she(d)&&!d.ok){i=!1;const h=typeof n.error=="function"?await n.error(`HTTP error! status: ${d.status}`):n.error,g=typeof n.description=="function"?await n.description(`HTTP error! status: ${d.status}`):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(d instanceof Error){i=!1;const h=typeof n.error=="function"?await n.error(d):n.error,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"error",description:g,...w})}else if(n.success!==void 0){i=!1;const h=typeof n.success=="function"?await n.success(d):n.success,g=typeof n.description=="function"?await n.description(d):n.description,w=typeof h=="object"&&!ue.isValidElement(h)?h:{message:h};this.create({id:a,type:"success",description:g,...w})}}).catch(async d=>{if(s=["reject",d],n.error!==void 0){i=!1;const m=typeof n.error=="function"?await n.error(d):n.error,h=typeof n.description=="function"?await n.description(d):n.description,v=typeof m=="object"&&!ue.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((d,m)=>c.then(()=>s[0]==="reject"?m(s[1]):d(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||DE++;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 pa=new ihe,ohe=(e,t)=>{const n=t?.id||DE++;return pa.addToast({title:e,...t,id:n}),n},she=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",lhe=ohe,che=()=>pa.toasts,uhe=()=>pa.getActiveToasts(),Jt=Object.assign(lhe,{success:pa.success,info:pa.info,warning:pa.warning,error:pa.error,custom:pa.custom,message:pa.message,promise:pa.promise,dismiss:pa.dismiss,loading:pa.loading},{getHistory:che,getToasts:uhe});Yme("[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 qg(e){return e.label!==void 0}const dhe=3,fhe="24px",phe="16px",zU=4e3,mhe=356,hhe=14,ghe=45,bhe=200;function $i(...e){return e.filter(Boolean).join(" ")}function vhe(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}const yhe=e=>{var t,n,a,r,i,s,c,u,d;const{invert:m,toast:h,unstyled:g,interacting:v,setHeights:w,visibleToasts:S,heights:y,index:_,toasts:E,expanded:k,removeToast:C,defaultRichColors:R,closeButton:I,style:A,cancelButtonStyle:O,actionButtonStyle:M,className:U="",descriptionClassName:H="",duration:K,position:Q,gap:te,expandByDefault:ae,classNames:B,icons:Z,closeButtonAriaLabel:G="Close toast"}=e,[re,ne]=ue.useState(null),[j,V]=ue.useState(null),[z,L]=ue.useState(!1),[$,F]=ue.useState(!1),[W,X]=ue.useState(!1),[ie,le]=ue.useState(!1),[J,q]=ue.useState(!1),[se,he]=ue.useState(0),[ce,Te]=ue.useState(0),He=ue.useRef(h.duration||K||zU),Ee=ue.useRef(null),ke=ue.useRef(null),ze=_===0,fe=_+1<=S,Oe=h.type,Be=h.dismissible!==!1,Se=h.className||"",tt=h.descriptionClassName||"",it=ue.useMemo(()=>y.findIndex(Ye=>Ye.toastId===h.id)||0,[y,h.id]),ht=ue.useMemo(()=>{var Ye;return(Ye=h.closeButton)!=null?Ye:I},[h.closeButton,I]),Rt=ue.useMemo(()=>h.duration||K||zU,[h.duration,K]),je=ue.useRef(0),Fe=ue.useRef(0),pt=ue.useRef(0),Qe=ue.useRef(null),[Tt,nt]=Q.split("-"),Ie=ue.useMemo(()=>y.reduce((Ye,vt,Mt)=>Mt>=it?Ye:Ye+vt.height,0),[y,it]),$e=ahe(),Ve=h.invert||m,at=Oe==="loading";Fe.current=ue.useMemo(()=>it*te+Ie,[it,Ie]),ue.useEffect(()=>{He.current=Rt},[Rt]),ue.useEffect(()=>{L(!0)},[]),ue.useEffect(()=>{const Ye=ke.current;if(Ye){const vt=Ye.getBoundingClientRect().height;return Te(vt),w(Mt=>[{toastId:h.id,height:vt,position:h.position},...Mt]),()=>w(Mt=>Mt.filter(Pt=>Pt.toastId!==h.id))}},[w,h.id]),ue.useLayoutEffect(()=>{if(!z)return;const Ye=ke.current,vt=Ye.style.height;Ye.style.height="auto";const Mt=Ye.getBoundingClientRect().height;Ye.style.height=vt,Te(Mt),w(Pt=>Pt.find(fn=>fn.toastId===h.id)?Pt.map(fn=>fn.toastId===h.id?{...fn,height:Mt}:fn):[{toastId:h.id,height:Mt,position:h.position},...Pt])},[z,h.title,h.description,w,h.id,h.jsx,h.action,h.cancel]);const dt=ue.useCallback(()=>{F(!0),he(Fe.current),w(Ye=>Ye.filter(vt=>vt.toastId!==h.id)),setTimeout(()=>{C(h)},bhe)},[h,C,w,Fe]);ue.useEffect(()=>{if(h.promise&&Oe==="loading"||h.duration===1/0||h.type==="loading")return;let Ye;return k||v||$e?(()=>{if(pt.current<je.current){const Pt=new Date().getTime()-je.current;He.current=He.current-Pt}pt.current=new Date().getTime()})():(()=>{He.current!==1/0&&(je.current=new Date().getTime(),Ye=setTimeout(()=>{h.onAutoClose==null||h.onAutoClose.call(h,h),dt()},He.current))})(),()=>clearTimeout(Ye)},[k,v,h,Oe,$e,dt]),ue.useEffect(()=>{h.delete&&(dt(),h.onDismiss==null||h.onDismiss.call(h,h))},[dt,h.delete]);function wt(){var Ye;if(Z?.loading){var vt;return ue.createElement("div",{className:$i(B?.loader,h==null||(vt=h.classNames)==null?void 0:vt.loader,"sonner-loader"),"data-visible":Oe==="loading"},Z.loading)}return ue.createElement(Jme,{className:$i(B?.loader,h==null||(Ye=h.classNames)==null?void 0:Ye.loader),visible:Oe==="loading"})}const xt=h.icon||Z?.[Oe]||qme(Oe);var dn,hn;return ue.createElement("li",{tabIndex:0,ref:ke,className:$i(U,Se,B?.toast,h==null||(t=h.classNames)==null?void 0:t.toast,B?.default,B?.[Oe],h==null||(n=h.classNames)==null?void 0:n[Oe]),"data-sonner-toast":"","data-rich-colors":(dn=h.richColors)!=null?dn:R,"data-styled":!(h.jsx||h.unstyled||g),"data-mounted":z,"data-promise":!!h.promise,"data-swiped":J,"data-removed":$,"data-visible":fe,"data-y-position":Tt,"data-x-position":nt,"data-index":_,"data-front":ze,"data-swiping":W,"data-dismissible":Be,"data-type":Oe,"data-invert":Ve,"data-swipe-out":ie,"data-swipe-direction":j,"data-expanded":!!(k||ae&&z),"data-testid":h.testId,style:{"--index":_,"--toasts-before":_,"--z-index":E.length-_,"--offset":`${$?se:Fe.current}px`,"--initial-height":ae?"auto":`${ce}px`,...A,...h.style},onDragEnd:()=>{X(!1),ne(null),Qe.current=null},onPointerDown:Ye=>{Ye.button!==2&&(at||!Be||(Ee.current=new Date,he(Fe.current),Ye.target.setPointerCapture(Ye.pointerId),Ye.target.tagName!=="BUTTON"&&(X(!0),Qe.current={x:Ye.clientX,y:Ye.clientY})))},onPointerUp:()=>{var Ye,vt,Mt;if(ie||!Be)return;Qe.current=null;const Pt=Number(((Ye=ke.current)==null?void 0:Ye.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),fr=Number(((vt=ke.current)==null?void 0:vt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),fn=new Date().getTime()-((Mt=Ee.current)==null?void 0:Mt.getTime()),Kn=re==="x"?Pt:fr,Zn=Math.abs(Kn)/fn;if(Math.abs(Kn)>=ghe||Zn>.11){he(Fe.current),h.onDismiss==null||h.onDismiss.call(h,h),V(re==="x"?Pt>0?"right":"left":fr>0?"down":"up"),dt(),le(!0);return}else{var wn,pn;(wn=ke.current)==null||wn.style.setProperty("--swipe-amount-x","0px"),(pn=ke.current)==null||pn.style.setProperty("--swipe-amount-y","0px")}q(!1),X(!1),ne(null)},onPointerMove:Ye=>{var vt,Mt,Pt;if(!Qe.current||!Be||((vt=window.getSelection())==null?void 0:vt.toString().length)>0)return;const fn=Ye.clientY-Qe.current.y,Kn=Ye.clientX-Qe.current.x;var Zn;const wn=(Zn=e.swipeDirections)!=null?Zn:vhe(Q);!re&&(Math.abs(Kn)>1||Math.abs(fn)>1)&&ne(Math.abs(Kn)>Math.abs(fn)?"x":"y");let pn={x:0,y:0};const aa=en=>1/(1.5+Math.abs(en)/20);if(re==="y"){if(wn.includes("top")||wn.includes("bottom"))if(wn.includes("top")&&fn<0||wn.includes("bottom")&&fn>0)pn.y=fn;else{const en=fn*aa(fn);pn.y=Math.abs(en)<Math.abs(fn)?en:fn}}else if(re==="x"&&(wn.includes("left")||wn.includes("right")))if(wn.includes("left")&&Kn<0||wn.includes("right")&&Kn>0)pn.x=Kn;else{const en=Kn*aa(Kn);pn.x=Math.abs(en)<Math.abs(Kn)?en:Kn}(Math.abs(pn.x)>0||Math.abs(pn.y)>0)&&q(!0),(Mt=ke.current)==null||Mt.style.setProperty("--swipe-amount-x",`${pn.x}px`),(Pt=ke.current)==null||Pt.style.setProperty("--swipe-amount-y",`${pn.y}px`)}},ht&&!h.jsx&&Oe!=="loading"?ue.createElement("button",{"aria-label":G,"data-disabled":at,"data-close-button":!0,onClick:at||!Be?()=>{}:()=>{dt(),h.onDismiss==null||h.onDismiss.call(h,h)},className:$i(B?.closeButton,h==null||(a=h.classNames)==null?void 0:a.closeButton)},(hn=Z?.close)!=null?hn:rhe):null,(Oe||h.icon||h.promise)&&h.icon!==null&&(Z?.[Oe]!==null||h.icon)?ue.createElement("div",{"data-icon":"",className:$i(B?.icon,h==null||(r=h.classNames)==null?void 0:r.icon)},h.promise||h.type==="loading"&&!h.icon?h.icon||wt():null,h.type!=="loading"?xt:null):null,ue.createElement("div",{"data-content":"",className:$i(B?.content,h==null||(i=h.classNames)==null?void 0:i.content)},ue.createElement("div",{"data-title":"",className:$i(B?.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?ue.createElement("div",{"data-description":"",className:$i(H,tt,B?.description,h==null||(c=h.classNames)==null?void 0:c.description)},typeof h.description=="function"?h.description():h.description):null),ue.isValidElement(h.cancel)?h.cancel:h.cancel&&qg(h.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:h.cancelButtonStyle||O,onClick:Ye=>{qg(h.cancel)&&Be&&(h.cancel.onClick==null||h.cancel.onClick.call(h.cancel,Ye),dt())},className:$i(B?.cancelButton,h==null||(u=h.classNames)==null?void 0:u.cancelButton)},h.cancel.label):null,ue.isValidElement(h.action)?h.action:h.action&&qg(h.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:h.actionButtonStyle||M,onClick:Ye=>{qg(h.action)&&(h.action.onClick==null||h.action.onClick.call(h.action,Ye),!Ye.defaultPrevented&&dt())},className:$i(B?.actionButton,h==null||(d=h.classNames)==null?void 0:d.actionButton)},h.action.label):null)};function FU(){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 whe(e,t){const n={};return[e,t].forEach((a,r)=>{const i=r===1,s=i?"--mobile-offset":"--offset",c=i?phe:fhe;function u(d){["top","right","bottom","left"].forEach(m=>{n[`${s}-${m}`]=typeof d=="number"?`${d}px`:d})}typeof a=="number"||typeof a=="string"?u(a):typeof a=="object"?["top","right","bottom","left"].forEach(d=>{a[d]===void 0?n[`${s}-${d}`]=c:n[`${s}-${d}`]=typeof a[d]=="number"?`${a[d]}px`:a[d]}):u(c)}),n}const C8=ue.forwardRef(function(t,n){const{id:a,invert:r,position:i="bottom-right",hotkey:s=["altKey","KeyT"],expand:c,closeButton:u,className:d,offset:m,mobileOffset:h,theme:g="light",richColors:v,duration:w,style:S,visibleToasts:y=dhe,toastOptions:_,dir:E=FU(),gap:k=hhe,icons:C,containerAriaLabel:R="Notifications"}=t,[I,A]=ue.useState([]),O=ue.useMemo(()=>a?I.filter(z=>z.toasterId===a):I.filter(z=>!z.toasterId),[I,a]),M=ue.useMemo(()=>Array.from(new Set([i].concat(O.filter(z=>z.position).map(z=>z.position)))),[O,i]),[U,H]=ue.useState([]),[K,Q]=ue.useState(!1),[te,ae]=ue.useState(!1),[B,Z]=ue.useState(g!=="system"?g:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),G=ue.useRef(null),re=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),ne=ue.useRef(null),j=ue.useRef(!1),V=ue.useCallback(z=>{A(L=>{var $;return($=L.find(F=>F.id===z.id))!=null&&$.delete||pa.dismiss(z.id),L.filter(({id:F})=>F!==z.id)})},[]);return ue.useEffect(()=>pa.subscribe(z=>{if(z.dismiss){requestAnimationFrame(()=>{A(L=>L.map($=>$.id===z.id?{...$,delete:!0}:$))});return}setTimeout(()=>{sV.flushSync(()=>{A(L=>{const $=L.findIndex(F=>F.id===z.id);return $!==-1?[...L.slice(0,$),{...L[$],...z},...L.slice($+1)]:[z,...L]})})})}),[I]),ue.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 z=window.matchMedia("(prefers-color-scheme: dark)");try{z.addEventListener("change",({matches:L})=>{Z(L?"dark":"light")})}catch{z.addListener(({matches:$})=>{try{Z($?"dark":"light")}catch(F){console.error(F)}})}},[g]),ue.useEffect(()=>{I.length<=1&&Q(!1)},[I]),ue.useEffect(()=>{const z=L=>{var $;if(s.every(X=>L[X]||L.code===X)){var W;Q(!0),(W=G.current)==null||W.focus()}L.code==="Escape"&&(document.activeElement===G.current||($=G.current)!=null&&$.contains(document.activeElement))&&Q(!1)};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[s]),ue.useEffect(()=>{if(G.current)return()=>{ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null,j.current=!1)}},[G.current]),ue.createElement("section",{ref:n,"aria-label":`${R} ${re}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},M.map((z,L)=>{var $;const[F,W]=z.split("-");return O.length?ue.createElement("ol",{key:z,dir:E==="auto"?FU():E,tabIndex:-1,ref:G,className:d,"data-sonner-toaster":!0,"data-sonner-theme":B,"data-y-position":F,"data-x-position":W,style:{"--front-toast-height":`${(($=U[0])==null?void 0:$.height)||0}px`,"--width":`${mhe}px`,"--gap":`${k}px`,...S,...whe(m,h)},onBlur:X=>{j.current&&!X.currentTarget.contains(X.relatedTarget)&&(j.current=!1,ne.current&&(ne.current.focus({preventScroll:!0}),ne.current=null))},onFocus:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||j.current||(j.current=!0,ne.current=X.relatedTarget)},onMouseEnter:()=>Q(!0),onMouseMove:()=>Q(!0),onMouseLeave:()=>{te||Q(!1)},onDragEnd:()=>Q(!1),onPointerDown:X=>{X.target instanceof HTMLElement&&X.target.dataset.dismissible==="false"||ae(!0)},onPointerUp:()=>ae(!1)},O.filter(X=>!X.position&&L===0||X.position===z).map((X,ie)=>{var le,J;return ue.createElement(yhe,{key:X.id,icons:C,index:ie,toast:X,defaultRichColors:v,duration:(le=_?.duration)!=null?le:w,className:_?.className,descriptionClassName:_?.descriptionClassName,invert:r,visibleToasts:y,closeButton:(J=_?.closeButton)!=null?J:u,interacting:te,position:z,style:_?.style,unstyled:_?.unstyled,classNames:_?.classNames,cancelButtonStyle:_?.cancelButtonStyle,actionButtonStyle:_?.actionButtonStyle,closeButtonAriaLabel:_?.closeButtonAriaLabel,removeToast:V,toasts:O.filter(q=>q.position==X.position),heights:U.filter(q=>q.position==X.position),setHeights:H,expandByDefault:c,gap:k,expanded:K,swipeDirections:t.swipeDirections})})):null}))}),BU=Object.freeze(Object.defineProperty({__proto__:null,Toaster:C8,toast:Jt},Symbol.toStringTag,{value:"Module"}));var Iy="Dialog",[R8]=Ci(Iy),[xhe,Ri]=R8(Iy),A8=e=>{const{__scopeDialog:t,children:n,open:a,defaultOpen:r,onOpenChange:i,modal:s=!0}=e,c=x.useRef(null),u=x.useRef(null),[d,m]=jo({prop:a,defaultProp:r??!1,onChange:i,caller:Iy});return f.jsx(xhe,{scope:t,triggerRef:c,contentRef:u,contentId:Dr(),titleId:Dr(),descriptionId:Dr(),open:d,onOpenChange:m,onOpenToggle:x.useCallback(()=>m(h=>!h),[m]),modal:s,children:n})};A8.displayName=Iy;var I8="DialogTrigger",O8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(I8,n),i=Qt(t,r.triggerRef);return f.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":MN(r.open),...a,ref:i,onClick:Ge(e.onClick,r.onOpenToggle)})});O8.displayName=I8;var LN="DialogPortal",[She,D8]=R8(LN,{forceMount:void 0}),j8=e=>{const{__scopeDialog:t,forceMount:n,children:a,container:r}=e,i=Ri(LN,t);return f.jsx(She,{scope:t,forceMount:n,children:x.Children.map(a,s=>f.jsx(Ma,{present:n||i.open,children:f.jsx(_d,{asChild:!0,container:r,children:s})}))})};j8.displayName=LN;var uv="DialogOverlay",L8=x.forwardRef((e,t)=>{const n=D8(uv,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ri(uv,e.__scopeDialog);return i.modal?f.jsx(Ma,{present:a||i.open,children:f.jsx(_he,{...r,ref:t})}):null});L8.displayName=uv;var Ehe=Ml("DialogOverlay.RemoveScroll"),_he=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(uv,n);return f.jsx(gm,{as:Ehe,allowPinchZoom:!0,shards:[r.contentRef],children:f.jsx(Et.div,{"data-state":MN(r.open),...a,ref:t,style:{pointerEvents:"auto",...a.style}})})}),zl="DialogContent",$8=x.forwardRef((e,t)=>{const n=D8(zl,e.__scopeDialog),{forceMount:a=n.forceMount,...r}=e,i=Ri(zl,e.__scopeDialog);return f.jsx(Ma,{present:a||i.open,children:i.modal?f.jsx(khe,{...r,ref:t}):f.jsx(The,{...r,ref:t})})});$8.displayName=zl;var khe=x.forwardRef((e,t)=>{const n=Ri(zl,e.__scopeDialog),a=x.useRef(null),r=Qt(t,n.contentRef,a);return x.useEffect(()=>{const i=a.current;if(i)return xy(i)},[]),f.jsx(M8,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ge(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ge(e.onPointerDownOutside,i=>{const s=i.detail.originalEvent,c=s.button===0&&s.ctrlKey===!0;(s.button===2||c)&&i.preventDefault()}),onFocusOutside:Ge(e.onFocusOutside,i=>i.preventDefault())})}),The=x.forwardRef((e,t)=>{const n=Ri(zl,e.__scopeDialog),a=x.useRef(!1),r=x.useRef(!1);return f.jsx(M8,{...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()}})}),M8=x.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:a,onOpenAutoFocus:r,onCloseAutoFocus:i,...s}=e,c=Ri(zl,n),u=x.useRef(null),d=Qt(t,u);return py(),f.jsxs(f.Fragment,{children:[f.jsx(fm,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:r,onUnmountAutoFocus:i,children:f.jsx(xd,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":MN(c.open),...s,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(Nhe,{titleId:c.titleId}),f.jsx(Rhe,{contentRef:u,descriptionId:c.descriptionId})]})]})}),$N="DialogTitle",P8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri($N,n);return f.jsx(Et.h2,{id:r.titleId,...a,ref:t})});P8.displayName=$N;var U8="DialogDescription",z8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(U8,n);return f.jsx(Et.p,{id:r.descriptionId,...a,ref:t})});z8.displayName=U8;var F8="DialogClose",B8=x.forwardRef((e,t)=>{const{__scopeDialog:n,...a}=e,r=Ri(F8,n);return f.jsx(Et.button,{type:"button",...a,ref:t,onClick:Ge(e.onClick,()=>r.onOpenChange(!1))})});B8.displayName=F8;function MN(e){return e?"open":"closed"}var H8="DialogTitleWarning",[rTe,V8]=ple(H8,{contentName:zl,titleName:$N,docsSlug:"dialog"}),Nhe=({titleId:e})=>{const t=V8(H8),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
94
94
|
|
|
95
95
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
96
96
|
|
|
@@ -1657,7 +1657,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1657
1657
|
<\/script>
|
|
1658
1658
|
</body>
|
|
1659
1659
|
</html>`,YK=1,q4=2,qK=3,X4=4,XK=5,J4=Symbol.for("quilt.threads.serialize"),w_e=Symbol.for("quilt.threads.transferable");class x_e 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 Q4 extends Error{constructor(){super("You attempted to call a function on a closed thread.")}}let S_e="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function JK(e=21){let t="",n=crypto.getRandomValues(new Uint8Array(e));for(let a=0;a<e;a++)t+=S_e[63&n[a]];return t}var Zf,Jc,Yf,Rb,j_,QK;class E_e{constructor(){fi(this,j_),fi(this,Zf,new Map),fi(this,Jc,new Map),fi(this,Yf,new Map),fi(this,Rb,new WeakMap)}get(t){return Mn(this,Jc).get(t)}release(t){const n=Mn(this,Jc).get(t);return n&&(Mn(this,Jc).delete(t),Mn(this,Zf).delete(n)),!!n}serialize(t){let n=Mn(this,Zf).get(t);return n==null&&(n=JK(),Mn(this,Zf).set(t,n),Mn(this,Jc).set(n,t)),n}deserialize(t,n){var a,r;let i=(a=Mn(this,Yf).get(t))==null?void 0:a.deref();return i||(i=(...s)=>{if(!Mn(this,Yf).has(t))throw new Error("You attempted to call a function that was already revoked.");return n.call((c,u,d)=>{n.messages.send([qK,c,t,u],d)},s)},(r=Rr(this,j_,QK).call(this,n))==null||r.register(i,t),Mn(this,Yf).set(t,new WeakRef(i)),i)}}Zf=new WeakMap,Jc=new WeakMap,Yf=new WeakMap,Rb=new WeakMap,j_=new WeakSet,QK=function(e){let t=Mn(this,Rb).get(e);if(!(typeof FinalizationRegistry>"u"))return t||(t=new FinalizationRegistry(n=>{e.messages.send([XK,n])}),Mn(this,Rb).set(e,t)),t};function __e(e){return e!=null&&(Symbol.asyncIterator in e||Symbol.iterator in e)&&typeof e.next=="function"}function e2(e){if(e==null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t==null||t===Object.prototype}const OS="_@f",t2="_@i";var hp,gp,Za,Ab,xs;class k_e{constructor(t){fi(this,Za),fi(this,hp),fi(this,gp),O_(this,hp,t?.serialize),O_(this,gp,t?.deserialize)}serialize(t,n,a){return Rr(this,Za,Ab).call(this,t,n,a)}deserialize(t,n){return Rr(this,Za,xs).call(this,t,n)}}hp=new WeakMap,gp=new WeakMap,Za=new WeakSet,Ab=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(Mn(this,hp)&&!r){const c=Mn(this,hp).call(this,e,u=>Rr(this,Za,Ab).call(this,u,t,n,a,!0),t,n);if(c!==void 0)return a.set(e,c),c}if(e[w_e])return n?.push(e),a.set(e,e),e;const i=c=>Rr(this,Za,Ab).call(this,c,t,n,a);if(typeof e[J4]=="function"){const c=e[J4]({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(([d,m])=>[i(d),i(m)]),u=new Map(c);return a.set(e,u),u}if(e instanceof Set){const c=[...e].map(d=>i(d)),u=new Set(c);return a.set(e,u),u}const s=__e(e);if(e2(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[t2]=!0),a.set(e,c),c}}if(typeof e=="function"){const i=t.functions.serialize(e,t,n),s={[OS]:i};return a.set(e,s),s}return a.set(e,e),e},xs=function(e,t,n=!1){if(e==null)return e;if(typeof e=="object"){if(Mn(this,gp)&&!n){const r=Mn(this,gp).call(this,e,i=>Rr(this,Za,xs).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=>Rr(this,Za,xs).call(this,r,t));if(e instanceof Map)return new Map([...e].map(([r,i])=>[Rr(this,Za,xs).call(this,r,t),Rr(this,Za,xs).call(this,i,t)]));if(e instanceof Set)return new Set([...e].map(r=>Rr(this,Za,xs).call(this,r,t)));if(OS in e)return t.functions.deserialize(e[OS],t);if(!e2(e))return e;const a={};for(const r of Object.keys(e))r===t2?a[Symbol.asyncIterator]=()=>a:a[r]=Rr(this,Za,xs).call(this,e[r],t);return a}return e};var Qc,Cl,Ss,L_,eZ,$_,tZ;class T_e{constructor(t,{imports:n,exports:a,functions:r=new E_e,serialization:i=new k_e,signal:s}={}){fi(this,Ss),fi(this,Qc),fi(this,Cl,new Map);var c,u,d,m;this.messages=t,O_(this,Qc,s?new x_e(s):new AbortController),this.exports=a??{},this.imports=N_e(Rr(this,Ss,eZ).bind(this),n),this.functions=r,this.serialization=i,(u=(c=this.functions).start)==null||u.call(c,this),(m=(d=this.serialization).start)==null||m.call(d,this),this.signal.addEventListener("abort",()=>{for(const h of Mn(this,Cl).keys())Rr(this,Ss,$_).call(this,h,void 0,new Q4);Mn(this,Cl).clear()},{once:!0}),t.listen(async h=>{if(!(Array.isArray(h)&&typeof h[0]=="number"))return;const g=h;switch(g[0]){case YK:{const[,v,w,S]=g,y=this.exports[w]??(()=>{throw new Error(`No '${w}' method is exported from this thread`)});await Rr(this,Ss,L_).call(this,y,S,(_,E,k)=>{this.messages.send([q4,v,_,E],k)});break}case qK:{const[,v,w,S]=g,y=this.functions.get(w,this)??C_e;await Rr(this,Ss,L_).call(this,y,S,(_,E,k)=>{this.messages.send([X4,v,_,E],k)});break}case q4:case X4:{Rr(this,Ss,$_).call(this,...g.slice(1));break}case XK:{const v=g[1];this.functions.release(v,this);break}}},{signal:this.signal})}get signal(){return Mn(this,Qc).signal}get closed(){return Mn(this,Qc).signal.aborted}close(){Mn(this,Qc).abort()}call(t,n){if(this.closed)return Promise.reject(new Q4);const a=[],r=this.serialization.serialize(n,this,a),i=JK(),s=Rr(this,Ss,tZ).call(this,i);return t(i,r,a),s}}Qc=new WeakMap,Cl=new WeakMap,Ss=new WeakSet,L_=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))}},eZ=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([YK,n,e,a],r)},t)}catch(n){return Promise.reject(n)}}},$_=function(...e){const t=e[0],n=Mn(this,Cl).get(t);n&&(n(...e),Mn(this,Cl).delete(t))},tZ=function(e){const t=new Promise((n,a)=>{Mn(this,Cl).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 N_e(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 C_e(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}const R_e="quilt.threads.ping",n2="quilt.threads.pong";function A_e(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===n2&&(n=!0,s.abort(),i())},{signal:s.signal}),s.signal.addEventListener("abort",()=>i(),{once:!0}),a(R_e)});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!==n2&&i(c.data)},{signal:s})}}}class I_e extends T_e{constructor(t,{targetOrigin:n="*",...a}={}){super(A_e(t.contentWindow,{targetOrigin:n}),a),this.iframe=t}}const nZ=ue.forwardRef(({content:e,children:t,...n},a)=>f.jsx("span",{ref:a,...n,children:e||t}));nZ.displayName="UIText";const rZ=ue.forwardRef(({label:e,onPress:t,onClick:n,children:a,...r},i)=>f.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}));rZ.displayName="UIButton";const aZ=ue.forwardRef(({direction:e="vertical",spacing:t="8",align:n="stretch",justify:a="flex-start",children:r,...i},s)=>f.jsx("div",{ref:s,style:{display:"flex",flexDirection:e==="horizontal"?"row":"column",gap:`${t}px`,alignItems:n,justifyContent:a},...i,children:r}));aZ.displayName="UIStack";const iZ=ue.forwardRef(({src:e,alt:t,width:n,height:a,children:r,...i},s)=>f.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}));iZ.displayName="UIImage";const QO={name:"basic",elements:[{tagName:"ui-text",component:nZ,propMapping:{content:"content"},eventMapping:{}},{tagName:"ui-button",component:rZ,propMapping:{label:"label"},eventMapping:{press:"onPress"}},{tagName:"ui-stack",component:aZ,propMapping:{direction:"direction",spacing:"spacing",align:"align",justify:"justify"},eventMapping:{}},{tagName:"ui-image",component:iZ,propMapping:{src:"src",alt:"alt",width:"width",height:"height"},eventMapping:{}}]},O_e=({receiver:e})=>{const t=x.useRef(null);return x.useEffect(()=>{if(t.current)return e.connect(t.current),()=>{e.disconnect()}},[e]),f.jsx("div",{ref:t,"data-testid":"standard-dom-renderer-container"})},D_e=({resource:e,library:t,remoteElements:n=[],onUIAction:a})=>{const r=x.useRef(null),i=x.useRef(null),[s,c]=x.useState(null),u=x.useMemo(()=>(e.mimeType||"").includes("framework=react")?"react":"webcomponents",[e.mimeType]),d=`${t?.name}-${u}`,{receiver:m,components:h}=x.useMemo(()=>{switch(u){case"react":{const v=new u_e,w=t||QO,S=new Map;return w&&w.elements.forEach(y=>{const _=g_e(y.component);S.set(y.tagName,_)}),{receiver:v,components:S}}case"webcomponents":default:return{receiver:new d_e,components:null}}},[e,t,n]);x.useEffect(()=>{function v(w){var S;if(r.current&&w.source===r.current.contentWindow){const y=w.data;if(!y)return;(S=a?.(y))==null||S.catch(_=>{console.error("Error handling UI action result in RemoteDOMResourceRenderer:",_)})}}return window.addEventListener("message",v),()=>window.removeEventListener("message",v)},[a]),x.useEffect(()=>{const v=i.current;return i.current=null,()=>{v?.close()}},[d]);const g=()=>{const v=r.current;if(!v||i.current)return;const w=new I_e(v);i.current=w;const{code:S,error:y}=t_e(e);if(y){c(y);return}if(S&&m!=null&&m.connection){const _={code:S,remoteElements:n,useReactRenderer:u==="react",componentLibrary:t?.name};w.imports.render(_,m.connection).catch(E=>console.error("Error calling remote render:",E))}};return s?f.jsx("p",{className:"text-red-500",children:s}):f.jsxs(f.Fragment,{children:[f.jsx("iframe",{ref:r,srcDoc:y_e,sandbox:"allow-scripts",style:{display:"none"},title:"Remote DOM Sandbox",onLoad:g},d),u==="react"&&h?f.jsx(v_e,{receiver:m,components:h}):f.jsx(O_e,{receiver:m})]})};function j_e(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 eD=e=>{const{resource:t,onUIAction:n,supportedContentTypes:a,htmlProps:r,remoteDomProps:i}=e,s=j_e(t);if(a&&s&&!a.includes(s))return f.jsxs("p",{className:"text-red-500",children:["Unsupported content type: ",s,"."]});switch(s){case"rawHtml":case"externalUrl":return f.jsx(HK,{resource:t,onUIAction:n,...r});case"remoteDom":return f.jsx(D_e,{resource:t,onUIAction:n,library:i?.library||QO,...i});default:return f.jsx("p",{className:"text-red-500",children:"Unsupported resource type."})}};eD.displayName="UIResourceRenderer";const L_e={tagName:"ui-button",remoteAttributes:["label"],remoteEvents:["click","press"]},$_e={tagName:"ui-text",remoteAttributes:["content"]},M_e={tagName:"ui-stack",remoteAttributes:["direction","spacing","align","justify"]},P_e={tagName:"ui-image",remoteAttributes:["src","alt","width","height"]},U_e=x.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://")?f.jsx("div",{className:"my-4 p-0 border h-[350px] rounded-2xl border-zinc-200 overflow-hidden bg-card",children:f.jsx(eD,{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 r2({toolName:e,toolArgs:t,result:n,serverId:a,readResource:r,toolMeta:i}){const[s,c]=x.useState(null);x.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=x.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]),d=x.useMemo(()=>!!i?.["openai/outputTemplate"],[i]),m=x.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=x.useMemo(()=>m&&u.content.find(w=>w.type==="resource"&&w.resource?.uri?.startsWith("ui://")&&w.resource?.mimeType==="text/html+skybridge")?.resource||null,[m,u]);if(x.useEffect(()=>{if(h){c(h);return}if(d&&i&&r){const v=i["openai/outputTemplate"];console.log("[ToolResultRenderer] Fetching resource for Apps SDK tool:",v),r(v).then(w=>{console.log("[ToolResultRenderer] Resource fetched:",w),w?.contents&&Array.isArray(w.contents)&&w.contents.length>0?c(w.contents[0]):console.warn("[ToolResultRenderer] No contents in fetched resource:",w)}).catch(w=>{console.error("[ToolResultRenderer] Failed to fetch resource:",w)})}},[h,d,i,r]),(d||m)&&s&&a&&r)return f.jsx(ZO,{componentUrl:s.uri,toolName:e,toolArgs:t,toolResult:u,serverId:a,readResource:r,noWrapper:!0,className:"my-4",showConsole:!1});if((d||m)&&!s)return f.jsx("div",{className:"flex items-center justify-center w-full h-[200px] rounded border",children:f.jsx(Ei,{className:"size-5"})});if(d&&(!a||!r))return console.error("[ToolResultRenderer] Apps SDK tool but missing serverId or readResource:",{toolName:e,hasServerId:!!a,hasReadResource:!!r}),f.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:f.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?f.jsx(f.Fragment,{children:g.map(v=>f.jsx(U_e,{resource:v},`${e}-mcp-ui-${v.uri}`))}):(console.log("[ToolResultRenderer] Not rendering (no UI resources found):",{toolName:e,isAppsSdkTool:d,hasAppsSdkComponent:m,hasResourceData:!!s,contentLength:u?.content?.length}),null)}function z_e({content:e,timestamp:t}){return!e||e.length===0?null:f.jsx("div",{className:"flex items-start gap-3 justify-end group/user-message",children:f.jsxs("div",{className:"flex-1 min-w-0 flex flex-col items-end",children:[f.jsx("div",{className:"bg-zinc-200 dark:bg-zinc-800 text-primary rounded-3xl px-4 py-2 max-w-[80%] break-words",children:f.jsx("p",{className:"text-base leading-7 font-sans text-start break-words",children:e})}),t&&f.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:new Date(t).toLocaleTimeString()})]})})}const F_e=x.memo(({messages:e,isLoading:t,serverId:n,readResource:a,tools:r})=>{const i=x.useRef(null),s=d=>r?.find(h=>h.name===d)?._meta;x.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 d=e[e.length-1];if(d.role==="user")return!0;if(d.role==="assistant"){const m=typeof d.content=="string"?d.content:Array.isArray(d.content)?d.content.map(g=>typeof g=="string"?g:g.text||JSON.stringify(g)).join(""):JSON.stringify(d.content);return!(m&&m.trim().length>0)}return!1})(),u=d=>{if(!t)return!1;const m=e[e.length-1];return d.id===m.id&&m.role==="assistant"};return f.jsxs("div",{className:"space-y-6 max-w-3xl mx-auto px-2",children:[e.map(d=>{const m=typeof d.content=="string"?d.content:Array.isArray(d.content)?d.content.map(h=>typeof h=="string"?h:h.text||JSON.stringify(h)).join(""):JSON.stringify(d.content);return d.role==="user"?f.jsx(z_e,{content:m,timestamp:d.timestamp},d.id):d.role==="assistant"?f.jsx("div",{className:"space-y-4",children:d.parts&&d.parts.length>0?d.parts.map((h,g)=>{const v=h.type==="text"?`${d.id}-text-${g}-${h.text?.slice(0,20)}`:`${d.id}-tool-${h.toolInvocation?.toolName}-${g}`;return h.type==="text"?f.jsx(z4,{content:h.text||"",timestamp:g===d.parts.length-1?d.timestamp:void 0,_isStreaming:u(d)},v):h.type==="tool-invocation"&&h.toolInvocation?f.jsxs("div",{children:[f.jsx(F4,{toolName:h.toolInvocation.toolName,args:h.toolInvocation.args,result:h.toolInvocation.result,state:h.toolInvocation.result?"result":"call"}),h.toolInvocation.result&&f.jsx(r2,{toolName:h.toolInvocation.toolName,toolArgs:h.toolInvocation.args,result:h.toolInvocation.result,serverId:n,readResource:a,toolMeta:s(h.toolInvocation.toolName)})]},v):null}):f.jsxs(f.Fragment,{children:[f.jsx(z4,{content:m,timestamp:d.timestamp,_isStreaming:u(d)}),d.toolCalls&&d.toolCalls.length>0&&f.jsx("div",{className:"space-y-2",children:d.toolCalls.map(h=>{const g=`${d.id}-${h.toolName}-${JSON.stringify(h.args).slice(0,50)}`;return f.jsxs("div",{children:[f.jsx(F4,{toolName:h.toolName,args:h.args,result:h.result,state:h.result?"result":"call"}),h.result&&f.jsx(r2,{toolName:h.toolName,toolArgs:h.args,result:h.result,serverId:n,readResource:a,toolMeta:s(h.toolName)})]},g)})})]})},d.id):null}),c&&f.jsx("div",{className:"flex items-start gap-3",children:f.jsx("div",{className:"flex-1",children:f.jsx("div",{className:"rounded-lg p-4 max-w-fit",children:f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("span",{className:"text-sm",children:f.jsx(ixe,{duration:2,spread:1,children:"Thinking..."})})})})})}),f.jsx("div",{ref:i})]})});function oZ(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 B_e({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:a}){const[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.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 C="mcp:auth",R=oZ(e),I=`${C}_${R}_tokens`,A=localStorage.getItem(I);if(A){const O=JSON.parse(A);g={...n,oauthTokens:O}}else console.warn("No OAuth tokens found in localStorage for key:",I)}catch(C){console.warn("Failed to retrieve OAuth tokens:",C)}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(C=>({role:C.role,content:C.content}))})});if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);const w=`assistant-${Date.now()}`;let S="";const y=[];i(C=>[...C,{id:w,role:"assistant",content:"",timestamp:Date.now(),parts:[]}]);const _=v.body?.getReader(),E=new TextDecoder;if(!_)throw new Error("No response body");let k="";for(;;){const{done:C,value:R}=await _.read();if(C)break;k+=E.decode(R,{stream:!0});const I=k.split(`
|
|
1660
|
-
`);k=I.pop()||"";for(const A of I)if(A.trim()&&A.startsWith("data: "))try{const O=JSON.parse(A.slice(6));if(console.log("[Client received event]",O.type,O.toolName||O.content?.slice?.(0,30)),O.type==="message")console.log("[Message started]",O.id);else if(O.type==="text"){S+=O.content;const M=y[y.length-1];M&&M.type==="text"?M.text=S:y.push({type:"text",text:S}),console.log("[Parts after text]",y.length,"parts, text length:",S.length),i(U=>U.map(H=>H.id===w?{...H,parts:[...y]}:H))}else if(O.type==="tool-call")S&&(S=""),y.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",y.length,"parts, tool:",O.toolName),i(M=>M.map(U=>U.id===w?{...U,parts:[...y]}:U));else if(O.type==="tool-result"){const M=y.find(U=>U.type==="tool-invocation"&&U.toolInvocation?.toolName===O.toolName&&!U.toolInvocation?.result);M&&M.toolInvocation?(M.toolInvocation.result=O.result,M.toolInvocation.state="result",console.log("[Parts after tool-result]",y.length,"parts, updated:",O.toolName),i(U=>U.map(H=>H.id===w?{...H,parts:[...y]}:H))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",y.length),i(M=>M.map(U=>U.id===w?{...U,parts:[...y],content:""}:U));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,A)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const S=g;S.status&&(v=`HTTP ${S.status}: ${v}`),(S.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const w={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(S=>[...S,w])}finally{c(!1)}},[t,a,e,r,n]),d=x.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:d}}function H_e({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),h=x.useCallback(async v=>{if(!v.trim()||!t||!n)return;const w={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(_=>[..._,w]),c(!0),u.current=new AbortController;const S=Date.now();let y=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(C=>[...C,{id:_,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 C;if(t.provider==="openai"){const{ChatOpenAI:R}=await Qn(async()=>{const{ChatOpenAI:I}=await import("./index-C98SBxLG.js");return{ChatOpenAI:I}},__vite__mapDeps([5,6,7,3,8,9]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:R}=await Qn(async()=>{const{ChatAnthropic:I}=await import("./index-xIW0QfEK.js");return{ChatAnthropic:I}},__vite__mapDeps([10,7,6,3]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:R}=await Qn(async()=>{const{ChatGoogleGenerativeAI:I}=await import("./index-n6TPfFwj.js");return{ChatGoogleGenerativeAI:I}},__vite__mapDeps([11,7,6,3,9]));C=new R({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:C,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==m.current.instance){const{MCPAgent:C}=await Qn(async()=>{const{MCPAgent:R}=await import("./browser-BXiX12HB.js");return{MCPAgent:R}},__vite__mapDeps([12,8,6,7,3,9]));d.current=new C({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 d.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",d.current.conversationHistory?.length);for await(const C of d.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(C.event==="on_chat_model_stream"&&C.data?.chunk?.text){const R=C.data.chunk.text;if(typeof R=="string"&&R.length>0){E+=R;const I=k[k.length-1];I&&I.type==="text"?I.text=E:k.push({type:"text",text:E}),i(A=>A.map(O=>O.id===_?{...O,parts:[...k]}:O))}}else if(C.event==="on_tool_start"){E&&(E="");let R={};C.data?.input?R=C.data.input:C.data?.tool_input?R=C.data.tool_input:C.data&&(R=C.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:C.name,eventData:C.data,extractedArgs:R}),y++,k.push({type:"tool-invocation",toolInvocation:{toolName:C.name||"unknown",args:R,state:"pending"}}),i(I=>I.map(A=>A.id===_?{...A,parts:[...k]}:A))}else if(C.event==="on_tool_end"){const R=k.find(I=>I.type==="tool-invocation"&&I.toolInvocation?.toolName===C.name&&!I.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:C.name,hasToolPart:!!R,output:C.data?.output}),R&&R.toolInvocation){let I=C.data?.output;if(I?.kwargs?.content&&typeof I.kwargs.content=="string")try{I=JSON.parse(I.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),I=I.kwargs.content}else if(I?.content&&typeof I.content=="string")try{I=JSON.parse(I.content)}catch{I=I.content}R.toolInvocation.result=I,R.toolInvocation.state="result";const A=I?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:C.name,hasMeta:!!I?._meta,hasStructuredContent:!!I?.structuredContent,appsSdkUri:A}),A&&typeof A=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",A);try{const O=await a(A);console.log("[useChatMessagesClientSide] Resource fetched:",O);const M=I?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const U=O.contents.map(K=>({type:"resource",resource:K}));console.log("[useChatMessagesClientSide] Created MCP resources:",U);const H={...I,content:[...I.content||[],...U],structuredContent:M};R.toolInvocation.result=H,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}i(O=>O.map(M=>M.id===_?{...M,parts:[...k]}:M))}}}i(C=>C.map(R=>R.id===_?{...R,parts:[...k],content:""}:R)),t&&yr.getInstance().capture(new jU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!0,executionMode:"client-side",duration:Date.now()-S})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const C=_;C.status&&(E=`HTTP ${C.status}: ${E}`),(C.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&yr.getInstance().capture(new jU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!1,executionMode:"client-side",duration:Date.now()-S,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(C=>[...C,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=x.useCallback(()=>{i([]),d.current&&d.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const a2={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function sZ({mcpServerUrl:e}){const[t,n]=x.useState(null),[a,r]=x.useState(null),[i,s]=x.useState(!1),[c,u]=x.useState("openai"),[d,m]=x.useState(""),[h,g]=x.useState(a2.openai),v=x.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(U){return console.error("Failed to load API keys:",U),{}}return{}},[]),w=x.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[S,y]=x.useState("none"),[_,E]=x.useState(""),[k,C]=x.useState(""),[R,I]=x.useState("");x.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),U=v();if(M)try{const H=JSON.parse(M);n(H),u(H.provider),m(U[H.provider]||H.apiKey||""),g(H.model)}catch(H){console.error("Failed to load LLM config:",H)}},[v]),x.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const U=JSON.parse(M);r(U),y(U.type),U.username&&E(U.username),U.password&&C(U.password),U.token&&I(U.token)}catch(U){console.error("Failed to load auth config:",U)}else try{const U="mcp:auth",H=oZ(e),K=`${U}_${H}_tokens`;localStorage.getItem(K)&&(r({type:"oauth"}),y("oauth"))}catch(U){console.error("Failed to check for OAuth tokens:",U)}},[e]),x.useEffect(()=>{g(a2[c]);const M=v();m(M[c]||"")},[c,v]);const A=x.useCallback(()=>{if(!d.trim())return;const M=v();M[c]=d,w(M);const U={provider:c,apiKey:d,model:h},H={type:S,...S==="basic"&&{username:_.trim(),password:k.trim()},...S==="bearer"&&{token:R.trim()}};n(U),r(H),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(U)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(H)),s(!1)},[c,d,h,S,_,k,R,v,w]),O=x.useCallback(()=>{n(null),r(null);const M=v();delete M[c],w(M),m(""),E(""),C(""),I(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,w]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:d,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:S,saveLLMConfig:A,clearConfig:O}}function V_e({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=x.useState(""),s=x.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:d,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:w,tempModel:S,setTempModel:y,saveLLMConfig:_,clearConfig:E}=sZ({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},C=B_e({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),R=H_e(k),{messages:I,isLoading:A,sendMessage:O,clearMessages:M}=n?R:C;i7({onNewChat:M}),x.useEffect(()=>{c&&I.length===0&&s.current&&s.current.focus()},[c,I.length]),x.useEffect(()=>{!A&&I.length>0&&s.current&&s.current.focus()},[A,I.length]);const U=x.useCallback(()=>{r.trim()&&(O(r),i(""))},[r,O]),H=x.useCallback(Q=>{Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),U())},[U]),K=x.useCallback(()=>{E(),M()},[E,M]);return c&&I.length===0?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"absolute top-4 right-4 z-10",children:f.jsx(l_,{open:d,onOpenChange:m,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSave:_,onClear:K,showClearButton:!0,buttonLabel:"Change API Key"})}),f.jsx(rxe,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:A,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:H,onSubmit:Q=>{Q.preventDefault(),U()},onConfigDialogOpenChange:m})]}):f.jsxs("div",{className:"flex flex-col h-full relative",children:[f.jsx(exe,{llmConfig:c,hasMessages:I.length>0,configDialogOpen:d,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSaveConfig:_,onClearConfig:K}),f.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?f.jsx(F_e,{messages:I,isLoading:A,serverId:e.url,readResource:a,tools:e.tools}):f.jsx(axe,{onConfigureClick:()=>m(!0)})}),c&&f.jsx(txe,{inputValue:r,isConnected:t,isLoading:A,textareaRef:s,onInputChange:i,onKeyDown:H,onSendMessage:U})]})}const aw=x.createContext(null);aw.displayName="PanelGroupContext";const Wn={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"},tD=10,Ol=x.useLayoutEffect,i2=pd.useId,G_e=typeof i2=="function"?i2:()=>null;let W_e=0;function nD(e=null){const t=G_e(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+W_e++),e??n.current}function lZ({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:d,onExpand:m,onResize:h,order:g,style:v,tagName:w="div",...S}){const y=x.useContext(aw);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:C,groupId:R,isPanelCollapsed:I,reevaluatePanelConstraints:A,registerPanel:O,resizePanel:M,unregisterPanel:U}=y,H=nD(s),K=x.useRef({callbacks:{onCollapse:d,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:a,defaultSize:r,maxSize:c,minSize:u},id:H,idIsFromProps:s!==void 0,order:g});x.useRef({didLogMissingDefaultSizeWarning:!1}),Ol(()=>{const{callbacks:te,constraints:ae}=K.current,B={...ae};K.current.id=H,K.current.idIsFromProps=s!==void 0,K.current.order=g,te.onCollapse=d,te.onExpand=m,te.onResize=h,ae.collapsedSize=n,ae.collapsible=a,ae.defaultSize=r,ae.maxSize=c,ae.minSize=u,(B.collapsedSize!==ae.collapsedSize||B.collapsible!==ae.collapsible||B.maxSize!==ae.maxSize||B.minSize!==ae.minSize)&&A(K.current,B)}),Ol(()=>{const te=K.current;return O(te),()=>{U(te)}},[g,H,O,U]),x.useImperativeHandle(i,()=>({collapse:()=>{_(K.current)},expand:te=>{E(K.current,te)},getId(){return H},getSize(){return k(K.current)},isCollapsed(){return I(K.current)},isExpanded(){return!I(K.current)},resize:te=>{M(K.current,te)}}),[_,E,k,I,H,M]);const Q=C(K.current,r);return x.createElement(w,{...S,children:e,className:t,id:H,style:{...Q,...v},[Wn.groupId]:R,[Wn.panel]:"",[Wn.panelCollapsible]:a||void 0,[Wn.panelId]:H,[Wn.panelSize]:parseFloat(""+Q.flexGrow).toFixed(1)})}const cZ=x.forwardRef((e,t)=>x.createElement(lZ,{...e,forwardedRef:t}));lZ.displayName="Panel";cZ.displayName="forwardRef(Panel)";let M_=null,Ib=-1,Ns=null;function K_e(e,t,n){const a=(t&mZ)!==0,r=(t&hZ)!==0,i=(t&gZ)!==0,s=(t&bZ)!==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 Z_e(){Ns!==null&&(document.head.removeChild(Ns),M_=null,Ns=null,Ib=-1)}function DS(e,t,n){var a,r;const i=K_e(e,t);if(M_!==i){if(M_=i,Ns===null&&(Ns=document.createElement("style"),document.head.appendChild(Ns)),Ib>=0){var s;(s=Ns.sheet)===null||s===void 0||s.removeRule(Ib)}Ib=(a=(r=Ns.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function uZ(e){return e.type==="keydown"}function dZ(e){return e.type.startsWith("pointer")}function fZ(e){return e.type.startsWith("mouse")}function iw(e){if(dZ(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(fZ(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Y_e(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function q_e(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 X_e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:l2(e),b:l2(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;Nt(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:s2(o2(n.a)),b:s2(o2(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 J_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Q_e(e){var t;const n=getComputedStyle((t=pZ(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function eke(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Q_e(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"||J_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function o2(e){let t=e.length;for(;t--;){const n=e[t];if(Nt(n,"Missing node"),eke(n))return n}return null}function s2(e){return e&&Number(getComputedStyle(e).zIndex)||0}function l2(e){const t=[];for(;e;)t.push(e),e=pZ(e);return t}function pZ(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const mZ=1,hZ=2,gZ=4,bZ=8,tke=Y_e()==="coarse";let bi=[],xu=!1,Cs=new Map,ow=new Map;const Vp=new Set;function nke(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=Cs.get(s))!==null&&i!==void 0?i:0;return Cs.set(s,u+1),Vp.add(c),$v(),function(){var m;ow.delete(e),Vp.delete(c);const h=(m=Cs.get(s))!==null&&m!==void 0?m:1;if(Cs.set(s,h-1),$v(),h===1&&Cs.delete(s),bi.includes(c)){const g=bi.indexOf(c);g>=0&&bi.splice(g,1),sw(),r("up",!0,null)}}}function rke(e){const{target:t}=e,{x:n,y:a}=iw(e);xu=!0,rD({target:t,x:n,y:a}),$v(),bi.length>0&&(Mv("down",e),sw(),e.preventDefault(),vZ(t)||e.stopImmediatePropagation())}function jS(e){const{x:t,y:n}=iw(e);if(xu&&e.type!=="pointerleave"&&e.buttons===0&&(xu=!1,Mv("up",e)),!xu){const{target:a}=e;rD({target:a,x:t,y:n})}Mv("move",e),sw(),bi.length>0&&e.preventDefault()}function LS(e){const{target:t}=e,{x:n,y:a}=iw(e);ow.clear(),xu=!1,bi.length>0&&(e.preventDefault(),vZ(t)||e.stopImmediatePropagation()),Mv("up",e),rD({target:t,x:n,y:a}),sw(),$v()}function vZ(e){let t=e;for(;t;){if(t.hasAttribute(Wn.resizeHandle))return!0;t=t.parentElement}return!1}function rD({target:e,x:t,y:n}){bi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),Vp.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:d,right:m,top:h}=c,g=tke?s.coarse:s.fine;if(t>=d-g&&t<=m+g&&n>=h-g&&n<=u+g){if(a!==null&&document.contains(a)&&i!==a&&!i.contains(a)&&!a.contains(i)&&X_e(a,i)>0){let w=a,S=!1;for(;w&&!w.contains(i);){if(q_e(w.getBoundingClientRect(),c)){S=!0;break}w=w.parentElement}if(S)return}bi.push(r)}})}function $S(e,t){ow.set(e,t)}function sw(){let e=!1,t=!1;bi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;ow.forEach(a=>{n|=a}),e&&t?DS("intersection",n):e?DS("horizontal",n):t?DS("vertical",n):Z_e()}let MS;function $v(){var e;(e=MS)===null||e===void 0||e.abort(),MS=new AbortController;const t={capture:!0,signal:MS.signal};Vp.size&&(xu?(bi.length>0&&Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",LS,t),r.addEventListener("pointerleave",jS,t),r.addEventListener("pointermove",jS,t))}),Cs.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",LS,t),r.addEventListener("pointercancel",LS,t)})):Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",rke,t),r.addEventListener("pointermove",jS,t))}))}function Mv(e,t){Vp.forEach(n=>{const{setResizeHandlerState:a}=n,r=bi.includes(n);a(e,r,t)})}function ake(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function Nt(e,t){if(!e)throw console.error(t),Error(t)}function Wl(e,t,n=tD){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Eo(e,t,n=tD){return Wl(e,t,n)===0}function Ia(e,t,n){return Wl(e,t,n)===0}function ike(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(!Ia(r,i,n))return!1}return!0}function pu({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];Nt(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(Wl(n,c)<0)if(i){const u=(r+c)/2;Wl(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(tD)),n}function qf({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Ia(e,0))return t;const s=[...t],[c,u]=a;Nt(c!=null,"Invalid first pivot index"),Nt(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];Nt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(Nt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,v)){const _=S-y;Wl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?c:u,g=n[h];Nt(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(Nt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,S)){const _=y-v;Wl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const S=t[g];Nt(S!=null,`Previous layout not found for panel index ${g}`);const _=pu({panelConstraints:n,panelIndex:g,size:100})-S;if(v+=_,g+=h,g<0||g>=n.length)break}const w=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-w:w}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(d),w=t[g];Nt(w!=null,`Previous layout not found for panel index ${g}`);const S=w-v,y=pu({panelConstraints:n,panelIndex:g,size:S});if(!Ia(w,y)&&(d+=w-y,s[g]=y,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(ike(r,s))return r;{const h=e<0?u:c,g=t[h];Nt(g!=null,`Previous layout not found for panel index ${h}`);const v=g+d,w=pu({panelConstraints:n,panelIndex:h,size:v});if(s[h]=w,!Ia(w,v)){let S=v-w,_=e<0?u:c;for(;_>=0&&_<n.length;){const E=s[_];Nt(E!=null,`Previous layout not found for panel index ${_}`);const k=E+S,C=pu({panelConstraints:n,panelIndex:_,size:k});if(Ia(E,C)||(S-=C-E,s[_]=C),Ia(S,0))break;e>0?_--:_++}}}const m=s.reduce((h,g)=>g+h,0);return Ia(m,100)?s:r}function oke({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];Nt(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:w=100,minSize:S=0}=v;g===c?(a=S,r=w):(i+=S,s+=w)});const u=Math.min(r,100-i),d=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:d,valueNow:m}}function Gp(e,t=document){return Array.from(t.querySelectorAll(`[${Wn.resizeHandleId}][data-panel-group-id="${e}"]`))}function yZ(e,t,n=document){const r=Gp(e,n).findIndex(i=>i.getAttribute(Wn.resizeHandleId)===t);return r??null}function wZ(e,t,n){const a=yZ(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function ske(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function xZ(e,t=document){if(ske(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function lw(e,t=document){const n=t.querySelector(`[${Wn.resizeHandleId}="${e}"]`);return n||null}function lke(e,t,n,a=document){var r,i,s,c;const u=lw(t,a),d=Gp(e,a),m=u?d.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 cke({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Ol(()=>{if(!i)return;const c=Gp(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:d,valueMin:m,valueNow:h}=oke({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];Nt(v,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",v.id),g.setAttribute("aria-valuemax",""+Math.round(d)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{c.forEach((u,d)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,a,r,i]),x.useEffect(()=>{if(!i)return;const c=t.current;Nt(c,"Eager values not found");const{panelDataArray:u}=c,d=xZ(n,i);Nt(d!=null,`No group found for id "${n}"`);const m=Gp(n,i);Nt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Wn.resizeHandleId);Nt(v,"Resize handle element has no handle id attribute");const[w,S]=lke(n,v,u,i);if(w==null||S==null)return()=>{};const y=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===w);if(E>=0){const k=u[E];Nt(k,`No panel data found for index ${E}`);const C=a[E],{collapsedSize:R=0,collapsible:I,minSize:A=0}=k.constraints;if(C!=null&&I){const O=qf({delta:Ia(C,R)?A-R:R-C,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:wZ(n,v,i),prevLayout:a,trigger:"keyboard"});a!==O&&s(O)}}break}}};return g.addEventListener("keydown",y),()=>{g.removeEventListener("keydown",y)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,a,r,s])}function c2(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 SZ(e,t){const n=e==="horizontal",{x:a,y:r}=iw(t);return n?a:r}function uke(e,t,n,a,r){const i=n==="horizontal",s=lw(t,r);Nt(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Wn.groupId);Nt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const d=SZ(n,e),m=xZ(c,r);Nt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function dke(e,t,n,a,r,i){if(uZ(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:uke(e,t,n,a,i)}function fke({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];Nt(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];Nt(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;if(c!=null)continue;const u=e.length-a,d=r/u;a++,t[i]=d,r-=d}return t}function Vc(e,t,n){t.forEach((a,r)=>{const i=e[r];Nt(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:d=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:w}=s;w&&w(a,h),m&&(g||v)&&(v&&(h==null||Eo(h,d))&&!Eo(a,d)&&v(),g&&(h==null||!Eo(h,d))&&Eo(a,d)&&g())}})}function ob(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 pke({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 mke(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function u2(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 EZ(e){return`react-resizable-panels:${e}`}function _Z(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 kZ(e,t){try{const n=EZ(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function hke(e,t,n){var a,r;const i=(a=kZ(e,n))!==null&&a!==void 0?a:{},s=_Z(t);return(r=i[s])!==null&&r!==void 0?r:null}function gke(e,t,n,a,r){var i;const s=EZ(e),c=_Z(t),u=(i=kZ(e,r))!==null&&i!==void 0?i:{};u[c]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{r.setItem(s,JSON.stringify(u))}catch(d){console.error(d)}}function d2({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(!Ia(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];Nt(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];Nt(s!=null,`No layout data found for index ${i}`);const c=pu({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Ia(r,0))for(let i=0;i<t.length;i++){const s=n[i];Nt(s!=null,`No layout data found for index ${i}`);const c=s+r,u=pu({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Ia(r,0)))break}return n}const bke=100,Xf={getItem:e=>(u2(Xf),Xf.getItem(e)),setItem:(e,t)=>{u2(Xf),Xf.setItem(e,t)}},f2={};function TZ({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=Xf,style:d,tagName:m="div",...h}){const g=nD(i),v=x.useRef(null),[w,S]=x.useState(null),[y,_]=x.useState([]),E=ake(),k=x.useRef({}),C=x.useRef(new Map),R=x.useRef(0),I=x.useRef({autoSaveId:e,direction:a,dragState:w,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),A=x.useRef({layout:y,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(r,()=>({getId:()=>I.current.id,getLayout:()=>{const{layout:z}=A.current;return z},setLayout:z=>{const{onLayout:L}=I.current,{layout:$,panelDataArray:F}=A.current,W=d2({layout:z,panelConstraints:F.map(X=>X.constraints)});c2($,W)||(_(W),A.current.layout=W,L&&L(W),Vc(F,W,k.current))}}),[]),Ol(()=>{I.current.autoSaveId=e,I.current.direction=a,I.current.dragState=w,I.current.id=g,I.current.onLayout=s,I.current.storage=u}),cke({committedValuesRef:I,eagerValuesRef:A,groupId:g,layout:y,panelDataArray:A.current.panelDataArray,setLayout:_,panelGroupElement:v.current}),x.useEffect(()=>{const{panelDataArray:z}=A.current;if(e){if(y.length===0||y.length!==z.length)return;let L=f2[e];L==null&&(L=mke(gke,bke),f2[e]=L);const $=[...z],F=new Map(C.current);L(e,$,F,y,u)}},[e,y,u]),x.useEffect(()=>{});const O=x.useCallback(z=>{const{onLayout:L}=I.current,{layout:$,panelDataArray:F}=A.current;if(z.constraints.collapsible){const W=F.map(J=>J.constraints),{collapsedSize:X=0,panelSize:ie,pivotIndices:le}=vl(F,z,$);if(Nt(ie!=null,`Panel size not found for panel "${z.id}"`),!Eo(ie,X)){C.current.set(z.id,ie);const q=eu(F,z)===F.length-1?ie-X:X-ie,se=qf({delta:q,initialLayout:$,panelConstraints:W,pivotIndices:le,prevLayout:$,trigger:"imperative-api"});ob($,se)||(_(se),A.current.layout=se,L&&L(se),Vc(F,se,k.current))}}},[]),M=x.useCallback((z,L)=>{const{onLayout:$}=I.current,{layout:F,panelDataArray:W}=A.current;if(z.constraints.collapsible){const X=W.map(he=>he.constraints),{collapsedSize:ie=0,panelSize:le=0,minSize:J=0,pivotIndices:q}=vl(W,z,F),se=L??J;if(Eo(le,ie)){const he=C.current.get(z.id),ce=he!=null&&he>=se?he:se,He=eu(W,z)===W.length-1?le-ce:ce-le,Ee=qf({delta:He,initialLayout:F,panelConstraints:X,pivotIndices:q,prevLayout:F,trigger:"imperative-api"});ob(F,Ee)||(_(Ee),A.current.layout=Ee,$&&$(Ee),Vc(W,Ee,k.current))}}},[]),U=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{panelSize:F}=vl($,z,L);return Nt(F!=null,`Panel size not found for panel "${z.id}"`),F},[]),H=x.useCallback((z,L)=>{const{panelDataArray:$}=A.current,F=eu($,z);return pke({defaultSize:L,dragState:w,layout:y,panelData:$,panelIndex:F})},[w,y]),K=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=vl($,z,L);return Nt(X!=null,`Panel size not found for panel "${z.id}"`),W===!0&&Eo(X,F)},[]),Q=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=vl($,z,L);return Nt(X!=null,`Panel size not found for panel "${z.id}"`),!W||Wl(X,F)>0},[]),te=x.useCallback(z=>{const{panelDataArray:L}=A.current;L.push(z),L.sort(($,F)=>{const W=$.order,X=F.order;return W==null&&X==null?0:W==null?-1:X==null?1:W-X}),A.current.panelDataArrayChanged=!0,E()},[E]);Ol(()=>{if(A.current.panelDataArrayChanged){A.current.panelDataArrayChanged=!1;const{autoSaveId:z,onLayout:L,storage:$}=I.current,{layout:F,panelDataArray:W}=A.current;let X=null;if(z){const le=hke(z,W,$);le&&(C.current=new Map(Object.entries(le.expandToSizes)),X=le.layout)}X==null&&(X=fke({panelDataArray:W}));const ie=d2({layout:X,panelConstraints:W.map(le=>le.constraints)});c2(F,ie)||(_(ie),A.current.layout=ie,L&&L(ie),Vc(W,ie,k.current))}}),Ol(()=>{const z=A.current;return()=>{z.layout=[]}},[]);const ae=x.useCallback(z=>{let L=!1;const $=v.current;return $&&window.getComputedStyle($,null).getPropertyValue("direction")==="rtl"&&(L=!0),function(W){W.preventDefault();const X=v.current;if(!X)return()=>null;const{direction:ie,dragState:le,id:J,keyboardResizeBy:q,onLayout:se}=I.current,{layout:he,panelDataArray:ce}=A.current,{initialLayout:Te}=le??{},He=wZ(J,z,X);let Ee=dke(W,z,ie,le,q,X);const ke=ie==="horizontal";ke&&L&&(Ee=-Ee);const ze=ce.map(Be=>Be.constraints),fe=qf({delta:Ee,initialLayout:Te??he,panelConstraints:ze,pivotIndices:He,prevLayout:he,trigger:uZ(W)?"keyboard":"mouse-or-touch"}),Oe=!ob(he,fe);(dZ(W)||fZ(W))&&R.current!=Ee&&(R.current=Ee,!Oe&&Ee!==0?ke?$S(z,Ee<0?mZ:hZ):$S(z,Ee<0?gZ:bZ):$S(z,0)),Oe&&(_(fe),A.current.layout=fe,se&&se(fe),Vc(ce,fe,k.current))}},[]),B=x.useCallback((z,L)=>{const{onLayout:$}=I.current,{layout:F,panelDataArray:W}=A.current,X=W.map(he=>he.constraints),{panelSize:ie,pivotIndices:le}=vl(W,z,F);Nt(ie!=null,`Panel size not found for panel "${z.id}"`);const q=eu(W,z)===W.length-1?ie-L:L-ie,se=qf({delta:q,initialLayout:F,panelConstraints:X,pivotIndices:le,prevLayout:F,trigger:"imperative-api"});ob(F,se)||(_(se),A.current.layout=se,$&&$(se),Vc(W,se,k.current))},[]),Z=x.useCallback((z,L)=>{const{layout:$,panelDataArray:F}=A.current,{collapsedSize:W=0,collapsible:X}=L,{collapsedSize:ie=0,collapsible:le,maxSize:J=100,minSize:q=0}=z.constraints,{panelSize:se}=vl(F,z,$);se!=null&&(X&&le&&Eo(se,W)?Eo(W,ie)||B(z,ie):se<q?B(z,q):se>J&&B(z,J))},[B]),G=x.useCallback((z,L)=>{const{direction:$}=I.current,{layout:F}=A.current;if(!v.current)return;const W=lw(z,v.current);Nt(W,`Drag handle element not found for id "${z}"`);const X=SZ($,L);S({dragHandleId:z,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:X,initialLayout:F})},[]),re=x.useCallback(()=>{S(null)},[]),ne=x.useCallback(z=>{const{panelDataArray:L}=A.current,$=eu(L,z);$>=0&&(L.splice($,1),delete k.current[z.id],A.current.panelDataArrayChanged=!0,E())},[E]),j=x.useMemo(()=>({collapsePanel:O,direction:a,dragState:w,expandPanel:M,getPanelSize:U,getPanelStyle:H,groupId:g,isPanelCollapsed:K,isPanelExpanded:Q,reevaluatePanelConstraints:Z,registerPanel:te,registerResizeHandle:ae,resizePanel:B,startDragging:G,stopDragging:re,unregisterPanel:ne,panelGroupElement:v.current}),[O,w,a,M,U,H,g,K,Q,Z,te,ae,B,G,re,ne]),V={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(aw.Provider,{value:j},x.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...V,...d},[Wn.group]:"",[Wn.groupDirection]:a,[Wn.groupId]:g}))}const NZ=x.forwardRef((e,t)=>x.createElement(TZ,{...e,forwardedRef:t}));TZ.displayName="PanelGroup";NZ.displayName="forwardRef(PanelGroup)";function eu(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function vl(e,t,n){const a=eu(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function vke({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){x.useEffect(()=>{if(e||n==null||a==null)return;const r=lw(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(Wn.groupId);Nt(c,`No group element found for id "${c}"`);const u=Gp(c,a),d=yZ(c,t,a);Nt(d!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?d>0?d-1:u.length-1:d+1<u.length?d+1:0;u[m].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[a,e,t,n])}function CZ({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:d,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...w}){var S,y;const _=x.useRef(null),E=x.useRef({onClick:s,onDragging:c,onPointerDown:d,onPointerUp:m});x.useEffect(()=>{E.current.onClick=s,E.current.onDragging=c,E.current.onPointerDown=d,E.current.onPointerUp=m});const k=x.useContext(aw);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:C,groupId:R,registerResizeHandle:I,startDragging:A,stopDragging:O,panelGroupElement:M}=k,U=nD(r),[H,K]=x.useState("inactive"),[Q,te]=x.useState(!1),[ae,B]=x.useState(null),Z=x.useRef({state:H});Ol(()=>{Z.current.state=H}),x.useEffect(()=>{if(n)B(null);else{const j=I(U);B(()=>j)}},[n,U,I]);const G=(S=a?.coarse)!==null&&S!==void 0?S:15,re=(y=a?.fine)!==null&&y!==void 0?y:5;x.useEffect(()=>{if(n||ae==null)return;const j=_.current;Nt(j,"Element ref not attached");let V=!1;return nke(U,j,C,{coarse:G,fine:re},(L,$,F)=>{if(!$){K("inactive");return}switch(L){case"down":{K("drag"),V=!1,Nt(F,'Expected event to be defined for "down" action'),A(U,F);const{onDragging:W,onPointerDown:X}=E.current;W?.(!0),X?.();break}case"move":{const{state:W}=Z.current;V=!0,W!=="drag"&&K("hover"),Nt(F,'Expected event to be defined for "move" action'),ae(F);break}case"up":{K("hover"),O();const{onClick:W,onDragging:X,onPointerUp:ie}=E.current;X?.(!1),ie?.(),V||W?.();break}}})},[G,C,n,re,I,U,ae,A,O]),vke({disabled:n,handleId:U,resizeHandler:ae,panelGroupElement:M});const ne={touchAction:"none",userSelect:"none"};return x.createElement(v,{...w,children:e,className:t,id:r,onBlur:()=>{te(!1),i?.()},onFocus:()=>{te(!0),u?.()},ref:_,role:"separator",style:{...ne,...h},tabIndex:g,[Wn.groupDirection]:C,[Wn.groupId]:R,[Wn.resizeHandle]:"",[Wn.resizeHandleActive]:H==="drag"?"pointer":Q?"keyboard":void 0,[Wn.resizeHandleEnabled]:!n,[Wn.resizeHandleId]:U,[Wn.resizeHandleState]:H})}CZ.displayName="PanelResizeHandle";function Qr({className:e,...t}){return f.jsx(NZ,{"data-slot":"resizable-panel-group",className:De("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Rn({...e}){return f.jsx(cZ,{"data-slot":"resizable-panel",...e})}function vi({withHandle:e,className:t,...n}){return f.jsx(CZ,{"data-slot":"resizable-handle",className:De("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&f.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:f.jsx(ome,{className:"size-2.5"})})})}function Mm({className:e,...t}){return f.jsx("kbd",{"data-slot":"kbd",className:De("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}function yke({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{ref:u,placeholder:"Search notifications...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Td,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(Mm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Clear all"})]})})]})}function Zs({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return f.jsx("button",{id:e,type:"button",onClick:c,className:De("w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group",t&&"bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500",n&&"ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset",u),children:f.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[a&&f.jsx("div",{className:"flex-shrink-0 mt-1",children:f.jsx("div",{className:De("p-2.5 rounded-full transition-colors",t?"bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600"),children:a})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"flex items-center gap-2 mb-1",children:f.jsx("h3",{className:De("font-medium truncate font-mono text-sm"),children:r})}),i&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function wke({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(kd,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>f.jsx(Zs,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&f.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=r(s.timestamp),d=s.params&&Object.keys(s.params).length>0?Object.keys(s.params).length:0,m=d>0?` | ${d} param${d>1?"s":""}`:"";return u+m})(),onClick:()=>n(s)},s.id))})}function xke({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.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:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(nd,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Le,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?f.jsx(AN,{className:"h-4 w-4 mr-1"}):f.jsx(x8,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,children:s?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,children:f.jsx(wm,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:i,children:f.jsx(DN,{className:"h-4 w-4"})}),c&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(Yi,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{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`})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(CN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function Pv(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 Ske({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{v&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const Z=R.current;if(!Z)return;const G=()=>{Z.scrollTop>0&&(O.current=!0,w(!1))};return Z.addEventListener("scroll",G),()=>Z.removeEventListener("scroll",G)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),x.useEffect(()=>{S&&A.current&&A.current.focus()},[S]);const M=x.useCallback(()=>{d.trim()||y(!1)},[d]),U=x.useMemo(()=>{if(!d.trim())return e;const Z=d.toLowerCase();return e.filter(G=>G.method.toLowerCase().includes(Z)||JSON.stringify(G.params||{}).toLowerCase().includes(Z))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const Z=G=>{const re=G.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||G.metaKey||G.ctrlKey||G.altKey)return;const j=U;if(G.key==="ArrowDown")G.preventDefault(),g(V=>{const z=V+1;return z>=j.length?0:z});else if(G.key==="ArrowUp")G.preventDefault(),g(V=>{const z=V-1;return z<0?j.length-1:z});else if(G.key==="Enter"&&h>=0){G.preventDefault();const V=U[h];V&&H(V)}};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[h,U]),x.useEffect(()=>{if(h>=0){const Z=`notification-${U[h]?.id}`,G=document.getElementById(Z);G&&G.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,U]);const H=x.useCallback(Z=>{u(Z)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),Q=x.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)),C(!0),setTimeout(()=>C(!1),2e3)}catch(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[c]),te=x.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"}),G=URL.createObjectURL(Z),re=document.createElement("a");re.href=G,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(G)}catch(Z){console.error("[NotificationsTab] Failed to download notification:",Z)}},[c]),ae=x.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)}},[]),B=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:Pv}:null;return s?f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(yke,{isSearchExpanded:S,searchQuery:d,filteredNotificationsCount:U.length,notificationsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:M,onClearAll:K,searchInputRef:A}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(wke,{notifications:U,selectedNotification:c,onNotificationSelect:H,focusedIndex:h,formatRelativeTime:Pv,listRef:R})})]})})}),f.jsx(vi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(xke,{notification:B,previewMode:_,onTogglePreview:()=>E(!_),onCopy:Q,onDownload:te,onFullscreen:ae,onClose:()=>u(null),isCopied:k})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(CN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function RZ({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:d="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:w,primaryTabName:S}){const y=e===S;return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?f.jsx(kn,{ref:w,placeholder:d,value:n,onChange:_=>h(_.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:y?a:r}),y&&f.jsxs(f.Fragment,{children:[f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:f.jsx(Td,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(Mm,{children:"F"})]})]})]})]})}),f.jsxs(Le,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[y?f.jsx(c,{}):f.jsx(u,{}),f.jsx("span",{className:"hidden sm:inline",children:y?r:a}),y&&s>0&&f.jsx(xr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function p2({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Cp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((r,i)=>f.jsx(Zs,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(Cp,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&f.jsxs(xr,{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 m2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(RZ,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:Cp,secondaryIcon:nd,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}function h2({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,focusedIndex:r}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(nd,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),f.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,s)=>f.jsx(Zs,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:f.jsx(nd,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function Eke({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.length>0))return f.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],d=typeof u=="string"?u:JSON.stringify(u);return s.type==="boolean"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx("input",{id:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),f.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(Vl,{id:c,value:d,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&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:c,value:d,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return f.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function g2({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return x.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?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsx(Le,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Ei,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(k8,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"}),f.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:"⌘↵"})]})}),f.jsxs(Le,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(jN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(Eke,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),f.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 _ke(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 b2({results:e,copiedResult:t,onCopy:n}){return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:e.length>0?f.jsx("div",{className:"space-y-4 flex-1 h-full",children:e.map((a,r)=>{const i=a.error||_ke(a.result);return f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(nd,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(a.timestamp).toLocaleTimeString()})]}),a.duration!==void 0&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Rp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.duration,"ms"]})]}),f.jsx("div",{className:"flex gap-2 ml-auto",children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>n(r,a.result),className:"h-6 px-2",children:t===r?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})})})]}),i?f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:i})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:a.result,filename:`prompt-result-${a.promptName}-${Date.now()}.json`})})]},r)})}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(kd,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function aD({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=x.useState([]),i=x.useRef(null),[s,c]=x.useState(new Set),[u]=x.useState(""),d=v=>{c(w=>{const S=new Set(w);return S.has(v)?S.delete(v):S.add(v),S})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const w=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});w.ok||console.warn("[RPC Logger] Failed to clear server buffer:",w.status)}catch(v){console.warn("[RPC Logger] Error clearing server buffer:",v)}},h=x.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);x.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),x.useEffect(()=>{t?.(a.length)},[a.length,t]),x.useEffect(()=>{let v=null;try{const w=new URLSearchParams;w.set("replay","3"),w.set("_t",Date.now().toString()),e&&e.length>0&&w.set("serverIds",e.join(","));const S=`/inspector/api/rpc/stream?${w.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",S),v=new globalThis.EventSource(S),v.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},v.onmessage=y=>{try{const _=JSON.parse(y.data);if(!_||_.type!=="rpc")return;const{serverId:E,direction:k,message:C,timestamp:R}=_,I=C,A=typeof I?.method=="string"?I.method:I?.result!==void 0?"result":I?.error!==void 0?"error":"unknown",O={id:`${R??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:A,timestamp:R??new Date().toISOString(),payload:C};console.log("[RPC Logger] Received RPC event:",{method:A,direction:k,serverId:E}),r(M=>{const U=[O,...M].slice(0,1e3);return t?.(U.length),U})}catch(_){console.error("[RPC Logger] Error parsing SSE message:",_)}},v.onerror=y=>{console.error("[RPC Logger] SSE connection error:",y);try{v?.close()}catch{}}}catch(w){console.error("[RPC Logger] Failed to create SSE connection:",w)}return()=>{try{v?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=x.useMemo(()=>{let v=a;if(e&&e.length>0){const w=new Set(e);v=v.filter(S=>w.has(S.serverId))}if(u.trim()){const w=u.toLowerCase();v=v.filter(S=>S.serverId.toLowerCase().includes(w)||S.method.toLowerCase().includes(w)||S.direction.toLowerCase().includes(w)||JSON.stringify(S.payload).toLowerCase().includes(w))}return v},[a,u,e]);return f.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:f.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?f.jsxs("div",{className:"text-center py-8",children:[f.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),f.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const w=s.has(v.id);return f.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[f.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(v.id),children:[f.jsx("div",{className:"flex-shrink-0",children:w?f.jsx(Xl,{className:"h-3 w-3 text-muted-foreground transition-transform"}):f.jsx(Npe,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),f.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[f.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),f.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"?f.jsx(hpe,{className:"h-3 w-3"}):f.jsx(bpe,{className:"h-3 w-3"})}),f.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),w&&f.jsx("div",{className:"border-t bg-muted/20",children:f.jsx("div",{className:"p-3",children:f.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:f.jsx(Jn,{data:v.payload})})})})]},v.id)})})})}const v2="mcp-inspector-saved-prompts";function AZ({ref:e,prompts:t,callPrompt:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),[c,u]=x.useState(null),{selectedPromptName:d,setSelectedPromptName:m}=Jl(),[h,g]=x.useState({}),[v,w]=x.useState([]),[S,y]=x.useState(!1),[_,E]=x.useState(null),[k,C]=x.useState(""),[R,I]=x.useState("prompts"),[A,O]=x.useState([]),[M,U]=x.useState(!1),[H,K]=x.useState(""),[Q,te]=x.useState(!1),[ae,B]=x.useState(-1),Z=x.useRef(null),[G,re]=x.useState(!1),[ne,j]=x.useState("list"),[V,z]=x.useState(0),[L,$]=x.useState(!0),F=x.useRef(null),W=x.useRef(null);x.useEffect(()=>{const Ee=()=>{re(window.innerWidth<1024)};return Ee(),window.addEventListener("resize",Ee),()=>window.removeEventListener("resize",Ee)},[]),x.useEffect(()=>{j(i?"detail":"list")},[i]),x.useEffect(()=>{G&&v.length>0&&!S&&j("response")},[v,S,G]),x.useImperativeHandle(e,()=>({focusSearch:()=>{te(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{C(""),te(!1),Z.current&&Z.current.blur()}})),x.useEffect(()=>{try{const Ee=localStorage.getItem(v2);if(Ee){const ke=JSON.parse(Ee);O(ke)}}catch(Ee){console.error("[PromptsTab] Failed to load saved prompts:",Ee)}},[]);const X=x.useCallback(Ee=>{try{localStorage.setItem(v2,JSON.stringify(Ee))}catch(ke){console.error("[PromptsTab] Failed to save prompts:",ke)}},[]);x.useEffect(()=>{Q&&Z.current&&Z.current.focus()},[Q]);const ie=x.useCallback(()=>{k.trim()||te(!1)},[k]),le=x.useMemo(()=>{if(!k.trim())return t;const Ee=k.toLowerCase();return t.filter(ke=>ke.name.toLowerCase().includes(Ee)||ke.description?.toLowerCase().includes(Ee))},[t,k]),J=x.useCallback(Ee=>{s(Ee);const ke={};Ee.arguments&&Ee.arguments.forEach(ze=>{ze.default!==void 0?ke[ze.name]=ze.default:ze.type==="string"?ke[ze.name]="":ze.type==="number"?ke[ze.name]=0:ze.type==="boolean"?ke[ze.name]=!1:ze.type==="array"?ke[ze.name]=[]:ze.type==="object"&&(ke[ze.name]={})}),g(ke)},[]),q=x.useCallback(Ee=>{const ke=t.find(ze=>ze.name===Ee.promptName);ke&&(s(ke),g(Ee.args),u(Ee))},[t]);x.useEffect(()=>{B(-1)},[k,R]),x.useEffect(()=>{const Ee=ke=>{const ze=ke.target;if(ze.tagName==="INPUT"||ze.tagName==="TEXTAREA"||ze.contentEditable==="true"||ke.metaKey||ke.ctrlKey||ke.altKey)return;const Oe=R==="prompts"?le:A;if(ke.key==="ArrowDown")ke.preventDefault(),B(Be=>{const Se=Be+1;return Se>=Oe.length?0:Se});else if(ke.key==="ArrowUp")ke.preventDefault(),B(Be=>{const Se=Be-1;return Se<0?Oe.length-1:Se});else if(ke.key==="Enter"&&ae>=0)if(ke.preventDefault(),R==="prompts"){const Be=le[ae];Be&&J(Be)}else{const Be=A[ae];Be&&q(Be)}};return document.addEventListener("keydown",Ee),()=>document.removeEventListener("keydown",Ee)},[ae,le,A,R,J,q]),x.useEffect(()=>{if(ae>=0){const Ee=R==="prompts"?`prompt-${le[ae]?.name}`:`saved-prompt-${A[ae]?.id}`,ke=document.getElementById(Ee);ke&&ke.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ae,le,A,R]),x.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:d,promptsCount:t.length,currentSelectedPrompt:i?.name}),d&&t.length>0){const Ee=t.find(ke=>ke.name===d);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:d,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 ke=setTimeout(()=>{J(Ee);const ze=document.getElementById(`prompt-${Ee.name}`);ze&&(console.warn("[PromptsTab] Scrolling to prompt element"),ze.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(ke)}}},[d,t,i,J,m]);const se=x.useCallback((Ee,ke)=>{g(ze=>({...ze,[Ee]:ke}))},[]),he=x.useCallback(async()=>{if(!i||S)return;y(!0);const Ee=Date.now();try{const ke=await n(i.name,h),ze=Date.now()-Ee;yr.getInstance().capture(new DU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),w(Oe=>[{promptName:i.name,args:h,result:ke,timestamp:Ee,duration:ze},...Oe])}catch(ke){yr.getInstance().capture(new DU({promptName:i.name,serverId:a,success:!1,error:ke instanceof Error?ke.message:"Unknown error"})).catch(()=>{});const fe={promptName:i.name,args:h,result:null,error:ke instanceof Error?ke.message:String(ke),timestamp:Ee,duration:Date.now()-Ee};w(Oe=>[fe,...Oe])}finally{y(!1)}},[i,h,S,n,a]),ce=x.useCallback(async(Ee,ke)=>{try{await navigator.clipboard.writeText(JSON.stringify(ke,null,2)),E(Ee),setTimeout(()=>E(null),2e3)}catch(ze){console.error("[PromptsTab] Failed to copy result:",ze)}},[]),Te=x.useCallback(()=>{i&&(K(""),U(!0))},[i]),He=x.useCallback(Ee=>{X(A.filter(ke=>ke.id!==Ee)),c?.id===Ee&&u(null)},[A,X,c]);return G?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[ne!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{ne==="response"?j("detail"):(s(null),j("list"))},className:"p-0 h-8 w-8",children:f.jsx(RN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{s(null),j("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),ne!=="list"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{ne==="response"&&j("detail")},className:ne==="detail"?"text-foreground hover:underline":ne==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),ne==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($y,{initial:!1,mode:"popLayout",children:[ne==="list"&&f.jsxs(ga.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:[f.jsx(m2,{activeTab:R,isSearchExpanded:Q,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>te(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>I(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(p2,{prompts:le,selectedPrompt:i,onPromptSelect:J,focusedIndex:ae}):f.jsx(h2,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ae})]},"list"),ne==="detail"&&f.jsx(ga.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:f.jsx(g2,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:se,onExecute:he,onSave:Te})},"detail"),ne==="response"&&f.jsx(ga.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:f.jsx(b2,{results:v,copiedResult:_,onCopy:ce})},"response")]})})]}):f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:33,className:"flex flex-col h-full relative",children:f.jsxs(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(m2,{activeTab:R,isSearchExpanded:Q,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>te(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>I(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(p2,{prompts:le,selectedPrompt:i,onPromptSelect:J,focusedIndex:ae}):f.jsx(h2,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ae})]})}),f.jsx(vi,{withHandle:!0}),f.jsxs(Rn,{ref:F,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>$(!0),onExpand:()=>$(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),L?(F.current?.resize(25),$(!1)):(F.current?.resize(5),$(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),V>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:V}),V>0&&!L&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),W.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{className:`h-4 w-4 text-muted-foreground transition-transform ${L?"rotate-180":""}`})]}),!L&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(aD,{serverIds:[a],onCountChange:z,onClearRef:W})})]})]})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Qr,{direction:"vertical",children:[f.jsx(Rn,{defaultSize:40,children:f.jsx(g2,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:se,onExecute:he,onSave:Te})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:50,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(b2,{results:v,copiedResult:_,onCopy:ce})})})]})})]})}AZ.displayName="PromptsTab";function Su(e){if(!e?.mimeType)return!1;const t=e.mimeType.toLowerCase();return t==="text/html"||t==="text/html+skybridge"||t==="text/uri-list"||t.startsWith("application/vnd.mcp-ui.remote-dom")}function kke(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function IZ({resource:e,onUIAction:t,className:n}){const a=async i=>t?.(i),r=kke(e);return f.jsx("div",{className:n,children:f.jsx(eD,{resource:r,onUIAction:a,htmlProps:{autoResizeIframe:{width:!0,height:!0},style:{width:"100%",minHeight:"200px"},sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},remoteDomProps:{remoteElements:[$_e,L_e,M_e,P_e],library:QO}})})}function Tke(e){if("error"in e&&e.error)return e.error;if(!("isError"in e&&e.isError))return null;if("contents"in e&&Array.isArray(e.contents)){const t=e.contents.filter(n=>"text"in n).map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
1660
|
+
`);k=I.pop()||"";for(const A of I)if(A.trim()&&A.startsWith("data: "))try{const O=JSON.parse(A.slice(6));if(console.log("[Client received event]",O.type,O.toolName||O.content?.slice?.(0,30)),O.type==="message")console.log("[Message started]",O.id);else if(O.type==="text"){S+=O.content;const M=y[y.length-1];M&&M.type==="text"?M.text=S:y.push({type:"text",text:S}),console.log("[Parts after text]",y.length,"parts, text length:",S.length),i(U=>U.map(H=>H.id===w?{...H,parts:[...y]}:H))}else if(O.type==="tool-call")S&&(S=""),y.push({type:"tool-invocation",toolInvocation:{toolName:O.toolName,args:O.args,state:"pending"}}),console.log("[Parts after tool-call]",y.length,"parts, tool:",O.toolName),i(M=>M.map(U=>U.id===w?{...U,parts:[...y]}:U));else if(O.type==="tool-result"){const M=y.find(U=>U.type==="tool-invocation"&&U.toolInvocation?.toolName===O.toolName&&!U.toolInvocation?.result);M&&M.toolInvocation?(M.toolInvocation.result=O.result,M.toolInvocation.state="result",console.log("[Parts after tool-result]",y.length,"parts, updated:",O.toolName),i(U=>U.map(H=>H.id===w?{...H,parts:[...y]}:H))):console.warn("[tool-result] Could not find matching tool part for",O.toolName)}else if(O.type==="done")console.log("[Done] Final parts:",y.length),i(M=>M.map(U=>U.id===w?{...U,parts:[...y],content:""}:U));else if(O.type==="error")throw new Error(O.message||"Streaming error")}catch(O){console.error("Failed to parse streaming event:",O,A)}}}catch(g){let v="Unknown error occurred";if(g instanceof Error){v=g.message;const S=g;S.status&&(v=`HTTP ${S.status}: ${v}`),(S.code===401||v.includes("401")||v.includes("Unauthorized"))&&(v="Authentication failed (401). Check your Authorization header in the connection settings.")}const w={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${v}`,timestamp:Date.now()};i(S=>[...S,w])}finally{c(!1)}},[t,a,e,r,n]),d=x.useCallback(()=>{i([])},[]);return{messages:r,isLoading:s,sendMessage:u,clearMessages:d}}function H_e({connection:e,llmConfig:t,isConnected:n,readResource:a}){const[r,i]=x.useState([]),[s,c]=x.useState(!1),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),h=x.useCallback(async v=>{if(!v.trim()||!t||!n)return;const w={id:`user-${Date.now()}`,role:"user",content:v.trim(),timestamp:Date.now()};i(_=>[..._,w]),c(!0),u.current=new AbortController;const S=Date.now();let y=0;try{const _=`assistant-${Date.now()}`;let E="";const k=[];if(i(C=>[...C,{id:_,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 C;if(t.provider==="openai"){const{ChatOpenAI:R}=await Qn(async()=>{const{ChatOpenAI:I}=await import("./index-DMdheUGh.js");return{ChatOpenAI:I}},__vite__mapDeps([5,6,7,3,8,9]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="anthropic"){const{ChatAnthropic:R}=await Qn(async()=>{const{ChatAnthropic:I}=await import("./index-O0gjGlMB.js");return{ChatAnthropic:I}},__vite__mapDeps([10,7,6,3]));C=new R({model:t.model,apiKey:t.apiKey})}else if(t.provider==="google"){const{ChatGoogleGenerativeAI:R}=await Qn(async()=>{const{ChatGoogleGenerativeAI:I}=await import("./index-BFcdg9p1.js");return{ChatGoogleGenerativeAI:I}},__vite__mapDeps([11,7,6,3,9]));C=new R({model:t.model,apiKey:t.apiKey})}else throw new Error(`Unsupported LLM provider: ${t.provider}`);m.current={instance:C,provider:t.provider,model:t.model,apiKey:t.apiKey}}if(!d.current||d.current.llm!==m.current.instance){const{MCPAgent:C}=await Qn(async()=>{const{MCPAgent:R}=await import("./browser-BzPxdp9T.js");return{MCPAgent:R}},__vite__mapDeps([12,8,6,7,3,9]));d.current=new C({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 d.current.initialize()}else console.log("[useChatMessagesClientSide] Reusing existing agent. History length:",d.current.conversationHistory?.length);for await(const C of d.current.streamEvents(v,10,!1,void 0)){if(u.current?.signal.aborted)break;if(C.event==="on_chat_model_stream"&&C.data?.chunk?.text){const R=C.data.chunk.text;if(typeof R=="string"&&R.length>0){E+=R;const I=k[k.length-1];I&&I.type==="text"?I.text=E:k.push({type:"text",text:E}),i(A=>A.map(O=>O.id===_?{...O,parts:[...k]}:O))}}else if(C.event==="on_tool_start"){E&&(E="");let R={};C.data?.input?R=C.data.input:C.data?.tool_input?R=C.data.tool_input:C.data&&(R=C.data),console.log("[useChatMessagesClientSide] on_tool_start:",{toolName:C.name,eventData:C.data,extractedArgs:R}),y++,k.push({type:"tool-invocation",toolInvocation:{toolName:C.name||"unknown",args:R,state:"pending"}}),i(I=>I.map(A=>A.id===_?{...A,parts:[...k]}:A))}else if(C.event==="on_tool_end"){const R=k.find(I=>I.type==="tool-invocation"&&I.toolInvocation?.toolName===C.name&&!I.toolInvocation?.result);if(console.log("[useChatMessagesClientSide] on_tool_end event:",{toolName:C.name,hasToolPart:!!R,output:C.data?.output}),R&&R.toolInvocation){let I=C.data?.output;if(I?.kwargs?.content&&typeof I.kwargs.content=="string")try{I=JSON.parse(I.kwargs.content)}catch(O){console.warn("[useChatMessagesClientSide] Failed to parse kwargs.content:",O),I=I.kwargs.content}else if(I?.content&&typeof I.content=="string")try{I=JSON.parse(I.content)}catch{I=I.content}R.toolInvocation.result=I,R.toolInvocation.state="result";const A=I?._meta?.["openai/outputTemplate"];if(console.log("[useChatMessagesClientSide] Tool result:",{toolName:C.name,hasMeta:!!I?._meta,hasStructuredContent:!!I?.structuredContent,appsSdkUri:A}),A&&typeof A=="string"&&a){console.log("[useChatMessagesClientSide] Detected Apps SDK component, fetching resource:",A);try{const O=await a(A);console.log("[useChatMessagesClientSide] Resource fetched:",O);const M=I?.structuredContent||null;if(O?.contents&&Array.isArray(O.contents)){const U=O.contents.map(K=>({type:"resource",resource:K}));console.log("[useChatMessagesClientSide] Created MCP resources:",U);const H={...I,content:[...I.content||[],...U],structuredContent:M};R.toolInvocation.result=H,console.log("[useChatMessagesClientSide] Updated result with resources")}else console.warn("[useChatMessagesClientSide] No contents in resourceData:",O)}catch(O){console.error("Failed to fetch Apps SDK resource:",O)}}i(O=>O.map(M=>M.id===_?{...M,parts:[...k]}:M))}}}i(C=>C.map(R=>R.id===_?{...R,parts:[...k],content:""}:R)),t&&yr.getInstance().capture(new jU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!0,executionMode:"client-side",duration:Date.now()-S})).catch(()=>{})}catch(_){console.error("Client-side agent error:",_);let E="Unknown error occurred";if(_ instanceof Error){E=_.message;const C=_;C.status&&(E=`HTTP ${C.status}: ${E}`),(C.code===401||E.includes("401")||E.includes("Unauthorized"))&&(E="Authentication failed (401). Check your Authorization header in the connection settings.")}t&&yr.getInstance().capture(new jU({serverId:e.url,provider:t.provider,model:t.model,messageCount:r.length+1,toolCallsCount:y,success:!1,executionMode:"client-side",duration:Date.now()-S,error:E})).catch(()=>{});const k={id:`error-${Date.now()}`,role:"assistant",content:`Error: ${E}`,timestamp:Date.now()};i(C=>[...C,k])}finally{c(!1),u.current=null}},[e,t,n,r,a]),g=x.useCallback(()=>{i([]),d.current&&d.current.clearConversationHistory()},[]);return{messages:r,isLoading:s,sendMessage:h,clearMessages:g}}const a2={openai:"gpt-4o",anthropic:"claude-haiku-4-5-20251001",google:"gemini-2.5-flash"};function sZ({mcpServerUrl:e}){const[t,n]=x.useState(null),[a,r]=x.useState(null),[i,s]=x.useState(!1),[c,u]=x.useState("openai"),[d,m]=x.useState(""),[h,g]=x.useState(a2.openai),v=x.useCallback(()=>{const M=localStorage.getItem("mcp-inspector-api-keys");if(M)try{return JSON.parse(M)}catch(U){return console.error("Failed to load API keys:",U),{}}return{}},[]),w=x.useCallback(M=>{localStorage.setItem("mcp-inspector-api-keys",JSON.stringify(M))},[]),[S,y]=x.useState("none"),[_,E]=x.useState(""),[k,C]=x.useState(""),[R,I]=x.useState("");x.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-llm-config"),U=v();if(M)try{const H=JSON.parse(M);n(H),u(H.provider),m(U[H.provider]||H.apiKey||""),g(H.model)}catch(H){console.error("Failed to load LLM config:",H)}},[v]),x.useEffect(()=>{const M=localStorage.getItem("mcp-inspector-auth-config");if(M)try{const U=JSON.parse(M);r(U),y(U.type),U.username&&E(U.username),U.password&&C(U.password),U.token&&I(U.token)}catch(U){console.error("Failed to load auth config:",U)}else try{const U="mcp:auth",H=oZ(e),K=`${U}_${H}_tokens`;localStorage.getItem(K)&&(r({type:"oauth"}),y("oauth"))}catch(U){console.error("Failed to check for OAuth tokens:",U)}},[e]),x.useEffect(()=>{g(a2[c]);const M=v();m(M[c]||"")},[c,v]);const A=x.useCallback(()=>{if(!d.trim())return;const M=v();M[c]=d,w(M);const U={provider:c,apiKey:d,model:h},H={type:S,...S==="basic"&&{username:_.trim(),password:k.trim()},...S==="bearer"&&{token:R.trim()}};n(U),r(H),localStorage.setItem("mcp-inspector-llm-config",JSON.stringify(U)),localStorage.setItem("mcp-inspector-auth-config",JSON.stringify(H)),s(!1)},[c,d,h,S,_,k,R,v,w]),O=x.useCallback(()=>{n(null),r(null);const M=v();delete M[c],w(M),m(""),E(""),C(""),I(""),y("none"),localStorage.removeItem("mcp-inspector-llm-config"),localStorage.removeItem("mcp-inspector-auth-config")},[c,v,w]);return{llmConfig:t,authConfig:a,configDialogOpen:i,setConfigDialogOpen:s,tempProvider:c,setTempProvider:u,tempApiKey:d,setTempApiKey:m,tempModel:h,setTempModel:g,tempAuthType:S,saveLLMConfig:A,clearConfig:O}}function V_e({connection:e,isConnected:t,useClientSide:n=!0,readResource:a}){const[r,i]=x.useState(""),s=x.useRef(null),{llmConfig:c,authConfig:u,configDialogOpen:d,setConfigDialogOpen:m,tempProvider:h,setTempProvider:g,tempApiKey:v,setTempApiKey:w,tempModel:S,setTempModel:y,saveLLMConfig:_,clearConfig:E}=sZ({mcpServerUrl:e.url}),k={connection:e,llmConfig:c,isConnected:t,readResource:a},C=B_e({mcpServerUrl:e.url,llmConfig:c,authConfig:u,isConnected:t}),R=H_e(k),{messages:I,isLoading:A,sendMessage:O,clearMessages:M}=n?R:C;i7({onNewChat:M}),x.useEffect(()=>{c&&I.length===0&&s.current&&s.current.focus()},[c,I.length]),x.useEffect(()=>{!A&&I.length>0&&s.current&&s.current.focus()},[A,I.length]);const U=x.useCallback(()=>{r.trim()&&(O(r),i(""))},[r,O]),H=x.useCallback(Q=>{Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),U())},[U]),K=x.useCallback(()=>{E(),M()},[E,M]);return c&&I.length===0?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"absolute top-4 right-4 z-10",children:f.jsx(l_,{open:d,onOpenChange:m,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSave:_,onClear:K,showClearButton:!0,buttonLabel:"Change API Key"})}),f.jsx(rxe,{mcpServerUrl:e.url,inputValue:r,isConnected:t,isLoading:A,textareaRef:s,llmConfig:c,onInputChange:i,onKeyDown:H,onSubmit:Q=>{Q.preventDefault(),U()},onConfigDialogOpenChange:m})]}):f.jsxs("div",{className:"flex flex-col h-full relative",children:[f.jsx(exe,{llmConfig:c,hasMessages:I.length>0,configDialogOpen:d,onConfigDialogOpenChange:m,onClearChat:M,tempProvider:h,tempModel:S,tempApiKey:v,onProviderChange:g,onModelChange:y,onApiKeyChange:w,onSaveConfig:_,onClearConfig:K}),f.jsx("div",{className:"flex-1 overflow-y-auto p-2 sm:p-4 pt-[80px] sm:pt-[100px]",children:c?f.jsx(F_e,{messages:I,isLoading:A,serverId:e.url,readResource:a,tools:e.tools}):f.jsx(axe,{onConfigureClick:()=>m(!0)})}),c&&f.jsx(txe,{inputValue:r,isConnected:t,isLoading:A,textareaRef:s,onInputChange:i,onKeyDown:H,onSendMessage:U})]})}const aw=x.createContext(null);aw.displayName="PanelGroupContext";const Wn={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"},tD=10,Ol=x.useLayoutEffect,i2=pd.useId,G_e=typeof i2=="function"?i2:()=>null;let W_e=0;function nD(e=null){const t=G_e(),n=x.useRef(e||t||null);return n.current===null&&(n.current=""+W_e++),e??n.current}function lZ({children:e,className:t="",collapsedSize:n,collapsible:a,defaultSize:r,forwardedRef:i,id:s,maxSize:c,minSize:u,onCollapse:d,onExpand:m,onResize:h,order:g,style:v,tagName:w="div",...S}){const y=x.useContext(aw);if(y===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:_,expandPanel:E,getPanelSize:k,getPanelStyle:C,groupId:R,isPanelCollapsed:I,reevaluatePanelConstraints:A,registerPanel:O,resizePanel:M,unregisterPanel:U}=y,H=nD(s),K=x.useRef({callbacks:{onCollapse:d,onExpand:m,onResize:h},constraints:{collapsedSize:n,collapsible:a,defaultSize:r,maxSize:c,minSize:u},id:H,idIsFromProps:s!==void 0,order:g});x.useRef({didLogMissingDefaultSizeWarning:!1}),Ol(()=>{const{callbacks:te,constraints:ae}=K.current,B={...ae};K.current.id=H,K.current.idIsFromProps=s!==void 0,K.current.order=g,te.onCollapse=d,te.onExpand=m,te.onResize=h,ae.collapsedSize=n,ae.collapsible=a,ae.defaultSize=r,ae.maxSize=c,ae.minSize=u,(B.collapsedSize!==ae.collapsedSize||B.collapsible!==ae.collapsible||B.maxSize!==ae.maxSize||B.minSize!==ae.minSize)&&A(K.current,B)}),Ol(()=>{const te=K.current;return O(te),()=>{U(te)}},[g,H,O,U]),x.useImperativeHandle(i,()=>({collapse:()=>{_(K.current)},expand:te=>{E(K.current,te)},getId(){return H},getSize(){return k(K.current)},isCollapsed(){return I(K.current)},isExpanded(){return!I(K.current)},resize:te=>{M(K.current,te)}}),[_,E,k,I,H,M]);const Q=C(K.current,r);return x.createElement(w,{...S,children:e,className:t,id:H,style:{...Q,...v},[Wn.groupId]:R,[Wn.panel]:"",[Wn.panelCollapsible]:a||void 0,[Wn.panelId]:H,[Wn.panelSize]:parseFloat(""+Q.flexGrow).toFixed(1)})}const cZ=x.forwardRef((e,t)=>x.createElement(lZ,{...e,forwardedRef:t}));lZ.displayName="Panel";cZ.displayName="forwardRef(Panel)";let M_=null,Ib=-1,Ns=null;function K_e(e,t,n){const a=(t&mZ)!==0,r=(t&hZ)!==0,i=(t&gZ)!==0,s=(t&bZ)!==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 Z_e(){Ns!==null&&(document.head.removeChild(Ns),M_=null,Ns=null,Ib=-1)}function DS(e,t,n){var a,r;const i=K_e(e,t);if(M_!==i){if(M_=i,Ns===null&&(Ns=document.createElement("style"),document.head.appendChild(Ns)),Ib>=0){var s;(s=Ns.sheet)===null||s===void 0||s.removeRule(Ib)}Ib=(a=(r=Ns.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${i} !important;}`))!==null&&a!==void 0?a:-1}}function uZ(e){return e.type==="keydown"}function dZ(e){return e.type.startsWith("pointer")}function fZ(e){return e.type.startsWith("mouse")}function iw(e){if(dZ(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(fZ(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Y_e(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function q_e(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 X_e(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:l2(e),b:l2(t)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),a=e;Nt(a,"Stacking order can only be calculated for elements with a common ancestor");const r={a:s2(o2(n.a)),b:s2(o2(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 J_e=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Q_e(e){var t;const n=getComputedStyle((t=pZ(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function eke(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Q_e(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"||J_e.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function o2(e){let t=e.length;for(;t--;){const n=e[t];if(Nt(n,"Missing node"),eke(n))return n}return null}function s2(e){return e&&Number(getComputedStyle(e).zIndex)||0}function l2(e){const t=[];for(;e;)t.push(e),e=pZ(e);return t}function pZ(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const mZ=1,hZ=2,gZ=4,bZ=8,tke=Y_e()==="coarse";let bi=[],xu=!1,Cs=new Map,ow=new Map;const Vp=new Set;function nke(e,t,n,a,r){var i;const{ownerDocument:s}=t,c={direction:n,element:t,hitAreaMargins:a,setResizeHandlerState:r},u=(i=Cs.get(s))!==null&&i!==void 0?i:0;return Cs.set(s,u+1),Vp.add(c),$v(),function(){var m;ow.delete(e),Vp.delete(c);const h=(m=Cs.get(s))!==null&&m!==void 0?m:1;if(Cs.set(s,h-1),$v(),h===1&&Cs.delete(s),bi.includes(c)){const g=bi.indexOf(c);g>=0&&bi.splice(g,1),sw(),r("up",!0,null)}}}function rke(e){const{target:t}=e,{x:n,y:a}=iw(e);xu=!0,rD({target:t,x:n,y:a}),$v(),bi.length>0&&(Mv("down",e),sw(),e.preventDefault(),vZ(t)||e.stopImmediatePropagation())}function jS(e){const{x:t,y:n}=iw(e);if(xu&&e.type!=="pointerleave"&&e.buttons===0&&(xu=!1,Mv("up",e)),!xu){const{target:a}=e;rD({target:a,x:t,y:n})}Mv("move",e),sw(),bi.length>0&&e.preventDefault()}function LS(e){const{target:t}=e,{x:n,y:a}=iw(e);ow.clear(),xu=!1,bi.length>0&&(e.preventDefault(),vZ(t)||e.stopImmediatePropagation()),Mv("up",e),rD({target:t,x:n,y:a}),sw(),$v()}function vZ(e){let t=e;for(;t;){if(t.hasAttribute(Wn.resizeHandle))return!0;t=t.parentElement}return!1}function rD({target:e,x:t,y:n}){bi.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),Vp.forEach(r=>{const{element:i,hitAreaMargins:s}=r,c=i.getBoundingClientRect(),{bottom:u,left:d,right:m,top:h}=c,g=tke?s.coarse:s.fine;if(t>=d-g&&t<=m+g&&n>=h-g&&n<=u+g){if(a!==null&&document.contains(a)&&i!==a&&!i.contains(a)&&!a.contains(i)&&X_e(a,i)>0){let w=a,S=!1;for(;w&&!w.contains(i);){if(q_e(w.getBoundingClientRect(),c)){S=!0;break}w=w.parentElement}if(S)return}bi.push(r)}})}function $S(e,t){ow.set(e,t)}function sw(){let e=!1,t=!1;bi.forEach(a=>{const{direction:r}=a;r==="horizontal"?e=!0:t=!0});let n=0;ow.forEach(a=>{n|=a}),e&&t?DS("intersection",n):e?DS("horizontal",n):t?DS("vertical",n):Z_e()}let MS;function $v(){var e;(e=MS)===null||e===void 0||e.abort(),MS=new AbortController;const t={capture:!0,signal:MS.signal};Vp.size&&(xu?(bi.length>0&&Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("contextmenu",LS,t),r.addEventListener("pointerleave",jS,t),r.addEventListener("pointermove",jS,t))}),Cs.forEach((n,a)=>{const{body:r}=a;r.addEventListener("pointerup",LS,t),r.addEventListener("pointercancel",LS,t)})):Cs.forEach((n,a)=>{const{body:r}=a;n>0&&(r.addEventListener("pointerdown",rke,t),r.addEventListener("pointermove",jS,t))}))}function Mv(e,t){Vp.forEach(n=>{const{setResizeHandlerState:a}=n,r=bi.includes(n);a(e,r,t)})}function ake(){const[e,t]=x.useState(0);return x.useCallback(()=>t(n=>n+1),[])}function Nt(e,t){if(!e)throw console.error(t),Error(t)}function Wl(e,t,n=tD){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Eo(e,t,n=tD){return Wl(e,t,n)===0}function Ia(e,t,n){return Wl(e,t,n)===0}function ike(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(!Ia(r,i,n))return!1}return!0}function pu({panelConstraints:e,panelIndex:t,size:n}){const a=e[t];Nt(a!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:i,maxSize:s=100,minSize:c=0}=a;if(Wl(n,c)<0)if(i){const u=(r+c)/2;Wl(n,u)<0?n=r:n=c}else n=c;return n=Math.min(s,n),n=parseFloat(n.toFixed(tD)),n}function qf({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:a,prevLayout:r,trigger:i}){if(Ia(e,0))return t;const s=[...t],[c,u]=a;Nt(c!=null,"Invalid first pivot index"),Nt(u!=null,"Invalid second pivot index");let d=0;if(i==="keyboard"){{const h=e<0?u:c,g=n[h];Nt(g,`Panel constraints not found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(Nt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,v)){const _=S-y;Wl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}{const h=e<0?c:u,g=n[h];Nt(g,`No panel constraints found for index ${h}`);const{collapsedSize:v=0,collapsible:w,minSize:S=0}=g;if(w){const y=t[h];if(Nt(y!=null,`Previous layout not found for panel index ${h}`),Ia(y,S)){const _=y-v;Wl(_,Math.abs(e))>0&&(e=e<0?0-_:_)}}}}{const h=e<0?1:-1;let g=e<0?u:c,v=0;for(;;){const S=t[g];Nt(S!=null,`Previous layout not found for panel index ${g}`);const _=pu({panelConstraints:n,panelIndex:g,size:100})-S;if(v+=_,g+=h,g<0||g>=n.length)break}const w=Math.min(Math.abs(e),Math.abs(v));e=e<0?0-w:w}{let g=e<0?c:u;for(;g>=0&&g<n.length;){const v=Math.abs(e)-Math.abs(d),w=t[g];Nt(w!=null,`Previous layout not found for panel index ${g}`);const S=w-v,y=pu({panelConstraints:n,panelIndex:g,size:S});if(!Ia(w,y)&&(d+=w-y,s[g]=y,d.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?g--:g++}}if(ike(r,s))return r;{const h=e<0?u:c,g=t[h];Nt(g!=null,`Previous layout not found for panel index ${h}`);const v=g+d,w=pu({panelConstraints:n,panelIndex:h,size:v});if(s[h]=w,!Ia(w,v)){let S=v-w,_=e<0?u:c;for(;_>=0&&_<n.length;){const E=s[_];Nt(E!=null,`Previous layout not found for panel index ${_}`);const k=E+S,C=pu({panelConstraints:n,panelIndex:_,size:k});if(Ia(E,C)||(S-=C-E,s[_]=C),Ia(S,0))break;e>0?_--:_++}}}const m=s.reduce((h,g)=>g+h,0);return Ia(m,100)?s:r}function oke({layout:e,panelsArray:t,pivotIndices:n}){let a=0,r=100,i=0,s=0;const c=n[0];Nt(c!=null,"No pivot index found"),t.forEach((h,g)=>{const{constraints:v}=h,{maxSize:w=100,minSize:S=0}=v;g===c?(a=S,r=w):(i+=S,s+=w)});const u=Math.min(r,100-i),d=Math.max(a,100-s),m=e[c];return{valueMax:u,valueMin:d,valueNow:m}}function Gp(e,t=document){return Array.from(t.querySelectorAll(`[${Wn.resizeHandleId}][data-panel-group-id="${e}"]`))}function yZ(e,t,n=document){const r=Gp(e,n).findIndex(i=>i.getAttribute(Wn.resizeHandleId)===t);return r??null}function wZ(e,t,n){const a=yZ(e,t,n);return a!=null?[a,a+1]:[-1,-1]}function ske(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function xZ(e,t=document){if(ske(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function lw(e,t=document){const n=t.querySelector(`[${Wn.resizeHandleId}="${e}"]`);return n||null}function lke(e,t,n,a=document){var r,i,s,c;const u=lw(t,a),d=Gp(e,a),m=u?d.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 cke({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:a,panelDataArray:r,panelGroupElement:i,setLayout:s}){x.useRef({didWarnAboutMissingResizeHandle:!1}),Ol(()=>{if(!i)return;const c=Gp(n,i);for(let u=0;u<r.length-1;u++){const{valueMax:d,valueMin:m,valueNow:h}=oke({layout:a,panelsArray:r,pivotIndices:[u,u+1]}),g=c[u];if(g!=null){const v=r[u];Nt(v,`No panel data found for index "${u}"`),g.setAttribute("aria-controls",v.id),g.setAttribute("aria-valuemax",""+Math.round(d)),g.setAttribute("aria-valuemin",""+Math.round(m)),g.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{c.forEach((u,d)=>{u.removeAttribute("aria-controls"),u.removeAttribute("aria-valuemax"),u.removeAttribute("aria-valuemin"),u.removeAttribute("aria-valuenow")})}},[n,a,r,i]),x.useEffect(()=>{if(!i)return;const c=t.current;Nt(c,"Eager values not found");const{panelDataArray:u}=c,d=xZ(n,i);Nt(d!=null,`No group found for id "${n}"`);const m=Gp(n,i);Nt(m,`No resize handles found for group id "${n}"`);const h=m.map(g=>{const v=g.getAttribute(Wn.resizeHandleId);Nt(v,"Resize handle element has no handle id attribute");const[w,S]=lke(n,v,u,i);if(w==null||S==null)return()=>{};const y=_=>{if(!_.defaultPrevented)switch(_.key){case"Enter":{_.preventDefault();const E=u.findIndex(k=>k.id===w);if(E>=0){const k=u[E];Nt(k,`No panel data found for index ${E}`);const C=a[E],{collapsedSize:R=0,collapsible:I,minSize:A=0}=k.constraints;if(C!=null&&I){const O=qf({delta:Ia(C,R)?A-R:R-C,initialLayout:a,panelConstraints:u.map(M=>M.constraints),pivotIndices:wZ(n,v,i),prevLayout:a,trigger:"keyboard"});a!==O&&s(O)}}break}}};return g.addEventListener("keydown",y),()=>{g.removeEventListener("keydown",y)}});return()=>{h.forEach(g=>g())}},[i,e,t,n,a,r,s])}function c2(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 SZ(e,t){const n=e==="horizontal",{x:a,y:r}=iw(t);return n?a:r}function uke(e,t,n,a,r){const i=n==="horizontal",s=lw(t,r);Nt(s,`No resize handle element found for id "${t}"`);const c=s.getAttribute(Wn.groupId);Nt(c,"Resize handle element has no group id attribute");let{initialCursorPosition:u}=a;const d=SZ(n,e),m=xZ(c,r);Nt(m,`No group element found for id "${c}"`);const h=m.getBoundingClientRect(),g=i?h.width:h.height;return(d-u)/g*100}function dke(e,t,n,a,r,i){if(uZ(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:uke(e,t,n,a,i)}function fke({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];Nt(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];Nt(s,`Panel constraints not found for index ${i}`);const{defaultSize:c}=s;if(c!=null)continue;const u=e.length-a,d=r/u;a++,t[i]=d,r-=d}return t}function Vc(e,t,n){t.forEach((a,r)=>{const i=e[r];Nt(i,`Panel data not found for index ${r}`);const{callbacks:s,constraints:c,id:u}=i,{collapsedSize:d=0,collapsible:m}=c,h=n[u];if(h==null||a!==h){n[u]=a;const{onCollapse:g,onExpand:v,onResize:w}=s;w&&w(a,h),m&&(g||v)&&(v&&(h==null||Eo(h,d))&&!Eo(a,d)&&v(),g&&(h==null||!Eo(h,d))&&Eo(a,d)&&g())}})}function ob(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 pke({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 mke(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function u2(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 EZ(e){return`react-resizable-panels:${e}`}function _Z(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 kZ(e,t){try{const n=EZ(e),a=t.getItem(n);if(a){const r=JSON.parse(a);if(typeof r=="object"&&r!=null)return r}}catch{}return null}function hke(e,t,n){var a,r;const i=(a=kZ(e,n))!==null&&a!==void 0?a:{},s=_Z(t);return(r=i[s])!==null&&r!==void 0?r:null}function gke(e,t,n,a,r){var i;const s=EZ(e),c=_Z(t),u=(i=kZ(e,r))!==null&&i!==void 0?i:{};u[c]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{r.setItem(s,JSON.stringify(u))}catch(d){console.error(d)}}function d2({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(!Ia(a,100)&&n.length>0)for(let i=0;i<t.length;i++){const s=n[i];Nt(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];Nt(s!=null,`No layout data found for index ${i}`);const c=pu({panelConstraints:t,panelIndex:i,size:s});s!=c&&(r+=s-c,n[i]=c)}if(!Ia(r,0))for(let i=0;i<t.length;i++){const s=n[i];Nt(s!=null,`No layout data found for index ${i}`);const c=s+r,u=pu({panelConstraints:t,panelIndex:i,size:c});if(s!==u&&(r-=u-s,n[i]=u,Ia(r,0)))break}return n}const bke=100,Xf={getItem:e=>(u2(Xf),Xf.getItem(e)),setItem:(e,t)=>{u2(Xf),Xf.setItem(e,t)}},f2={};function TZ({autoSaveId:e=null,children:t,className:n="",direction:a,forwardedRef:r,id:i=null,onLayout:s=null,keyboardResizeBy:c=null,storage:u=Xf,style:d,tagName:m="div",...h}){const g=nD(i),v=x.useRef(null),[w,S]=x.useState(null),[y,_]=x.useState([]),E=ake(),k=x.useRef({}),C=x.useRef(new Map),R=x.useRef(0),I=x.useRef({autoSaveId:e,direction:a,dragState:w,id:g,keyboardResizeBy:c,onLayout:s,storage:u}),A=x.useRef({layout:y,panelDataArray:[],panelDataArrayChanged:!1});x.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),x.useImperativeHandle(r,()=>({getId:()=>I.current.id,getLayout:()=>{const{layout:z}=A.current;return z},setLayout:z=>{const{onLayout:L}=I.current,{layout:$,panelDataArray:F}=A.current,W=d2({layout:z,panelConstraints:F.map(X=>X.constraints)});c2($,W)||(_(W),A.current.layout=W,L&&L(W),Vc(F,W,k.current))}}),[]),Ol(()=>{I.current.autoSaveId=e,I.current.direction=a,I.current.dragState=w,I.current.id=g,I.current.onLayout=s,I.current.storage=u}),cke({committedValuesRef:I,eagerValuesRef:A,groupId:g,layout:y,panelDataArray:A.current.panelDataArray,setLayout:_,panelGroupElement:v.current}),x.useEffect(()=>{const{panelDataArray:z}=A.current;if(e){if(y.length===0||y.length!==z.length)return;let L=f2[e];L==null&&(L=mke(gke,bke),f2[e]=L);const $=[...z],F=new Map(C.current);L(e,$,F,y,u)}},[e,y,u]),x.useEffect(()=>{});const O=x.useCallback(z=>{const{onLayout:L}=I.current,{layout:$,panelDataArray:F}=A.current;if(z.constraints.collapsible){const W=F.map(J=>J.constraints),{collapsedSize:X=0,panelSize:ie,pivotIndices:le}=vl(F,z,$);if(Nt(ie!=null,`Panel size not found for panel "${z.id}"`),!Eo(ie,X)){C.current.set(z.id,ie);const q=eu(F,z)===F.length-1?ie-X:X-ie,se=qf({delta:q,initialLayout:$,panelConstraints:W,pivotIndices:le,prevLayout:$,trigger:"imperative-api"});ob($,se)||(_(se),A.current.layout=se,L&&L(se),Vc(F,se,k.current))}}},[]),M=x.useCallback((z,L)=>{const{onLayout:$}=I.current,{layout:F,panelDataArray:W}=A.current;if(z.constraints.collapsible){const X=W.map(he=>he.constraints),{collapsedSize:ie=0,panelSize:le=0,minSize:J=0,pivotIndices:q}=vl(W,z,F),se=L??J;if(Eo(le,ie)){const he=C.current.get(z.id),ce=he!=null&&he>=se?he:se,He=eu(W,z)===W.length-1?le-ce:ce-le,Ee=qf({delta:He,initialLayout:F,panelConstraints:X,pivotIndices:q,prevLayout:F,trigger:"imperative-api"});ob(F,Ee)||(_(Ee),A.current.layout=Ee,$&&$(Ee),Vc(W,Ee,k.current))}}},[]),U=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{panelSize:F}=vl($,z,L);return Nt(F!=null,`Panel size not found for panel "${z.id}"`),F},[]),H=x.useCallback((z,L)=>{const{panelDataArray:$}=A.current,F=eu($,z);return pke({defaultSize:L,dragState:w,layout:y,panelData:$,panelIndex:F})},[w,y]),K=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=vl($,z,L);return Nt(X!=null,`Panel size not found for panel "${z.id}"`),W===!0&&Eo(X,F)},[]),Q=x.useCallback(z=>{const{layout:L,panelDataArray:$}=A.current,{collapsedSize:F=0,collapsible:W,panelSize:X}=vl($,z,L);return Nt(X!=null,`Panel size not found for panel "${z.id}"`),!W||Wl(X,F)>0},[]),te=x.useCallback(z=>{const{panelDataArray:L}=A.current;L.push(z),L.sort(($,F)=>{const W=$.order,X=F.order;return W==null&&X==null?0:W==null?-1:X==null?1:W-X}),A.current.panelDataArrayChanged=!0,E()},[E]);Ol(()=>{if(A.current.panelDataArrayChanged){A.current.panelDataArrayChanged=!1;const{autoSaveId:z,onLayout:L,storage:$}=I.current,{layout:F,panelDataArray:W}=A.current;let X=null;if(z){const le=hke(z,W,$);le&&(C.current=new Map(Object.entries(le.expandToSizes)),X=le.layout)}X==null&&(X=fke({panelDataArray:W}));const ie=d2({layout:X,panelConstraints:W.map(le=>le.constraints)});c2(F,ie)||(_(ie),A.current.layout=ie,L&&L(ie),Vc(W,ie,k.current))}}),Ol(()=>{const z=A.current;return()=>{z.layout=[]}},[]);const ae=x.useCallback(z=>{let L=!1;const $=v.current;return $&&window.getComputedStyle($,null).getPropertyValue("direction")==="rtl"&&(L=!0),function(W){W.preventDefault();const X=v.current;if(!X)return()=>null;const{direction:ie,dragState:le,id:J,keyboardResizeBy:q,onLayout:se}=I.current,{layout:he,panelDataArray:ce}=A.current,{initialLayout:Te}=le??{},He=wZ(J,z,X);let Ee=dke(W,z,ie,le,q,X);const ke=ie==="horizontal";ke&&L&&(Ee=-Ee);const ze=ce.map(Be=>Be.constraints),fe=qf({delta:Ee,initialLayout:Te??he,panelConstraints:ze,pivotIndices:He,prevLayout:he,trigger:uZ(W)?"keyboard":"mouse-or-touch"}),Oe=!ob(he,fe);(dZ(W)||fZ(W))&&R.current!=Ee&&(R.current=Ee,!Oe&&Ee!==0?ke?$S(z,Ee<0?mZ:hZ):$S(z,Ee<0?gZ:bZ):$S(z,0)),Oe&&(_(fe),A.current.layout=fe,se&&se(fe),Vc(ce,fe,k.current))}},[]),B=x.useCallback((z,L)=>{const{onLayout:$}=I.current,{layout:F,panelDataArray:W}=A.current,X=W.map(he=>he.constraints),{panelSize:ie,pivotIndices:le}=vl(W,z,F);Nt(ie!=null,`Panel size not found for panel "${z.id}"`);const q=eu(W,z)===W.length-1?ie-L:L-ie,se=qf({delta:q,initialLayout:F,panelConstraints:X,pivotIndices:le,prevLayout:F,trigger:"imperative-api"});ob(F,se)||(_(se),A.current.layout=se,$&&$(se),Vc(W,se,k.current))},[]),Z=x.useCallback((z,L)=>{const{layout:$,panelDataArray:F}=A.current,{collapsedSize:W=0,collapsible:X}=L,{collapsedSize:ie=0,collapsible:le,maxSize:J=100,minSize:q=0}=z.constraints,{panelSize:se}=vl(F,z,$);se!=null&&(X&&le&&Eo(se,W)?Eo(W,ie)||B(z,ie):se<q?B(z,q):se>J&&B(z,J))},[B]),G=x.useCallback((z,L)=>{const{direction:$}=I.current,{layout:F}=A.current;if(!v.current)return;const W=lw(z,v.current);Nt(W,`Drag handle element not found for id "${z}"`);const X=SZ($,L);S({dragHandleId:z,dragHandleRect:W.getBoundingClientRect(),initialCursorPosition:X,initialLayout:F})},[]),re=x.useCallback(()=>{S(null)},[]),ne=x.useCallback(z=>{const{panelDataArray:L}=A.current,$=eu(L,z);$>=0&&(L.splice($,1),delete k.current[z.id],A.current.panelDataArrayChanged=!0,E())},[E]),j=x.useMemo(()=>({collapsePanel:O,direction:a,dragState:w,expandPanel:M,getPanelSize:U,getPanelStyle:H,groupId:g,isPanelCollapsed:K,isPanelExpanded:Q,reevaluatePanelConstraints:Z,registerPanel:te,registerResizeHandle:ae,resizePanel:B,startDragging:G,stopDragging:re,unregisterPanel:ne,panelGroupElement:v.current}),[O,w,a,M,U,H,g,K,Q,Z,te,ae,B,G,re,ne]),V={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return x.createElement(aw.Provider,{value:j},x.createElement(m,{...h,children:t,className:n,id:i,ref:v,style:{...V,...d},[Wn.group]:"",[Wn.groupDirection]:a,[Wn.groupId]:g}))}const NZ=x.forwardRef((e,t)=>x.createElement(TZ,{...e,forwardedRef:t}));TZ.displayName="PanelGroup";NZ.displayName="forwardRef(PanelGroup)";function eu(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function vl(e,t,n){const a=eu(e,t),i=a===e.length-1?[a-1,a]:[a,a+1],s=n[a];return{...t.constraints,panelSize:s,pivotIndices:i}}function vke({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:a}){x.useEffect(()=>{if(e||n==null||a==null)return;const r=lw(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(Wn.groupId);Nt(c,`No group element found for id "${c}"`);const u=Gp(c,a),d=yZ(c,t,a);Nt(d!==null,`No resize element found for id "${t}"`);const m=s.shiftKey?d>0?d-1:u.length-1:d+1<u.length?d+1:0;u[m].focus();break}}};return r.addEventListener("keydown",i),()=>{r.removeEventListener("keydown",i)}},[a,e,t,n])}function CZ({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:a,id:r,onBlur:i,onClick:s,onDragging:c,onFocus:u,onPointerDown:d,onPointerUp:m,style:h={},tabIndex:g=0,tagName:v="div",...w}){var S,y;const _=x.useRef(null),E=x.useRef({onClick:s,onDragging:c,onPointerDown:d,onPointerUp:m});x.useEffect(()=>{E.current.onClick=s,E.current.onDragging=c,E.current.onPointerDown=d,E.current.onPointerUp=m});const k=x.useContext(aw);if(k===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:C,groupId:R,registerResizeHandle:I,startDragging:A,stopDragging:O,panelGroupElement:M}=k,U=nD(r),[H,K]=x.useState("inactive"),[Q,te]=x.useState(!1),[ae,B]=x.useState(null),Z=x.useRef({state:H});Ol(()=>{Z.current.state=H}),x.useEffect(()=>{if(n)B(null);else{const j=I(U);B(()=>j)}},[n,U,I]);const G=(S=a?.coarse)!==null&&S!==void 0?S:15,re=(y=a?.fine)!==null&&y!==void 0?y:5;x.useEffect(()=>{if(n||ae==null)return;const j=_.current;Nt(j,"Element ref not attached");let V=!1;return nke(U,j,C,{coarse:G,fine:re},(L,$,F)=>{if(!$){K("inactive");return}switch(L){case"down":{K("drag"),V=!1,Nt(F,'Expected event to be defined for "down" action'),A(U,F);const{onDragging:W,onPointerDown:X}=E.current;W?.(!0),X?.();break}case"move":{const{state:W}=Z.current;V=!0,W!=="drag"&&K("hover"),Nt(F,'Expected event to be defined for "move" action'),ae(F);break}case"up":{K("hover"),O();const{onClick:W,onDragging:X,onPointerUp:ie}=E.current;X?.(!1),ie?.(),V||W?.();break}}})},[G,C,n,re,I,U,ae,A,O]),vke({disabled:n,handleId:U,resizeHandler:ae,panelGroupElement:M});const ne={touchAction:"none",userSelect:"none"};return x.createElement(v,{...w,children:e,className:t,id:r,onBlur:()=>{te(!1),i?.()},onFocus:()=>{te(!0),u?.()},ref:_,role:"separator",style:{...ne,...h},tabIndex:g,[Wn.groupDirection]:C,[Wn.groupId]:R,[Wn.resizeHandle]:"",[Wn.resizeHandleActive]:H==="drag"?"pointer":Q?"keyboard":void 0,[Wn.resizeHandleEnabled]:!n,[Wn.resizeHandleId]:U,[Wn.resizeHandleState]:H})}CZ.displayName="PanelResizeHandle";function Qr({className:e,...t}){return f.jsx(NZ,{"data-slot":"resizable-panel-group",className:De("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t})}function Rn({...e}){return f.jsx(cZ,{"data-slot":"resizable-panel",...e})}function vi({withHandle:e,className:t,...n}){return f.jsx(CZ,{"data-slot":"resizable-handle",className:De("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",t),...n,children:e&&f.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:f.jsx(ome,{className:"size-2.5"})})})}function Mm({className:e,...t}){return f.jsx("kbd",{"data-slot":"kbd",className:De("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e),...t})}function yke({isSearchExpanded:e,searchQuery:t,filteredNotificationsCount:n,notificationsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onClearAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{ref:u,placeholder:"Search notifications...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Notifications"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Td,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(Mm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Clear all"})]})})]})}function Zs({id:e,isSelected:t,isFocused:n,icon:a,title:r,description:i,metadata:s,onClick:c,className:u}){return f.jsx("button",{id:e,type:"button",onClick:c,className:De("w-full text-left cursor-pointer p-2 sm:p-4 border-b dark:border-zinc-700 hover:bg-gray-50 dark:hover:bg-zinc-800/50 transition-colors group",t&&"bg-zinc-50 dark:bg-zinc-800 border-l-4 border-l-zinc-500",n&&"ring-2 ring-zinc-500 dark:ring-zinc-400 ring-inset",u),children:f.jsxs("div",{className:"flex items-start gap-2 sm:gap-3",children:[a&&f.jsx("div",{className:"flex-shrink-0 mt-1",children:f.jsx("div",{className:De("p-2.5 rounded-full transition-colors",t?"bg-zinc-500 dark:bg-zinc-100/80 text-zinc-100 dark:text-zinc-900":"bg-gray-100 dark:bg-zinc-700 text-gray-600 dark:text-gray-400 group-hover:bg-gray-200 dark:group-hover:bg-zinc-600"),children:a})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"flex items-center gap-2 mb-1",children:f.jsx("h3",{className:De("font-medium truncate font-mono text-sm"),children:r})}),i&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2",children:i})]})]})})}function wke({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(kd,{vertical:!0,noBorder:!0,message:"No notifications yet"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>f.jsx(Zs,{id:`notification-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.method,!s.read&&f.jsx("span",{className:"size-1.5 block rounded-full bg-orange-500"})]}),description:(()=>{const u=r(s.timestamp),d=s.params&&Object.keys(s.params).length>0?Object.keys(s.params).length:0,m=d>0?` | ${d} param${d>1?"s":""}`:"";return u+m})(),onClick:()=>n(s)},s.id))})}function xke({notification:e,previewMode:t,onTogglePreview:n,onCopy:a,onDownload:r,onFullscreen:i,isCopied:s=!1,onClose:c}){return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.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:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(nd,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:e.formatRelativeTime(e.timestamp)})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsxs(Le,{variant:"ghost",size:"sm",onClick:n,className:t?"":"text-purple-600 dark:text-purple-400",children:[t?f.jsx(AN,{className:"h-4 w-4 mr-1"}):f.jsx(x8,{className:"h-4 w-4 mr-1"}),t?"JSON":"Formatted"]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,children:s?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,children:f.jsx(wm,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:i,children:f.jsx(DN,{className:"h-4 w-4"})}),c&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(Yi,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{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`})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(CN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a notification to view details"})]})}function Pv(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 Ske({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:a,clearNotifications:r,serverId:i,isConnected:s}){const[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{v&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const Z=R.current;if(!Z)return;const G=()=>{Z.scrollTop>0&&(O.current=!0,w(!1))};return Z.addEventListener("scroll",G),()=>Z.removeEventListener("scroll",G)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{c&&!c.read&&n(c.id)},[c,n]),x.useEffect(()=>{S&&A.current&&A.current.focus()},[S]);const M=x.useCallback(()=>{d.trim()||y(!1)},[d]),U=x.useMemo(()=>{if(!d.trim())return e;const Z=d.toLowerCase();return e.filter(G=>G.method.toLowerCase().includes(Z)||JSON.stringify(G.params||{}).toLowerCase().includes(Z))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const Z=G=>{const re=G.target;if(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.contentEditable==="true"||G.metaKey||G.ctrlKey||G.altKey)return;const j=U;if(G.key==="ArrowDown")G.preventDefault(),g(V=>{const z=V+1;return z>=j.length?0:z});else if(G.key==="ArrowUp")G.preventDefault(),g(V=>{const z=V-1;return z<0?j.length-1:z});else if(G.key==="Enter"&&h>=0){G.preventDefault();const V=U[h];V&&H(V)}};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[h,U]),x.useEffect(()=>{if(h>=0){const Z=`notification-${U[h]?.id}`,G=document.getElementById(Z);G&&G.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,U]);const H=x.useCallback(Z=>{u(Z)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to clear all notifications? This cannot be undone.")&&(r(),u(null))},[r]),Q=x.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)),C(!0),setTimeout(()=>C(!1),2e3)}catch(Z){console.error("[NotificationsTab] Failed to copy notification:",Z)}},[c]),te=x.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"}),G=URL.createObjectURL(Z),re=document.createElement("a");re.href=G,re.download=`notification-${Date.now()}.json`,document.body.appendChild(re),re.click(),document.body.removeChild(re),URL.revokeObjectURL(G)}catch(Z){console.error("[NotificationsTab] Failed to download notification:",Z)}},[c]),ae=x.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)}},[]),B=c?{method:c.method,params:c.params,timestamp:c.timestamp,read:c.read,formatRelativeTime:Pv}:null;return s?f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(yke,{isSearchExpanded:S,searchQuery:d,filteredNotificationsCount:U.length,notificationsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:M,onClearAll:K,searchInputRef:A}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(wke,{notifications:U,selectedNotification:c,onNotificationSelect:H,focusedIndex:h,formatRelativeTime:Pv,listRef:R})})]})})}),f.jsx(vi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(xke,{notification:B,previewMode:_,onTogglePreview:()=>E(!_),onCopy:Q,onDownload:te,onFullscreen:ae,onClose:()=>u(null),isCopied:k})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(CN,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function RZ({activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabTitle:a,secondaryTabTitle:r,primaryCount:i,secondaryCount:s,secondaryIcon:c,primaryIcon:u,searchPlaceholder:d="Search...",onSearchExpand:m,onSearchChange:h,onSearchBlur:g,onTabSwitch:v,searchInputRef:w,primaryTabName:S}){const y=e===S;return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:t?f.jsx(kn,{ref:w,placeholder:d,value:n,onChange:_=>h(_.target.value),onBlur:g,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:y?a:r}),y&&f.jsxs(f.Fragment,{children:[f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:i}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:m,className:"h-8 w-8 p-0",children:f.jsx(Td,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(Mm,{children:"F"})]})]})]})]})}),f.jsxs(Le,{variant:"ghost",size:"sm",onClick:v,className:"gap-2 flex-shrink-0",children:[y?f.jsx(c,{}):f.jsx(u,{}),f.jsx("span",{className:"hidden sm:inline",children:y?r:a}),y&&s>0&&f.jsx(xr,{className:"bg-purple-500/20 text-purple-600 dark:text-purple-400 border-transparent",variant:"outline",children:s})]})]})}function p2({prompts:e,selectedPrompt:t,onPromptSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Cp,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No prompts available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((r,i)=>f.jsx(Zs,{id:`prompt-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(Cp,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.arguments&&r.arguments.length>0&&f.jsxs(xr,{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 m2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredPromptsCount:a,savedPromptsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(RZ,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"prompts",secondaryTabName:"saved",primaryTabTitle:"Prompts",secondaryTabTitle:"History",primaryCount:a,secondaryCount:r,primaryIcon:Cp,secondaryIcon:nd,searchPlaceholder:"Search prompts...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}function h2({savedPrompts:e,selectedPrompt:t,onLoadPrompt:n,onDeletePrompt:a,focusedIndex:r}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(nd,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No history"}),f.jsx("p",{className:"text-sm text-gray-400 dark:text-gray-500 mt-1",children:"Prompts you execute will appear here"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((i,s)=>f.jsx(Zs,{id:`saved-prompt-${i.id}`,isSelected:t?.id===i.id,isFocused:r===s,icon:f.jsx(nd,{className:"h-4 w-4"}),title:i.name,description:`${i.promptName} - ${new Date(i.savedAt).toLocaleString()}`,onClick:()=>n(i)},i.id))})}function Eke({selectedPrompt:e,promptArgs:t,onArgChange:n}){const a=e?.arguments||[];if(!(a.length>0))return f.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],d=typeof u=="string"?u:JSON.stringify(u);return s.type==="boolean"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx("input",{id:c,type:"checkbox",checked:!!u,onChange:m=>n(c,m.target.checked),className:"rounded","aria-label":`Toggle ${c}`}),f.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s.description})]})]},c):s.type==="number"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:c,type:"number",value:Number(u)||0,onChange:m=>n(c,Number(m.target.value)),placeholder:s.description||`Enter ${c}`}),s.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):s.type==="array"||s.type==="object"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(Vl,{id:c,value:d,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&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:c,className:"text-sm font-medium",children:[c,s.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:c,value:d,onChange:m=>n(c,m.target.value),placeholder:s.description||`Enter ${c}`}),s.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:s.description})]},c)};return f.jsx("div",{className:"space-y-4",children:a.map(s=>i(s))})}function g2({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s}){return x.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?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsx(Le,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Ei,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(k8,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"}),f.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:"⌘↵"})]})}),f.jsxs(Le,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(jN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]})]})]}),e.description&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(Eke,{selectedPrompt:e,promptArgs:t,onArgChange:r})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a prompt to get started"}),f.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 _ke(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 b2({results:e,copiedResult:t,onCopy:n}){return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:e.length>0?f.jsx("div",{className:"space-y-4 flex-1 h-full",children:e.map((a,r)=>{const i=a.error||_ke(a.result);return f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:"flex items-center gap-2 px-4 pt-2 border-b border-gray-200 dark:border-zinc-600 pb-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(nd,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(a.timestamp).toLocaleTimeString()})]}),a.duration!==void 0&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Rp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[a.duration,"ms"]})]}),f.jsx("div",{className:"flex gap-2 ml-auto",children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>n(r,a.result),className:"h-6 px-2",children:t===r?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})})})]}),i?f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:i})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:a.result,filename:`prompt-result-${a.promptName}-${Date.now()}.json`})})]},r)})}):f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(kd,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})})}function aD({serverIds:e,onCountChange:t,onClearRef:n}={}){const[a,r]=x.useState([]),i=x.useRef(null),[s,c]=x.useState(new Set),[u]=x.useState(""),d=v=>{c(w=>{const S=new Set(w);return S.has(v)?S.delete(v):S.add(v),S})},m=async()=>{r([]),c(new Set),t?.(0);try{const v=new URLSearchParams;e&&e.length>0&&v.set("serverIds",e.join(","));const w=await fetch(`/inspector/api/rpc/log?${v.toString()}`,{method:"DELETE"});w.ok||console.warn("[RPC Logger] Failed to clear server buffer:",w.status)}catch(v){console.warn("[RPC Logger] Error clearing server buffer:",v)}},h=x.useMemo(()=>!e||e.length===0?"":[...e].sort().join(","),[e]);x.useEffect(()=>(n&&(n.current=m),()=>{n&&(n.current=null)}),[n,m]),x.useEffect(()=>{t?.(a.length)},[a.length,t]),x.useEffect(()=>{let v=null;try{const w=new URLSearchParams;w.set("replay","3"),w.set("_t",Date.now().toString()),e&&e.length>0&&w.set("serverIds",e.join(","));const S=`/inspector/api/rpc/stream?${w.toString()}`;console.log("[RPC Logger] Connecting to SSE stream:",S),v=new globalThis.EventSource(S),v.onopen=()=>{console.log("[RPC Logger] SSE connection opened")},v.onmessage=y=>{try{const _=JSON.parse(y.data);if(!_||_.type!=="rpc")return;const{serverId:E,direction:k,message:C,timestamp:R}=_,I=C,A=typeof I?.method=="string"?I.method:I?.result!==void 0?"result":I?.error!==void 0?"error":"unknown",O={id:`${R??Date.now()}-${Math.random().toString(36).slice(2)}`,serverId:typeof E=="string"?E:"unknown",direction:typeof k=="string"?k.toUpperCase():"",method:A,timestamp:R??new Date().toISOString(),payload:C};console.log("[RPC Logger] Received RPC event:",{method:A,direction:k,serverId:E}),r(M=>{const U=[O,...M].slice(0,1e3);return t?.(U.length),U})}catch(_){console.error("[RPC Logger] Error parsing SSE message:",_)}},v.onerror=y=>{console.error("[RPC Logger] SSE connection error:",y);try{v?.close()}catch{}}}catch(w){console.error("[RPC Logger] Failed to create SSE connection:",w)}return()=>{try{v?.close(),console.log("[RPC Logger] SSE connection closed")}catch{}}},[h]);const g=x.useMemo(()=>{let v=a;if(e&&e.length>0){const w=new Set(e);v=v.filter(S=>w.has(S.serverId))}if(u.trim()){const w=u.toLowerCase();v=v.filter(S=>S.serverId.toLowerCase().includes(w)||S.method.toLowerCase().includes(w)||S.direction.toLowerCase().includes(w)||JSON.stringify(S.payload).toLowerCase().includes(w))}return v},[a,u,e]);return f.jsx("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:f.jsx("div",{ref:i,className:"flex-1 min-h-0 overflow-y-auto",children:g.length===0?f.jsxs("div",{className:"text-center py-8",children:[f.jsx("div",{className:"text-xs text-muted-foreground",children:"No messages yet"}),f.jsx("div",{className:"text-[10px] text-muted-foreground mt-1",children:"JSON-RPC messages will appear here"})]}):g.map(v=>{const w=s.has(v.id);return f.jsxs("div",{className:"group hover:bg-muted/50 transition-all duration-200 overflow-hidden",children:[f.jsxs("div",{className:"px-3 py-2 flex items-center gap-2 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(v.id),children:[f.jsx("div",{className:"flex-shrink-0",children:w?f.jsx(Xl,{className:"h-3 w-3 text-muted-foreground transition-transform"}):f.jsx(Npe,{className:"h-3 w-3 text-muted-foreground transition-transform"})}),f.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[f.jsx("span",{className:"text-muted-foreground font-mono text-xs",children:new Date(v.timestamp).toLocaleTimeString()}),f.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"?f.jsx(hpe,{className:"h-3 w-3"}):f.jsx(bpe,{className:"h-3 w-3"})}),f.jsx("span",{className:"text-xs font-mono text-foreground truncate",children:v.method})]})]}),w&&f.jsx("div",{className:"border-t bg-muted/20",children:f.jsx("div",{className:"p-3",children:f.jsx("div",{className:"max-h-[40vh] overflow-auto rounded-sm bg-background/60 p-2",children:f.jsx(Jn,{data:v.payload})})})})]},v.id)})})})}const v2="mcp-inspector-saved-prompts";function AZ({ref:e,prompts:t,callPrompt:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),[c,u]=x.useState(null),{selectedPromptName:d,setSelectedPromptName:m}=Jl(),[h,g]=x.useState({}),[v,w]=x.useState([]),[S,y]=x.useState(!1),[_,E]=x.useState(null),[k,C]=x.useState(""),[R,I]=x.useState("prompts"),[A,O]=x.useState([]),[M,U]=x.useState(!1),[H,K]=x.useState(""),[Q,te]=x.useState(!1),[ae,B]=x.useState(-1),Z=x.useRef(null),[G,re]=x.useState(!1),[ne,j]=x.useState("list"),[V,z]=x.useState(0),[L,$]=x.useState(!0),F=x.useRef(null),W=x.useRef(null);x.useEffect(()=>{const Ee=()=>{re(window.innerWidth<1024)};return Ee(),window.addEventListener("resize",Ee),()=>window.removeEventListener("resize",Ee)},[]),x.useEffect(()=>{j(i?"detail":"list")},[i]),x.useEffect(()=>{G&&v.length>0&&!S&&j("response")},[v,S,G]),x.useImperativeHandle(e,()=>({focusSearch:()=>{te(!0),setTimeout(()=>{Z.current&&Z.current.focus()},0)},blurSearch:()=>{C(""),te(!1),Z.current&&Z.current.blur()}})),x.useEffect(()=>{try{const Ee=localStorage.getItem(v2);if(Ee){const ke=JSON.parse(Ee);O(ke)}}catch(Ee){console.error("[PromptsTab] Failed to load saved prompts:",Ee)}},[]);const X=x.useCallback(Ee=>{try{localStorage.setItem(v2,JSON.stringify(Ee))}catch(ke){console.error("[PromptsTab] Failed to save prompts:",ke)}},[]);x.useEffect(()=>{Q&&Z.current&&Z.current.focus()},[Q]);const ie=x.useCallback(()=>{k.trim()||te(!1)},[k]),le=x.useMemo(()=>{if(!k.trim())return t;const Ee=k.toLowerCase();return t.filter(ke=>ke.name.toLowerCase().includes(Ee)||ke.description?.toLowerCase().includes(Ee))},[t,k]),J=x.useCallback(Ee=>{s(Ee);const ke={};Ee.arguments&&Ee.arguments.forEach(ze=>{ze.default!==void 0?ke[ze.name]=ze.default:ze.type==="string"?ke[ze.name]="":ze.type==="number"?ke[ze.name]=0:ze.type==="boolean"?ke[ze.name]=!1:ze.type==="array"?ke[ze.name]=[]:ze.type==="object"&&(ke[ze.name]={})}),g(ke)},[]),q=x.useCallback(Ee=>{const ke=t.find(ze=>ze.name===Ee.promptName);ke&&(s(ke),g(Ee.args),u(Ee))},[t]);x.useEffect(()=>{B(-1)},[k,R]),x.useEffect(()=>{const Ee=ke=>{const ze=ke.target;if(ze.tagName==="INPUT"||ze.tagName==="TEXTAREA"||ze.contentEditable==="true"||ke.metaKey||ke.ctrlKey||ke.altKey)return;const Oe=R==="prompts"?le:A;if(ke.key==="ArrowDown")ke.preventDefault(),B(Be=>{const Se=Be+1;return Se>=Oe.length?0:Se});else if(ke.key==="ArrowUp")ke.preventDefault(),B(Be=>{const Se=Be-1;return Se<0?Oe.length-1:Se});else if(ke.key==="Enter"&&ae>=0)if(ke.preventDefault(),R==="prompts"){const Be=le[ae];Be&&J(Be)}else{const Be=A[ae];Be&&q(Be)}};return document.addEventListener("keydown",Ee),()=>document.removeEventListener("keydown",Ee)},[ae,le,A,R,J,q]),x.useEffect(()=>{if(ae>=0){const Ee=R==="prompts"?`prompt-${le[ae]?.name}`:`saved-prompt-${A[ae]?.id}`,ke=document.getElementById(Ee);ke&&ke.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ae,le,A,R]),x.useEffect(()=>{if(console.warn("[PromptsTab] Auto-selection effect triggered:",{selectedPromptName:d,promptsCount:t.length,currentSelectedPrompt:i?.name}),d&&t.length>0){const Ee=t.find(ke=>ke.name===d);if(console.warn("[PromptsTab] Prompt lookup result:",{selectedPromptName:d,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 ke=setTimeout(()=>{J(Ee);const ze=document.getElementById(`prompt-${Ee.name}`);ze&&(console.warn("[PromptsTab] Scrolling to prompt element"),ze.scrollIntoView({behavior:"smooth",block:"nearest"}))},100);return()=>clearTimeout(ke)}}},[d,t,i,J,m]);const se=x.useCallback((Ee,ke)=>{g(ze=>({...ze,[Ee]:ke}))},[]),he=x.useCallback(async()=>{if(!i||S)return;y(!0);const Ee=Date.now();try{const ke=await n(i.name,h),ze=Date.now()-Ee;yr.getInstance().capture(new DU({promptName:i.name,serverId:a,success:!0})).catch(()=>{}),w(Oe=>[{promptName:i.name,args:h,result:ke,timestamp:Ee,duration:ze},...Oe])}catch(ke){yr.getInstance().capture(new DU({promptName:i.name,serverId:a,success:!1,error:ke instanceof Error?ke.message:"Unknown error"})).catch(()=>{});const fe={promptName:i.name,args:h,result:null,error:ke instanceof Error?ke.message:String(ke),timestamp:Ee,duration:Date.now()-Ee};w(Oe=>[fe,...Oe])}finally{y(!1)}},[i,h,S,n,a]),ce=x.useCallback(async(Ee,ke)=>{try{await navigator.clipboard.writeText(JSON.stringify(ke,null,2)),E(Ee),setTimeout(()=>E(null),2e3)}catch(ze){console.error("[PromptsTab] Failed to copy result:",ze)}},[]),Te=x.useCallback(()=>{i&&(K(""),U(!0))},[i]),He=x.useCallback(Ee=>{X(A.filter(ke=>ke.id!==Ee)),c?.id===Ee&&u(null)},[A,X,c]);return G?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[ne!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{ne==="response"?j("detail"):(s(null),j("list"))},className:"p-0 h-8 w-8",children:f.jsx(RN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{s(null),j("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Prompts"}),ne!=="list"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{ne==="response"&&j("detail")},className:ne==="detail"?"text-foreground hover:underline":ne==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),ne==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($y,{initial:!1,mode:"popLayout",children:[ne==="list"&&f.jsxs(ga.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:[f.jsx(m2,{activeTab:R,isSearchExpanded:Q,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>te(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>I(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(p2,{prompts:le,selectedPrompt:i,onPromptSelect:J,focusedIndex:ae}):f.jsx(h2,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ae})]},"list"),ne==="detail"&&f.jsx(ga.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:f.jsx(g2,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:se,onExecute:he,onSave:Te})},"detail"),ne==="response"&&f.jsx(ga.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:f.jsx(b2,{results:v,copiedResult:_,onCopy:ce})},"response")]})})]}):f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:33,className:"flex flex-col h-full relative",children:f.jsxs(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(m2,{activeTab:R,isSearchExpanded:Q,searchQuery:k,filteredPromptsCount:le.length,savedPromptsCount:A.length,onSearchExpand:()=>te(!0),onSearchChange:C,onSearchBlur:ie,onTabSwitch:()=>I(R==="prompts"?"saved":"prompts"),searchInputRef:Z}),R==="prompts"?f.jsx(p2,{prompts:le,selectedPrompt:i,onPromptSelect:J,focusedIndex:ae}):f.jsx(h2,{savedPrompts:A,selectedPrompt:c,onLoadPrompt:q,onDeletePrompt:He,focusedIndex:ae})]})}),f.jsx(vi,{withHandle:!0}),f.jsxs(Rn,{ref:F,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>$(!0),onExpand:()=>$(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),L?(F.current?.resize(25),$(!1)):(F.current?.resize(5),$(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),V>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:V}),V>0&&!L&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:Ee=>{Ee.preventDefault(),Ee.stopPropagation(),W.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{className:`h-4 w-4 text-muted-foreground transition-transform ${L?"rotate-180":""}`})]}),!L&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(aD,{serverIds:[a],onCountChange:z,onClearRef:W})})]})]})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Qr,{direction:"vertical",children:[f.jsx(Rn,{defaultSize:40,children:f.jsx(g2,{selectedPrompt:i,promptArgs:h,isExecuting:S,isConnected:r,onArgChange:se,onExecute:he,onSave:Te})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:50,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(b2,{results:v,copiedResult:_,onCopy:ce})})})]})})]})}AZ.displayName="PromptsTab";function Su(e){if(!e?.mimeType)return!1;const t=e.mimeType.toLowerCase();return t==="text/html"||t==="text/html+skybridge"||t==="text/uri-list"||t.startsWith("application/vnd.mcp-ui.remote-dom")}function kke(e){return{uri:e.uri,mimeType:e.mimeType,text:e.text,blob:e.blob}}function IZ({resource:e,onUIAction:t,className:n}){const a=async i=>t?.(i),r=kke(e);return f.jsx("div",{className:n,children:f.jsx(eD,{resource:r,onUIAction:a,htmlProps:{autoResizeIframe:{width:!0,height:!0},style:{width:"100%",minHeight:"200px"},sandboxPermissions:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"},remoteDomProps:{remoteElements:[$_e,L_e,M_e,P_e],library:QO}})})}function Tke(e){if("error"in e&&e.error)return e.error;if(!("isError"in e&&e.isError))return null;if("contents"in e&&Array.isArray(e.contents)){const t=e.contents.filter(n=>"text"in n).map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
1661
1661
|
`)}return"An error occurred"}function y2({result:e,isLoading:t,previewMode:n,serverId:a,readResource:r,onTogglePreview:i,onCopy:s,onDownload:c,onFullscreen:u,isCopied:d=!1}){let m=[],h;if(e?.resourceAnnotations&&(m=Object.keys(e.resourceAnnotations).filter(y=>y.startsWith("openai/")),h=e.resourceAnnotations["openai/outputTemplate"]),e?.result?.contents?.[0]?._meta){const y=e.result.contents[0]._meta,_=Object.keys(y).filter(E=>E.startsWith("openai/"));_.length>0&&(m=[...m,..._]),!h&&y["openai/outputTemplate"]&&(h=y["openai/outputTemplate"]),!h&&e.uri&&e.uri.startsWith("ui://widget/")&&(h=e.uri)}const g=!!(m.length>0&&h&&typeof h=="string"&&a&&r);if(t)return f.jsx("div",{className:"flex absolute left-0 top-0 items-center justify-center w-full h-full",children:f.jsx(Ei,{className:"size-5"})});if(!e)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a resource to view its contents"}),f.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a resource from the list to see its data"})]});const v=e.error||Tke(e.result);if(v)return f.jsx("div",{className:"p-4",children:f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:v})]})});const w=e?.result?.contents&&Array.isArray(e.result.contents)&&e.result.contents.some(y=>y.mimeType&&Su(y)),S=w?e.result.contents.filter(y=>y.mimeType&&Su(y)):[];return f.jsxs("div",{className:"flex flex-col h-full",children:[f.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:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(nd,{className:"h-3 w-3 text-gray-400"}),f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleTimeString()})]}),(()=>{const y=e?.duration??e.result?.duration??e.result?.metrics?.durationMs;return y!==void 0?f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(Rp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[y,"ms"]})]}):null})(),w&&f.jsx(xr,{variant:"outline",className:"text-xs bg-purple-50 dark:bg-purple-900/20 border-none border-purple-200 dark:border-purple-800/50 text-purple-600 dark:text-purple-400",children:"MCP UI"}),g&&f.jsx(xr,{variant:"outline",className:"text-xs bg-blue-50 dark:bg-blue-900/20 border-none border-blue-200 dark:border-blue-800/50 text-blue-600 dark:text-blue-400",children:"OpenAI Widget"})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[(w||g)&&f.jsxs(Le,{variant:"ghost",size:"sm",onClick:i,className:n?"":"text-purple-600 dark:text-purple-400",children:[n?f.jsx(AN,{className:"h-4 w-4 mr-1"}):f.jsx(x8,{className:"h-4 w-4 mr-1"}),n?"JSON":g?"Component":"Preview"]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:s,children:d?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,children:f.jsx(wm,{className:"h-4 w-4"})}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,children:f.jsx(DN,{className:"h-4 w-4"})})]})]}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:g&&a&&r&&h?n?f.jsx("div",{className:"flex-1 h-full",children:f.jsx(ZO,{componentUrl:h,toolName:e.uri,toolArgs:{},toolResult:e.result,serverId:a,readResource:r,className:"w-full h-full relative flex p-4"})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})}):w?n?f.jsxs("div",{className:"space-y-0 h-full",children:[S.map((y,_)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx("div",{className:"w-full h-full",children:f.jsx(IZ,{resource:y,className:"w-full h-full"})})},`mcp-ui-${y.uri||`resource-${Date.now()}-${Math.random()}`}`)),(()=>{if(e.result.contents&&Array.isArray(e.result.contents)){const y=e.result.contents.filter(_=>!(_.mimeType&&Su(_)));if(y.length>0)return f.jsx("div",{className:"px-4",children:f.jsx(Jn,{data:y,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-non-ui-${Date.now()}.json`})})}return null})()]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-mcp-ui-${Date.now()}.json`})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:e.result,filename:`resource-${e.uri.replace(/[^a-zA-Z0-9]/g,"-")}-${Date.now()}.json`})})})]})}function Nke(e,t){if(!e&&!t)return f.jsx(eme,{className:"h-5 w-5"});const n=(e||t||"").toLowerCase();return n.includes("image")?f.jsx(Xpe,{className:"h-5 w-5"}):n.includes("json")||n.includes("javascript")||n.includes("typescript")?f.jsx(Ype,{className:"h-5 w-5"}):n.includes("html")||n.includes("xml")?f.jsx(ame,{className:"h-5 w-5"}):n.includes("database")||n.includes("sql")?f.jsx(Ay,{className:"h-5 w-5"}):f.jsx(IN,{className:"h-5 w-5"})}function w2({resources:e,selectedResource:t,onResourceSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Ay,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No resources available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>{const s=Nke(r.mimeType,r.uri),c=[r.description,r.mimeType&&f.jsx("span",{className:"font-mono",children:r.mimeType},"mime")].filter(Boolean);return f.jsx(Zs,{id:`resource-${r.uri}`,isSelected:t?.uri===r.uri,isFocused:a===i,icon:s,title:r.name,description:c.length>0?f.jsxs("span",{className:"flex flex-col gap-1",children:[r.description&&f.jsx("span",{children:r.description}),r.mimeType&&f.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-500 font-mono",children:r.mimeType})]}):void 0,onClick:()=>n(r)},r.uri)})})}function x2({isSearchExpanded:e,searchQuery:t,filteredResourcesCount:n,onSearchExpand:a,onSearchChange:r,onSearchBlur:i,searchInputRef:s}){return f.jsx("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{ref:s,placeholder:"Search resources...",value:t,onChange:c=>r(c.target.value),onBlur:i,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Resources"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Td,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(Mm,{children:"F"})]})]})]})})})}function OZ({ref:e,resources:t,readResource:n,serverId:a,isConnected:r}){const[i,s]=x.useState(null),{selectedResourceUri:c,setSelectedResourceUri:u}=Jl(),[d,m]=x.useState(null),[h,g]=x.useState(!1),[v,w]=x.useState(""),[S]=x.useState("resources"),[y,_]=x.useState(!0),[E,k]=x.useState(!1),[C,R]=x.useState(-1),[I,A]=x.useState(!1),O=x.useRef(null),M=x.useRef(null),[U,H]=x.useState(!1),[K,Q]=x.useState("list"),[te,ae]=x.useState(0),[B,Z]=x.useState(!0),G=x.useRef(null),re=x.useRef(null);x.useEffect(()=>{const F=()=>{H(window.innerWidth<1024)};return F(),window.addEventListener("resize",F),()=>window.removeEventListener("resize",F)},[]),x.useEffect(()=>{Q(i?"detail":"list")},[i]),x.useImperativeHandle(e,()=>({focusSearch:()=>{k(!0),setTimeout(()=>{O.current&&O.current.focus()},0)},blurSearch:()=>{w(""),k(!1),O.current&&O.current.blur()}})),x.useEffect(()=>{E&&O.current&&O.current.focus()},[E]);const ne=x.useCallback(()=>{v.trim()||k(!1)},[v]),j=x.useMemo(()=>{if(!v)return t;const F=v.toLowerCase();return t.filter(W=>W.name.toLowerCase().includes(F)||W.description?.toLowerCase().includes(F)||W.uri.toLowerCase().includes(F))},[t,v]),V=x.useCallback(async F=>{if(s(F),r){g(!0);const W=Date.now();try{const X=await n(F.uri);yr.getInstance().capture(new OU({resourceUri:F.uri,serverId:a,success:!0})).catch(()=>{}),m({uri:F.uri,result:X,timestamp:W,resourceAnnotations:F.annotations})}catch(X){yr.getInstance().capture(new OU({resourceUri:F.uri,serverId:a,success:!1,error:X instanceof Error?X.message:"Unknown error"})).catch(()=>{}),m({uri:F.uri,result:null,error:X instanceof Error?X.message:"Unknown error",timestamp:W,resourceAnnotations:F.annotations})}finally{g(!1)}}},[n,a,r]);x.useEffect(()=>{R(-1)},[v,S]),x.useEffect(()=>{const F=W=>{const X=W.target;if(X.tagName==="INPUT"||X.tagName==="TEXTAREA"||X.contentEditable==="true"||W.metaKey||W.ctrlKey||W.altKey)return;const le=j;if(W.key==="ArrowDown")W.preventDefault(),R(J=>{const q=J+1;return q>=le.length?0:q});else if(W.key==="ArrowUp")W.preventDefault(),R(J=>{const q=J-1;return q<0?le.length-1:q});else if(W.key==="Enter"&&C>=0){W.preventDefault();const J=j[C];J&&V(J)}};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[C,j,V]),x.useEffect(()=>{if(C>=0){const F=`resource-${j[C]?.uri}`,W=document.getElementById(F);W&&W.scrollIntoView({behavior:"smooth",block:"nearest"})}},[C,j]),x.useEffect(()=>{if(c&&t.length>0){const F=t.find(W=>W.uri===c);F&&i?.uri!==F.uri&&(u(null),setTimeout(()=>{V(F);const W=document.getElementById(`resource-${F.uri}`);W&&W.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[c,t,i,V,u]);const z=x.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify(d.result,null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(F){console.error("[ResourcesTab] Failed to copy result:",F)}},[d]),L=x.useCallback(()=>{if(d)try{const F=new globalThis.Blob([JSON.stringify(d.result,null,2)],{type:"application/json"}),W=URL.createObjectURL(F),X=document.createElement("a");X.href=W,X.download=`resource-${Date.now()}.json`,document.body.appendChild(X),X.click(),document.body.removeChild(X),URL.revokeObjectURL(W)}catch(F){console.error("[ResourcesTab] Failed to download result:",F)}},[d]),$=x.useCallback(async()=>{if(M.current)try{document.fullscreenElement?await document.exitFullscreen():await M.current.requestFullscreen()}catch(F){console.error("[ResourcesTab] Failed to toggle fullscreen:",F)}},[]);return U?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[K!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{s(null),Q("list")},className:"p-0 h-8 w-8",children:f.jsx(RN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{s(null),Q("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Resources"}),K==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Content"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($y,{initial:!1,mode:"popLayout",children:[K==="list"&&f.jsxs(ga.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:[f.jsx(x2,{activeTab:S,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:j.length,onSearchExpand:()=>k(!0),onSearchChange:w,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(w2,{resources:j,selectedResource:i,onResourceSelect:V,focusedIndex:C})})]},"list"),K==="detail"&&f.jsx(ga.div,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"spring",stiffness:300,damping:30},className:"absolute inset-0 bg-white dark:bg-zinc-900 z-10",children:f.jsx("div",{ref:M,className:"h-full",children:f.jsx(y2,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:z,onDownload:L,onFullscreen:$,isCopied:I})})},"detail")]})})]}):f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:25,children:f.jsxs(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(x2,{activeTab:S,isSearchExpanded:E,searchQuery:v,filteredResourcesCount:j.length,onSearchExpand:()=>k(!0),onSearchChange:w,onSearchBlur:ne,onTabSwitch:()=>{},searchInputRef:O}),f.jsx(w2,{resources:j,selectedResource:i,onResourceSelect:V,focusedIndex:C})]})}),f.jsx(vi,{withHandle:!0}),f.jsxs(Rn,{ref:G,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>Z(!0),onExpand:()=>Z(!1),className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:F=>{F.preventDefault(),F.stopPropagation(),B?(G.current?.resize(25),Z(!1)):(G.current?.resize(5),Z(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),te>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:te}),te>0&&!B&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:F=>{F.preventDefault(),F.stopPropagation(),re.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{className:`h-4 w-4 text-muted-foreground transition-transform ${B?"":"rotate-180"}`})]}),!B&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(aD,{serverIds:[a],onCountChange:ae,onClearRef:re})})]})]})}),f.jsx(vi,{}),f.jsx(Rn,{defaultSize:50,children:f.jsx(Qr,{direction:"vertical",children:f.jsx(Rn,{defaultSize:70,children:f.jsx("div",{ref:M,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(y2,{result:d,isLoading:h,previewMode:y,serverId:a,readResource:n,onTogglePreview:()=>_(!y),onCopy:z,onDownload:L,onFullscreen:$,isCopied:I})})})})})]})}OZ.displayName="ResourcesTab";function S2({savedRequests:e,selectedRequest:t,onLoadRequest:n,onDeleteRequest:a,focusedIndex:r}){if(e.length===0)return f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Ay,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"No saved requests yet"}),f.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Execute a tool and click Save to store requests"})]});const i=(s,c)=>{s.stopPropagation(),c()};return f.jsx("div",{className:"overflow-y-auto flex-1 border-r dark:border-zinc-700 overscroll-contain",children:e.map((s,c)=>f.jsxs("div",{className:"relative group",children:[f.jsx(Zs,{id:`saved-${s.id}`,isSelected:t?.id===s.id,isFocused:r===c,icon:f.jsx(cv,{className:"h-4 w-4"}),title:s.name,description:s.toolName,metadata:f.jsx("div",{className:"flex flex-col gap-1",children:f.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:new Date(s.savedAt).toLocaleString()})}),onClick:()=>n(s)}),f.jsx("div",{className:"absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"secondary",size:"sm",onClick:u=>i(u,()=>a(s.id)),className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Delete saved request"})})]})})]},s.id))})}function E2({isOpen:e,requestName:t,defaultPlaceholder:n,onRequestNameChange:a,onSave:r,onCancel:i}){return e?f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:i,children:f.jsxs("div",{className:"bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700",onClick:s=>s.stopPropagation(),children:[f.jsx("h3",{className:"text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",children:"Save Request"}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsx(Kt,{htmlFor:"request-name",children:"Request Name (optional)"}),f.jsx(kn,{id:"request-name",value:t,onChange:s=>a(s.target.value),placeholder:n,className:"mt-2",onKeyDown:s=>{s.key==="Enter"&&r()},autoFocus:!0})]}),f.jsxs("div",{className:"flex justify-end gap-2",children:[f.jsx(Le,{variant:"outline",onClick:i,children:"Cancel"}),f.jsxs(Le,{onClick:r,children:[f.jsx(jN,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})]})}):null}function DZ(e,t){if(!e?.$ref)return e;const n=e.$ref;if(n.startsWith("#/")){const a=n.substring(2).split("/");let r=t;for(const i of a)if(r&&typeof r=="object"&&i in r)r=r[i];else return console.warn(`Could not resolve $ref: ${n}`),e;return r}return e}function Cke(e,t){if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.find(a=>a.type!=="null");if(n)return{...DZ(n,t),nullable:!0}}return e}function Rke(e){return Array.isArray(e.enum)?e.enum:null}function _2({selectedTool:e,toolArgs:t,onArgChange:n}){const a=e?.inputSchema?.properties||{},r=e?.inputSchema?.required||[];return Object.keys(a).length>0?f.jsx("div",{className:"space-y-4",children:Object.entries(a).map(([s,c])=>{const u=e?.inputSchema||{};let d=Cke(c,u);d=DZ(d,u);const m=Rke(d),h=d.type==="string"&&m!==null,g=d;g.required=r.includes(s);const v=t[s];let w="";return v!=null&&(typeof v=="string"?w=v:typeof v=="object"&&v!==null?w=JSON.stringify(v,null,2):w=String(v)),g.type==="object"||g.type==="array"?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(Vl,{id:s,value:w,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`,className:"min-h-[100px]"}),g?.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):h&&m?f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:s,className:"text-sm font-medium",children:[s,g.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsxs(Co,{value:String(t[s]||""),onValueChange:y=>n(s,y),children:[f.jsx(Ao,{id:s,className:"w-full",children:f.jsx(Ro,{placeholder:g.description||"Select an option"})}),f.jsx(Io,{children:m.map((y,_)=>f.jsx(Ir,{value:y,children:g.enumNames?.[_]||y},y))})]}),g.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s):f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:s,className:"text-sm font-medium",children:[s,g?.required&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),f.jsx(kn,{id:s,value:w,onChange:y=>n(s,y.target.value),placeholder:g?.description||`Enter ${s}`}),g?.description&&f.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:g.description})]},s)})}):f.jsx("div",{className:"flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",children:"No parameters required"})}function k2({selectedTool:e,toolArgs:t,isExecuting:n,isConnected:a,onArgChange:r,onExecute:i,onSave:s,onCancel:c}){const[u,d]=x.useState(!1),[m,h]=x.useState(()=>{if(typeof window<"u"){const S=localStorage.getItem("mcp-inspector-show-tool-metadata");return S?JSON.parse(S):!1}return!1}),[g,v]=x.useState(!1);x.useEffect(()=>{typeof window<"u"&&localStorage.setItem("mcp-inspector-show-tool-metadata",JSON.stringify(m))},[m]);const w=()=>{if(!e)return;const S={name:e.name,description:e.description||"",_meta:e._meta};navigator.clipboard.writeText(JSON.stringify(S,null,2)),v(!0),setTimeout(()=>v(!1),2e3)};return x.useEffect(()=>{const S=y=>{(y.metaKey||y.ctrlKey)&&y.key==="Enter"&&e&&!n&&a&&(y.preventDefault(),i()),y.key==="Escape"&&n&&c&&(y.preventDefault(),c())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[e,n,a,i,c]),e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsx("div",{className:"flex-shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-4 sm:pr-4",children:f.jsxs("div",{children:[f.jsxs("div",{className:"flex flex-row items-center justify-between mb-0 gap-2",children:[f.jsx("h3",{className:"text-base sm:text-lg font-semibold",children:e.name}),f.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs(Le,{variant:m?"default":"outline",onClick:()=>h(!m),disabled:n,size:"sm",className:"lg:size-default gap-2",title:"Toggle tool metadata",children:[f.jsx(AN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Metadata"})]})}),f.jsx(Lt,{children:f.jsx("p",{children:"Show tool definition metadata"})})]}),f.jsxs(Le,{variant:"outline",onClick:s,disabled:n,size:"sm",className:"lg:size-default gap-2",children:[f.jsx(jN,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Save"})]}),n&&c?f.jsxs(Dt,{open:u?void 0:!1,children:[f.jsx(jt,{asChild:!0,children:f.jsx("div",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),className:"relative",children:f.jsx(Le,{onClick:c,variant:u?"destructive":"default",size:"sm",className:"lg:size-default gap-2 transition-all",children:u?f.jsxs(f.Fragment,{children:[f.jsx(Yi,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Cancel"}),f.jsx("span",{className:"hidden sm:inline text-[12px] border border-current p-1 rounded-full ml-2",children:"Esc"})]}):f.jsxs(f.Fragment,{children:[f.jsx(Ei,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]})})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Hover to cancel (or press Esc)"})})]}):f.jsx(Le,{onClick:i,disabled:n||!a,size:"sm",className:"lg:size-default pr-1! gap-0",children:n?f.jsxs(f.Fragment,{children:[f.jsx(Ei,{className:"mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Executing..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(k8,{className:"h-4 w-4 sm:mr-2"}),f.jsx("span",{className:"hidden sm:inline",children:"Execute"}),f.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:"⌘↵"})]})})]})]}),e.description&&f.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2",children:e.description})]})}),m?f.jsxs("div",{className:"flex-1 overflow-hidden flex gap-4 px-3 sm:px-6 pb-4",children:[f.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:f.jsx(_2,{selectedTool:e,toolArgs:t,onArgChange:r})}),f.jsxs("div",{className:"w-2/5 flex flex-col bg-zinc-50 dark:bg-zinc-900/50 rounded border border-zinc-200 dark:border-zinc-800 overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between p-3 border-b border-zinc-200 dark:border-zinc-800 flex-shrink-0",children:[f.jsx("h4",{className:"text-sm font-medium",children:"Tool Definition"}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:w,className:"h-7 w-7 p-0",title:"Copy metadata",children:g?f.jsx(ta,{className:"h-3.5 w-3.5 text-green-600"}):f.jsx(jr,{className:"h-3.5 w-3.5"})})]}),f.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:f.jsx("pre",{className:"text-xs font-mono text-zinc-700 dark:text-zinc-300 whitespace-pre-wrap break-words",children:JSON.stringify({name:e.name,description:e.description||"(no description)",_meta:e._meta||null},null,2)})})]})]}):f.jsx("div",{className:"flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3",children:f.jsx(_2,{selectedTool:e,toolArgs:t,onArgChange:r})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx("p",{className:"text-gray-500 dark:text-gray-400 mb-2",children:"Select a tool to get started"}),f.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Choose a tool from the list to view its details and execute it"})]})}function T2(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 Ake(e){if(!e?.isError)return null;if(e.content&&Array.isArray(e.content)){const t=e.content.filter(n=>n.type==="text").map(n=>n.text).filter(Boolean);if(t.length>0)return t.join(`
|
|
1662
1662
|
`)}return"An error occurred"}function Ike(e){try{return JSON.parse(e),!0}catch{return!1}}function Oke({content:e}){return!Array.isArray(e)||e.length===0?f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content"}):f.jsx("div",{className:"space-y-4",children:e.map((t,n)=>{if(t.type==="text"){const a=t.text||"";if(Ike(a))try{const r=JSON.parse(a);return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content (JSON)"}),f.jsx(Jn,{data:r,filename:`content-${n}.json`})]},n)}catch{}return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Text Content"}),f.jsx("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words",children:a})]},n)}if(t.type==="image")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Image Content"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[f.jsx("img",{src:`data:${t.mimeType||"image/png"};base64,${t.data}`,alt:"Result",className:"max-w-full rounded"}),t.annotations&&f.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:f.jsx(Jn,{data:t.annotations,filename:`image-annotations-${n}.json`})})]})]},n);if(t.type==="audio")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Audio Content"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",children:[f.jsx("audio",{controls:!0,src:`data:${t.mimeType||"audio/wav"};base64,${t.data}`,className:"w-full"}),t.annotations&&f.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:f.jsx(Jn,{data:t.annotations,filename:`audio-annotations-${n}.json`})})]})]},n);if(t.type==="resource_link")return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Resource Link"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[f.jsxs("div",{className:"font-mono text-sm break-all",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",t.uri]}),t.name&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Name:"})," ",t.name]}),t.description&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Description:"})," ",t.description]}),t.mimeType&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",t.mimeType]}),t.annotations&&f.jsxs("div",{className:"mt-2",children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),f.jsx(Jn,{data:t.annotations,filename:`resource-link-annotations-${n}.json`})]})]})]},n);if(t.type==="resource"){const a=t.resource||{};return f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Embedded Resource"}),f.jsxs("div",{className:"bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",children:[f.jsxs("div",{className:"font-mono text-sm break-all",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"URI:"})," ",a.uri]}),a.mimeType&&f.jsxs("div",{className:"text-sm",children:[f.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"MIME Type:"})," ",a.mimeType]}),a.text&&f.jsxs("div",{children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Content:"}),f.jsx("div",{className:"bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto",children:a.text})]}),a.blob&&f.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:["[Binary content: ",a.blob.length||0," bytes]"]}),a.annotations&&f.jsxs("div",{className:"mt-2",children:[f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Annotations:"}),f.jsx(Jn,{data:a.annotations,filename:`resource-annotations-${n}.json`})]})]})]},n)}return f.jsxs("div",{className:"space-y-2",children:[f.jsxs("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:["Unknown Content Type: ",t.type||"N/A"]}),f.jsx(Jn,{data:t,filename:`content-${n}.json`})]},n)})})}function N2({results:e,copiedResult:t,previewMode:n,serverId:a,readResource:r,onCopy:i,onTogglePreview:s,onMaximize:c,isMaximized:u=!1}){const[d,m]=x.useState(0),[h,g]=x.useState(""),[v,w]=x.useState(!0),S=e[0],y=S?e.filter(te=>te.toolName===S.toolName):[],_=y[d]||y[0],E=e.findIndex(te=>te===_);x.useEffect(()=>{y.length>0&&d>=y.length&&m(0)},[y.length,d]),x.useEffect(()=>{const te=()=>{_&&g(T2(_.timestamp))};te();const ae=setInterval(te,1e3);return()=>clearInterval(ae)},[_]);const k=x.useMemo(()=>_?.args,[_?.timestamp,d]),C=x.useMemo(()=>_?.result,[_?.timestamp,d]),R=x.useCallback(te=>r(te),[r]);if(e.length===0)return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:f.jsx("div",{className:"flex items-center justify-center h-full",children:f.jsx("div",{className:"text-center",children:f.jsx(kd,{vertical:!0,noBorder:!0,message:"No Results yet"})})})})});const I=_.toolMeta?.["openai/outputTemplate"],A=!!(I&&typeof I=="string"&&_.appsSdkResource),O=I,M=_.result?.content||[],U=M.filter(te=>te.type==="resource"&&Su(te.resource)),H=U.length>0,K=!!(M&&M.length>0||_.result?.structuredContent),Q=!H&&!A&&K;return f.jsx("div",{className:"flex flex-col h-full bg-white dark:bg-black border-t dark:border-zinc-700",children:f.jsx("div",{className:"flex-1 overflow-y-auto h-full",children:f.jsxs("div",{className:"space-y-0 flex-1 h-full flex flex-col",children:[f.jsxs("div",{className:`flex items-center gap-2 px-4 pt-2 ${H||A||Q?"border-b border-gray-200 dark:border-zinc-600 pb-2":""}`,children:[f.jsx("h3",{className:"text-sm font-medium hidden sm:block",children:"Response"}),_.duration!==void 0&&f.jsxs("div",{className:"hidden sm:flex items-center gap-1",children:[f.jsx(Rp,{className:"h-3 w-3 text-gray-400"}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[_.duration,"ms"]})]}),A&&f.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[f.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",O||"No URI"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Component"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw JSON"})]})]}),H&&!A&&f.jsxs("div",{className:"flex items-center gap-4 sm:ml-4",children:[f.jsxs("span",{className:"hidden sm:inline text-xs text-gray-500 dark:text-gray-400",children:["URI: ",U[0]?.resource?.uri||"No URI"]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Preview"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>s(),className:`text-xs font-medium ${n?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"JSON"})]})]}),Q&&f.jsxs("div",{className:"flex items-center gap-2 sm:ml-4",children:[f.jsx("button",{onClick:()=>w(!0),className:`text-xs font-medium ${v?"text-black dark:text-white":"text-zinc-500 dark:text-zinc-400"}`,children:"Formatted"}),f.jsx("span",{className:"text-xs text-zinc-400",children:"|"}),f.jsx("button",{onClick:()=>w(!1),className:`text-xs font-medium ${v?"text-zinc-500 dark:text-zinc-400":"text-black dark:text-white"}`,children:"Raw"})]}),f.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(A||H)&&c&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,title:u?"Restore":"Maximize",children:u?f.jsx(bme,{className:"h-4 w-4"}):f.jsx(DN,{className:"h-4 w-4"})}),y.length>1&&f.jsxs(Co,{value:d.toString(),onValueChange:te=>m(parseInt(te)),children:[f.jsx(Ao,{size:"sm",className:"w-[140px] h-8 text-xs",children:f.jsx(Ro,{children:f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx(cv,{className:"h-3 w-3"}),f.jsx("span",{children:h})]})})}),f.jsx(Io,{children:y.map((te,ae)=>f.jsx(Ir,{value:ae.toString(),children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(cv,{className:"h-3 w-3"}),f.jsx("span",{children:T2(te.timestamp)}),f.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",new Date(te.timestamp).toLocaleTimeString(),")"]})]})},ae))})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>i(E,_.result),children:t===E?f.jsx(ta,{className:"h-4 w-4"}):f.jsx(jr,{className:"h-4 w-4"})})]})]}),(()=>{const te=_.error||Ake(_.result);return te?f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:te})]}):(()=>{if(A){const ae=_.appsSdkResource;return ae.isLoading?f.jsx(f.Fragment,{}):ae.error?f.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4",children:[f.jsx("p",{className:"text-red-800 dark:text-red-300 font-medium",children:"Resource Error:"}),f.jsx("p",{className:"text-red-700 dark:text-red-400 text-sm",children:ae.error})]}):n?f.jsx("div",{className:"flex-1",children:f.jsx(ZO,{componentUrl:O,toolName:_.toolName,toolArgs:k,toolResult:C,serverId:a,readResource:R,className:"w-full h-full relative p-4"})}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})}if(H)return n?f.jsxs("div",{className:"space-y-0 h-full",children:[U.map((ae,B)=>f.jsx("div",{className:"mx-0 size-full",children:f.jsx(IZ,{resource:ae.resource,onUIAction:Z=>{},className:"w-full h-full relative"})},B)),M.filter(ae=>!(ae.type==="resource"&&Su(ae.resource))).length>0&&f.jsx("div",{className:"px-4",children:f.jsx(Jn,{data:M.filter(ae=>!(ae.type==="resource"&&Su(ae.resource))),filename:`tool-result-${_.toolName}-non-ui-${Date.now()}.json`})})]}):f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:_.result,filename:`tool-result-${_.toolName}-mcp-ui-${Date.now()}.json`})});if(Q&&v){const ae=_.result?.structuredContent;return f.jsxs("div",{className:"px-4 pt-4 space-y-4",children:[ae&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:"Structured Content"}),f.jsx(Jn,{data:ae,filename:`structured-content-${_.toolName}-${Date.now()}.json`})]}),M&&M.length>0&&f.jsx(Oke,{content:M}),!ae&&(!M||M.length===0)&&f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No content to display"})]})}return f.jsx("div",{className:"px-4 pt-4",children:f.jsx(Jn,{data:_.result,filename:`tool-result-${_.toolName}-${Date.now()}.json`})})})()})()]})})})}function C2({tools:e,selectedTool:t,onToolSelect:n,focusedIndex:a}){return e.length===0?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(Ul,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"No tools available"})]}):f.jsx("div",{className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((r,i)=>f.jsx(Zs,{id:`tool-${r.name}`,isSelected:t?.name===r.name,isFocused:a===i,icon:f.jsx(Ul,{className:"h-4 w-4"}),title:r.name,description:r.description,metadata:r.inputSchema?.properties&&f.jsxs(xr,{variant:"outline",className:"text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",children:[Object.keys(r.inputSchema.properties).length," params"]}),onClick:()=>n(r)},r.name))})}function R2({activeTab:e,isSearchExpanded:t,searchQuery:n,filteredToolsCount:a,savedRequestsCount:r,onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d}){return f.jsx(RZ,{activeTab:e,isSearchExpanded:t,searchQuery:n,primaryTabName:"tools",secondaryTabName:"saved",primaryTabTitle:"Tools",secondaryTabTitle:"Saved",primaryCount:a,secondaryCount:r,primaryIcon:Ul,secondaryIcon:Ay,searchPlaceholder:"Search tools...",onSearchExpand:i,onSearchChange:s,onSearchBlur:c,onTabSwitch:u,searchInputRef:d})}const A2="mcp-inspector-saved-requests";function jZ({ref:e,tools:t,callTool:n,readResource:a,serverId:r,isConnected:i}){const[s,c]=x.useState(null),[u,d]=x.useState(null),{selectedToolName:m,setSelectedToolName:h}=Jl(),[g,v]=x.useState({}),[w,S]=x.useState([]),[y,_]=x.useState(!1),[E,k]=x.useState(null),[C,R]=x.useState(null),[I,A]=x.useState(""),[O,M]=x.useState("tools"),[U,H]=x.useState([]),[K,Q]=x.useState(!1),[te,ae]=x.useState(""),[B,Z]=x.useState(!0),[G,re]=x.useState(!1),[ne,j]=x.useState(-1),V=x.useRef(null),[z,L]=x.useState(!1),[$,F]=x.useState("list"),[W,X]=x.useState(!1),[ie,le]=x.useState(0),[J,q]=x.useState(!0),[se,he]=x.useState(void 0),ce=x.useRef(null),Te=x.useRef(null),He=x.useRef(null),Ee=x.useRef(null),ke=x.useRef(null);x.useEffect(()=>{const Ie=()=>{L(window.innerWidth<1024)};return Ie(),window.addEventListener("resize",Ie),()=>window.removeEventListener("resize",Ie)},[]),x.useEffect(()=>{F(s?"detail":"list")},[s]),x.useEffect(()=>{z&&w.length>0&&!y&&F("response")},[w,y,z]),x.useImperativeHandle(e,()=>({focusSearch:()=>{re(!0),setTimeout(()=>{V.current&&V.current.focus()},0)},blurSearch:()=>{A(""),re(!1),V.current&&V.current.blur()}})),x.useEffect(()=>{try{const Ie=localStorage.getItem(A2);Ie&&H(JSON.parse(Ie))}catch(Ie){console.error("[ToolsTab] Failed to load saved requests:",Ie)}},[]);const ze=x.useCallback(Ie=>{try{localStorage.setItem(A2,JSON.stringify(Ie)),H(Ie)}catch($e){console.error("[ToolsTab] Failed to save requests:",$e)}},[]),fe=x.useMemo(()=>{if(!I.trim())return t;const Ie=I.toLowerCase();return t.filter($e=>$e.name.toLowerCase().includes(Ie)||$e.description?.toLowerCase().includes(Ie))},[t,I]),Oe=x.useCallback(Ie=>{c(Ie);const $e={};Ie.inputSchema?.properties&&Object.entries(Ie.inputSchema.properties).forEach(([Ve,at])=>{const dt=at;dt.default!==void 0?$e[Ve]=dt.default:dt.type==="string"?$e[Ve]="":dt.type==="number"?$e[Ve]=0:dt.type==="boolean"?$e[Ve]=!1:dt.type==="array"?$e[Ve]="[]":dt.type==="object"&&($e[Ve]="{}")}),v($e)},[]),Be=x.useCallback(Ie=>{const $e=t.find(Ve=>Ve.name===Ie.toolName);$e&&(c($e),v(Ie.args),d(Ie))},[t]);x.useEffect(()=>{G&&V.current&&V.current.focus()},[G]);const Se=x.useCallback(()=>{I.trim()||re(!1)},[I]);x.useEffect(()=>{O!=="tools"&&re(!1)},[O]),x.useEffect(()=>{j(-1)},[I,O]),x.useEffect(()=>{const Ie=$e=>{const Ve=$e.target;if(Ve.tagName==="INPUT"||Ve.tagName==="TEXTAREA"||Ve.contentEditable==="true"||$e.metaKey||$e.ctrlKey||$e.altKey)return;const dt=O==="tools"?fe:U;if($e.key==="ArrowDown")$e.preventDefault(),j(wt=>{const xt=wt+1;return xt>=dt.length?0:xt});else if($e.key==="ArrowUp")$e.preventDefault(),j(wt=>{const xt=wt-1;return xt<0?dt.length-1:xt});else if($e.key==="Enter"&&ne>=0)if($e.preventDefault(),O==="tools"){const wt=fe[ne];wt&&Oe(wt)}else{const wt=U[ne];wt&&Be(wt)}};return document.addEventListener("keydown",Ie),()=>document.removeEventListener("keydown",Ie)},[ne,fe,U,O,Oe,Be]),x.useEffect(()=>{if(ne>=0){const Ie=O==="tools"?`tool-${fe[ne]?.name}`:`saved-${U[ne]?.id}`,$e=document.getElementById(Ie);$e&&$e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[ne,fe,U,O]),x.useEffect(()=>{if(m&&t.length>0){const Ie=t.find($e=>$e.name===m);if(Ie&&s?.name!==Ie.name){h(null);const $e=setTimeout(()=>{Oe(Ie);const Ve=document.getElementById(`tool-${Ie.name}`);Ve&&Ve.scrollIntoView({behavior:"smooth",block:"nearest"})},100);return()=>clearTimeout($e)}}},[m,t,s,Oe,h]);const tt=x.useCallback((Ie,$e)=>{v(Ve=>{const at={...Ve};if(s?.inputSchema?.properties?.[Ie]){const wt=s.inputSchema.properties[Ie].type;if(wt==="object"||wt==="array")at[Ie]=$e;else if(wt==="string")at[Ie]=$e;else try{at[Ie]=JSON.parse($e)}catch{at[Ie]=$e}}else at[Ie]=$e;return at})},[s]),it=x.useCallback(async()=>{if(!s||y)return;const Ie=new AbortController;R(Ie),_(!0);const $e=Date.now();try{const Ve={...g};s.inputSchema?.properties&&Object.entries(s.inputSchema.properties).forEach(([Ye,vt])=>{const Pt=vt.type,fr=Ve[Ye];if((Pt==="object"||Pt==="array")&&typeof fr=="string")try{Ve[Ye]=JSON.parse(fr)}catch{}});const at=await n(s.name,Ve,{timeout:6e5,resetTimeoutOnProgress:!0,signal:Ie.signal}),dt=Date.now()-$e;yr.getInstance().capture(new IU({toolName:s.name,serverId:r,success:!0,duration:dt})).catch(()=>{});const xt=s?._meta||s?.metadata,dn=xt?.["openai/outputTemplate"];let hn;if(dn&&typeof dn=="string"){const Ye={toolName:s.name,args:g,result:at,timestamp:$e,duration:dt,toolMeta:xt,appsSdkResource:{uri:dn,resourceData:null,isLoading:!0}};S([Ye]);try{const vt=await a(dn);let Mt=null;if(at?.structuredContent)Mt=at.structuredContent;else if(Array.isArray(at)&&at[0]){const Pt=at[0];Pt.output?.value?.structuredContent?Mt=Pt.output.value.structuredContent:Pt.structuredContent?Mt=Pt.structuredContent:Pt.output?.value&&(Mt=Pt.output.value)}Mt||(Mt=at),hn={uri:dn,resourceData:{...vt,structuredContent:Mt},isLoading:!1}}catch(vt){hn={uri:dn,resourceData:null,isLoading:!1,error:vt instanceof Error?vt.message:String(vt)}}S(vt=>vt.map((Mt,Pt)=>Pt===0?{...Mt,appsSdkResource:hn}:Mt))}else S(Ye=>[{toolName:s.name,args:g,result:at,timestamp:$e,duration:dt,toolMeta:xt},...Ye])}catch(Ve){const at=Date.now()-$e;yr.getInstance().capture(new IU({toolName:s.name,serverId:r,success:!1,duration:at,error:Ve instanceof Error?Ve.message:String(Ve)})).catch(()=>{});const wt=s?._meta||s?.metadata,xt={toolName:s.name,args:g,result:null,error:Ve instanceof Error?Ve.message:String(Ve),timestamp:$e,duration:at,toolMeta:wt},dn=wt?.["openai/outputTemplate"];S(dn?[xt]:hn=>[xt,...hn])}finally{_(!1)}},[s,g,y,n,a,r]),ht=x.useCallback(async(Ie,$e)=>{try{await navigator.clipboard.writeText(JSON.stringify($e,null,2)),k(Ie),setTimeout(()=>k(null),2e3)}catch(Ve){console.error("[ToolsTab] Failed to copy result:",Ve)}},[]),Rt=x.useCallback(Ie=>{S($e=>$e.filter((Ve,at)=>at!==Ie))},[]),je=x.useMemo(()=>s?w.filter(Ie=>Ie.toolName===s.name):[],[w,s]),Fe=x.useCallback(Ie=>{const $e=je[Ie];if($e){const Ve=window.open("","_blank","width=800,height=600");Ve&&(Ve.document.write(`
|
|
1663
1663
|
<html>
|
|
@@ -1673,4 +1673,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1673
1673
|
<pre>${JSON.stringify($e.result,null,2)}</pre>
|
|
1674
1674
|
</body>
|
|
1675
1675
|
</html>
|
|
1676
|
-
`),Ve.document.close())}},[w]),pt=x.useCallback(()=>{W?(ce.current&&ce.current.expand(),Te.current&&Te.current.expand(),X(!1)):(ce.current&&ce.current.collapse(),Te.current&&Te.current.collapse(),X(!0))},[W]),Qe=x.useCallback(()=>{s&&(ae(""),Q(!0))},[s]),Tt=x.useCallback(()=>{if(!s)return;const Ie={id:`${Date.now()}-${Math.random()}`,name:te.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};ze([...U,Ie]),yr.getInstance().capture(new npe({toolName:s.name,serverId:r})).catch(()=>{}),Q(!1),ae("")},[s,te,g,U,ze,r]),nt=x.useCallback(Ie=>{ze(U.filter($e=>$e.id!==Ie)),u?.id===Ie&&d(null)},[U,ze,u]);return z?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[$!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{$==="response"?F("detail"):(c(null),F("list"))},className:"p-0 h-8 w-8",children:f.jsx(RN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{c(null),F("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),$==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{F("response")},className:$==="detail"?"text-foreground hover:underline":$==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),$==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($y,{initial:!1,mode:"popLayout",children:[$==="list"&&f.jsxs(ga.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:[f.jsx(R2,{activeTab:O,isSearchExpanded:G,searchQuery:I,filteredToolsCount:fe.length,savedRequestsCount:U.length,onSearchExpand:()=>re(!0),onSearchChange:A,onSearchBlur:Se,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(C2,{tools:fe,selectedTool:s,onToolSelect:Oe,focusedIndex:ne}):f.jsx(S2,{savedRequests:U,selectedRequest:u,onLoadRequest:Be,onDeleteRequest:nt,focusedIndex:ne})]},"list"),$==="detail"&&f.jsx(ga.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:f.jsx(k2,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:tt,onExecute:it,onSave:Qe})},"detail"),$==="response"&&f.jsx(ga.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:f.jsx(N2,{results:je,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:ht,onDelete:Rt,onFullscreen:Fe,onTogglePreview:()=>Z(!B)})},"response")]})}),f.jsx(E2,{isOpen:K,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Tt,onCancel:()=>Q(!1)})]}):f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{ref:ce,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:f.jsxs(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(R2,{activeTab:O,isSearchExpanded:G,searchQuery:I,filteredToolsCount:fe.length,savedRequestsCount:U.length,onSearchExpand:()=>re(!0),onSearchChange:A,onSearchBlur:Se,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(C2,{tools:fe,selectedTool:s,onToolSelect:Oe,focusedIndex:ne}):f.jsx(S2,{savedRequests:U,selectedRequest:u,onLoadRequest:Be,onDeleteRequest:nt,focusedIndex:ne})]})}),f.jsx(vi,{withHandle:!0}),f.jsxs(Rn,{ref:Ee,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>{q(!0)},onExpand:()=>{q(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),J?(Ee.current?.resize(25),q(!1)):(Ee.current?.resize(5),q(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),ie>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:ie}),ie>0&&!J&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),ke.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{className:`h-4 w-4 text-muted-foreground transition-transform ${J?"":"rotate-180"}`})]}),!J&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(aD,{serverIds:[r],onCountChange:le,onClearRef:ke})})]})]})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Qr,{direction:"vertical",children:[f.jsx(Rn,{ref:Te,defaultSize:40,collapsible:!0,children:f.jsx(k2,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:tt,onExecute:it,onSave:Qe,onCancel:()=>{C&&C.abort()}})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{ref:He,defaultSize:60,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(N2,{results:je,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:ht,onDelete:Rt,onFullscreen:Fe,onTogglePreview:()=>Z(!B),onMaximize:pt,isMaximized:W})})})]})}),f.jsx(E2,{isOpen:K,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Tt,onCancel:()=>Q(!1)})]})}jZ.displayName="ToolsTab";function Dke({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Td,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(Mm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Reject all"})]})})]})}function jke({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(kd,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):f.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,d=s.request.params?.maxTokens;return f.jsx(Zs,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,f.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":""}`),d&&h.push(`max ${d} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function Lke({llmConfig:e}){const t=x.useRef(null);return{generateResponse:x.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:d,AIMessage:m}=await Qn(async()=>{const{HumanMessage:w,AIMessage:S}=await import("./index-CRN2s3We.js").then(y=>y.bD);return{HumanMessage:w,AIMessage:S}},[]);for(const w of c){if(!w||!w.role){console.warn("Skipping invalid message:",w);continue}const S=Array.isArray(w.content)?w.content[0]:w.content;if(!S){console.warn("Skipping message with no content:",w);continue}S.type==="text"&&S.text?w.role==="user"?u.push(new d(S.text)):w.role==="assistant"&&u.push(new m(S.text)):console.warn("Skipping message with unsupported content type:",S)}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 w;const S={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(S.maxTokens=i),s!==void 0?S.temperature=s:e.temperature!==void 0&&(S.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:y}=await Qn(async()=>{const{ChatOpenAI:_}=await import("./index-C98SBxLG.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,3,8,9]));w=new y(S)}else if(e.provider==="anthropic"){const{ChatAnthropic:y}=await Qn(async()=>{const{ChatAnthropic:_}=await import("./index-xIW0QfEK.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,3]));w=new y(S)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:y}=await Qn(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-n6TPfFwj.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,3,9]));w=new y(S)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:w,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 $ke({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d,llmConfig:m}){const[h,g]=x.useState("manual"),[v,w]=x.useState("stub-model"),[S,y]=x.useState("endTurn"),[_,E]=x.useState("assistant"),[k,C]=x.useState("text"),[R,I]=x.useState("positive"),[A,O]=x.useState(""),[M,U]=x.useState("image/png"),[H,K]=x.useState(!1),[Q,te]=x.useState(null),{generateResponse:ae,isAvailable:B}=Lke({llmConfig:m});x.useEffect(()=>{e&&(w("stub-model"),y("endTurn"),E("assistant"),C("text"),I("positive"),O(""),U("image/png"),te(null))},[e?.id]);const Z=async()=>{if(!(!e||!B)){K(!0),te(null);try{const j=await ae({request:e.request});w(j.model||m?.model||"stub-model"),y(j.stopReason||"endTurn"),E(j.role||"assistant");const V=Array.isArray(j.content)?j.content[0]:j.content;V.type==="text"?(C("text"),I(V.text||"")):V.type==="image"&&(C("image"),O(V.data||""),U(V.mimeType||"image/png"))}catch(j){const V=j instanceof Error?j.message:"Failed to generate response";te(V),Jt.error("LLM Generation Failed",{description:V})}finally{K(!1)}}},G=x.useMemo(()=>{const j={model:v,stopReason:S,role:_,content:{type:k}};return k==="text"?j.content.text=R:k==="image"&&(j.content.data=A,j.content.mimeType=M),j},[v,S,_,k,R,A,M]),re=()=>{if(!e)return;const j=BT.safeParse(G);if(!j.success){Jt.error("Invalid response",{description:`Validation failed: ${j.error.message}`});return}t(e.id,j.data),a(),Qn(()=>Promise.resolve().then(()=>pd),void 0).then(V=>{const z=Jt(V.createElement("div",{className:"space-y-3"},V.createElement("div",null,V.createElement("strong",null,"Sampling Response Sent"),V.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),V.createElement("div",{className:"flex gap-2"},V.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 L=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(L),Jt.dismiss(z)}},"View Tool Result"))),{duration:5e3})})},ne=()=>{e&&(n(e.id,"User rejected sampling request"),a())};return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ta,{className:"h-4 w-4 text-green-600"}):f.jsx(jr,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Copy request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(wm,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Download request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(ON,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Fullscreen"})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Yi,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(Jn,{data:e.request})})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Kt,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),f.jsxs(Co,{value:h,onValueChange:j=>g(j),children:[f.jsx(Ao,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:f.jsx(Ro,{})}),f.jsxs(Io,{children:[f.jsx(Ir,{value:"manual",children:"Manual"}),f.jsx(Ir,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&f.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[B?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Le,{onClick:Z,disabled:H,size:"sm",className:"flex items-center gap-2",children:H?f.jsxs(f.Fragment,{children:[f.jsx(Ls,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):f.jsxs(f.Fragment,{children:[f.jsx($me,{className:"h-4 w-4"}),"Generate with LLM"]})}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),Q&&f.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:Q})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`model-${e.id}`,children:"Model"}),f.jsx(kn,{id:`model-${e.id}`,value:v,onChange:j=>w(j.target.value),placeholder:"stub-model",disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),f.jsx(kn,{id:`stopReason-${e.id}`,value:S,onChange:j=>y(j.target.value),placeholder:"endTurn",disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`role-${e.id}`,children:"Role"}),f.jsxs(Co,{value:_,onValueChange:j=>E(j),disabled:h==="llm"&&H,children:[f.jsx(Ao,{id:`role-${e.id}`,children:f.jsx(Ro,{})}),f.jsxs(Io,{children:[f.jsx(Ir,{value:"assistant",children:"assistant"}),f.jsx(Ir,{value:"user",children:"user"})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),f.jsxs(Co,{value:k,onValueChange:j=>C(j),disabled:h==="llm"&&H,children:[f.jsx(Ao,{id:`contentType-${e.id}`,children:f.jsx(Ro,{})}),f.jsxs(Io,{children:[f.jsx(Ir,{value:"text",children:"text"}),f.jsx(Ir,{value:"image",children:"image"})]})]})]}),k==="text"&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`text-${e.id}`,children:"Text Content"}),f.jsx(Vl,{id:`text-${e.id}`,value:R,onChange:j=>I(j.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&H})]}),k==="image"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),f.jsx(Vl,{id:`imageData-${e.id}`,value:A,onChange:j=>O(j.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),f.jsx(kn,{id:`mimeType-${e.id}`,value:M,onChange:j=>U(j.target.value),placeholder:"image/png",disabled:h==="llm"&&H})]})]})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(Le,{onClick:re,className:"flex-1",disabled:h==="llm"&&H,children:"Approve"}),f.jsx(Le,{onClick:ne,variant:"outline",className:"flex-1",disabled:h==="llm"&&H,children:"Reject"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}function Mke({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=Jl(),{llmConfig:u}=sZ({mcpServerUrl:i}),[d,m]=x.useState(null),[h,g]=x.useState(""),[v,w]=x.useState(-1),[S,y]=x.useState(!0),[_,E]=x.useState(!1),[k,C]=x.useState(!0),[R,I]=x.useState(!1),A=x.useRef(null),O=x.useRef(null),M=x.useRef(null),U=x.useRef(!1);x.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:s,pendingRequestsCount:e.length,currentSelectedId:d?.id}),s&&e.length>0){const G=e.find(re=>re.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[SamplingTab] Auto-selecting request:",G.id),c(null),m(G),setTimeout(()=>{const re=document.getElementById(`sampling-request-${G.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),x.useEffect(()=>{const G=re=>{const j=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",j);const V=e.find(z=>z.id===j);V&&(console.log("[SamplingTab] Selecting request from event:",j),m(V),setTimeout(()=>{const z=document.getElementById(`sampling-request-${j}`);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",G),()=>window.removeEventListener("navigate-to-sampling",G)},[e]),x.useEffect(()=>{S&&e.length>0&&A.current&&!U.current&&(A.current.scrollTop=0)},[e.length,S]),x.useEffect(()=>{const G=A.current;if(!G)return;const re=()=>{G.scrollTop>0&&(U.current=!0,y(!1))};return G.addEventListener("scroll",re),()=>G.removeEventListener("scroll",re)},[]),x.useEffect(()=>{e.length===0&&(U.current=!1,y(!0))},[e.length]),x.useEffect(()=>{_&&M.current&&M.current.focus()},[_]);const H=x.useCallback(()=>{h.trim()||E(!1)},[h]),K=x.useMemo(()=>{if(!h.trim())return e;const G=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(G)||JSON.stringify(re.request||{}).toLowerCase().includes(G))},[e,h]);x.useEffect(()=>{w(-1)},[h]),x.useEffect(()=>{const G=re=>{const ne=re.target;if(ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const V=K;if(re.key==="ArrowDown")re.preventDefault(),w(z=>{const L=z+1;return L>=V.length?0:L});else if(re.key==="ArrowUp")re.preventDefault(),w(z=>{const L=z-1;return L<0?V.length-1:L});else if(re.key==="Enter"&&v>=0){re.preventDefault();const z=K[v];z&&Q(z)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[v,K]),x.useEffect(()=>{if(v>=0){const G=`sampling-request-${K[v]?.id}`,re=document.getElementById(G);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,K]);const Q=x.useCallback(G=>{m(G)},[]),te=x.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(G=>{n(G.id,"User rejected all requests")}),m(null))},[e,n]),ae=x.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)),I(!0),setTimeout(()=>I(!1),2e3)}catch(G){console.error("[SamplingTab] Failed to copy request:",G)}},[d]),B=x.useCallback(()=>{if(d)try{const G=new globalThis.Blob([JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)],{type:"application/json"}),re=URL.createObjectURL(G),ne=document.createElement("a");ne.href=re,ne.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(re)}catch(G){console.error("[SamplingTab] Failed to download request:",G)}},[d]),Z=x.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(G){console.error("[SamplingTab] Failed to toggle fullscreen:",G)}},[]);return r?f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(Dke,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:K.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:H,onRejectAll:te,searchInputRef:M}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(jke,{requests:K,selectedRequest:d,onRequestSelect:Q,focusedIndex:v,formatRelativeTime:Pv,listRef:A})})]})})}),f.jsx(vi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx($ke,{request:d,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>C(!k),isCopied:R,onCopy:ae,onDownload:B,onFullscreen:Z,llmConfig:u})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(E8,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function Pke({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onCancelAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Td,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(Mm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Yi,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Cancel all"})]})})]})}function Uke({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(kd,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.mode||"form",d=u==="form"&&"requestedSchema"in s.request&&s.request.requestedSchema;return f.jsx(Zs,{id:`elicitation-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,f.jsx(xr,{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=[];d&&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 zke({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d}){const[m,h]=x.useState({}),[g,v]=x.useState(!1),w=e?.request.mode||"form",S=w==="form",y=w==="url";x.useEffect(()=>{if(e&&S&&"requestedSchema"in e.request){const A=e.request.requestedSchema,O={};if(A?.type==="object"&&A.properties)for(const[M,U]of Object.entries(A.properties)){const H=U;H.default!==void 0?O[M]=H.default:H.type==="boolean"?O[M]=!1:H.type==="number"||H.type==="integer"?O[M]=0:O[M]=""}h(O)}v(!1)},[e?.id,S]);const _=(A,O)=>{h(M=>({...M,[A]:O}))},E=()=>{if(e){if(S){if("requestedSchema"in e.request){const A=e.request.requestedSchema;if(A?.required){const O=A.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(O.length>0){Jt.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else y&&t(e.id,{action:"accept"});a(),Qn(()=>Promise.resolve().then(()=>pd),void 0).then(A=>{const O=Jt(A.createElement("div",{className:"space-y-3"},A.createElement("div",null,A.createElement("strong",null,"Elicitation Response Sent"),A.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),A.createElement("div",{className:"flex gap-2"},A.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),Jt.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),a())},C=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},R=()=>{e&&y&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},I=x.useMemo(()=>{if(!e||!S||!("requestedSchema"in e.request))return null;const A=e.request.requestedSchema;if(!A||A.type!=="object"||!A.properties)return f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=A.properties,M=A.required||[];return f.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([U,H])=>{const K=H,Q=M.includes(U),te=K.type||"string",ae=K.title||U,B=K.description;return f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:`field-${U}`,children:[ae,Q&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),B&&f.jsx("p",{className:"text-xs text-muted-foreground",children:B}),te==="boolean"?f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(Bp,{id:`field-${U}`,checked:m[U]||!1,onCheckedChange:Z=>_(U,Z)}),f.jsx(Kt,{htmlFor:`field-${U}`,className:"text-sm font-normal cursor-pointer",children:K.title||U})]}):te==="number"||te==="integer"?f.jsx(kn,{id:`field-${U}`,type:"number",value:m[U]||"",onChange:Z=>_(U,te==="integer"?parseInt(Z.target.value,10):parseFloat(Z.target.value)),placeholder:K.default?.toString()||""}):K.enum?f.jsxs("select",{id:`field-${U}`,value:m[U]||"",onChange:Z=>_(U,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:[f.jsx("option",{value:"",children:"Select..."}),K.enum.map(Z=>f.jsx("option",{value:Z,children:Z},Z))]}):te==="string"&&(K.format==="textarea"||K.maxLength>100)?f.jsx(Vl,{id:`field-${U}`,value:m[U]||"",onChange:Z=>_(U,Z.target.value),placeholder:K.default||"",rows:4}):f.jsx(kn,{id:`field-${U}`,type:"text",value:m[U]||"",onChange:Z=>_(U,Z.target.value),placeholder:K.default||""})]},U)})})},[e,m,S]);return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx(xr,{variant:"outline",className:y?"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:w}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ta,{className:"h-4 w-4 text-green-600"}):f.jsx(jr,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Copy request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(wm,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Download request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(ON,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Fullscreen"})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Yi,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),f.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),y&&"url"in e.request&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),f.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[f.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),f.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[f.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),f.jsxs(Le,{size:"sm",variant:"outline",onClick:R,className:"flex items-center gap-2",children:[f.jsx(IE,{className:"h-4 w-4"}),"Open URL"]})]}),f.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[f.jsx(Bp,{id:"url-completed",checked:g,onCheckedChange:A=>v(!!A)}),f.jsx(Kt,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),S&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),I]}),S&&"requestedSchema"in e.request&&e.request.requestedSchema&&f.jsxs("details",{className:"space-y-2",children:[f.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(Jn,{data:e.request.requestedSchema})})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(Le,{onClick:E,className:"flex-1",children:"Accept"}),f.jsx(Le,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),f.jsx(Le,{onClick:C,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function Fke({pendingRequests:e=[],onApprove:t,onReject:n,serverId:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=Jl(),[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:c?.id}),i&&e.length>0){const B=e.find(Z=>Z.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!B,B?.id),B&&(console.log("[ElicitationTab] Auto-selecting request:",B.id),s(null),u(B),setTimeout(()=>{const Z=document.getElementById(`elicitation-request-${B.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Z),Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,s]),x.useEffect(()=>{const B=Z=>{const re=Z.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",re);const ne=e.find(j=>j.id===re);ne&&(console.log("[ElicitationTab] Selecting request from event:",re),u(ne),setTimeout(()=>{const j=document.getElementById(`elicitation-request-${re}`);j&&j.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",B),()=>window.removeEventListener("navigate-to-elicitation",B)},[e]),x.useEffect(()=>{v&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const B=R.current;if(!B)return;const Z=()=>{B.scrollTop>0&&(O.current=!0,w(!1))};return B.addEventListener("scroll",Z),()=>B.removeEventListener("scroll",Z)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{S&&A.current&&A.current.focus()},[S]);const M=x.useCallback(()=>{d.trim()||y(!1)},[d]),U=x.useMemo(()=>{if(!d.trim())return e;const B=d.toLowerCase();return e.filter(Z=>Z.serverName.toLowerCase().includes(B)||Z.request.message.toLowerCase().includes(B)||JSON.stringify(Z.request||{}).toLowerCase().includes(B))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const B=Z=>{const G=Z.target;if(G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const ne=U;if(Z.key==="ArrowDown")Z.preventDefault(),g(j=>{const V=j+1;return V>=ne.length?0:V});else if(Z.key==="ArrowUp")Z.preventDefault(),g(j=>{const V=j-1;return V<0?ne.length-1:V});else if(Z.key==="Enter"&&h>=0){Z.preventDefault();const j=U[h];j&&H(j)}};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[h,U]),x.useEffect(()=>{if(h>=0){const B=`elicitation-request-${U[h]?.id}`,Z=document.getElementById(B);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,U]);const H=x.useCallback(B=>{u(B)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(B=>{n(B.id,"User cancelled all requests")}),u(null))},[e,n]),Q=x.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)),C(!0),setTimeout(()=>C(!1),2e3)}catch(B){console.error("[ElicitationTab] Failed to copy request:",B)}},[c]),te=x.useCallback(()=>{if(c)try{const B=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(B),G=document.createElement("a");G.href=Z,G.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(Z)}catch(B){console.error("[ElicitationTab] Failed to download request:",B)}},[c]),ae=x.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(B){console.error("[ElicitationTab] Failed to toggle fullscreen:",B)}},[]);return r?f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(Pke,{isSearchExpanded:S,searchQuery:d,filteredRequestsCount:U.length,requestsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:K,searchInputRef:A}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(Uke,{requests:U,selectedRequest:c,onRequestSelect:H,focusedIndex:h,formatRelativeTime:Pv,listRef:R})})]})})}),f.jsx(vi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(zke,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:_,onTogglePreview:()=>E(!_),isCopied:k,onCopy:Q,onDownload:te,onFullscreen:ae})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(N8,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function Bke({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:f.jsx(jZ,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:f.jsx(AZ,{ref:a,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:f.jsx(OZ,{ref:r,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:f.jsx(V_e,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),f.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:f.jsx(Mke,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),f.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:f.jsx(Fke,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:f.jsx(Ske,{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"&&f.jsx(f.Fragment,{children:i})]}):f.jsx(f.Fragment,{children:i})}function I2({className:e}){return f.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentcolor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[f.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"}),f.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const LZ=x.createContext(void 0);function $Z(){const e=x.use(LZ);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const MZ=x.createContext(void 0);function Hke(){return x.use(MZ)}function P_({ref:e,children:t,defaultValue:n,value:a,onValueChange:r,className:i,...s}){const[c,u]=x.useState(n||""),d=a!==void 0,m=x.useCallback(g=>{d||u(g),r?.(g)},[d,r]),h=d?a:c;return f.jsx(LZ,{value:{activeValue:h,handleValueChange:m},children:f.jsx("div",{ref:e,className:De("flex flex-col gap-2",i),...s,children:t})})}P_.displayName="Tabs";function U_({ref:e,children:t,className:n,variant:a="default",...r}){const{activeValue:i}=$Z(),[s,c]=x.useState({width:0,left:0}),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),g=x.Children.toArray(t).findIndex(S=>x.isValidElement(S)&&S.props.value===i),v=x.useCallback(()=>{const S=u.current;if(!S)return;const _=S.querySelectorAll("button")[g];if(_){const E=S.getBoundingClientRect(),k=_.getBoundingClientRect();c({width:k.width,left:k.left-E.left})}},[g]),w=x.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(v,16)},[v]);return x.useEffect(()=>{const S=setTimeout(v,10);return()=>clearTimeout(S)},[v]),x.useEffect(()=>{const S=u.current;return S?(d.current=new ResizeObserver(()=>{w()}),d.current.observe(S),S.querySelectorAll("button").forEach(_=>{d.current&&d.current.observe(_)}),()=>{d.current&&d.current.disconnect(),m.current&&clearTimeout(m.current)}):void 0},[w]),x.useEffect(()=>{const S=()=>{w()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[w]),x.useEffect(()=>{const S=u.current;if(!S)return;const y=S.querySelector("[data-width]");y&&(y.style.width=`${s.width}px`,y.style.left=`${s.left}px`)},[s]),f.jsx(MZ,{value:{variant:a},children:f.jsxs("div",{ref:u,className:De("relative flex bg-none",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),...r,children:[t,f.jsx("span",{className:De("absolute transition-all duration-200 ease-out z-0",a==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%-8px)] top-1 border border-zinc-300 dark:border-zinc-600",a==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white"),"data-width":s.width,"data-left":s.left})]})})}U_.displayName="TabsList";function z_({ref:e,children:t,value:n,className:a,disabled:r,icon:i,...s}){const{activeValue:c,handleValueChange:u}=$Z(),m=Hke()?.variant||"default",h=c===n;return f.jsxs("button",{ref:e,disabled:r,onClick:()=>u(n),className:De("relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer",m==="default"&&"rounded-md px-4 py-2.5",m==="underline"&&"px-6 py-3 border-b-2 border-transparent",h&&"text-foreground",!h&&"text-muted-foreground hover:text-foreground",a),...s,children:[i&&f.jsx(i,{className:"mr-2 h-4 w-4"}),t]})}z_.displayName="TabsTrigger";function O2({className:e}){const{theme:t,setTheme:n}=nw(),a=x.useRef(null),[r,i]=x.useState(!1);x.useEffect(()=>{i(!0)},[]);const s=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?f.jsx(PU,{className:"size-4"}):t==="light"?f.jsx(Fme,{className:"size-5"}):f.jsx(wme,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",d=async()=>{if(!a.current)return;const m=s();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{vd.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:w}=a.current.getBoundingClientRect(),S=h+w/2,y=g+v/2,_=window.innerWidth-g,E=window.innerHeight-h,k=Math.hypot(Math.max(g,_),Math.max(h,E));document.documentElement.animate({clipPath:[`circle(0px at ${y}px ${S}px)`,`circle(${k}px at ${y}px ${S}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?f.jsx("button",{ref:a,onClick:d,className:De(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):f.jsx("button",{ref:a,className:De(e),"aria-label":"Toggle theme",children:f.jsx(PU,{className:"size-4"})})}function D2({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[a,r]=x.useState(!1),i=.2,s=.7,c=.6,u=4,d=i+s+c,m=0,h=i/d,g=(i+s)/d,v=1;return f.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:De("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[f.jsx("div",{className:"relative",children:f.jsxs(ga.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:De("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[f.jsxs(ga.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:d,times:[m,h,g,v],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.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"}),f.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),f.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),f.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.jsx(Vke,{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:d}),f.jsx(j2,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d}),f.jsx(j2,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d})]})]})}),t==="expanded"&&f.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",children:[f.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),f.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function Vke({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return f.jsx(ga.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 j2({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return f.jsx(ga.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 PZ({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:d}=nw(),m=d==="dark"?"#000000":"#ffffff",h=d==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=i||h;return f.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":r,"--speed":a,"--cut":n,"--bg":v},className:De("group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]","transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px",d==="dark"?"border-black/10 text-black":"border-white/10 text-white",s),ref:e,...u,children:[f.jsx("div",{className:De("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:f.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:f.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,f.jsx("div",{className:De("absolute inset-0 size-full","rounded-2xl px-4 py-1.5 text-sm font-medium","transform-gpu transition-all duration-300 ease-in-out",d==="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]")}),f.jsx("div",{className:De("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}PZ.displayName="ShimmerButton";function L2({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 f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),f.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),f.jsx(Lt,{children:f.jsx("p",{children:r})})]})}function $2({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=bd(),s=c=>{const u=e.find(d=>d.id===c);if(!u||u.state!=="ready"){Jt.error("Server is not connected and cannot be inspected");return}n(c)};return r?f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(TE,{children:[f.jsx(NE,{asChild:!0,children:f.jsxs(Le,{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?f.jsx(Tl,{serverUrl:t.url,serverName:t.name,size:"md"}):f.jsx(Ime,{className:"h-5 w-5"}),f.jsx(Xl,{className:"h-4 w-4"})]})}),f.jsxs(lv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(CE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Vf,{}),e.length===0?f.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(c=>f.jsxs(To,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Tl,{serverUrl:c.url,serverName:c.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:c.name}),f.jsx(L2,{status:c.state})]}),f.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:f.jsx(bu,{className:"h-3 w-3"})})]},c.id)),f.jsx(Vf,{}),f.jsx(To,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(TE,{children:[f.jsx(NE,{asChild:!0,children:f.jsxs(PZ,{className:De("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-10"),children:[t&&f.jsx(Tl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&f.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx("button",{onClick:c=>{c.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"})}),f.jsx(Lt,{children:f.jsx("p",{className:"max-w-xs",children:t.error})})]}):f.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&&f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx("button",{type:"button",onClick:()=>{a(t.id)},className:"absolute right-2 top-1/2 -translate-y-1/2 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:f.jsx(bu,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Edit connection settings"})})]}),f.jsxs(lv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(CE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Vf,{}),e.length===0?f.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(c=>f.jsxs(To,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Tl,{serverUrl:c.url,serverName:c.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:c.name}),f.jsx(L2,{status:c.state})]}),f.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:f.jsx(bu,{className:"h-3 w-3"})})]},c.id)),f.jsx(Vf,{}),f.jsx(To,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const M2=[{id:"tools",label:"Tools",icon:Ul},{id:"prompts",label:"Prompts",icon:Cp},{id:"resources",label:"Resources",icon:nme},{id:"sampling",label:"Sampling",icon:E8},{id:"elicitation",label:"Elicitation",icon:N8},{id:"notifications",label:"Notifications",icon:CN},{id:"chat",label:"Chat",icon:mme}];function P2(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 Gke({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s}){const{tunnelUrl:c}=Jl(),u=t&&c,[d,m]=x.useState(!1),h=async()=>{if(c)try{await navigator.clipboard.writeText(`${c}/mcp`),m(!0),Jt.success("Tunnel URL copied to clipboard"),setTimeout(()=>m(!1),2e3)}catch{Jt.error("Failed to copy URL")}};return f.jsxs("header",{className:"w-full mx-auto",children:[f.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[f.jsxs("div",{className:"flex items-center justify-between w-full",children:[f.jsx("div",{className:"flex-1 flex justify-start",children:f.jsx($2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),f.jsx("div",{className:"flex-shrink-0 flex justify-center",children:f.jsx("div",{className:"scale-150",children:f.jsx(D2,{state:"collapsed"})})}),f.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:f.jsx(I2,{className:"h-4 w-4"})})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(O2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&f.jsx("div",{className:"w-full",children:f.jsx(P_,{value:n,onValueChange:g=>r(g),children:f.jsx(U_,{className:"w-full justify-center",children:M2.map(g=>{const v=P2(g.id,t);return f.jsxs(z_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 flex-1 flex-row gap-2 relative",children:[v>0&&f.jsx("span",{className:De(n===g.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:v}),f.jsx("span",{className:"sr-only",children:g.label})]},g.id)})})})})]}),f.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[f.jsx($2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&f.jsx(P_,{value:n,onValueChange:g=>r(g),children:f.jsx(U_,{className:"overflow-x-auto",children:M2.map(g=>{const v=P2(g.id,t);return f.jsx(z_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",children:f.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[g.label,v>0&&f.jsx("span",{className:De(n===g.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:v})]})},g.id)})})}),u&&f.jsxs(I7,{children:[f.jsx(O7,{asChild:!0,children:f.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:[f.jsx(Rp,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),f.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),f.jsx(TC,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[f.jsx(Rp,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),f.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[f.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[c,"/mcp"]}),f.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:h,children:d?f.jsx(ta,{className:"size-3.5 text-green-600"}):f.jsx(jr,{className:"size-3.5"})})]})]}),f.jsxs("div",{children:[f.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),f.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"1."}),f.jsxs("span",{children:["Enable"," ",f.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"2."}),f.jsxs("span",{children:["In"," ",f.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",f.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"3."}),f.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),f.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[f.jsxs(Dt,{children:[f.jsx(jt,{children:f.jsx(O2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),f.jsx(Lt,{children:f.jsx("p",{children:"Toggle theme"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs(Le,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[f.jsx(Upe,{className:"size-4"}),f.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),f.jsx(Lt,{children:f.jsx("p",{children:"Command Palette"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[f.jsx(I2,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(D2,{state:"expanded"})]})]})]})}function Wke({children:e}){const t=bd(),n=Bo(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=NN(),{selectedServerId:u,setSelectedServerId:d,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v}=Jl(),[w,S]=x.useState(!1),[y,_]=x.useState(null),E=s0e();x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("tunnelUrl");v(Z)},[n.search,v]),x.useEffect(()=>{const B=re=>{const j=re.detail.requestId;u&&g(u,"sampling",j)},Z=re=>{const j=re.detail.requestId;u&&g(u,"elicitation",j)},G=re=>{const j=re.detail.toolName;u&&j?g(u,"tools",j):u&&h("tools")};return window.addEventListener("navigate-to-sampling",B),window.addEventListener("navigate-to-elicitation",Z),window.addEventListener("navigate-to-tool-result",G),()=>{window.removeEventListener("navigate-to-sampling",B),window.removeEventListener("navigate-to-elicitation",Z),window.removeEventListener("navigate-to-tool-result",G)}},[u,h,g]);const k=x.useRef(null),C=x.useRef(null),R=x.useRef(null),{isAutoConnecting:I}=o0e({connections:a,addConnection:r,removeConnection:i,configLoaded:c}),A=x.useCallback(B=>{yr.getInstance().capture(new tpe({trigger:B})).catch(()=>{}),S(!0)},[]),O=B=>{const Z=a.find(j=>j.id===B);if(!Z||Z.state!=="ready"){Jt.error("Server is not connected and cannot be inspected");return}d(B);const re=new URLSearchParams(n.search).get("tunnelUrl"),ne=re?`/?server=${encodeURIComponent(B)}&tunnelUrl=${encodeURIComponent(re)}`:`/?server=${encodeURIComponent(B)}`;t(ne)},M=x.useCallback(B=>{_(B)},[]),U=x.useCallback(B=>{y&&(B.url!==y?(i(y),r(B.url,B.name,B.proxyConfig,B.transportType)):s(y,{name:B.name,proxyConfig:B.proxyConfig,transportType:B.transportType}),_(null),Jt.success("Connection settings updated"))},[y,i,r,s]),H=(B,Z,G)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:B,itemName:Z,serverId:G}),G){const re=a.find(z=>z.id===G);if(console.warn("[Layout] Server lookup:",{serverId:G,serverFound:!!re,serverState:re?.state}),!re||re.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),Jt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:G,tab:B,itemName:Z}),g(G,B,Z);const j=new URLSearchParams(n.search).get("tunnelUrl"),V=j?`/?server=${encodeURIComponent(G)}&tunnelUrl=${encodeURIComponent(j)}`:`/?server=${encodeURIComponent(G)}`;console.warn("[Layout] Navigating to:",V),t(V)}else console.warn("[Layout] No serverId, just updating tab to:",B),h(B)},K=a.find(B=>B.id===u),Q=K?K.tools.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.tools.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]),te=K?K.prompts.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.prompts.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]),ae=K?K.resources.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.resources.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]);return x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server"),G=Z?decodeURIComponent(Z):null;G!==u&&d(G)},[n.search,u,d]),x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server");if(!Z)return;const G=decodeURIComponent(Z),re=a.find(ne=>ne.id===G);if(!re){const ne=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(ne)}if(re.state==="failed"){const ne=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(ne)}},[n.search,t,a]),i7({onCommandPalette:()=>A("keyboard"),onToolsTab:()=>{K&&h("tools")},onPromptsTab:()=>{K&&h("prompts")},onResourcesTab:()=>{K&&h("resources")},onChatTab:()=>{K&&h("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{m==="tools"&&k.current?k.current.focusSearch():m==="prompts"&&C.current?C.current.focusSearch():m==="resources"&&R.current&&R.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&k.current?k.current.blurSearch():m==="prompts"&&C.current?C.current.blurSearch():m==="resources"&&R.current&&R.current.blurSearch()}}),I?f.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Ei,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})}):f.jsx(v8,{children:f.jsxs("div",{className:"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",children:[f.jsx(Gke,{connections:a,selectedServer:K,activeTab:m,onServerSelect:O,onTabChange:h,onCommandPaletteOpen:()=>A("button"),onOpenConnectionOptions:M}),f.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:f.jsx(Bke,{selectedServer:K,activeTab:m,toolsSearchRef:k,promptsSearchRef:C,resourcesSearchRef:R,children:e})}),f.jsx(j0e,{isOpen:w,onOpenChange:S,tools:Q,prompts:te,resources:ae,savedRequests:E,connections:a,onNavigate:H,onServerSelect:O}),f.jsx(SG,{connection:y&&a.find(B=>B.id===y)||null,open:y!==null,onOpenChange:B=>{B||_(null)},onConnect:U})]})})}function Kke(){const[e,t]=x.useState("processing"),[n,a]=x.useState("");return x.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),XT().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"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Ls,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),f.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var Zke=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,d=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(w=>{let S=w==="class",y=S&&i?r.map(_=>i[_]||_):r;S?(u.classList.remove(...y),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(w,v)}),h(v)}function h(v){c&&d.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,w=s&&v==="system"?g():v;m(w)}catch{}},Yke=x.createContext(void 0),qke={setTheme:e=>{},themes:[]},Xke=()=>{var e;return(e=x.useContext(Yke))!=null?e:qke};x.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:a,enableColorScheme:r,defaultTheme:i,value:s,themes:c,nonce:u,scriptProps:d})=>{let m=JSON.stringify([n,t,i,e,c,s,a,r]).slice(1,-1);return x.createElement("script",{...d,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${Zke.toString()})(${m})`}})});function Jke({...e}){const{theme:t="system"}=Xke();return f.jsx(C8,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Qke(){return f.jsx(EEe,{children:f.jsx(lpe,{children:f.jsxs(i0e,{children:[f.jsx(ose,{basename:"/inspector",children:f.jsxs(Moe,{children:[f.jsx(gE,{path:"/oauth/callback",element:f.jsx(Kke,{})}),f.jsx(gE,{path:"/",element:f.jsx(Wke,{children:f.jsx(a0e,{})})})]})}),f.jsx(Jke,{position:"top-center"})]})})})}const U2=new URLSearchParams(window.location.search);if(U2.has("code")||U2.has("error"))try{XT()}catch(e){console.error("[inspector] OAuth callback error:",e)}const z2=document.getElementById("root");z2?Wie.createRoot(z2).render(f.jsx(Qke,{})):console.error("[inspector] Root element not found");export{iB as $,vT as A,e5 as B,Q6 as C,Qv as D,a5 as E,pH as F,pb as G,Mi as H,MP as I,Rie as J,XT as K,V2 as L,_ie as M,hX as N,ue as R,J2 as T,tX as V,Nie as W,Ct as Z,Pe as _,Qn as a,pd as b,vd as c,zS as d,tTe as e,hi as f,Wp as g,FS as h,ei as i,h6 as j,SB as k,uF as l,pF as m,m6 as n,aB as o,xF as p,ute as q,x as r,fk as s,j6 as t,Db as u,pX as v,we as w,mte as x,VS as y,Pte as z};
|
|
1676
|
+
`),Ve.document.close())}},[w]),pt=x.useCallback(()=>{W?(ce.current&&ce.current.expand(),Te.current&&Te.current.expand(),X(!1)):(ce.current&&ce.current.collapse(),Te.current&&Te.current.collapse(),X(!0))},[W]),Qe=x.useCallback(()=>{s&&(ae(""),Q(!0))},[s]),Tt=x.useCallback(()=>{if(!s)return;const Ie={id:`${Date.now()}-${Math.random()}`,name:te.trim()||`${s.name} - ${new Date().toLocaleString()}`,toolName:s.name,args:g,savedAt:Date.now(),serverId:s._serverId,serverName:s._serverName};ze([...U,Ie]),yr.getInstance().capture(new npe({toolName:s.name,serverId:r})).catch(()=>{}),Q(!1),ae("")},[s,te,g,U,ze,r]),nt=x.useCallback(Ie=>{ze(U.filter($e=>$e.id!==Ie)),u?.id===Ie&&d(null)},[U,ze,u]);return z?f.jsxs("div",{className:"h-full flex flex-col overflow-hidden relative bg-background",children:[$!=="list"&&f.jsxs("div",{className:"flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",children:[f.jsx(Le,{variant:"ghost",size:"sm",onClick:()=>{$==="response"?F("detail"):(c(null),F("list"))},className:"p-0 h-8 w-8",children:f.jsx(RN,{className:"h-4 w-4"})}),f.jsxs("div",{className:"flex items-center text-sm font-medium",children:[f.jsx("button",{onClick:()=>{c(null),F("list")},className:"text-muted-foreground hover:text-foreground hover:underline cursor-pointer",children:"Tools"}),$==="detail"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("button",{onClick:()=>{F("response")},className:$==="detail"?"text-foreground hover:underline":$==="response"?"text-muted-foreground hover:text-foreground hover:underline cursor-pointer":"text-muted-foreground",children:"Execute"})]}),$==="response"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"mx-2 text-muted-foreground",children:"/"}),f.jsx("span",{className:"text-foreground",children:"Response"})]})]})]}),f.jsx("div",{className:"flex-1 relative overflow-hidden",children:f.jsxs($y,{initial:!1,mode:"popLayout",children:[$==="list"&&f.jsxs(ga.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:[f.jsx(R2,{activeTab:O,isSearchExpanded:G,searchQuery:I,filteredToolsCount:fe.length,savedRequestsCount:U.length,onSearchExpand:()=>re(!0),onSearchChange:A,onSearchBlur:Se,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(C2,{tools:fe,selectedTool:s,onToolSelect:Oe,focusedIndex:ne}):f.jsx(S2,{savedRequests:U,selectedRequest:u,onLoadRequest:Be,onDeleteRequest:nt,focusedIndex:ne})]},"list"),$==="detail"&&f.jsx(ga.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:f.jsx(k2,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:tt,onExecute:it,onSave:Qe})},"detail"),$==="response"&&f.jsx(ga.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:f.jsx(N2,{results:je,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:ht,onDelete:Rt,onFullscreen:Fe,onTogglePreview:()=>Z(!B)})},"response")]})}),f.jsx(E2,{isOpen:K,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Tt,onCancel:()=>Q(!1)})]}):f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{ref:ce,defaultSize:33,collapsible:!0,className:"flex flex-col h-full relative",children:f.jsxs(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:[f.jsx(Rn,{defaultSize:75,minSize:30,children:f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[f.jsx(R2,{activeTab:O,isSearchExpanded:G,searchQuery:I,filteredToolsCount:fe.length,savedRequestsCount:U.length,onSearchExpand:()=>re(!0),onSearchChange:A,onSearchBlur:Se,onTabSwitch:()=>M(O==="tools"?"saved":"tools"),searchInputRef:V}),O==="tools"?f.jsx(C2,{tools:fe,selectedTool:s,onToolSelect:Oe,focusedIndex:ne}):f.jsx(S2,{savedRequests:U,selectedRequest:u,onLoadRequest:Be,onDeleteRequest:nt,focusedIndex:ne})]})}),f.jsx(vi,{withHandle:!0}),f.jsxs(Rn,{ref:Ee,defaultSize:0,collapsible:!0,minSize:5,collapsedSize:5,onCollapse:()=>{q(!0)},onExpand:()=>{q(!1)},className:"flex flex-col border-t dark:border-zinc-700",children:[f.jsxs("div",{className:"group flex items-center justify-between p-3 shrink-0 cursor-pointer hover:bg-muted/50 transition-colors",onClick:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),J?(Ee.current?.resize(25),q(!1)):(Ee.current?.resize(5),q(!0))},children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"text-sm font-medium",children:"RPC Messages"}),ie>0&&f.jsx(xr,{variant:"secondary",className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",children:ie}),ie>0&&!J&&f.jsx(Le,{variant:"ghost",size:"sm",onClick:Ie=>{Ie.preventDefault(),Ie.stopPropagation(),ke.current?.()},className:"h-6 w-6 p-0",title:"Clear all messages",children:f.jsx($s,{className:"h-3.5 w-3.5"})})]}),f.jsx(Xl,{className:`h-4 w-4 text-muted-foreground transition-transform ${J?"":"rotate-180"}`})]}),!J&&f.jsx("div",{className:"flex-1 overflow-hidden min-h-0",children:f.jsx(aD,{serverIds:[r],onCountChange:le,onClearRef:ke})})]})]})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{defaultSize:67,children:f.jsxs(Qr,{direction:"vertical",children:[f.jsx(Rn,{ref:Te,defaultSize:40,collapsible:!0,children:f.jsx(k2,{selectedTool:s,toolArgs:g,isExecuting:y,isConnected:i,onArgChange:tt,onExecute:it,onSave:Qe,onCancel:()=>{C&&C.abort()}})}),f.jsx(vi,{withHandle:!0}),f.jsx(Rn,{ref:He,defaultSize:60,children:f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(N2,{results:je,copiedResult:E,previewMode:B,serverId:r,readResource:a,onCopy:ht,onDelete:Rt,onFullscreen:Fe,onTogglePreview:()=>Z(!B),onMaximize:pt,isMaximized:W})})})]})}),f.jsx(E2,{isOpen:K,requestName:te,defaultPlaceholder:`${s?.name} - ${new Date().toLocaleString()}`,onRequestNameChange:ae,onSave:Tt,onCancel:()=>Q(!1)})]})}jZ.displayName="ToolsTab";function Dke({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onRejectAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Sampling"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Td,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(Mm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx($s,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Reject all"})]})})]})}function jke({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(kd,{vertical:!0,noBorder:!0,message:"No sampling requests"})}):f.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,d=s.request.params?.maxTokens;return f.jsx(Zs,{id:`sampling-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,f.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":""}`),d&&h.push(`max ${d} tokens`);const g=h.length>0?` | ${h.join(", ")}`:"";return m+g})(),onClick:()=>n(s)},s.id)})})}function Lke({llmConfig:e}){const t=x.useRef(null);return{generateResponse:x.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:d,AIMessage:m}=await Qn(async()=>{const{HumanMessage:w,AIMessage:S}=await import("./index-CYBG3mWU.js").then(y=>y.bD);return{HumanMessage:w,AIMessage:S}},[]);for(const w of c){if(!w||!w.role){console.warn("Skipping invalid message:",w);continue}const S=Array.isArray(w.content)?w.content[0]:w.content;if(!S){console.warn("Skipping message with no content:",w);continue}S.type==="text"&&S.text?w.role==="user"?u.push(new d(S.text)):w.role==="assistant"&&u.push(new m(S.text)):console.warn("Skipping message with unsupported content type:",S)}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 w;const S={model:e.model,apiKey:e.apiKey};if(i!==void 0&&(S.maxTokens=i),s!==void 0?S.temperature=s:e.temperature!==void 0&&(S.temperature=e.temperature),e.provider==="openai"){const{ChatOpenAI:y}=await Qn(async()=>{const{ChatOpenAI:_}=await import("./index-DMdheUGh.js");return{ChatOpenAI:_}},__vite__mapDeps([5,6,7,3,8,9]));w=new y(S)}else if(e.provider==="anthropic"){const{ChatAnthropic:y}=await Qn(async()=>{const{ChatAnthropic:_}=await import("./index-O0gjGlMB.js");return{ChatAnthropic:_}},__vite__mapDeps([10,7,6,3]));w=new y(S)}else if(e.provider==="google"){const{ChatGoogleGenerativeAI:y}=await Qn(async()=>{const{ChatGoogleGenerativeAI:_}=await import("./index-BFcdg9p1.js");return{ChatGoogleGenerativeAI:_}},__vite__mapDeps([11,7,6,3,9]));w=new y(S)}else throw new Error(`Unsupported LLM provider: ${e.provider}`);t.current={instance:w,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 $ke({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d,llmConfig:m}){const[h,g]=x.useState("manual"),[v,w]=x.useState("stub-model"),[S,y]=x.useState("endTurn"),[_,E]=x.useState("assistant"),[k,C]=x.useState("text"),[R,I]=x.useState("positive"),[A,O]=x.useState(""),[M,U]=x.useState("image/png"),[H,K]=x.useState(!1),[Q,te]=x.useState(null),{generateResponse:ae,isAvailable:B}=Lke({llmConfig:m});x.useEffect(()=>{e&&(w("stub-model"),y("endTurn"),E("assistant"),C("text"),I("positive"),O(""),U("image/png"),te(null))},[e?.id]);const Z=async()=>{if(!(!e||!B)){K(!0),te(null);try{const j=await ae({request:e.request});w(j.model||m?.model||"stub-model"),y(j.stopReason||"endTurn"),E(j.role||"assistant");const V=Array.isArray(j.content)?j.content[0]:j.content;V.type==="text"?(C("text"),I(V.text||"")):V.type==="image"&&(C("image"),O(V.data||""),U(V.mimeType||"image/png"))}catch(j){const V=j instanceof Error?j.message:"Failed to generate response";te(V),Jt.error("LLM Generation Failed",{description:V})}finally{K(!1)}}},G=x.useMemo(()=>{const j={model:v,stopReason:S,role:_,content:{type:k}};return k==="text"?j.content.text=R:k==="image"&&(j.content.data=A,j.content.mimeType=M),j},[v,S,_,k,R,A,M]),re=()=>{if(!e)return;const j=BT.safeParse(G);if(!j.success){Jt.error("Invalid response",{description:`Validation failed: ${j.error.message}`});return}t(e.id,j.data),a(),Qn(()=>Promise.resolve().then(()=>pd),void 0).then(V=>{const z=Jt(V.createElement("div",{className:"space-y-3"},V.createElement("div",null,V.createElement("strong",null,"Sampling Response Sent"),V.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),V.createElement("div",{className:"flex gap-2"},V.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 L=new globalThis.CustomEvent("navigate-to-tool-result",{detail:{toolName:e.toolName}});window.dispatchEvent(L),Jt.dismiss(z)}},"View Tool Result"))),{duration:5e3})})},ne=()=>{e&&(n(e.id,"User rejected sampling request"),a())};return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ta,{className:"h-4 w-4 text-green-600"}):f.jsx(jr,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Copy request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(wm,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Download request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(ON,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Fullscreen"})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Yi,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Request"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(Jn,{data:e.request})})]}),f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Response"}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Kt,{htmlFor:`responseMode-${e.id}`,className:"text-xs text-gray-500 dark:text-gray-400",children:"Mode:"}),f.jsxs(Co,{value:h,onValueChange:j=>g(j),children:[f.jsx(Ao,{id:`responseMode-${e.id}`,className:"w-32 h-8 text-xs",children:f.jsx(Ro,{})}),f.jsxs(Io,{children:[f.jsx(Ir,{value:"manual",children:"Manual"}),f.jsx(Ir,{value:"llm",children:"LLM"})]})]})]})]}),h==="llm"&&f.jsxs("div",{className:"space-y-2 p-3 bg-muted rounded-lg",children:[B?f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(Le,{onClick:Z,disabled:H,size:"sm",className:"flex items-center gap-2",children:H?f.jsxs(f.Fragment,{children:[f.jsx(Ls,{className:"h-4 w-4 animate-spin"}),"Generating..."]}):f.jsxs(f.Fragment,{children:[f.jsx($me,{className:"h-4 w-4"}),"Generate with LLM"]})}),f.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Using ",m?.provider," (",m?.model,")"]})]}):f.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"LLM not configured. Please configure LLM in the Chat tab."}),Q&&f.jsx("div",{className:"text-xs text-red-600 dark:text-red-400",children:Q})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`model-${e.id}`,children:"Model"}),f.jsx(kn,{id:`model-${e.id}`,value:v,onChange:j=>w(j.target.value),placeholder:"stub-model",disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`stopReason-${e.id}`,children:"Stop Reason"}),f.jsx(kn,{id:`stopReason-${e.id}`,value:S,onChange:j=>y(j.target.value),placeholder:"endTurn",disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`role-${e.id}`,children:"Role"}),f.jsxs(Co,{value:_,onValueChange:j=>E(j),disabled:h==="llm"&&H,children:[f.jsx(Ao,{id:`role-${e.id}`,children:f.jsx(Ro,{})}),f.jsxs(Io,{children:[f.jsx(Ir,{value:"assistant",children:"assistant"}),f.jsx(Ir,{value:"user",children:"user"})]})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`contentType-${e.id}`,children:"Content Type"}),f.jsxs(Co,{value:k,onValueChange:j=>C(j),disabled:h==="llm"&&H,children:[f.jsx(Ao,{id:`contentType-${e.id}`,children:f.jsx(Ro,{})}),f.jsxs(Io,{children:[f.jsx(Ir,{value:"text",children:"text"}),f.jsx(Ir,{value:"image",children:"image"})]})]})]}),k==="text"&&f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`text-${e.id}`,children:"Text Content"}),f.jsx(Vl,{id:`text-${e.id}`,value:R,onChange:j=>I(j.target.value),placeholder:"Enter response text...",rows:6,disabled:h==="llm"&&H})]}),k==="image"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`imageData-${e.id}`,children:"Base64 Image Data"}),f.jsx(Vl,{id:`imageData-${e.id}`,value:A,onChange:j=>O(j.target.value),placeholder:"Base64 encoded image data...",rows:4,disabled:h==="llm"&&H})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(Kt,{htmlFor:`mimeType-${e.id}`,children:"MIME Type"}),f.jsx(kn,{id:`mimeType-${e.id}`,value:M,onChange:j=>U(j.target.value),placeholder:"image/png",disabled:h==="llm"&&H})]})]})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(Le,{onClick:re,className:"flex-1",disabled:h==="llm"&&H,children:"Approve"}),f.jsx(Le,{onClick:ne,variant:"outline",className:"flex-1",disabled:h==="llm"&&H,children:"Reject"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select a sampling request to view details"})})}function Mke({pendingRequests:e,onApprove:t,onReject:n,serverId:a,isConnected:r,mcpServerUrl:i}){const{selectedSamplingRequestId:s,setSelectedSamplingRequestId:c}=Jl(),{llmConfig:u}=sZ({mcpServerUrl:i}),[d,m]=x.useState(null),[h,g]=x.useState(""),[v,w]=x.useState(-1),[S,y]=x.useState(!0),[_,E]=x.useState(!1),[k,C]=x.useState(!0),[R,I]=x.useState(!1),A=x.useRef(null),O=x.useRef(null),M=x.useRef(null),U=x.useRef(!1);x.useEffect(()=>{if(console.log("[SamplingTab] Auto-selection check:",{selectedSamplingRequestId:s,pendingRequestsCount:e.length,currentSelectedId:d?.id}),s&&e.length>0){const G=e.find(re=>re.id===s);console.log("[SamplingTab] Found request for auto-selection:",!!G,G?.id),G&&(console.log("[SamplingTab] Auto-selecting request:",G.id),c(null),m(G),setTimeout(()=>{const re=document.getElementById(`sampling-request-${G.id}`);console.log("[SamplingTab] Scrolling to element:",!!re),re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[s,e,c]),x.useEffect(()=>{const G=re=>{const j=re.detail.requestId;console.log("[SamplingTab] Custom navigate event received:",j);const V=e.find(z=>z.id===j);V&&(console.log("[SamplingTab] Selecting request from event:",j),m(V),setTimeout(()=>{const z=document.getElementById(`sampling-request-${j}`);z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-sampling",G),()=>window.removeEventListener("navigate-to-sampling",G)},[e]),x.useEffect(()=>{S&&e.length>0&&A.current&&!U.current&&(A.current.scrollTop=0)},[e.length,S]),x.useEffect(()=>{const G=A.current;if(!G)return;const re=()=>{G.scrollTop>0&&(U.current=!0,y(!1))};return G.addEventListener("scroll",re),()=>G.removeEventListener("scroll",re)},[]),x.useEffect(()=>{e.length===0&&(U.current=!1,y(!0))},[e.length]),x.useEffect(()=>{_&&M.current&&M.current.focus()},[_]);const H=x.useCallback(()=>{h.trim()||E(!1)},[h]),K=x.useMemo(()=>{if(!h.trim())return e;const G=h.toLowerCase();return e.filter(re=>re.serverName.toLowerCase().includes(G)||JSON.stringify(re.request||{}).toLowerCase().includes(G))},[e,h]);x.useEffect(()=>{w(-1)},[h]),x.useEffect(()=>{const G=re=>{const ne=re.target;if(ne.tagName==="INPUT"||ne.tagName==="TEXTAREA"||ne.contentEditable==="true"||re.metaKey||re.ctrlKey||re.altKey)return;const V=K;if(re.key==="ArrowDown")re.preventDefault(),w(z=>{const L=z+1;return L>=V.length?0:L});else if(re.key==="ArrowUp")re.preventDefault(),w(z=>{const L=z-1;return L<0?V.length-1:L});else if(re.key==="Enter"&&v>=0){re.preventDefault();const z=K[v];z&&Q(z)}};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[v,K]),x.useEffect(()=>{if(v>=0){const G=`sampling-request-${K[v]?.id}`,re=document.getElementById(G);re&&re.scrollIntoView({behavior:"smooth",block:"nearest"})}},[v,K]);const Q=x.useCallback(G=>{m(G)},[]),te=x.useCallback(()=>{window.confirm("Are you sure you want to reject all sampling requests? This cannot be undone.")&&(e.forEach(G=>{n(G.id,"User rejected all requests")}),m(null))},[e,n]),ae=x.useCallback(async()=>{if(d)try{await navigator.clipboard.writeText(JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)),I(!0),setTimeout(()=>I(!1),2e3)}catch(G){console.error("[SamplingTab] Failed to copy request:",G)}},[d]),B=x.useCallback(()=>{if(d)try{const G=new globalThis.Blob([JSON.stringify({id:d.id,serverName:d.serverName,timestamp:d.timestamp,request:d.request},null,2)],{type:"application/json"}),re=URL.createObjectURL(G),ne=document.createElement("a");ne.href=re,ne.download=`sampling-request-${Date.now()}.json`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne),URL.revokeObjectURL(re)}catch(G){console.error("[SamplingTab] Failed to download request:",G)}},[d]),Z=x.useCallback(async()=>{if(O.current)try{document.fullscreenElement?await document.exitFullscreen():await O.current.requestFullscreen()}catch(G){console.error("[SamplingTab] Failed to toggle fullscreen:",G)}},[]);return r?f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(Dke,{isSearchExpanded:_,searchQuery:h,filteredRequestsCount:K.length,requestsCount:e.length,onSearchExpand:()=>E(!0),onSearchChange:g,onSearchBlur:H,onRejectAll:te,searchInputRef:M}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(jke,{requests:K,selectedRequest:d,onRequestSelect:Q,focusedIndex:v,formatRelativeTime:Pv,listRef:A})})]})})}),f.jsx(vi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:O,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx($ke,{request:d,onApprove:t,onReject:n,onClose:()=>m(null),previewMode:k,onTogglePreview:()=>C(!k),isCopied:R,onCopy:ae,onDownload:B,onFullscreen:Z,llmConfig:u})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(E8,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function Pke({isSearchExpanded:e,searchQuery:t,filteredRequestsCount:n,requestsCount:a,onSearchExpand:r,onSearchChange:i,onSearchBlur:s,onCancelAll:c,searchInputRef:u}){return f.jsxs("div",{className:"flex flex-row items-center justify-between p-4 sm:p-4 py-3 gap-2",children:[f.jsx("div",{className:"flex items-center gap-2 flex-1",children:e?f.jsx(kn,{ref:u,placeholder:"Search requests...",value:t,onChange:d=>i(d.target.value),onBlur:s,className:"h-8 border-gray-300 dark:border-zinc-600"}):f.jsxs(f.Fragment,{children:[f.jsx("h2",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Elicitation"}),f.jsx(xr,{className:"bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent",variant:"outline",children:n}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0",children:f.jsx(Td,{className:"h-4 w-4"})})}),f.jsxs(Lt,{side:"bottom",className:"flex gap-2",children:["Search",f.jsx(Mm,{children:"F"})]})]})]})}),f.jsx("div",{className:"flex items-center gap-2",children:f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,disabled:a===0,className:"h-8 w-8 p-0",children:f.jsx(Yi,{className:"h-4 w-4"})})}),f.jsx(Lt,{side:"bottom",children:"Cancel all"})]})})]})}function Uke({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:a,formatRelativeTime:r,listRef:i}){return e.length===0?f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx(kd,{vertical:!0,noBorder:!0,message:"No elicitation requests"})}):f.jsx("div",{ref:i,className:"overflow-y-auto flex-1 overscroll-contain",children:e.map((s,c)=>{const u=s.request.mode||"form",d=u==="form"&&"requestedSchema"in s.request&&s.request.requestedSchema;return f.jsx(Zs,{id:`elicitation-request-${s.id}`,isSelected:t?.id===s.id,isFocused:a===c,title:f.jsxs("span",{className:"flex items-center gap-3",children:[s.serverName,f.jsx(xr,{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=[];d&&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 zke({request:e,onApprove:t,onReject:n,onClose:a,previewMode:r,onTogglePreview:i,isCopied:s,onCopy:c,onDownload:u,onFullscreen:d}){const[m,h]=x.useState({}),[g,v]=x.useState(!1),w=e?.request.mode||"form",S=w==="form",y=w==="url";x.useEffect(()=>{if(e&&S&&"requestedSchema"in e.request){const A=e.request.requestedSchema,O={};if(A?.type==="object"&&A.properties)for(const[M,U]of Object.entries(A.properties)){const H=U;H.default!==void 0?O[M]=H.default:H.type==="boolean"?O[M]=!1:H.type==="number"||H.type==="integer"?O[M]=0:O[M]=""}h(O)}v(!1)},[e?.id,S]);const _=(A,O)=>{h(M=>({...M,[A]:O}))},E=()=>{if(e){if(S){if("requestedSchema"in e.request){const A=e.request.requestedSchema;if(A?.required){const O=A.required.filter(M=>m[M]===void 0||m[M]===""||m[M]===null);if(O.length>0){Jt.error("Missing required fields",{description:`Please fill in: ${O.join(", ")}`});return}}}t(e.id,{action:"accept",data:m})}else y&&t(e.id,{action:"accept"});a(),Qn(()=>Promise.resolve().then(()=>pd),void 0).then(A=>{const O=Jt(A.createElement("div",{className:"space-y-3"},A.createElement("div",null,A.createElement("strong",null,"Elicitation Response Sent"),A.createElement("p",{className:"text-sm text-muted-foreground mt-1"},"The tool will continue executing.")),A.createElement("div",{className:"flex gap-2"},A.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),Jt.dismiss(O)}},"View Tool Result"))),{duration:5e3})})}},k=()=>{e&&(t(e.id,{action:"decline"}),a())},C=()=>{e&&(n(e.id,"User cancelled elicitation request"),a())},R=()=>{e&&y&&"url"in e.request&&(window.open(e.request.url,"_blank"),v(!0))},I=x.useMemo(()=>{if(!e||!S||!("requestedSchema"in e.request))return null;const A=e.request.requestedSchema;if(!A||A.type!=="object"||!A.properties)return f.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No form schema available"});const O=A.properties,M=A.required||[];return f.jsx("div",{className:"space-y-4",children:Object.entries(O).map(([U,H])=>{const K=H,Q=M.includes(U),te=K.type||"string",ae=K.title||U,B=K.description;return f.jsxs("div",{className:"space-y-2",children:[f.jsxs(Kt,{htmlFor:`field-${U}`,children:[ae,Q&&f.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),B&&f.jsx("p",{className:"text-xs text-muted-foreground",children:B}),te==="boolean"?f.jsxs("div",{className:"flex items-center space-x-2",children:[f.jsx(Bp,{id:`field-${U}`,checked:m[U]||!1,onCheckedChange:Z=>_(U,Z)}),f.jsx(Kt,{htmlFor:`field-${U}`,className:"text-sm font-normal cursor-pointer",children:K.title||U})]}):te==="number"||te==="integer"?f.jsx(kn,{id:`field-${U}`,type:"number",value:m[U]||"",onChange:Z=>_(U,te==="integer"?parseInt(Z.target.value,10):parseFloat(Z.target.value)),placeholder:K.default?.toString()||""}):K.enum?f.jsxs("select",{id:`field-${U}`,value:m[U]||"",onChange:Z=>_(U,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:[f.jsx("option",{value:"",children:"Select..."}),K.enum.map(Z=>f.jsx("option",{value:Z,children:Z},Z))]}):te==="string"&&(K.format==="textarea"||K.maxLength>100)?f.jsx(Vl,{id:`field-${U}`,value:m[U]||"",onChange:Z=>_(U,Z.target.value),placeholder:K.default||"",rows:4}):f.jsx(kn,{id:`field-${U}`,type:"text",value:m[U]||"",onChange:Z=>_(U,Z.target.value),placeholder:K.default||""})]},U)})})},[e,m,S]);return e?f.jsxs("div",{className:"flex flex-col h-full",children:[f.jsxs("div",{className:"flex items-center justify-between p-4 border-b dark:border-zinc-700",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 dark:text-gray-100",children:e.serverName}),f.jsx(xr,{variant:"outline",className:y?"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:w}),f.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:new Date(e.timestamp).toLocaleString()})]}),f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0",children:s?f.jsx(ta,{className:"h-4 w-4 text-green-600"}):f.jsx(jr,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Copy request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:f.jsx(wm,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Download request"})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0",children:f.jsx(ON,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:"Fullscreen"})]}),f.jsx(Le,{variant:"ghost",size:"sm",onClick:a,className:"h-8 w-8 p-0",children:f.jsx(Yi,{className:"h-4 w-4"})})]})]}),f.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Message"}),f.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:e.request.message})]}),y&&"url"in e.request&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"External Action Required"}),f.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[f.jsx("p",{className:"text-sm text-muted-foreground",children:"This request requires you to complete an action at an external URL:"}),f.jsxs("div",{className:"flex items-center gap-2 p-2 bg-background rounded border",children:[f.jsx("code",{className:"flex-1 text-xs font-mono break-all",children:e.request.url}),f.jsxs(Le,{size:"sm",variant:"outline",onClick:R,className:"flex items-center gap-2",children:[f.jsx(IE,{className:"h-4 w-4"}),"Open URL"]})]}),f.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[f.jsx(Bp,{id:"url-completed",checked:g,onCheckedChange:A=>v(!!A)}),f.jsx(Kt,{htmlFor:"url-completed",className:"text-sm font-normal cursor-pointer",children:"I have completed the required action"})]})]})]}),S&&f.jsxs("div",{className:"space-y-2",children:[f.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100",children:"Form Data"}),I]}),S&&"requestedSchema"in e.request&&e.request.requestedSchema&&f.jsxs("details",{className:"space-y-2",children:[f.jsx("summary",{className:"text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer",children:"Schema (for reference)"}),f.jsx("div",{className:"bg-muted rounded-lg p-3 max-h-64 overflow-auto",children:f.jsx(Jn,{data:e.request.requestedSchema})})]})]}),f.jsxs("div",{className:"flex gap-2 p-4 border-t dark:border-zinc-700",children:[f.jsx(Le,{onClick:E,className:"flex-1",children:"Accept"}),f.jsx(Le,{onClick:k,variant:"outline",className:"flex-1",children:"Decline"}),f.jsx(Le,{onClick:C,variant:"outline",className:"flex-1",children:"Cancel"})]})]}):f.jsx("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Select an elicitation request to view details"})})}function Fke({pendingRequests:e=[],onApprove:t,onReject:n,serverId:a,isConnected:r}){const{selectedElicitationRequestId:i,setSelectedElicitationRequestId:s}=Jl(),[c,u]=x.useState(null),[d,m]=x.useState(""),[h,g]=x.useState(-1),[v,w]=x.useState(!0),[S,y]=x.useState(!1),[_,E]=x.useState(!0),[k,C]=x.useState(!1),R=x.useRef(null),I=x.useRef(null),A=x.useRef(null),O=x.useRef(!1);x.useEffect(()=>{if(console.log("[ElicitationTab] Auto-selection check:",{selectedElicitationRequestId:i,pendingRequestsCount:e.length,currentSelectedId:c?.id}),i&&e.length>0){const B=e.find(Z=>Z.id===i);console.log("[ElicitationTab] Found request for auto-selection:",!!B,B?.id),B&&(console.log("[ElicitationTab] Auto-selecting request:",B.id),s(null),u(B),setTimeout(()=>{const Z=document.getElementById(`elicitation-request-${B.id}`);console.log("[ElicitationTab] Scrolling to element:",!!Z),Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})},100))}},[i,e,s]),x.useEffect(()=>{const B=Z=>{const re=Z.detail.requestId;console.log("[ElicitationTab] Custom navigate event received:",re);const ne=e.find(j=>j.id===re);ne&&(console.log("[ElicitationTab] Selecting request from event:",re),u(ne),setTimeout(()=>{const j=document.getElementById(`elicitation-request-${re}`);j&&j.scrollIntoView({behavior:"smooth",block:"nearest"})},200))};return window.addEventListener("navigate-to-elicitation",B),()=>window.removeEventListener("navigate-to-elicitation",B)},[e]),x.useEffect(()=>{v&&e.length>0&&R.current&&!O.current&&(R.current.scrollTop=0)},[e.length,v]),x.useEffect(()=>{const B=R.current;if(!B)return;const Z=()=>{B.scrollTop>0&&(O.current=!0,w(!1))};return B.addEventListener("scroll",Z),()=>B.removeEventListener("scroll",Z)},[]),x.useEffect(()=>{e.length===0&&(O.current=!1,w(!0))},[e.length]),x.useEffect(()=>{S&&A.current&&A.current.focus()},[S]);const M=x.useCallback(()=>{d.trim()||y(!1)},[d]),U=x.useMemo(()=>{if(!d.trim())return e;const B=d.toLowerCase();return e.filter(Z=>Z.serverName.toLowerCase().includes(B)||Z.request.message.toLowerCase().includes(B)||JSON.stringify(Z.request||{}).toLowerCase().includes(B))},[e,d]);x.useEffect(()=>{g(-1)},[d]),x.useEffect(()=>{const B=Z=>{const G=Z.target;if(G.tagName==="INPUT"||G.tagName==="TEXTAREA"||G.contentEditable==="true"||Z.metaKey||Z.ctrlKey||Z.altKey)return;const ne=U;if(Z.key==="ArrowDown")Z.preventDefault(),g(j=>{const V=j+1;return V>=ne.length?0:V});else if(Z.key==="ArrowUp")Z.preventDefault(),g(j=>{const V=j-1;return V<0?ne.length-1:V});else if(Z.key==="Enter"&&h>=0){Z.preventDefault();const j=U[h];j&&H(j)}};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[h,U]),x.useEffect(()=>{if(h>=0){const B=`elicitation-request-${U[h]?.id}`,Z=document.getElementById(B);Z&&Z.scrollIntoView({behavior:"smooth",block:"nearest"})}},[h,U]);const H=x.useCallback(B=>{u(B)},[]),K=x.useCallback(()=>{window.confirm("Are you sure you want to cancel all elicitation requests? This cannot be undone.")&&(e.forEach(B=>{n(B.id,"User cancelled all requests")}),u(null))},[e,n]),Q=x.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)),C(!0),setTimeout(()=>C(!1),2e3)}catch(B){console.error("[ElicitationTab] Failed to copy request:",B)}},[c]),te=x.useCallback(()=>{if(c)try{const B=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(B),G=document.createElement("a");G.href=Z,G.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(G),G.click(),document.body.removeChild(G),URL.revokeObjectURL(Z)}catch(B){console.error("[ElicitationTab] Failed to download request:",B)}},[c]),ae=x.useCallback(async()=>{if(I.current)try{document.fullscreenElement?await document.exitFullscreen():await I.current.requestFullscreen()}catch(B){console.error("[ElicitationTab] Failed to toggle fullscreen:",B)}},[]);return r?f.jsxs(Qr,{direction:"horizontal",className:"h-full",children:[f.jsx(Rn,{defaultSize:40,minSize:30,children:f.jsx(Qr,{direction:"vertical",className:"h-full border-r dark:border-zinc-700",children:f.jsxs(Rn,{defaultSize:75,minSize:30,children:[f.jsx(Pke,{isSearchExpanded:S,searchQuery:d,filteredRequestsCount:U.length,requestsCount:e.length,onSearchExpand:()=>y(!0),onSearchChange:m,onSearchBlur:M,onCancelAll:K,searchInputRef:A}),f.jsx("div",{className:"flex flex-col h-full",children:f.jsx(Uke,{requests:U,selectedRequest:c,onRequestSelect:H,focusedIndex:h,formatRelativeTime:Pv,listRef:R})})]})})}),f.jsx(vi,{}),f.jsx(Rn,{defaultSize:60,minSize:40,children:f.jsx("div",{ref:I,className:"h-full bg-white dark:bg-zinc-900",children:f.jsx(zke,{request:c,onApprove:t,onReject:n,onClose:()=>u(null),previewMode:_,onTogglePreview:()=>E(!_),isCopied:k,onCopy:Q,onDownload:te,onFullscreen:ae})})})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-4 text-center",children:[f.jsx(N8,{className:"h-12 w-12 text-gray-400 dark:text-gray-600 mb-3"}),f.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:"Not connected to server"})]})}function Bke({selectedServer:e,activeTab:t,toolsSearchRef:n,promptsSearchRef:a,resourcesSearchRef:r,children:i}){return e?f.jsxs(f.Fragment,{children:[f.jsx("div",{style:{display:t==="tools"?"block":"none"},className:"h-full",children:f.jsx(jZ,{ref:n,tools:e.tools,callTool:e.callTool,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="prompts"?"block":"none"},className:"h-full",children:f.jsx(AZ,{ref:a,prompts:e.prompts,callPrompt:e.getPrompt,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="resources"?"block":"none"},className:"h-full",children:f.jsx(OZ,{ref:r,resources:e.resources,readResource:e.readResource,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="chat"?"block":"none"},className:"h-full",children:f.jsx(V_e,{connection:e,isConnected:e.state==="ready",readResource:e.readResource},e.id)}),f.jsx("div",{style:{display:t==="sampling"?"block":"none"},className:"h-full",children:f.jsx(Mke,{pendingRequests:e.pendingSamplingRequests,onApprove:e.approveSampling,onReject:e.rejectSampling,serverId:e.id,isConnected:e.state==="ready",mcpServerUrl:e.url})}),f.jsx("div",{style:{display:t==="elicitation"?"block":"none"},className:"h-full",children:f.jsx(Fke,{pendingRequests:e.pendingElicitationRequests,onApprove:e.approveElicitation,onReject:e.rejectElicitation,serverId:e.id,isConnected:e.state==="ready"})}),f.jsx("div",{style:{display:t==="notifications"?"block":"none"},className:"h-full",children:f.jsx(Ske,{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"&&f.jsx(f.Fragment,{children:i})]}):f.jsx(f.Fragment,{children:i})}function I2({className:e}){return f.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentcolor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",className:e,children:[f.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"}),f.jsx("path",{d:"M9 18c-4.51 2-5-2-7-2"})]})}const LZ=x.createContext(void 0);function $Z(){const e=x.use(LZ);if(!e)throw new Error("useTabs must be used within a TabsProvider");return e}const MZ=x.createContext(void 0);function Hke(){return x.use(MZ)}function P_({ref:e,children:t,defaultValue:n,value:a,onValueChange:r,className:i,...s}){const[c,u]=x.useState(n||""),d=a!==void 0,m=x.useCallback(g=>{d||u(g),r?.(g)},[d,r]),h=d?a:c;return f.jsx(LZ,{value:{activeValue:h,handleValueChange:m},children:f.jsx("div",{ref:e,className:De("flex flex-col gap-2",i),...s,children:t})})}P_.displayName="Tabs";function U_({ref:e,children:t,className:n,variant:a="default",...r}){const{activeValue:i}=$Z(),[s,c]=x.useState({width:0,left:0}),u=x.useRef(null),d=x.useRef(null),m=x.useRef(null),g=x.Children.toArray(t).findIndex(S=>x.isValidElement(S)&&S.props.value===i),v=x.useCallback(()=>{const S=u.current;if(!S)return;const _=S.querySelectorAll("button")[g];if(_){const E=S.getBoundingClientRect(),k=_.getBoundingClientRect();c({width:k.width,left:k.left-E.left})}},[g]),w=x.useCallback(()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(v,16)},[v]);return x.useEffect(()=>{const S=setTimeout(v,10);return()=>clearTimeout(S)},[v]),x.useEffect(()=>{const S=u.current;return S?(d.current=new ResizeObserver(()=>{w()}),d.current.observe(S),S.querySelectorAll("button").forEach(_=>{d.current&&d.current.observe(_)}),()=>{d.current&&d.current.disconnect(),m.current&&clearTimeout(m.current)}):void 0},[w]),x.useEffect(()=>{const S=()=>{w()};return window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[w]),x.useEffect(()=>{const S=u.current;if(!S)return;const y=S.querySelector("[data-width]");y&&(y.style.width=`${s.width}px`,y.style.left=`${s.left}px`)},[s]),f.jsx(MZ,{value:{variant:a},children:f.jsxs("div",{ref:u,className:De("relative flex bg-none",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),...r,children:[t,f.jsx("span",{className:De("absolute transition-all duration-200 ease-out z-0",a==="default"&&"bg-white dark:bg-zinc-700 rounded-full h-[calc(100%-8px)] top-1 border border-zinc-300 dark:border-zinc-600",a==="underline"&&"bottom-0 h-0.5 bg-black dark:bg-white"),"data-width":s.width,"data-left":s.left})]})})}U_.displayName="TabsList";function z_({ref:e,children:t,value:n,className:a,disabled:r,icon:i,...s}){const{activeValue:c,handleValueChange:u}=$Z(),m=Hke()?.variant||"default",h=c===n;return f.jsxs("button",{ref:e,disabled:r,onClick:()=>u(n),className:De("relative z-10 flex-1 inline-flex items-center justify-center whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 cursor-pointer",m==="default"&&"rounded-md px-4 py-2.5",m==="underline"&&"px-6 py-3 border-b-2 border-transparent",h&&"text-foreground",!h&&"text-muted-foreground hover:text-foreground",a),...s,children:[i&&f.jsx(i,{className:"mr-2 h-4 w-4"}),t]})}z_.displayName="TabsTrigger";function O2({className:e}){const{theme:t,setTheme:n}=nw(),a=x.useRef(null),[r,i]=x.useState(!1);x.useEffect(()=>{i(!0)},[]);const s=()=>t==="system"?"light":t==="light"?"dark":"system",c=()=>t==="system"?f.jsx(PU,{className:"size-4"}):t==="light"?f.jsx(Fme,{className:"size-5"}):f.jsx(wme,{className:"size-4"}),u=()=>t==="system"?"Switch to light mode":t==="light"?"Switch to dark mode":"Switch to system mode",d=async()=>{if(!a.current)return;const m=s();if(typeof document<"u"&&"startViewTransition"in document){await document.startViewTransition(()=>{vd.flushSync(()=>{n(m)})}).ready;const{top:h,left:g,width:v,height:w}=a.current.getBoundingClientRect(),S=h+w/2,y=g+v/2,_=window.innerWidth-g,E=window.innerHeight-h,k=Math.hypot(Math.max(g,_),Math.max(h,E));document.documentElement.animate({clipPath:[`circle(0px at ${y}px ${S}px)`,`circle(${k}px at ${y}px ${S}px)`]},{duration:700,easing:"ease-in-out",pseudoElement:"::view-transition-new(root)"})}else n(m)};return r?f.jsx("button",{ref:a,onClick:d,className:De(e),"aria-label":u(),title:`Current: ${t==="system"?"Auto":t==="light"?"Light":"Dark"}`,children:c()}):f.jsx("button",{ref:a,className:De(e),"aria-label":"Toggle theme",children:f.jsx(PU,{className:"size-4"})})}function D2({className:e,state:t="collapsed",href:n="https://mcp-use.com"}){const[a,r]=x.useState(!1),i=.2,s=.7,c=.6,u=4,d=i+s+c,m=0,h=i/d,g=(i+s)/d,v=1;return f.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:De("flex items-center transition-opacity -my-3",t==="expanded"?"space-x-2":"",e),onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[f.jsx("div",{className:"relative",children:f.jsxs(ga.svg,{viewBox:"0 0 303 303",initial:"rest",animate:a?"hover":"rest",className:De("text-foreground",t==="expanded"?"size-[40px]":"size-[20px]"),children:[f.jsxs(ga.g,{variants:{rest:{opacity:1},hover:{opacity:[1,0,0,1],transition:{duration:d,times:[m,h,g,v],ease:"easeInOut"}}},fill:"currentColor",fillRule:"nonzero",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.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"}),f.jsx("circle",{cx:"70.3",cy:"232.3",r:"50"}),f.jsx("circle",{cx:"232.3",cy:"70.3",r:"50"})]}),f.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round",children:[f.jsx(Vke,{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:d}),f.jsx(j2,{cx:70.3,cy:232.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d}),f.jsx(j2,{cx:232.3,cy:70.3,r:50,times:{T0:m,T1:h,T2:g,T3:v},total:d})]})]})}),t==="expanded"&&f.jsxs("div",{className:"font-ubuntu flex flex-col items-start -space-y-1 mr-3",children:[f.jsx("h1",{className:"text-xl font-medium",children:"mcp-use"}),f.jsx("span",{className:"text-lg text-muted-foreground tracking-wide font-sans font-light",children:"Inspector"})]})]})}function Vke({d:e,times:t,total:n}){const{T0:a,T1:r,T2:i,T3:s}=t;return f.jsx(ga.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 j2({cx:e,cy:t,r:n,times:a,total:r}){const{T0:i,T1:s,T2:c,T3:u}=a;return f.jsx(ga.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 PZ({ref:e,shimmerColor:t,shimmerSize:n="0.05em",shimmerDuration:a="3s",borderRadius:r="100px",background:i,className:s,children:c,...u}){const{resolvedTheme:d}=nw(),m=d==="dark"?"#000000":"#ffffff",h=d==="dark"?"rgba(255, 255, 255, 1)":"rgba(0, 0, 0, 1)",g=t||m,v=i||h;return f.jsxs("button",{style:{"--spread":"90deg","--shimmer-color":g,"--radius":r,"--speed":a,"--cut":n,"--bg":v},className:De("group relative z-0 flex cursor-pointer items-center justify-center overflow-hidden [border-radius:var(--radius)] border px-6 py-3 whitespace-nowrap [background:var(--bg)]","transform-gpu transition-transform duration-300 ease-in-out active:translate-y-px",d==="dark"?"border-black/10 text-black":"border-white/10 text-white",s),ref:e,...u,children:[f.jsx("div",{className:De("-z-30 blur-[2px]","[container-type:size] absolute inset-0 overflow-visible"),children:f.jsx("div",{className:"animate-shimmer-slide absolute inset-0 [aspect-ratio:1] h-[100cqh] [border-radius:0] [mask:none]",children:f.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,f.jsx("div",{className:De("absolute inset-0 size-full","rounded-2xl px-4 py-1.5 text-sm font-medium","transform-gpu transition-all duration-300 ease-in-out",d==="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]")}),f.jsx("div",{className:De("absolute [inset:var(--cut)] -z-20 [border-radius:var(--radius)] [background:var(--bg)]")})]})}PZ.displayName="ShimmerButton";function L2({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 f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs("div",{className:"relative",children:[f.jsx("div",{className:`absolute w-2 h-2 rounded-full ${a} animate-ping`}),f.jsx("div",{className:`relative w-2 h-2 rounded-full ${n}`})]})}),f.jsx(Lt,{children:f.jsx("p",{children:r})})]})}function $2({connections:e,selectedServer:t,onServerSelect:n,onOpenConnectionOptions:a,mobileMode:r=!1}){const i=bd(),s=c=>{const u=e.find(d=>d.id===c);if(!u||u.state!=="ready"){Jt.error("Server is not connected and cannot be inspected");return}n(c)};return r?f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(TE,{children:[f.jsx(NE,{asChild:!0,children:f.jsxs(Le,{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?f.jsx(Tl,{serverUrl:t.url,serverName:t.name,size:"md"}):f.jsx(Ime,{className:"h-5 w-5"}),f.jsx(Xl,{className:"h-4 w-4"})]})}),f.jsxs(lv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(CE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Vf,{}),e.length===0?f.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(c=>f.jsxs(To,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Tl,{serverUrl:c.url,serverName:c.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:c.name}),f.jsx(L2,{status:c.state})]}),f.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:f.jsx(bu,{className:"h-3 w-3"})})]},c.id)),f.jsx(Vf,{}),f.jsx(To,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})}):f.jsx("div",{className:"flex items-center gap-2",children:f.jsx("div",{className:"relative",children:f.jsxs(TE,{children:[f.jsx(NE,{asChild:!0,children:f.jsxs(PZ,{className:De("min-w-0 sm:min-w-[200px] p-0 px-1 text-sm h-11 justify-start bg-black dark:bg-white text-white dark:text-black border-black dark:border-white hover:bg-gray-800 dark:hover:bg-zinc-100 hover:border-gray-800 dark:hover:border-zinc-200",!t&&"pl-4",t&&"pr-10"),children:[t&&f.jsx(Tl,{serverUrl:t.url,serverName:t.name,size:"md",className:"mr-2"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("span",{className:"truncate",children:t?t.name:"Select server to inspect"}),t&&f.jsx("div",{className:"flex items-center gap-2",children:t.error&&t.state!=="ready"?f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx("button",{onClick:c=>{c.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"})}),f.jsx(Lt,{children:f.jsx("p",{className:"max-w-xs",children:t.error})})]}):f.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&&f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx("button",{type:"button",onClick:()=>{a(t.id)},className:"absolute right-2 top-1/2 -translate-y-1/2 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:f.jsx(bu,{className:"h-4 w-4"})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Edit connection settings"})})]}),f.jsxs(lv,{className:"w-[calc(100vw-2rem)] sm:w-[300px]",align:"start",children:[f.jsx(CE,{className:"cursor-pointer hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:()=>i("/"),children:"MCP Servers"}),f.jsx(Vf,{}),e.length===0?f.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(c=>f.jsxs(To,{onClick:()=>s(c.id),className:"flex items-center gap-3",children:[f.jsx(Tl,{serverUrl:c.url,serverName:c.name,size:"sm"}),f.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[f.jsx("div",{className:"font-medium",children:c.name}),f.jsx(L2,{status:c.state})]}),f.jsx(Le,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-zinc-100 dark:hover:bg-zinc-800",onClick:u=>{u.stopPropagation(),a(c.id)},children:f.jsx(bu,{className:"h-3 w-3"})})]},c.id)),f.jsx(Vf,{}),f.jsx(To,{onClick:()=>i("/"),children:f.jsx("span",{className:"text-blue-600 dark:text-blue-400",children:"+ Add new server"})})]})]})})})}const M2=[{id:"tools",label:"Tools",icon:Ul},{id:"prompts",label:"Prompts",icon:Cp},{id:"resources",label:"Resources",icon:nme},{id:"sampling",label:"Sampling",icon:E8},{id:"elicitation",label:"Elicitation",icon:N8},{id:"notifications",label:"Notifications",icon:CN},{id:"chat",label:"Chat",icon:mme}];function P2(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 Gke({connections:e,selectedServer:t,activeTab:n,onServerSelect:a,onTabChange:r,onCommandPaletteOpen:i,onOpenConnectionOptions:s}){const{tunnelUrl:c}=Jl(),u=t&&c,[d,m]=x.useState(!1),h=async()=>{if(c)try{await navigator.clipboard.writeText(`${c}/mcp`),m(!0),Jt.success("Tunnel URL copied to clipboard"),setTimeout(()=>m(!1),2e3)}catch{Jt.error("Failed to copy URL")}};return f.jsxs("header",{className:"w-full mx-auto",children:[f.jsxs("div",{className:"flex lg:hidden flex-col gap-3",children:[f.jsxs("div",{className:"flex items-center justify-between w-full",children:[f.jsx("div",{className:"flex-1 flex justify-start",children:f.jsx($2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s,mobileMode:!0})}),f.jsx("div",{className:"flex-shrink-0 flex justify-center",children:f.jsx("div",{className:"scale-150",children:f.jsx(D2,{state:"collapsed"})})}),f.jsxs("div",{className:"flex-1 flex justify-end items-center gap-2",children:[f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",asChild:!0,children:f.jsx("a",{href:"https://github.com/mcp-use/mcp-use",target:"_blank",rel:"noopener noreferrer",className:"p-2","aria-label":"GitHub",children:f.jsx(I2,{className:"h-4 w-4"})})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(O2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})]})]}),t&&f.jsx("div",{className:"w-full",children:f.jsx(P_,{value:n,onValueChange:g=>r(g),children:f.jsx(U_,{className:"w-full justify-center",children:M2.map(g=>{const v=P2(g.id,t);return f.jsxs(z_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 flex-1 flex-row gap-2 relative",children:[v>0&&f.jsx("span",{className:De(n===g.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:v}),f.jsx("span",{className:"sr-only",children:g.label})]},g.id)})})})})]}),f.jsxs("div",{className:"hidden lg:flex items-center justify-between gap-3",children:[f.jsxs("div",{className:"flex items-center flex-wrap gap-2 md:space-x-6 space-x-2",children:[f.jsx($2,{connections:e,selectedServer:t,onServerSelect:a,onOpenConnectionOptions:s}),t&&f.jsx(P_,{value:n,onValueChange:g=>r(g),children:f.jsx(U_,{className:"overflow-x-auto",children:M2.map(g=>{const v=P2(g.id,t);return f.jsx(z_,{value:g.id,icon:g.icon,className:"[&>svg]:mr-0 lg:[&>svg]:mr-2 relative",children:f.jsxs("div",{className:"items-center gap-2 hidden lg:flex",children:[g.label,v>0&&f.jsx("span",{className:De(n===g.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:v})]})},g.id)})})}),u&&f.jsxs(I7,{children:[f.jsx(O7,{asChild:!0,children:f.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:[f.jsx(Rp,{className:"size-4 text-purple-600 dark:text-purple-400 animate-pulse"}),f.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300 hidden lg:inline",children:"Tunnel"})]})}),f.jsx(TC,{className:"w-[calc(100vw-2rem)] sm:w-96",align:"start",children:f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{children:[f.jsxs("h4",{className:"font-semibold text-sm mb-2 flex items-center gap-2",children:[f.jsx(Rp,{className:"size-4 text-purple-600 dark:text-purple-400"}),"Tunnel URL"]}),f.jsxs("div",{className:"flex items-center gap-2 p-2 py-0 bg-muted rounded-full",children:[f.jsxs("code",{className:"flex-1 text-[10px] font-mono",children:[c,"/mcp"]}),f.jsx(Le,{variant:"ghost",size:"sm",className:"h-7 px-2",onClick:h,children:d?f.jsx(ta,{className:"size-3.5 text-green-600"}):f.jsx(jr,{className:"size-3.5"})})]})]}),f.jsxs("div",{children:[f.jsx("h5",{className:"font-semibold text-sm mb-2",children:"Use in ChatGPT"}),f.jsxs("ol",{className:"space-y-2 text-xs text-muted-foreground",children:[f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"1."}),f.jsxs("span",{children:["Enable"," ",f.jsx("span",{className:"font-medium text-foreground",children:"dev mode"})," ","from settings"]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"2."}),f.jsxs("span",{children:["In"," ",f.jsx("span",{className:"font-medium text-foreground",children:"App & Connectors"})," ","click on"," ",f.jsx("span",{className:"font-medium text-foreground",children:"create"})]})]}),f.jsxs("li",{className:"flex gap-2",children:[f.jsx("span",{className:"font-semibold text-foreground",children:"3."}),f.jsx("span",{children:"Use the tunnel URL in the input"})]})]})]})]})})]})]}),f.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[f.jsxs(Dt,{children:[f.jsx(jt,{children:f.jsx(O2,{className:"p-2 hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full transition-colors cursor-pointer"})}),f.jsx(Lt,{children:f.jsx("p",{children:"Toggle theme"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsxs(Le,{variant:"ghost",className:"hover:bg-zinc-200 dark:hover:bg-zinc-800 rounded-full px-1 -mx-3 flex gap-1",onClick:i,children:[f.jsx(Upe,{className:"size-4"}),f.jsx("span",{className:"text-base font-mono hidden sm:inline",children:"K"})]})}),f.jsx(Lt,{children:f.jsx("p",{children:"Command Palette"})})]}),f.jsxs(Dt,{children:[f.jsx(jt,{asChild:!0,children:f.jsx(Le,{variant:"ghost",size:"sm",asChild:!0,children:f.jsxs("a",{href:"https://github.com/mcp-use/mcp-use",className:"flex items-center gap-2",target:"_blank",rel:"noopener noreferrer",children:[f.jsx(I2,{className:"h-4 w-4"}),f.jsx("span",{className:"hidden sm:inline",children:"Github"})]})})}),f.jsx(Lt,{children:f.jsx("p",{children:"Give us a star ⭐"})})]}),f.jsx(D2,{state:"expanded"})]})]})]})}function Wke({children:e}){const t=bd(),n=Bo(),{connections:a,addConnection:r,removeConnection:i,updateConnectionConfig:s,configLoaded:c}=NN(),{selectedServerId:u,setSelectedServerId:d,activeTab:m,setActiveTab:h,navigateToItem:g,setTunnelUrl:v}=Jl(),[w,S]=x.useState(!1),[y,_]=x.useState(null),E=s0e();x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("tunnelUrl");v(Z)},[n.search,v]),x.useEffect(()=>{const B=re=>{const j=re.detail.requestId;u&&g(u,"sampling",j)},Z=re=>{const j=re.detail.requestId;u&&g(u,"elicitation",j)},G=re=>{const j=re.detail.toolName;u&&j?g(u,"tools",j):u&&h("tools")};return window.addEventListener("navigate-to-sampling",B),window.addEventListener("navigate-to-elicitation",Z),window.addEventListener("navigate-to-tool-result",G),()=>{window.removeEventListener("navigate-to-sampling",B),window.removeEventListener("navigate-to-elicitation",Z),window.removeEventListener("navigate-to-tool-result",G)}},[u,h,g]);const k=x.useRef(null),C=x.useRef(null),R=x.useRef(null),{isAutoConnecting:I}=o0e({connections:a,addConnection:r,removeConnection:i,configLoaded:c}),A=x.useCallback(B=>{yr.getInstance().capture(new tpe({trigger:B})).catch(()=>{}),S(!0)},[]),O=B=>{const Z=a.find(j=>j.id===B);if(!Z||Z.state!=="ready"){Jt.error("Server is not connected and cannot be inspected");return}d(B);const re=new URLSearchParams(n.search).get("tunnelUrl"),ne=re?`/?server=${encodeURIComponent(B)}&tunnelUrl=${encodeURIComponent(re)}`:`/?server=${encodeURIComponent(B)}`;t(ne)},M=x.useCallback(B=>{_(B)},[]),U=x.useCallback(B=>{y&&(B.url!==y?(i(y),r(B.url,B.name,B.proxyConfig,B.transportType)):s(y,{name:B.name,proxyConfig:B.proxyConfig,transportType:B.transportType}),_(null),Jt.success("Connection settings updated"))},[y,i,r,s]),H=(B,Z,G)=>{if(console.warn("[Layout] handleCommandPaletteNavigate called:",{tab:B,itemName:Z,serverId:G}),G){const re=a.find(z=>z.id===G);if(console.warn("[Layout] Server lookup:",{serverId:G,serverFound:!!re,serverState:re?.state}),!re||re.state!=="ready"){console.warn("[Layout] Server not ready, showing error"),Jt.error("Server is not connected and cannot be inspected");return}console.warn("[Layout] Calling navigateToItem:",{serverId:G,tab:B,itemName:Z}),g(G,B,Z);const j=new URLSearchParams(n.search).get("tunnelUrl"),V=j?`/?server=${encodeURIComponent(G)}&tunnelUrl=${encodeURIComponent(j)}`:`/?server=${encodeURIComponent(G)}`;console.warn("[Layout] Navigating to:",V),t(V)}else console.warn("[Layout] No serverId, just updating tab to:",B),h(B)},K=a.find(B=>B.id===u),Q=K?K.tools.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.tools.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]),te=K?K.prompts.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.prompts.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]),ae=K?K.resources.map(B=>({...B,_serverId:K.id})):a.flatMap(B=>B.state==="ready"?B.resources.map(Z=>({...Z,_serverId:B.id,_serverName:B.name})):[]);return x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server"),G=Z?decodeURIComponent(Z):null;G!==u&&d(G)},[n.search,u,d]),x.useEffect(()=>{const Z=new URLSearchParams(n.search).get("server");if(!Z)return;const G=decodeURIComponent(Z),re=a.find(ne=>ne.id===G);if(!re){const ne=setTimeout(()=>t("/"),3e3);return()=>clearTimeout(ne)}if(re.state==="failed"){const ne=setTimeout(()=>t("/"),2e3);return()=>clearTimeout(ne)}},[n.search,t,a]),i7({onCommandPalette:()=>A("keyboard"),onToolsTab:()=>{K&&h("tools")},onPromptsTab:()=>{K&&h("prompts")},onResourcesTab:()=>{K&&h("resources")},onChatTab:()=>{K&&h("chat")},onHome:()=>{t("/")},onFocusSearch:()=>{m==="tools"&&k.current?k.current.focusSearch():m==="prompts"&&C.current?C.current.focusSearch():m==="resources"&&R.current&&R.current.focusSearch()},onBlurSearch:()=>{m==="tools"&&k.current?k.current.blurSearch():m==="prompts"&&C.current?C.current.blurSearch():m==="resources"&&R.current&&R.current.blurSearch()}}),I?f.jsx("div",{className:"h-screen bg-white dark:bg-zinc-900 flex items-center justify-center",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Ei,{className:"h-8 w-8 text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Connecting to MCP server..."})]})}):f.jsx(v8,{children:f.jsxs("div",{className:"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",children:[f.jsx(Gke,{connections:a,selectedServer:K,activeTab:m,onServerSelect:O,onTabChange:h,onCommandPaletteOpen:()=>A("button"),onOpenConnectionOptions:M}),f.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:f.jsx(Bke,{selectedServer:K,activeTab:m,toolsSearchRef:k,promptsSearchRef:C,resourcesSearchRef:R,children:e})}),f.jsx(j0e,{isOpen:w,onOpenChange:S,tools:Q,prompts:te,resources:ae,savedRequests:E,connections:a,onNavigate:H,onServerSelect:O}),f.jsx(SG,{connection:y&&a.find(B=>B.id===y)||null,open:y!==null,onOpenChange:B=>{B||_(null)},onConnect:U})]})})}function Kke(){const[e,t]=x.useState("processing"),[n,a]=x.useState("");return x.useEffect(()=>{console.log("[OAuthCallback] Component mounted, handling authorization..."),console.log("[OAuthCallback] Current URL:",window.location.href),XT().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"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"flex flex-col items-center gap-4",children:[f.jsx(Ls,{className:"h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Completing authentication..."})]})}):e==="error"?f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-red-600 dark:text-red-400 mb-2",children:"Authentication Error"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400 mb-4",children:n}),f.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-500",children:"You can close this window and try again."})]})}):f.jsx("div",{className:"h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900",children:f.jsxs("div",{className:"max-w-md p-6",children:[f.jsx("h1",{className:"text-xl font-semibold text-green-600 dark:text-green-400 mb-2",children:"Authentication Successful!"}),f.jsx("p",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Redirecting you back..."})]})})}var Zke=(e,t,n,a,r,i,s,c)=>{let u=document.documentElement,d=["light","dark"];function m(v){(Array.isArray(e)?e:[e]).forEach(w=>{let S=w==="class",y=S&&i?r.map(_=>i[_]||_):r;S?(u.classList.remove(...y),u.classList.add(i&&i[v]?i[v]:v)):u.setAttribute(w,v)}),h(v)}function h(v){c&&d.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,w=s&&v==="system"?g():v;m(w)}catch{}},Yke=x.createContext(void 0),qke={setTheme:e=>{},themes:[]},Xke=()=>{var e;return(e=x.useContext(Yke))!=null?e:qke};x.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:a,enableColorScheme:r,defaultTheme:i,value:s,themes:c,nonce:u,scriptProps:d})=>{let m=JSON.stringify([n,t,i,e,c,s,a,r]).slice(1,-1);return x.createElement("script",{...d,suppressHydrationWarning:!0,nonce:typeof window>"u"?u:"",dangerouslySetInnerHTML:{__html:`(${Zke.toString()})(${m})`}})});function Jke({...e}){const{theme:t="system"}=Xke();return f.jsx(C8,{theme:t,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...e})}function Qke(){return f.jsx(EEe,{children:f.jsx(lpe,{children:f.jsxs(i0e,{children:[f.jsx(ose,{basename:"/inspector",children:f.jsxs(Moe,{children:[f.jsx(gE,{path:"/oauth/callback",element:f.jsx(Kke,{})}),f.jsx(gE,{path:"/",element:f.jsx(Wke,{children:f.jsx(a0e,{})})})]})}),f.jsx(Jke,{position:"top-center"})]})})})}const U2=new URLSearchParams(window.location.search);if(U2.has("code")||U2.has("error"))try{XT()}catch(e){console.error("[inspector] OAuth callback error:",e)}const z2=document.getElementById("root");z2?Wie.createRoot(z2).render(f.jsx(Qke,{})):console.error("[inspector] Root element not found");export{iB as $,vT as A,e5 as B,Q6 as C,Qv as D,a5 as E,pH as F,pb as G,Mi as H,MP as I,Rie as J,XT as K,V2 as L,_ie as M,hX as N,ue as R,J2 as T,tX as V,Nie as W,Ct as Z,Pe as _,Qn as a,pd as b,vd as c,zS as d,tTe as e,hi as f,Wp as g,FS as h,ei as i,h6 as j,SB as k,uF as l,pF as m,m6 as n,aB as o,xF as p,ute as q,x as r,fk as s,j6 as t,Db as u,pX as v,we as w,mte as x,VS as y,Pte as z};
|